mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 12:53:13 +03:00
d8187123af
fixes https://github.com/TryGhost/Team/issues/2332 Saves events in the database and collects error information. Do note that we can emit the same events multiple times, and as a result out of order. That means we should correctly handle that a delivered event might be fired after a permanent failure. So a delivered event is ignored if the email is already marked as failed. Also delivered_at is reset to null when we receive a permanent failure.
64 lines
1.1 KiB
JavaScript
64 lines
1.1 KiB
JavaScript
module.exports = class EmailBouncedEvent {
|
|
/**
|
|
* @readonly
|
|
* @type {string}
|
|
*/
|
|
id;
|
|
|
|
/**
|
|
* @readonly
|
|
* @type {string}
|
|
*/
|
|
email;
|
|
|
|
/**
|
|
* @readonly
|
|
* @type {string}
|
|
*/
|
|
memberId;
|
|
|
|
/**
|
|
* @readonly
|
|
* @type {string}
|
|
*/
|
|
emailId;
|
|
|
|
/**
|
|
* @readonly
|
|
* @type {{message: string, code: number, enhancedCode: string | null}}
|
|
*/
|
|
error;
|
|
|
|
/**
|
|
* @readonly
|
|
* @type {string}
|
|
*/
|
|
emailRecipientId;
|
|
|
|
/**
|
|
* @readonly
|
|
* @type {Date}
|
|
*/
|
|
timestamp;
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
constructor({id, email, memberId, emailId, error, emailRecipientId, timestamp}) {
|
|
this.id = id;
|
|
this.memberId = memberId;
|
|
this.emailId = emailId;
|
|
this.email = email;
|
|
this.error = error;
|
|
this.emailRecipientId = emailRecipientId;
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
static create(data) {
|
|
return new EmailBouncedEvent({
|
|
...data,
|
|
timestamp: data.timestamp || new Date
|
|
});
|
|
}
|
|
};
|