Skip to content

fix(broadcast): guard sending an edited draft on leftover recipients - #1605

Merged
viethung0o0 merged 1 commit into
mainfrom
fix/broadcast-draft-activation-gate
Oct 31, 2026
Merged

viethung0o0 merged 1 commit into
mainfrom
fix/broadcast-draft-activation-gate

Conversation

@viethung0o0

Copy link
Copy Markdown
Contributor

Follow-up to #1598.

Summary

  • Sending an edited draft (updateDraft with saveAsDraft: false) now goes through the same leftover-recipient check as scheduleDraft. Before, a draft moved back mid-preparation and then edited and sent could keep the old recipients
  • Pin the scheduling write to the draft's epoch read before that check, so a move back to draft in between makes the write match nothing
  • The restricted audience count and the audience preview already join the direct chat, so they reuse that join instead of a second existence check
  • Read filter fields through a shared contactFilterUsesField helper, deduplicate the stale-cleanup enqueue and drop an unreachable log in preparation
  • Public API: broadcasts.updateDraft describes the same retry-shortly refusal as broadcasts.schedule

Validation

  • Type checks for database, business, worker and builder; pnpm lint
  • Unit tests for database, business, worker and builder
  • Database tests for the purge, direct chat creation, filtered audience walk and activation race
  • Local browser run: the form and preview show the expected recipients; sending a draft that still had leftover recipients was refused, the cleanup ran, and sending again prepared exactly the current audience

- Sending an edited draft goes through the same leftover-recipient check as scheduling it
- Pin the scheduling write to the draft's epoch, so a move back to draft in between makes it match nothing
- Reuse the DM join in the restricted count and the audience preview instead of a second existence check
- Read filter fields through a shared helper and drop an unreachable log in preparation
@github-actions github-actions Bot added the bug Something isn't working as expected label Oct 31, 2026
@viethung0o0
viethung0o0 marked this pull request as ready for review October 31, 2026 11:11
@viethung0o0
viethung0o0 merged commit 6eac247 into main Oct 31, 2026
15 checks passed
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants