Add admin announcements that fan out to every user's inbox - #842
Conversation
|
Warning Review limit reachedNext included review available in 50 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (13)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Follow-ups this design leaves openNeither is needed at the current user count, recorded here so the next person does not re-derive them. Queue-backed fan-out
Sent logThe admin page has no history, so an operator cannot see whether a colleague already sent a notice. Deriving it from notification rows decays as users dismiss and the 200-row cap trims.
The queue work depends on the sent log, since the message carries only the id. |
Closes #840.
Admins get a new
/admin/announcementspage (Overview group in the admin sidebar) to send an operator-written title, message and optional in-app link to every user. Each user receives it as an ordinaryannouncementnotification in their inbox.What changed
announcementnotification type whose payload carries the copy as written, since there is no client-side wording to derive it from.sendAnnouncementselects every user id, inserts the rows in chunks of 20 (100 bound parameters per D1 statement) and pushesnotification:newto each user's session Durable Object on a best-effort basis. The per-user cap is left to the next ordinary notification to trim. Exported as@corates/workers/commands/notifications.sendAnnouncementActionvalidates title (80), body (280) and an optional in-app path that must start with/, then checksisAdminUserlike the other admin server functions.MegaphoneIconrenderer.NotificationRowshows an icon-only avatar when there is no actor and shows operator copy in full instead of truncating it to one line.Tests
packages/workers/src/commands/notifications/__tests__/sendAnnouncement.test.ts: 45 users span three insert chunks, every row is written, the last user's session DO received the push, and zero users sends nothing.packages/web/src/server/functions/__tests__/admin-announcements.server.test.ts: non-admins are rejected with a domain error and write nothing; admins fan out to every user including themselves.pnpm typecheckandpnpm lintare clean. The workers suite passes apart from the pre-existingemail-queuehook timeout, which is unrelated.Known limits
https://claude.ai/code/session_01C35qe7ZSeyaFUnw4LXJfJT