Skip to content

Comments

feat(comment): mixed anonymous/login comments + own delete flow#28

Open
ark1st wants to merge 16 commits intodevfrom
feat/comment-anon-and-delete-modal-dev
Open

feat(comment): mixed anonymous/login comments + own delete flow#28
ark1st wants to merge 16 commits intodevfrom
feat/comment-anon-and-delete-modal-dev

Conversation

@ark1st
Copy link
Collaborator

@ark1st ark1st commented Feb 18, 2026

중간 PR (WIP)

반영 내용

  • 비로그인/로그인 혼합 댓글 작성 흐름
  • 비로그인 랜덤 닉네임 정책
  • 본인 댓글 롱프레스 삭제 플로우 대응 백엔드 API
  • 익명 댓글 소유권/삭제 토큰 검증 보강
  • 댓글 관련 테스트 보강

비고

  • 다음 분기점에서 리뷰 피드백을 comment-by-comment로 반영 예정

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/comment-anon-and-delete-modal-dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @ark1st, 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와 롱프레스 삭제 플로우를 지원하도록 구현했습니다.
  • 보안 강화: 익명 댓글의 소유권 및 삭제 토큰 검증 로직을 보강하여 보안을 강화했습니다.
  • 테스트 보강: 댓글 관련 서비스 로직 및 API에 대한 테스트를 추가하고 보강했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • controller/dependencies.py
    • 선택적 사용자 인증을 위한 oauth2_scheme_optional을 추가했습니다.
    • get_current_user 로직을 _resolve_user_from_token으로 리팩토링하고, 선택적 사용자 인증을 지원하는 get_current_user_optional 함수를 도입했습니다.
  • controller/v1/comments.py
    • 댓글 조회 및 생성 엔드포인트에서 선택적 사용자 인증(get_current_user_optional)을 사용하도록 업데이트했습니다.
    • 댓글 삭제(DELETE /comments/{comment_id}) 엔드포인트를 새로 추가했습니다.
  • database.py
    • init_db 함수에 comments 테이블에 password_hash 컬럼이 없는 경우 추가하는 마이그레이션 로직을 포함했습니다.
  • main.py
    • 시드 데이터에 익명 댓글과 해당 비밀번호 해시를 추가했습니다.
  • models/comment.py
    • Comment 모델에 익명 댓글의 비밀번호 해시를 저장하기 위한 password_hash 필드를 추가했습니다.
  • pyproject.toml
    • 개발 의존성으로 pytestpytest-asyncio를 추가했습니다.
  • repositories/comment_repo.py
    • 특정 ID로 댓글을 조회하는 get_by_id 함수를 추가했습니다.
    • 댓글을 삭제하는 delete 함수를 추가했습니다.
  • schemas/comment_dto.py
    • CommentCreate 스키마에 nicknamepassword 필드 및 유효성 검사 로직을 추가했습니다.
    • CommentDeleteRequest 스키마를 정의했습니다.
    • CommentResponse 스키마에 is_anonymous, is_mine, delete_token 필드를 추가했습니다.
  • services/comment_service.py
    • 익명 닉네임 생성 로직, 비밀번호 해싱 및 검증 로직을 구현했습니다.
    • 댓글 생성 시 로그인 여부에 따라 작성자 및 비밀번호 해시를 처리하도록 변경했습니다.
    • 댓글 조회 시 is_mineis_anonymous 플래그를 설정하도록 업데이트했습니다.
    • 댓글 삭제 로직을 추가하여 로그인 사용자 및 익명 사용자의 삭제 흐름을 분리했습니다.
  • tests/test_comment_service.py
    • comment_service의 다양한 시나리오(로그인/익명 댓글 생성, 닉네임 처리, 비밀번호 검증, 댓글 삭제 권한 등)를 검증하는 새로운 테스트 파일을 추가했습니다.
  • uv.lock
    • pyproject.toml 변경사항에 따라 종속성 잠금 파일이 업데이트되었습니다.
Activity
  • 현재 작업 진행 중(WIP) 상태의 PR입니다.
  • 향후 리뷰 피드백을 댓글 단위로 반영할 예정입니다.
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

@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 PR introduces functionality for both logged-in and anonymous users to create and delete their own comments, encompassing authentication logic refactoring, anonymous comment handling, new API endpoints, and enhanced test cases. While the implementation for logged-in users is solid, there are significant security issues in the anonymous comment flow: a lack of brute-force protection on the deletion endpoint and a validation constraint mismatch that prevents the deletion of comments created with server-generated tokens. Additionally, I recommend removing unnecessary code in dependencies.py, improving the database migration method in database.py, and enhancing code clarity and specifying error messages in comment_service.py. The comprehensive test cases are a positive aspect, significantly improving code stability. Addressing these points will enhance the system's security, reliability, and maintainability.

…lete-modal-dev

# Conflicts:
#	controller/dependencies.py
#	controller/v1/comments.py
#	database.py
#	models/comment.py
#	schemas/comment_dto.py
#	services/comment_service.py
#	uv.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant