From: Tim Düsterhus Date: Mon, 15 Feb 2021 10:15:39 +0000 (+0100) Subject: Add wcf1_email_log_entry X-Git-Tag: 5.4.0_Alpha_1~252^2~15 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1483324c5b0cbf9b1d02bca77ea99c63a358679b;p=GitHub%2FWoltLab%2FWCF.git Add wcf1_email_log_entry --- diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_db.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_db.php index 64f65a1d6f..7809379b55 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_db.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_db.php @@ -30,6 +30,32 @@ use wcf\system\package\plugin\ScriptPackageInstallationPlugin; use wcf\system\WCF; $tables = [ + DatabaseTable::create('wcf1_email_log_entry') + ->columns([ + ObjectIdDatabaseTableColumn::create('entryID'), + NotNullInt10DatabaseTableColumn::create('time'), + NotNullVarchar255DatabaseTableColumn::create('messageID'), + NotNullVarchar255DatabaseTableColumn::create('recipient'), + IntDatabaseTableColumn::create('recipientID') + ->length(10) + ->notNull(false), + NotNullVarchar255DatabaseTableColumn::create('status'), + TextDatabaseTableColumn::create('message'), + ]) + ->indices([ + DatabaseTablePrimaryIndex::create() + ->columns(['entryID']), + DatabaseTableIndex::create('time') + ->columns(['time']), + ]) + ->foreignKeys([ + DatabaseTableForeignKey::create() + ->columns(['recipientID']) + ->referencedTable('wcf1_user') + ->referencedColumns(['userID']) + ->onDelete('SET NULL'), + ]), + // This update script was added with 5.3.3. We need to ensure that the change is applied // when someone attempts to upgrade from an older 5.3.x for whatever reason. // If the database already has the proper state this will be a simple noop. diff --git a/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntry.class.php b/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntry.class.php new file mode 100644 index 0000000000..e723646f0e --- /dev/null +++ b/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntry.class.php @@ -0,0 +1,33 @@ + + * @package WoltLabSuite\Core\Data\Email\Log\Entry + * + * @property-read int $entryID unique id of the log entry + * @property-read int $time timestamp when the delivery job was created + * @property-read string $messageID the email's 'Message-ID' + * @property-read string $recipient the recipient ("RCPT TO") + * @property-read ?int $recipientID the recipient's userID (if the email is being sent to a registered user) + * @property-read string $status one of the `STATUS_*` constants + * @property-read string $message a human readable explanation for the status + * + */ +class EmailLogEntry extends DatabaseObject +{ + public const STATUS_NEW = 'new'; + + public const STATUS_SUCCESS = 'success'; + + public const STATUS_TRANSIENT_FAILURE = 'transient_failure'; + + public const STATUS_PERMANENT_FAILURE = 'permanent_failure'; +} diff --git a/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntryAction.class.php b/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntryAction.class.php new file mode 100644 index 0000000000..1348b920b2 --- /dev/null +++ b/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntryAction.class.php @@ -0,0 +1,25 @@ + + * @package WoltLabSuite\Core\Data\Email\Log\Entry + * + * @method EmailLogEntry create() + * @method EmailLogEntryEditor[] getObjects() + * @method EmailLogEntryEditor getSingleObject() + */ +class EmailLogEntryAction extends AbstractDatabaseObjectAction +{ + /** + * @inheritDoc + */ + protected $className = EmailLogEntryEditor::class; +} diff --git a/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntryEditor.class.php b/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntryEditor.class.php new file mode 100644 index 0000000000..fc11a2e1be --- /dev/null +++ b/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntryEditor.class.php @@ -0,0 +1,25 @@ + + * @package WoltLabSuite\Core\Data\Email\Log\Entry + * + * @method static EmailLogEntry create(array $parameters = []) + * @method EmailLogEntry getDecoratedObject() + * @mixin EmailLogEntry + */ +class EmailLogEntryEditor extends DatabaseObjectEditor +{ + /** + * @inheritDoc + */ + protected static $baseClass = EmailLogEntry::class; +} diff --git a/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntryList.class.php b/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntryList.class.php new file mode 100644 index 0000000000..d7fcc4083b --- /dev/null +++ b/wcfsetup/install/files/lib/data/email/log/entry/EmailLogEntryList.class.php @@ -0,0 +1,26 @@ + + * @package WoltLabSuite\Core\Data\Emaiil\Log\Entry + * + * @method EmailLogEntry current() + * @method EmailLogEntry[] getObjects() + * @method EmailLogEntry|null search($objectID) + * @property EmailLogEntry[] $objects + */ +class EmailLogEntryList extends DatabaseObjectList +{ + /** + * @inheritDoc + */ + public $className = EmailLogEntry::class; +} diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index c035d5d883..9c4d5eae4f 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -551,6 +551,19 @@ CREATE TABLE wcf1_edit_history_entry ( KEY (obsoletedAt, obsoletedByUserID) ); +DROP TABLE IF EXISTS wcf1_email_log_entry; +CREATE TABLE wcf1_email_log_entry ( + entryID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, + time INT(10) NOT NULL, + messageID VARCHAR(255) NOT NULL, + recipient VARCHAR(255) NOT NULL, + recipientID INT(10) DEFAULT NULL, + status VARCHAR(255) NOT NULL, + message TEXT, + + KEY time (time) +); + DROP TABLE IF EXISTS wcf1_event_listener; CREATE TABLE wcf1_event_listener ( listenerID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, @@ -1995,6 +2008,8 @@ ALTER TABLE wcf1_edit_history_entry ADD FOREIGN KEY (objectTypeID) REFERENCES wc ALTER TABLE wcf1_edit_history_entry ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE SET NULL; ALTER TABLE wcf1_edit_history_entry ADD FOREIGN KEY (obsoletedByUserID) REFERENCES wcf1_user (userID) ON DELETE SET NULL; +ALTER TABLE wcf1_email_log_entry ADD FOREIGN KEY (recipientID) REFERENCES wcf1_user (userID) ON DELETE SET NULL; + ALTER TABLE wcf1_event_listener ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE; ALTER TABLE wcf1_language_item ADD FOREIGN KEY (languageID) REFERENCES wcf1_language (languageID) ON DELETE CASCADE;