diff --git a/src/db/models/Message.js b/src/db/models/Message.js index 2479a57..d8dd4fc 100644 --- a/src/db/models/Message.js +++ b/src/db/models/Message.js @@ -18,6 +18,23 @@ class Message extends BaseModel { } }; } + + $beforeUpdate() { + this.updated_at = this.formatDateForMySQL(new Date()); + this.received_at = this.formatDateForMySQL(new Date()); + this.created_at = this.formatDateForMySQL(new Date()); + } + + async $beforeInsert() { + await super.$beforeInsert(); + this.updated_at = this.formatDateForMySQL(new Date()); + this.received_at = this.formatDateForMySQL(new Date()); + this.created_at = this.formatDateForMySQL(new Date()); + } + + formatDateForMySQL(date) { + return date.toISOString().slice(0, 19).replace('T', ' '); + } } module.exports = Message; \ No newline at end of file diff --git a/src/haraka-plugins/queue/store_message.js b/src/haraka-plugins/queue/store_message.js index fb0709c..ca90cc9 100644 --- a/src/haraka-plugins/queue/store_message.js +++ b/src/haraka-plugins/queue/store_message.js @@ -33,7 +33,6 @@ exports.register = function () { subject: subject, body: body, headers: headers, - domain: transaction.rcpt_to[0].host, }; await MessageService.store(messageData);