-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer][SendGrid] add support for scheduling delivery via send_at
API parameter
#60372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 7.4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
use Symfony\Component\Mailer\Transport\AbstractApiTransport; | ||
use Symfony\Component\Mime\Address; | ||
use Symfony\Component\Mime\Email; | ||
use Symfony\Component\Mime\Header\DateHeader; | ||
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; | ||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; | ||
use Symfony\Contracts\HttpClient\HttpClientInterface; | ||
|
@@ -126,7 +127,12 @@ private function getPayload(Email $email, Envelope $envelope): array | |
continue; | ||
} | ||
|
||
if ($header instanceof TagHeader) { | ||
if ('send-at' === $name) { | ||
if (!$header instanceof DateHeader) { | ||
throw new TransportException(sprintf('The Send-At header should be a "%s" instance to deduce the correct timestamp.', DateHeader::class)); | ||
} | ||
$payload['send_at'] = $header->getDateTime()->getTimestamp(); | ||
} elseif ($header instanceof TagHeader) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about using guard clauses, instead of nested conditions, to improve readability? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi,thank you for your suggestion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a suggestion, but since you've added new conditions, this approach might make sense, as it's used in other integrations. I think it's worth waiting to hear and consider other opinions before making a final decision. |
||
if (10 === \count($categories)) { | ||
throw new TransportException(\sprintf('Too many "%s" instances present in the email headers. Sendgrid does not accept more than 10 categories on an email.', TagHeader::class)); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.