Skip to content

[#351] 영상 댓글 목록 조회 API 구현#352

Merged
hdg0116 merged 1 commit intodevfrom
feat/joy-videor-comment-view
Feb 12, 2026
Merged

[#351] 영상 댓글 목록 조회 API 구현#352
hdg0116 merged 1 commit intodevfrom
feat/joy-videor-comment-view

Conversation

@hdg0116
Copy link
Copy Markdown
Collaborator

@hdg0116 hdg0116 commented Feb 12, 2026

🔗 관련 이슈

✨ 변경 내용

  • 영상 댓글 목록 조회 API 구현

✅ 체크리스트

  • 로컬에서 빌드/테스트 통과
  • 관련 문서(README, API 문서 등) 업데이트
  • Breaking Change 여부 확인 (있다면 아래에 명시)

@hdg0116 hdg0116 self-assigned this Feb 12, 2026
@hdg0116 hdg0116 added the ✨feature New feature or request label Feb 12, 2026
@hdg0116 hdg0116 merged commit 0aa9543 into dev Feb 12, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @hdg0116, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 사용자가 특정 영상에 달린 모든 댓글과 답글을 한 번에 조회할 수 있는 기능을 도입합니다. 기존에는 타임스탬프 기반의 댓글만 조회할 수 있었으나, 이제는 영상의 전체 댓글 목록을 포괄적으로 제공하여 사용자 경험을 향상시킵니다. 이는 영상 콘텐츠에 대한 전반적인 피드백을 쉽게 파악할 수 있도록 돕습니다.

Highlights

  • 새로운 API 엔드포인트 추가: 특정 영상에 대한 모든 댓글을 조회할 수 있는 새로운 GET API 엔드포인트 /videos/{videoId}/comments/all이 추가되었습니다.
  • 댓글 조회 서비스 로직 구현: 영상 ID 유효성 검사 및 영상 존재 여부 확인을 포함하여 모든 영상 댓글을 가져오는 getAllVideoComments 서비스 함수가 구현되었습니다.
  • 데이터베이스 조회 기능 추가: Prisma를 사용하여 특정 영상의 모든 댓글을 데이터베이스에서 조회하는 findAllVideoComments 레포지토리 함수가 추가되었습니다.
  • Swagger 문서 업데이트: 새로 추가된 영상 전체 댓글 조회 API에 대한 Swagger 문서가 상세하게 작성되어 API 사용법 및 응답 형식을 명확히 설명합니다.
  • DTO 재사용 및 확장: 댓글 응답을 위해 shareLink.dto.js에 정의된 getShareCommentsResponseDTO가 활용되었으며, shareCommentItemDTO가 외부에서 사용 가능하도록 export 되었습니다.
Changelog
  • src/controllers/comment.controller.js
    • 새로운 DTO인 getShareCommentsResponseDTO를 임포트했습니다.
    • 새로운 서비스 함수 getAllVideoComments를 임포트했습니다.
    • 영상 전체 댓글을 조회하는 getAllVideoCommentsController를 추가하고, 이에 대한 Swagger 문서를 정의했습니다.
  • src/dtos/shareLink.dto.js
    • shareCommentItemDTO 함수를 외부에서 사용할 수 있도록 export 키워드를 추가했습니다.
  • src/repositories/comment.repository.js
    • 특정 videoId에 해당하는 모든 댓글을 createdAt 기준으로 오름차순 정렬하여 조회하는 findAllVideoComments 함수를 추가했습니다.
  • src/routes/comment.route.js
    • 새로운 컨트롤러 getAllVideoCommentsController를 임포트했습니다.
    • /videos/:videoId/comments/all 경로에 isLogin 미들웨어를 적용한 GET 요청 라우터를 추가하여 영상 전체 댓글 조회 기능을 활성화했습니다.
  • src/services/comment.service.js
    • 새로운 레포지토리 함수 findAllVideoComments를 임포트했습니다.
    • 영상 ID 유효성 검사 및 영상 존재 여부 확인 로직을 포함하는 getAllVideoComments 서비스 함수를 구현했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements an API to retrieve all comments for a video. While the overall changes look good, the implementation currently lacks proper authorization checks, leading to a Broken Access Control (IDOR) vulnerability where any authenticated user can access comments for any video by knowing its ID. It is recommended to implement ownership or access permission checks in the service layer, consistent with other comment-related endpoints in the application. Additionally, I've provided some specific review comments to enhance code clarity and maintainability.

Comment on lines +212 to +230
export const getAllVideoComments = async ({ videoId }) => {
let vid;
try {
vid = BigInt(videoId);
} catch {
throw new InvalidParameterError({ videoId }, "videoId가 올바르지 않습니다.");
}

if (vid <= 0n) {
throw new InvalidParameterError({ videoId }, "videoId가 올바르지 않습니다.");
}

const videoExists = await findVideoByIdWithProject(vid);
if (!videoExists) {
throw new VideoNotFoundError({ videoId: String(videoId) });
}

return findAllVideoComments({ videoId: vid });
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The getAllVideoComments service does not perform any authorization checks, only verifying the existence of the video. To prevent unauthorized data access, it should be updated to accept a userId and verify that the user has the necessary permissions (e.g., project ownership) to view the comments, similar to the implementation in getSlideComments. Additionally, the validation logic for videoId is currently split between a try-catch block and an if statement; combining these checks would improve code conciseness and readability.

  let vid;
  try {
    vid = BigInt(videoId);
    if (vid <= 0n) {
      throw new Error("videoId must be a positive BigInt");
    }
  } catch {
    throw new InvalidParameterError({ videoId }, "videoId가 올바르지 않습니다.");
  }

try {
const { videoId } = req.params;

const comments = await getAllVideoComments({ videoId });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The getAllVideoCommentsController endpoint lacks an authorization check to verify if the authenticated user has permission to view the comments for the specified videoId. While the route is protected by the isLogin middleware, it does not ensure that the user owns the project or has been granted access to it. This allows any authenticated user to retrieve all comments for any video by providing its ID, which is a Broken Access Control (IDOR) vulnerability.

    const comments = await getAllVideoComments({
      videoId,
      userId: req.user.id,
    });

error: null,
success: getShareCommentsResponseDTO({
comments,
currentUserId: req.user?.id ?? null,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 라우트는 isLogin 미들웨어를 사용하고 있으므로, 컨트롤러에 도달했을 때 req.user는 항상 존재한다고 가정할 수 있습니다. 따라서 req.user?.id ?? null 대신 req.user.id로 코드를 단순화하여 명확성과 일관성을 높일 수 있습니다.

        currentUserId: req.user.id,

@hdg0116 hdg0116 changed the title feat: 영상 댓글 목록 조회 API 구현 (#351) [Feat][조이] 영상 댓글 목록 조회 API 구현 (#351) Feb 12, 2026
@hdg0116 hdg0116 changed the title [Feat][조이] 영상 댓글 목록 조회 API 구현 (#351) [#351] 영상 댓글 목록 조회 API 구현 Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat][조이] 영상 댓글 목록 조회 API 구현

1 participant