From: Tim Düsterhus Date: Mon, 15 Feb 2021 10:44:32 +0000 (+0100) Subject: Create email log entry when creating a delivery job X-Git-Tag: 5.4.0_Alpha_1~252^2~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=619deea6e3b52675aa9c14ec413af911fb7128e3;p=GitHub%2FWoltLab%2FWCF.git Create email log entry when creating a delivery job --- diff --git a/wcfsetup/install/files/lib/system/background/job/EmailDeliveryBackgroundJob.class.php b/wcfsetup/install/files/lib/system/background/job/EmailDeliveryBackgroundJob.class.php index 04eb69f33d..1194682e41 100644 --- a/wcfsetup/install/files/lib/system/background/job/EmailDeliveryBackgroundJob.class.php +++ b/wcfsetup/install/files/lib/system/background/job/EmailDeliveryBackgroundJob.class.php @@ -2,9 +2,12 @@ namespace wcf\system\background\job; +use wcf\data\email\log\entry\EmailLogEntry; +use wcf\data\email\log\entry\EmailLogEntryAction; use wcf\system\email\Email; use wcf\system\email\Mailbox; use wcf\system\email\transport\exception\PermanentFailure; +use wcf\system\email\UserMailbox; /** * Delivers the given email to the given mailbox. @@ -40,6 +43,11 @@ class EmailDeliveryBackgroundJob extends AbstractBackgroundJob */ protected $envelopeTo; + /** + * @var int + */ + protected $emailLogEntryId; + /** * instance of the default transport * @var \wcf\system\email\transport\IEmailTransport @@ -59,6 +67,24 @@ class EmailDeliveryBackgroundJob extends AbstractBackgroundJob $this->email = $email; $this->envelopeFrom = $envelopeFrom; $this->envelopeTo = $envelopeTo; + + $this->emailLogEntryId = $this->createLog()->entryID; + } + + /** + * Creates the email log entry. + */ + final private function createLog(): EmailLogEntry + { + return (new EmailLogEntryAction([], 'create', [ + 'data' => [ + 'time' => \TIME_NOW, + 'messageID' => $this->email->getMessageID(), + 'recipient' => $this->envelopeTo->getAddress(), + 'recipientID' => ($this->envelopeTo instanceof UserMailbox) ? $this->envelopeTo->getUser()->userID : null, + 'status' => EmailLogEntry::STATUS_NEW, + ] + ]))->executeAction()['returnValues']; } /**