Fix spurious re-sync/preview for campaigns without an explicit template_id
CI / test (push) Successful in 21s
CI / test (push) Successful in 21s
campaignUnchanged compared input.TemplateID (0 when unset) literally against existing.TemplateID, but listmonk always assigns a real, nonzero template_id server-side even when create/update omits it. Every campaign without an explicit template_id was therefore flagged "changed" on every sync, forever, firing an unwanted extra preview email each time — caught via reground-campaigns' welcome/campaign.md re-previewing on an unrelated push. Treat TemplateID 0 as "don't compare" instead. Test fake now mirrors listmonk's real default-assignment behavior so this class of bug is caught.
This commit is contained in:
@@ -222,7 +222,13 @@ func campaignUnchanged(existing *listmonk.Campaign, input listmonk.CampaignInput
|
||||
// stored altbody is still null even though its body hasn't changed.
|
||||
existing.AltBody == input.Body &&
|
||||
existing.FromEmail == input.FromEmail &&
|
||||
existing.TemplateID == input.TemplateID &&
|
||||
// input.TemplateID == 0 means "unspecified, use whatever's assigned"
|
||||
// (see CampaignInput.TemplateID) -- listmonk always assigns some real,
|
||||
// nonzero template_id server-side even when it's omitted from the
|
||||
// create/update payload, so comparing 0 against that would flag every
|
||||
// campaign.md without an explicit template_id as changed on every
|
||||
// sync, forever.
|
||||
(input.TemplateID == 0 || existing.TemplateID == input.TemplateID) &&
|
||||
existing.Type == input.Type &&
|
||||
equalStringSets(existing.Tags, input.Tags) &&
|
||||
equalIntSets(existing.ListIDs, input.ListIDs) &&
|
||||
|
||||
Reference in New Issue
Block a user