Repository navigation
Keep a message sent right after an invite join from being lost - #449
Conversation
…FlowLab#442) A friend typed Hi seconds after joining an invite; this home had not synced the new grant yet, so the owner policy refused it and the sender saw nothing. - Read Bot Social's relationship.changed (active) / grant.changed (granted) and sync that Bot's grants before the next event in its queue: Bot Social #30 queues the join, with its grants written, before the first message. - On an owner-policy refusal of an inbound message, sync that Bot's grants once and judge it again (servers without #30, a lost event). - Still refused: call report_not_delivered so the sender is told; on the sender's home a message.not_delivered event writes a Not sent line into the owner's chat with that Bot.
Self-review (Bot) — verdict: PASSTip SHA: b7e0b27 Notes: grants are synced on Risk tier: T3 (per the risk tier check), so this needs the maintainer's approval on GitHub. Any new commit voids this PASS. |
Fixes #442
Server half: Birfy/bot-social#31 (Fixes Birfy/bot-social#30; owner decision option b: write the grant first, then confirm the join). Not deployed; production deploy needs the owner's yes. This PR works against the current production server too (see Compatibility).
What was wrong
Right after an invite join, the inviter's home had not yet synced the new friend's grant (
syncOutgoingGrantsran only on a roster fetch). The friend's first message hit the core owner policy (reach(),by: 'owner-policy'), was refused, logged and dropped, and the sender saw nothing.Fix (plugins/social only; no core change)
pollOncenow readsrelationship.changed(status: "active") andgrant.changed(status: "granted") in a Bot's queue and runssyncOutgoingGrants({ only })for that Bot before the next event. Bot Social ci: slim Test matrix to ubuntu Node 24 + DSH 0.2.0-rc.2 #31 commits the join's grants before announcing it and always queues that event before the friend's first message, so the message is judged with the grant.report_not_delivered { message_id, reason: "not_shared_yet" }. On the sender's home, themessage.not_deliveredevent writes "Not sent: Coder (Bob) was not ready to talk with you yet, so it did not get your message. Send it again." into the owner's chat with that Bot, in the same place a failed send shows its Not sent line.Decisions (minor, made here)
list_bot_grantspath and does not build grant records from the event'sgrantsfield. That keeps one mapping (talk-through classification, canonical handles). The event only triggers the sync.settings.via). When a Bot sent the message withmessage_friend_bot, the plugin only logs it and does not wake the Bot.Compatibility
relationship.changed(active) after writing grants, so the join-time sync works now. The retry works too.report_not_delivereddoes not exist there yet, so the refusal is only logged and the sender still sees nothing until ci: slim Test matrix to ubuntu Node 24 + DSH 0.2.0-rc.2 #31 is deployed.Tests
Four new tests in
plugins/social/test/social.test.js(#442: …):report_not_deliveredis called once per message. An older server that lacks the tool only logs it.message.not_deliveredwrites the Not sent line once into the owner's chat with that Bot, never shown as the friend typing it. No chat line when no owner chat goes through that Bot.Verify at tip
b7e0b27:ARCH_DOCS_BASE=upstream/main TZ=UTC npm run verify: pass (core 1011, social 273, tree 56, timeline 80, scripts 88, interop 37, live-e2e 16; lint, plugin lint, client bundle check and ds-bot patches check green). I did not run the smoke test (nocore/orsrc/host/change), a live two-home test or a test against production Bot Social.Docs:
docs/subsystems/social.mditem 11. Changelog:changelog.d/442-message-after-invite-join.fixed.md.Risk tier: T3 (risk-gate report at b7e0b27: path plugins/social/src/social.js)