From 78056e53a0dcf7fdbf988246aa65a52965c78b63 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Tue, 22 Jan 2019 12:06:45 +0100 Subject: [PATCH] Remove comment.id before inserting new ones --- packages/server/src/services/CommentService.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/server/src/services/CommentService.ts b/packages/server/src/services/CommentService.ts index f351a83..5c54948 100644 --- a/packages/server/src/services/CommentService.ts +++ b/packages/server/src/services/CommentService.ts @@ -45,6 +45,7 @@ export class CommentService extends BaseService implements ICommentService { .ensure('storyId') .throw() + delete comment.id comment.parentId = 0 comment.userId = userId comment.votes = 0 @@ -53,11 +54,6 @@ export class CommentService extends BaseService implements ICommentService { } async save(comment: IComment, userId: number) { - - comment.votes = 0 - comment.spams = 0 - comment.userId = userId - new Validator(comment) .ensure('message') .ensure('userId') @@ -65,6 +61,12 @@ export class CommentService extends BaseService implements ICommentService { .ensure('parentId') .throw() + delete comment.id + + comment.votes = 0 + comment.spams = 0 + comment.userId = userId + return this.getRepository(Comment).save(comment) }