Validate if newsletter has an unsubscribe link

[MAILPOET-3857]
This commit is contained in:
Pavel Dohnal
2021-10-19 12:53:50 +02:00
committed by Veljko V
parent 3a67210743
commit 813d43f857
3 changed files with 38 additions and 1 deletions

View File

@ -143,6 +143,25 @@ class SendingQueue extends APIEndpoint {
}
private function validateNewsletter(NewsletterEntity $newsletterEntity): ?string {
if (
$newsletterEntity->getBody()
&& is_array($newsletterEntity->getBody())
&& $newsletterEntity->getBody()['content']
) {
$body = json_encode($newsletterEntity->getBody()['content']);
if ($body === false) {
return __('Poet, please add prose to your masterpiece before you send it to your followers.');
}
// todo only check this if MSS is active
if ((strpos($body, '[link:subscription_unsubscribe_url]') === false)
&& (strpos($body, '[link:subscription_unsubscribe]') === false)
) {
return __('All emails must include an "Unsubscribe" link. Add a footer widget to your email to continue.');
}
} else {
return __('Poet, please add prose to your masterpiece before you send it to your followers.');
}
return null;
}