Commit e9ff324
committed
feat(user-service): cross-site thread-unread badge RPC
Adds a client-facing RPC that returns a per-user thread-unread badge
aggregated across every federation site the user participates in, and
removes the superseded (callerless) ThreadUnreadSummary leaf.
New client RPC: chat.user.{account}.request.user.{siteID}.thread.unread
-> ThreadUnreadResponse{ unread, unreadDirectMessage, unreadMention,
lastMessageAt?, unavailableSites? }.
How it works (mirrors the existing subscription-unread pattern, one
unread() helper): user-service reads all of the user's thread-subs from
the home-site replica (ThreadSubscriptionRepo.ListByAccount), groups them
by the room's home siteId, and per site (uncapped fan-out, chunked by
maxBatchSize) calls the new room-service ThreadRoomInfoBatch RPC
(chat.server.request.room.{siteID}.thread.info.batch) for each thread
room's lastMsgAt + parent roomType. Results fold via unread(): OR the
booleans, max lastMsgAt over found rows, unreadDirectMessage = unread &&
roomType==dm, unreadMention = hasMention. Per-site RPC failures degrade
into unavailableSites. Grouping by siteId counts each thread exactly once.
- pkg/subject: UserThreadUnread/Pattern, ThreadRoomInfoBatch/Subscribe.
- pkg/model: ThreadUnreadRequest/Response, ThreadRoomInfoBatchRequest/
Response, ThreadRoomInfo, ThreadSubRef.
- room-service: GetThreadRoomInfos store method (two projected finds,
no $lookup) + threadRoomInfoBatch handler.
- user-service: roomclient.GetThreadRoomInfoBatch,
mongorepo.ThreadSubscriptionRepo.ListByAccount, RoomClient/
ThreadSubscriptionRepository interfaces, GetThreadUnread aggregator.
- docs/client-api.md: documents the new thread.unread RPC.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BocBvJn2N9YYMmciA5EWJX1 parent 4bba9cd commit e9ff324
25 files changed
Lines changed: 2459 additions & 364 deletions
File tree
- docs
- superpowers
- plans
- specs
- pkg
- model
- subject
- room-service
- user-service
- mongorepo
- roomclient
- service
- mocks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3776 | 3776 | | |
3777 | 3777 | | |
3778 | 3778 | | |
| 3779 | + | |
3779 | 3780 | | |
3780 | 3781 | | |
3781 | 3782 | | |
| |||
4532 | 4533 | | |
4533 | 4534 | | |
4534 | 4535 | | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
| 4553 | + | |
| 4554 | + | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
| 4565 | + | |
| 4566 | + | |
| 4567 | + | |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
| 4575 | + | |
| 4576 | + | |
| 4577 | + | |
| 4578 | + | |
| 4579 | + | |
| 4580 | + | |
| 4581 | + | |
| 4582 | + | |
| 4583 | + | |
| 4584 | + | |
| 4585 | + | |
| 4586 | + | |
| 4587 | + | |
4535 | 4588 | | |
4536 | 4589 | | |
4537 | 4590 | | |
| |||
0 commit comments