78 $delivery_interval =
$recipient->getPrivateSetting(
'delayed_email_interval') ??
'daily';
81 return $this->queue_table->queueEmail(
$recipient->guid, $delivery_interval, $notification);
101 return ($this->invoker->call(
ELGG_IGNORE_ACCESS,
function() use ($delivery_interval, $timestamp) {
103 $last_recipient_guid = null;
107 $processRecipient =
function($row = null) use (&$last_recipient_guid, &
$notifications, $delivery_interval, $timestamp) {
110 }
catch (\Throwable $t) {
115 $this->queue_table->deleteRecipientRows($last_recipient_guid, $delivery_interval, $timestamp);
118 $last_recipient_guid = $row ? $row->recipient_guid : null;
122 $rows = $this->queue_table->getIntervalRows($delivery_interval, $timestamp);
125 foreach (
$rows as $row) {
128 if (!isset($last_recipient_guid)) {
129 $last_recipient_guid = $row->recipient_guid;
130 }
elseif ($last_recipient_guid !== $row->recipient_guid) {
132 $processRecipient($row);
135 $notfication = $row->getNotification();
143 if (isset($last_recipient_guid)) {
169 'delivery_interval' => $delivery_interval,
172 $body = $this->views->renderView(
'email/delayed_email/plaintext', $view_vars);
177 $html_body = $this->views->renderView(
'email/delayed_email/html', $view_vars);
181 'subject' => $this->translator->translate(
"notifications:delayed_email:subject:{$delivery_interval}", [],
$recipient->language),
184 '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.
__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.
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.
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof ElggRelationship) elseif(is_callable([$item, 'getType']))
Handle storing and processing delayed emails.
get_entity($guid)
Loads and returns an entity object from a guid.