80 $delivery_interval =
$recipient->delayed_email_interval ?:
'daily';
83 return $this->queue_table->queueEmail(
$recipient->guid, $delivery_interval, $notification);
103 return ($this->invoker->call(
ELGG_IGNORE_ACCESS,
function() use ($delivery_interval, $timestamp) {
110 }
catch (\Throwable $t) {
115 return $this->queue_table->deleteRecipientRows($recipient_guid, $delivery_interval, $timestamp, $max_id);
119 $recipient_guid = $this->queue_table->getNextRecipientGUID($delivery_interval, $timestamp);
120 while ($recipient_guid > 0) {
122 $rows = $this->queue_table->getRecipientRows($recipient_guid, $delivery_interval, $timestamp, self::NOTIFICATIONS_BATCH_SIZE);
123 while (!empty(
$rows)) {
126 foreach (
$rows as $row) {
127 $max_id =
max($max_id, $row->id);
138 $count += $processRecipient($recipient_guid, $notifications, $max_id);
141 $rows = $this->queue_table->getRecipientRows($recipient_guid, $delivery_interval, $timestamp, static::NOTIFICATIONS_BATCH_SIZE);
145 $recipient_guid = $this->queue_table->getNextRecipientGUID($delivery_interval, $timestamp);
170 'delivery_interval' => $delivery_interval,
173 $body = $this->views->renderView(
'email/delayed_email/plaintext', $view_vars);
178 $html_body = $this->views->renderView(
'email/delayed_email/html', $view_vars);
182 'subject' => $this->translator->translate(
"notifications:delayed_email:subject:{$delivery_interval}", [], (
string)
$recipient->language),
185 'html_body' => $html_body,
getRecipient()
Get the recipient entity.
processQueuedNotifications(string $delivery_interval, int $timestamp)
Send out notifications for the given delivery_interval.
static factory(array $options=[])
Create an email instance form an array of options.
const NOTIFICATIONS_BATCH_SIZE
__construct(DelayedEmailQueueTable $queue_table, EmailService $email, ViewsService $views, Translator $translator, Invoker $invoker)
Create a new service.
trait Loggable
Enables adding a logger.
const ELGG_IGNORE_ACCESS
elgg_call() flags
enqueueNotification(Notification $notification)
Queue a notification for delayed email delivery.
get_entity(int $guid)
Loads and returns an entity object from a guid.
A generic parent class for database exceptions.
processRecipientNotifications(int $recipient_guid, array $notifications, string $delivery_interval)
Send out the combined email notification for a given recipient.
Interfaces with the database to perform operations on the delayed_email_queue table.
getLogger()
Returns logger.
Handle storing and processing delayed emails.