Skip to content

外部AI連携向けに通知の既読APIを追加する #10003

@komagata

Description

@komagata

機能の説明

外部AIエージェントが通知を作業キューとして扱えるように、通知の既読化APIを追加する。

現状、GET /api/notifications で通知一覧は取得できる。一方で、APIから通知を既読にする、カテゴリ単位で既読にする、全既読にする操作は存在しない。

追加したいAPI候補:

  • POST /api/notifications/:id/read
  • POST /api/notifications/read_by_category
  • POST /api/notifications/read_all

または既存画面側の notifications/allmarksnotifications/read_by_category に対応するAPIを追加する。

何故この機能が必要なのか

pjord/hermes agent が通知を見て対応し、対応済みの通知を既読にできないと、同じ通知を何度も処理してしまう。

通知一覧取得だけでなく、処理済みマークをAPI経由で行える必要がある。

受け入れ条件

  • Bearer token で認証したユーザーが自分の通知を既読にできる
  • 個別通知を既読にできる
  • target/category 単位で未読通知を既読にできる
  • 全通知を既読にできる
  • 他人の通知は既読化できない
  • 成功時は処理件数または更新後の通知状態をJSONで返す
  • integration test で個別既読、カテゴリ既読、全既読、権限不足を確認する

関連コード

  • app/controllers/api/notifications_controller.rb: 通知一覧API
  • app/controllers/notifications/allmarks_controller.rb: 画面側の全既読処理
  • app/controllers/notifications/read_by_category_controller.rb: 画面側のカテゴリ既読処理
  • app/models/user.rb: mark_all_as_read_and_delete_cache_of_unreads
  • app/queries/user_notifications_query.rb
  • test/integration/api/notifications_test.rb

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    やる

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions