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) }