Skip to content

Conversation

@Pugma
Copy link
Contributor

@Pugma Pugma commented Jul 27, 2025

概要

タイトルの通り
責務の分離を進めた

なぜこの PR を入れたいのか

traQ の middleware では多数の処理が行われている
/router/middlewares/param_retriever.go のように、単に params から構造体を取り出すだけであれば問題がない

しかし、アクセス権限の確認などは domain / service に関わる内容であり、これは router 層に置くべきではないと考えた
特に、現状の設計は ConnectRPC での api handler 実装を行う際にも障壁となりうるものであると考えている
最終的には /router/middlewares/access_control.go をファイルごと削除したい

動作確認の手順

テストが通ってるので大丈夫だと思います

PR を出す前の確認事項

  • (機能の追加なら) 追加することの合意がチームで取れている
    • 取れていない場合はチェックを外して PR にすれば OK
  • 動作確認ができている
  • 自分で一度コードを眺めて自分的に問題はなさそう

見てほしいところ・聞きたいことなど

この方針で refactor を進めても大丈夫かをご確認したいです

@Pugma Pugma requested review from Takeno-hito and Copilot July 27, 2025 16:32

This comment was marked as outdated.

@Pugma Pugma requested a review from Copilot July 27, 2025 16:43
Copy link
Contributor

Copilot AI left a 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 IsAccessible method to the message service interface and implementation
  • Removes CheckMessageAccessPerm middleware 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
Copy link

Copilot AI Jul 27, 2025

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.

Copilot uses AI. Check for mistakes.
Pugma and others added 2 commits July 28, 2025 07:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Pugma Pugma requested a review from ramdos0207 July 28, 2025 04:18
@Takeno-hito Takeno-hito marked this pull request as draft August 11, 2025 02:44
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.

2 participants