From be09d0ce4a86d80a2852dfd1732f21e33e12a7cb Mon Sep 17 00:00:00 2001 From: Nikolai Ovtsinnikov Date: Thu, 3 Oct 2024 16:21:25 +0300 Subject: [PATCH 1/2] in case of redis error return MTA-STS is disabled --- lib/sender.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sender.js b/lib/sender.js index ab196f3..56dea97 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -100,7 +100,7 @@ class Sender extends EventEmitter { get: async domain => { if (!db.redis) { - return; + return { enabled: false, error: 'Redis connection error' }; // if no redis return that MTA-STS is disabled } try { let json = await db.redis.get(`sts:${domain}`); @@ -123,6 +123,7 @@ class Sender extends EventEmitter { } } catch (err) { log.error(this.logName + '/MTA-STS', 'Redis error domain=%s err=%s', domain, err.message); + return { enabled: false, error: 'Redis request and connection error' }; // If redis error return MTA-STS is disabled } } }, From 73e42c9f9706d71a5e63afc339b2179aa753b70a Mon Sep 17 00:00:00 2001 From: Nikolai Ovtsinnikov Date: Fri, 4 Oct 2024 12:18:57 +0300 Subject: [PATCH 2/2] refactor error message --- lib/sender.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sender.js b/lib/sender.js index 56dea97..4e930b4 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -100,7 +100,7 @@ class Sender extends EventEmitter { get: async domain => { if (!db.redis) { - return { enabled: false, error: 'Redis connection error' }; // if no redis return that MTA-STS is disabled + return { enabled: false, error: { message: 'Redis connection error' } }; // if no redis return that MTA-STS is disabled } try { let json = await db.redis.get(`sts:${domain}`); @@ -123,7 +123,7 @@ class Sender extends EventEmitter { } } catch (err) { log.error(this.logName + '/MTA-STS', 'Redis error domain=%s err=%s', domain, err.message); - return { enabled: false, error: 'Redis request and connection error' }; // If redis error return MTA-STS is disabled + return { enabled: false, error: { message: 'Redis request and connection error' } }; // If redis error return MTA-STS is disabled } } },