-
Notifications
You must be signed in to change notification settings - Fork 29
refactor: メッセージのアクセス権限チェックを service 層に移行 #2739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors message access permission checks by moving them from middleware to the service layer. The goal is to improve separation of concerns by removing domain logic from the router layer.
Key changes:
- Adds
IsAccessiblemethod to the message service interface and implementation - Removes
CheckMessageAccessPermmiddleware function - Adds access checks directly to message-related handlers
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| service/message/manager.go | Adds interface definition for IsAccessible method |
| service/message/manager_impl.go | Implements message access checking via channel access verification |
| router/v3/router.go | Removes message access permission middleware from route setup |
| router/v3/messages.go | Adds checkMessageAccess helper and access checks to all message handlers |
| router/middlewares/access_control.go | Removes CheckMessageAccessPerm middleware function |
| return false, fmt.Errorf("failed to check channel access: %w", err) | ||
| } | ||
|
|
||
| return accessible, nil |
Copilot
AI
Jul 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The function name IsAccessible is ambiguous as it doesn't specify what type of access is being checked. Consider renaming to IsAccessibleToUser or adding more specific documentation about what access permissions are being validated.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
概要
タイトルの通り
責務の分離を進めた
なぜこの PR を入れたいのか
traQ の middleware では多数の処理が行われている
/router/middlewares/param_retriever.goのように、単に params から構造体を取り出すだけであれば問題がないしかし、アクセス権限の確認などは domain / service に関わる内容であり、これは router 層に置くべきではないと考えた
特に、現状の設計は ConnectRPC での api handler 実装を行う際にも障壁となりうるものであると考えている
最終的には
/router/middlewares/access_control.goをファイルごと削除したい動作確認の手順
テストが通ってるので大丈夫だと思います
PR を出す前の確認事項
見てほしいところ・聞きたいことなど
この方針で refactor を進めても大丈夫かをご確認したいです