Remove comment.id before inserting new ones

This commit is contained in:
Jerko Steiner 2019-01-22 12:06:45 +01:00
parent 0c70a3b688
commit 78056e53a0

View File

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