Skip to content

Commit

Permalink
Fix: 유저 핸들이 틀린 경우 Answer에서 404반환
Browse files Browse the repository at this point in the history
  • Loading branch information
yunochi committed Jan 13, 2025
1 parent 54175f9 commit 6921e4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/app/api/_service/answer/answer-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,12 @@ export class AnswerService {
}

@RateLimit({ bucket_time: 300, req_limit: 600 }, 'ip')
public async GetSingleAnswerApi(_req: NextRequest, answerId: string) {
public async GetSingleAnswerApi(_req: NextRequest, answerId: string, userHandle: string) {
const answer = await this.prisma.answer.findUnique({
include: { answeredPerson: { include: { user: { include: { server: { select: { instanceType: true } } } } } } },
where: {
id: answerId,
answeredPersonHandle: userHandle,
},
});
if (!answer) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/api/db/answers/[userHandle]/[answerId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export async function DELETE(req: NextRequest, { params }: { params: Promise<{ a
return await service.deleteAnswer(req, answerId, null as unknown as jwtPayloadType);
}

export async function GET(req: NextRequest, { params }: { params: Promise<{ answerId: string }> }) {
export async function GET(req: NextRequest, { params }: { params: Promise<{ userHandle:string, answerId: string }> }) {
const service = AnswerService.getInstance();
const { answerId } = await params;
return await service.GetSingleAnswerApi(req, answerId);
const { answerId, userHandle } = await params;
return await service.GetSingleAnswerApi(req, answerId, userHandle);
}

0 comments on commit 6921e4b

Please sign in to comment.