Skip to content

fix(chat): legacy messaging/unread を chat/history isRead 集計に置換 (notedeck#469)#9

Merged
hitalin merged 1 commit into
mainfrom
fix/legacy-messaging-unread-469
May 9, 2026
Merged

fix(chat): legacy messaging/unread を chat/history isRead 集計に置換 (notedeck#469)#9
hitalin merged 1 commit into
mainfrom
fix/legacy-messaging-unread-469

Conversation

@hitalin
Copy link
Copy Markdown
Owner

@hitalin hitalin commented May 9, 2026

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` シグネチャ拡張:

  • 旧: `(host, token) -> Result`
  • 新: `(host, token, me_user_id) -> Result`

`me_user_id` を追加した理由は 自分送信メッセージを除外 するため。Misskey の `isRead` は DM の場合 "相手が読んだか" になるので、自分送信で `isRead=false` でも自分の未読扱いにしない。

戻り値は `bool` のまま (1 件でも未読あれば true)。NoteDeck 側の `useUnreadChat` (= 1/0 でカウント) と互換維持。件数表示にしたい場合は別 PR で signature を `-> i64` に拡張。

Test plan

新規テスト 4 件 (wiremock):

  • `get_unread_chat_returns_true_when_other_user_message_is_unread`
  • `get_unread_chat_excludes_self_messages` — 自分送信は `isRead=false` でも未読扱いしない
  • `get_unread_chat_returns_false_when_all_read`
  • `get_unread_chat_swallows_errors_and_returns_false` — 500 fallback

```
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

…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)。
@hitalin hitalin self-assigned this May 9, 2026
@hitalin hitalin merged commit 1489d3e into main May 9, 2026
1 check failed
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