fix(chat): legacy messaging/unread を chat/history isRead 集計に置換 (notedeck#469)#9
Merged
Merged
Conversation
…eck#469) Misskey 新 Chat API ([#15686](misskey-dev/misskey#15686), v2025) で legacy `messaging/unread` エンドポイントが完全廃止されたため、`chat/history` を `room=false` (DM) と `room=true` (room) で叩いて各 thread 最新 message の `isRead` フラグを集計するように置き換える。 シグネチャ拡張: `me_user_id: &str` を追加。自分送信メッセージの `isRead=false` (= 相手が未読) を自分の未読扱いにしないため。 戻り値は `bool` のまま (1 件でも未読あれば true)。Misskey 新 chat API には 件数を返す統一 API が無いため、現状の useUnreadChat (= 1/0) と互換維持。 テスト: 4 件追加 (other-user 未読 / self 除外 / all-read / 500 fallback)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Misskey 新 Chat API (#15686, v2025) で legacy `messaging/unread` エンドポイントが完全廃止されたため、`get_unread_chat` を `chat/history` の `isRead` 集計に置き換える。
Why
`packages/backend/src/server/api/endpoints/messaging/` ディレクトリ自体が Misskey develop に存在せず、最新サーバに対しては既存実装が API エラー (= UI バッジが常に 0) になっていた。
Misskey 新 chat API には統一的な「未読件数」エンドポイントが無いが、`chat/history` の各 thread 最新メッセージに `isRead` フラグがあるので、`room=false` (DM) と `room=true` (room) の両方を叩いて集計する。
Changes
`MisskeyClient::get_unread_chat` シグネチャ拡張:
`me_user_id` を追加した理由は 自分送信メッセージを除外 するため。Misskey の `isRead` は DM の場合 "相手が読んだか" になるので、自分送信で `isRead=false` でも自分の未読扱いにしない。
戻り値は `bool` のまま (1 件でも未読あれば true)。NoteDeck 側の `useUnreadChat` (= 1/0 でカウント) と互換維持。件数表示にしたい場合は別 PR で signature を `-> i64` に拡張。
Test plan
新規テスト 4 件 (wiremock):
```
cargo test --lib # 140 passed (4 新規)
cargo fmt --check # 私の変更箇所は pass
cargo clippy --no-default-features -- -D warnings # 私の変更箇所は pass
```
Note
main の CI は本 PR 以前から既存の lint 違反 (`db.rs:1089` ほか) で fail 状態。本 PR の変更範囲では fmt / clippy / test 全パスしている。
Related
🤖 Generated with Claude Code