Don't add a CTA if an emails contains a P.S.
Don't automatically add a CTA to a daily email if the email body text already contains a "P.S.".
This commit is contained in:
parent
b7f13b4be5
commit
9abf64b504
2 changed files with 16 additions and 1 deletions
|
@ -22,7 +22,9 @@ readonly final class AddRandomCtaToDailyEmail {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Don't add a CTA if the email already contains a "P.S.".
|
if (str_contains(haystack: $email->get('body')->value, needle: 'P.S.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$nodeStorage = $this->entityTypeManager->getStorage('node');
|
$nodeStorage = $this->entityTypeManager->getStorage('node');
|
||||||
$query = $nodeStorage->getQuery();
|
$query = $nodeStorage->getQuery();
|
||||||
|
|
|
@ -46,4 +46,17 @@ final class CallToActionTest extends ExistingSiteBase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_cta_in_body_prevents_automatically_adding_a_cta(): void {
|
||||||
|
$email = $this->createNode([
|
||||||
|
'body' => [
|
||||||
|
'format' => 'basic_html',
|
||||||
|
'value' => 'P.S. This email already contains a CTA.',
|
||||||
|
],
|
||||||
|
'field_daily_email_cta' => NULL,
|
||||||
|
'type' => 'daily_email',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEmpty($email->get('field_daily_email_cta'));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue