From 6a30dbd71aa1c8bf22157546915f7876a31995e3 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 9 Apr 2022 15:44:50 +0800 Subject: [PATCH] Fix Mattermost when channel is empty #1468 --- server/notification-providers/mattermost.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/notification-providers/mattermost.js b/server/notification-providers/mattermost.js index c2ffc23b8..fe7b685e1 100644 --- a/server/notification-providers/mattermost.js +++ b/server/notification-providers/mattermost.js @@ -15,12 +15,17 @@ class Mattermost extends NotificationProvider { let mattermostTestData = { username: mattermostUserName, text: msg, - } - await axios.post(notification.mattermostWebhookUrl, mattermostTestData) + }; + await axios.post(notification.mattermostWebhookUrl, mattermostTestData); return okMsg; } - const mattermostChannel = notification.mattermostchannel.toLowerCase(); + let mattermostChannel; + + if (typeof notification.mattermostchannel === "string") { + mattermostChannel = notification.mattermostchannel.toLowerCase(); + } + const mattermostIconEmoji = notification.mattermosticonemo; const mattermostIconUrl = notification.mattermosticonurl;