Add tests for campaignId generation

[MAILPOET-5033]
This commit is contained in:
John Oleksowicz
2023-02-14 12:53:35 -06:00
committed by Aschepikov
parent 1a04b05e0d
commit a6824cce36
2 changed files with 49 additions and 0 deletions

View File

@ -427,6 +427,14 @@ class SendingQueue {
);
}
/**
* @param NewsletterEntity $newsletter
* @param string $textBody - The pre-processed text body of the newsletter, before any shortcodes have been processed.
* Leaving the shortcodes unprocessed ensures that we get the same campaignId for different subscribers, as well as
* for different sends of the same automatic email when link tracking is enabled.
*
* @return string
*/
public function calculateCampaignId(NewsletterEntity $newsletter, string $textBody): string {
return substr(md5(implode('|', [$newsletter->getId(), $textBody, $newsletter->getSubject()])), 0, 16);
}