Fix race condition in email campaign updates for past-scheduled campaigns#355
Fix race condition in email campaign updates for past-scheduled campaigns#355
Conversation
|
@copilot Also add
from https://github.com/vivid-planet/comet/pull/5155/changes |
Co-authored-by: thomasdax98 <13380047+thomasdax98@users.noreply.github.com>
Done in commit 5bb6178. Added:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot The MinDate fix doesn't work because it apparently wasn't supported yet by the class-validator version: Error: packages/api build: src/email-campaign/dto/email-campaign-input.factory.ts(37,22): error TS2345: Argument of type '() => Date' is not assignable to parameter of type 'Date'. Fix this by create a custom IsFutureDate decorator |
…uation Co-authored-by: thomasdax98 <13380047+thomasdax98@users.noreply.github.com>
Co-authored-by: thomasdax98 <13380047+thomasdax98@users.noreply.github.com>
Fixed in commit 65ed7ab. Created a custom
|
Description
Email campaigns with past scheduled times could incorrectly block updates even when not yet sent. Two issues contributed to this problem:
sendingStatecheck didn't account for the delay between schedule time and actual Brevo execution@MinDate(new Date())validator was evaluated once at server startup, causing stale date validationSolution:
scheduledAt < now:@IsFutureDate()validator to evaluate date at validation time instead of server startup (replacing@MinDatewhich doesn't support function arguments in class-validator 0.13.1)This mirrors the fix from vivid-planet/comet#5155.
Changes:
email-campaign.resolver.tsbrevoApiCampaignsService.loadBrevoCampaignById()call for campaigns withscheduledAt < nowsendingStatebased on Brevo response before throwing errors@IsFutureDate()validator inemail-campaign-input.factory.tsfor runtime date validationIsFutureDatevalidator in package index for reusabilityExample
[x] I have verified if my change requires an example
Screenshots/screencasts
N/A
Changeset
[x] I have verified if my change requires a changeset
Related tasks and documents
Applies changes from https://github.com/vivid-planet/comet/pull/5155/changes
Open TODOs/questions
None
Further information
Pre-existing TypeScript compilation errors in
newsletter-image.block.tsandbrevo-api-campaigns.service.tsare unrelated to these changes.The custom
@IsFutureDate()validator was necessary because class-validator 0.13.1 doesn't support passing functions to@MinDate(). The validator maintains the same behavior as@MinDate(new Date())(using>=comparison) to ensure backward compatibility.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.