56 $delivery_interval =
$recipient->delayed_email_interval ?:
'daily';
59 return $this->queue_table->queueEmail(
$recipient->guid, $delivery_interval, $notification);
79 return ($this->invoker->call(
ELGG_IGNORE_ACCESS,
function() use ($delivery_interval, $timestamp) {
86 }
catch (\Throwable $t) {
91 return $this->queue_table->deleteRecipientRows($recipient_guid, $delivery_interval, $timestamp, $max_id);
95 $recipient_guid = $this->queue_table->getNextRecipientGUID($delivery_interval, $timestamp);
96 while ($recipient_guid > 0) {
98 $rows = $this->queue_table->getRecipientRows($recipient_guid, $delivery_interval, $timestamp, self::NOTIFICATIONS_BATCH_SIZE);
99 while (!empty(
$rows)) {
102 foreach (
$rows as $row) {
103 $max_id =
max($max_id, $row->id);
114 $count += $processRecipient($recipient_guid, $notifications, $max_id);
117 $rows = $this->queue_table->getRecipientRows($recipient_guid, $delivery_interval, $timestamp, static::NOTIFICATIONS_BATCH_SIZE);
121 $recipient_guid = $this->queue_table->getNextRecipientGUID($delivery_interval, $timestamp);
146 'delivery_interval' => $delivery_interval,
149 $body = $this->views->renderView(
'email/delayed_email/plaintext', $view_vars);
154 $html_body = $this->views->renderView(
'email/delayed_email/html', $view_vars);
158 'subject' => $this->translator->translate(
"notifications:delayed_email:subject:{$delivery_interval}", [], (
string)
$recipient->language),
161 '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
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.
__construct(protected DelayedEmailQueueTable $queue_table, protected EmailService $email, protected ViewsService $views, protected Translator $translator, protected Invoker $invoker)
Create a new service.
Handle storing and processing delayed emails.