Commit 711cad4
feat(room-worker): publish InboxMemberEvent to local INBOX + fix inbox-worker Subjects (#111)
Wires the publisher side of the INBOX-based search-sync pipeline landed
in #109. After this, search-sync-worker's spotlight + user-room
collections actually receive events end-to-end instead of spinning up
with an empty feed.
room-worker changes (handler.go)
--------------------------------
processAddMembers, processRemoveIndividual, processRemoveOrg now split
their member list by home site and publish InboxMemberEvent:
- Same-site accounts → one publish per call to
`chat.inbox.{site}.member_added/removed`
- Cross-site accounts → existing OUTBOX publish per destination,
inner payload migrated MemberAddEvent/MemberRemoveEvent →
InboxMemberEvent so the remote site's search-sync sees RoomName +
RoomType (needed for spotlight typeahead indexing).
InboxMemberEvent is a strict JSON superset of MemberAddEvent on the
fields inbox-worker reads (Accounts, RoomID, SiteID, JoinedAt,
HistorySharedSince), so inbox-worker's handleMemberAdded /
handleMemberRemoved continue to unmarshal into their existing types and
simply ignore the extra RoomName/RoomType fields. OrgID on
MemberRemoveEvent is dropped from the INBOX payload — not currently
read by any consumer, and InboxMemberEvent stays focused on what
search-sync needs. If inbox-worker ever needs OrgID, add it then.
Remove events omit RoomName/RoomType entirely (search-sync keys its
deletes by {account}_{roomID} and script-removes by roomID; neither
needs room metadata) so we skip the extra DB lookup on the remove
path.
inbox-worker changes (main.go)
------------------------------
One-line fix: `CreateOrUpdateStream` was copying only `.Name` from
`stream.Inbox()` and dropping `.Subjects`. The INBOX stream was being
created with zero subjects, so any publish to `chat.inbox.{site}.*`
would have failed once room-worker started publishing. Now passes
both.
The remote-site Sources + SubjectTransforms federation config is
intentionally left out — production multi-site isn't deployed yet, and
when it is we want inbox-worker (not search-sync-worker's bootstrap
path) to own that config.
Tests
-----
- TestHandler_ProcessAddMembers_PublishesToInbox — new, verifies local
INBOX publish carries RoomName/RoomType + cross-site OUTBOX payload
is InboxMemberEvent.
- TestHandler_ProcessRemoveMember_SelfLeave_IndividualOnly +
_OwnerRemovesIndividual + _OwnerRemovesOrg — bump expected publish
count +1 and assert the local INBOX publish carries the right
Accounts.
- TestHandler_ProcessRemoveMember_CrossSiteOutbox — assert OUTBOX
payload is InboxMemberEvent (not MemberRemoveEvent) and confirm NO
local INBOX publish fires when the removed user is remote.
Follows PR #109.
https://claude.ai/code/session_01XTmSpmv5dT6UXX7NpRdYqN
Co-authored-by: Claude <noreply@anthropic.com>1 parent 7754ae4 commit 711cad4
3 files changed
Lines changed: 257 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
| 151 | + | |
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
316 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
317 | 327 | | |
318 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
319 | 340 | | |
320 | 341 | | |
321 | | - | |
| 342 | + | |
322 | 343 | | |
323 | 344 | | |
324 | | - | |
325 | | - | |
| 345 | + | |
326 | 346 | | |
327 | 347 | | |
328 | 348 | | |
| |||
427 | 447 | | |
428 | 448 | | |
429 | 449 | | |
430 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
431 | 457 | | |
432 | 458 | | |
433 | | - | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
434 | 462 | | |
435 | 463 | | |
436 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
437 | 485 | | |
438 | | - | |
439 | | - | |
| 486 | + | |
440 | 487 | | |
441 | | - | |
442 | 488 | | |
443 | | - | |
| 489 | + | |
444 | 490 | | |
445 | 491 | | |
446 | 492 | | |
447 | | - | |
| 493 | + | |
448 | 494 | | |
449 | 495 | | |
450 | 496 | | |
| |||
665 | 711 | | |
666 | 712 | | |
667 | 713 | | |
668 | | - | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
669 | 722 | | |
670 | 723 | | |
671 | 724 | | |
672 | | - | |
| 725 | + | |
673 | 726 | | |
674 | 727 | | |
675 | | - | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
676 | 733 | | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
677 | 761 | | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
| 762 | + | |
| 763 | + | |
688 | 764 | | |
689 | | - | |
690 | | - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
691 | 770 | | |
692 | | - | |
693 | | - | |
| 771 | + | |
694 | 772 | | |
695 | 773 | | |
696 | 774 | | |
| |||
0 commit comments