Skip to content

Commit

Permalink
fix: avoid flow lock when updated by api key
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed May 16, 2024
1 parent b64e579 commit 9b3f7ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import {
LoopOnItemsActionSettingsWithValidation,
PieceActionSettings,
PieceTriggerSettings,
ProjectId, SeekPage, TriggerType, UserId } from '@activepieces/shared'
ProjectId, SeekPage, TriggerType, UserId,
} from '@activepieces/shared'

const branchSettingsValidator = TypeCompiler.Compile(
BranchActionSettingsWithValidation,
Expand Down Expand Up @@ -138,8 +139,9 @@ export const flowVersionService = {
}

mutatedFlowVersion.updated = dayjs().toISOString()
mutatedFlowVersion.updatedBy = userId

if (userId) {
mutatedFlowVersion.updatedBy = userId
}
return flowVersionRepo(entityManager).save(mutatedFlowVersion)
},

Expand Down Expand Up @@ -641,7 +643,7 @@ type GetFlowVersionOrThrowParams = {
type NewFlowVersion = Omit<FlowVersion, 'created' | 'updated'>

type ApplyOperationParams = {
userId: UserId
userId: UserId | null
projectId: ProjectId
flowVersion: FlowVersion
userOperation: FlowOperationRequest
Expand Down
2 changes: 1 addition & 1 deletion packages/server/api/src/app/flows/flow/flow.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const flowController: FastifyPluginAsyncTypebox = async (app) => {

const updatedFlow = await flowService.update({
id: request.params.id,
userId,
userId: request.principal.type === PrincipalType.SERVICE ? null : userId,
projectId: request.principal.projectId,
operation: request.body,
})
Expand Down
6 changes: 3 additions & 3 deletions packages/server/api/src/app/flows/flow/flow.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ type CountParams = {

type UpdateParams = {
id: FlowId
userId: UserId
userId: UserId | null
projectId: ProjectId
operation: FlowOperationRequest
lock?: boolean
Expand All @@ -505,7 +505,7 @@ type UpdateStatusParams = {

type UpdatePublishedVersionIdParams = {
id: FlowId
userId: UserId
userId: UserId | null
projectId: ProjectId
}

Expand All @@ -518,7 +518,7 @@ type NewFlow = Omit<Flow, 'created' | 'updated'>

type LockFlowVersionIfNotLockedParams = {
flowVersion: FlowVersion
userId: UserId
userId: UserId | null
projectId: ProjectId
entityManager: EntityManager
}
Expand Down

0 comments on commit 9b3f7ba

Please sign in to comment.