Skip to content

Commit 65837e4

Browse files
committed
fix: lint
1 parent afe7b6f commit 65837e4

File tree

2 files changed

+6
-68
lines changed

2 files changed

+6
-68
lines changed

src/api/ai-workflow/ai-workflow.controller.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,12 @@ export class AiWorkflowController {
255255
@Param('itemId') itemId: string,
256256
@Body(new ValidationPipe({ whitelist: true, transform: true }))
257257
patchData: UpdateAiWorkflowRunItemDto,
258-
@User() user: JwtUser,
259258
) {
260259
return this.aiWorkflowService.updateRunItem(
261260
workflowId,
262261
runId,
263262
itemId,
264263
patchData,
265-
user,
266264
);
267265
}
268266

src/api/ai-workflow/ai-workflow.service.ts

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@ export class AiWorkflowService {
496496
runId: string,
497497
itemId: string,
498498
patchData: UpdateAiWorkflowRunItemDto,
499-
user: JwtUser,
500499
) {
501500
const workflow = await this.prisma.aiWorkflow.findUnique({
502501
where: { id: workflowId },
@@ -545,71 +544,12 @@ export class AiWorkflowService {
545544
updateData.questionScore = patchData.questionScore;
546545
}
547546

548-
return this.prisma.$transaction(async (tx) => {
549-
await tx.aiWorkflowRunItem.update({
550-
where: { id: itemId },
551-
include: {
552-
comments: true,
553-
},
554-
data: updateData,
555-
});
556-
557-
if (patchData.comments) {
558-
for (const comment of patchData.comments) {
559-
if (comment.id) {
560-
const existingComment =
561-
await tx.aiWorkflowRunItemComment.findUnique({
562-
where: { id: comment.id },
563-
});
564-
if (!existingComment) {
565-
this.logger.error(`Comment with id ${comment.id} not found.`);
566-
throw new NotFoundException(
567-
`Comment with id ${comment.id} not found.`,
568-
);
569-
}
570-
571-
if (
572-
existingComment.createdBy !== user.userId &&
573-
!user.roles?.includes(UserRole.Admin)
574-
) {
575-
this.logger.error(
576-
`User ${user.userId} unauthorized to update comment ${comment.id}.`,
577-
);
578-
throw new ForbiddenException(
579-
`Unauthorized to update comment ${comment.id}.`,
580-
);
581-
}
582-
583-
await tx.aiWorkflowRunItemComment.update({
584-
where: { id: comment.id },
585-
data: {
586-
content: comment.content,
587-
updatedAt: new Date(),
588-
},
589-
});
590-
} else {
591-
await tx.aiWorkflowRunItemComment.create({
592-
data: {
593-
workflowRunItemId: itemId,
594-
content: comment.content,
595-
parentId: comment.parentId,
596-
createdBy: '',
597-
createdAt: new Date(),
598-
userId: user.userId as string,
599-
updatedAt: new Date(),
600-
updatedBy: '',
601-
},
602-
});
603-
}
604-
}
605-
}
606-
607-
return tx.aiWorkflowRunItem.findUnique({
608-
where: { id: itemId },
609-
include: {
610-
comments: true,
611-
},
612-
});
547+
return this.prisma.aiWorkflowRunItem.update({
548+
where: { id: itemId },
549+
include: {
550+
comments: true,
551+
},
552+
data: updateData,
613553
});
614554
}
615555
}

0 commit comments

Comments
 (0)