Skip to content

Commit e42d17c

Browse files
authored
Merge pull request #15 from oodd-team/OD-42
게시물 신고 기능 수정
2 parents 0e58666 + 32eb5ef commit e42d17c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/post-report/post-report.controller.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { PostReportDto } from './dtos/post-report.dto';
66
import { BaseResponse } from 'src/common/response/dto';
77
import { AuthGuard } from 'src/auth/guards/jwt.auth.guard';
88
import { Request } from 'express';
9+
import { UnauthorizedException } from 'src/common/exception/service.exception';
910

1011
@ApiBearerAuth('Authorization')
1112
@Controller('post-report')
@@ -21,10 +22,14 @@ export class PostReportController {
2122
): Promise<BaseResponse<string>> {
2223
const requesterId = req.user['id'];
2324

24-
await this.postReportService.reportPost({
25-
...postReportDto,
26-
requesterId,
27-
});
25+
// jwt 유저와 신고할 유저가 다른 경우
26+
if (postReportDto.requesterId != requesterId) {
27+
throw UnauthorizedException('신고 권한이 없습니다.');
28+
}
29+
30+
postReportDto.requesterId = requesterId;
31+
32+
await this.postReportService.reportPost(postReportDto);
2833

2934
return new BaseResponse(true, 'SUCCESS', '신고 완료');
3035
}

src/post-report/post-report.service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class PostReportService {
2525
where: {
2626
reporter : { id: reportDto.requesterId },
2727
post : { id: reportDto.postId },
28+
reason: reportDto.reason,
2829
},
2930
});
3031

0 commit comments

Comments
 (0)