Skip to content

Commit

Permalink
check comment in post"
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiet1618 committed Nov 21, 2023
1 parent db5a5d3 commit cd299af
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/controllers/social.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ export class SocialController {
async createReply(@Param("id") id: number, @Param("commentId") commentId: number, @Body() createComment: CreateCommentDto, @Headers('Authorization') accessToken: string) {
const user = await verifyAccessToken(accessToken);
const comment = await this.commentService.findCommentById(commentId);
// check comment in post
if (comment.postId !== Number(id)) {
throw new BadRequestException(`This comment don't in this post`);
}
if (comment.replyCommentId !== 0) {
throw new BadRequestException(`This comment is reply comment`);
}
Expand Down

0 comments on commit cd299af

Please sign in to comment.