From 7c0ff8130b179cb6961649533e7c77150279dc81 Mon Sep 17 00:00:00 2001 From: Ryahn Date: Mon, 27 Jan 2025 19:24:20 -0500 Subject: [PATCH] another fix --- src/db/models/Message.js | 17 +++++++++++++++++ src/haraka-plugins/queue/store_message.js | 1 - 2 files changed, 17 insertions(+), 1 deletion(-) 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);