Comprehensive workflow reminder management for booking lifecycle events#6
Comprehensive workflow reminder management for booking lifecycle events#6akshayutture-augment wants to merge 1 commit into
Conversation
…re still sent (#7232) * small UI fix * fix cancelling scheduled emails * improve comments * delete reminders for rescheduled bookings * add migration file * cancel rescheduled bookings immediately * remove immediate delete for request reschedule --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| immediateDelete?: boolean | ||
| ) => { | ||
| try { | ||
| await client.request({ | ||
| url: "/v3/user/scheduled_sends", | ||
| method: "POST", | ||
| body: { | ||
| batch_id: referenceId, | ||
| status: "cancel", | ||
| }, | ||
| }); | ||
| if (!referenceId) { | ||
| await prisma.workflowReminder.delete({ | ||
| where: { | ||
| id: reminderId, | ||
| }, | ||
| }); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| await client.request({ | ||
| url: `/v3/user/scheduled_sends/${referenceId}`, | ||
| method: "DELETE", | ||
| if (immediateDelete) { | ||
| await client.request({ | ||
| url: "/v3/user/scheduled_sends", | ||
| method: "POST", | ||
| body: { | ||
| batch_id: referenceId, | ||
| status: "cancel", | ||
| }, | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| await prisma.workflowReminder.update({ | ||
| where: { | ||
| id: reminderId, | ||
| }, | ||
| data: { | ||
| cancelled: true, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Cancelled bookings still send workflow reminders
With the new implementation of deleteScheduledEmailReminder (packages/features/ee/workflows/lib/reminders/emailReminderManager.ts lines 200‑232) we no longer cancel the SendGrid batch unless immediateDelete is explicitly set. The default path merely toggles a cancelled flag in the database. Booking cancellation flows such as packages/features/bookings/lib/handleCancelBooking.ts (lines 484‑489) call this helper without the immediateDelete flag, so after a host cancels an event the reminder remains scheduled at SendGrid until the cron job processes it. The cron in packages/features/ee/workflows/api/scheduleEmailReminders.ts first deletes any reminders whose scheduledDate <= now (lines 33‑41) before it attempts to cancel the ones flagged as cancelled (lines 43‑74). This means that if a booking is cancelled within the final hour before a reminder fires (the exact window the cron considers), the row is deleted before SendGrid is contacted, so the reminder email is still delivered for a cancelled booking. We need to keep cancelling the SendGrid batch immediately (or at least before removing the reminder record) for the non‑immediateDelete path to prevent reminders from being sent after a cancellation.
Useful? React with 👍 / 👎.
Test 6
Replicated from ai-code-review-evaluation/cal.com-cursor#6