Преглед на файлове

set condition global-notification-slack

zahmis преди 5 години
родител
ревизия
b142b2c5fa
променени са 2 файла, в които са добавени 16 реда и са изтрити 18 реда
  1. 15 3
      src/server/service/global-notification/global-notification-slack.js
  2. 1 15
      src/server/util/slack.js

+ 15 - 3
src/server/service/global-notification/global-notification-slack.js

@@ -31,9 +31,21 @@ class GlobalNotificationSlackService {
     const messageBody = this.generateMessageBody(event, path, triggeredBy, vars);
     const messageBody = this.generateMessageBody(event, path, triggeredBy, vars);
     const attachmentBody = this.generateAttachmentBody(event, path, triggeredBy, vars);
     const attachmentBody = this.generateAttachmentBody(event, path, triggeredBy, vars);
 
 
-    await Promise.all(notifications.map((notification) => {
-      return this.slackLegacy.sendGlobalNotification(messageBody, attachmentBody, notification.slackChannels);
-    }));
+    if (this.crowi.configManager.getConfig('notification', 'slack:isIncomingWebhookPrioritized')) {
+      await Promise.all(notifications.map((notification) => {
+        return this.slackLegacy.sendGlobalNotification(messageBody, attachmentBody, notification.slackChannels);
+      }));
+    }
+    else if (this.crowi.configManager.getConfig('crowi', 'slackbot:token')) {
+      await Promise.all(notifications.map((notification) => {
+        return this.slack.sendGlobalNotification(messageBody, attachmentBody, notification.slackChannels);
+      }));
+    }
+    else {
+      await Promise.all(notifications.map((notification) => {
+        return this.slackLegacy.sendGlobalNotification(messageBody, attachmentBody, notification.slackChannels);
+      }));
+    }
   }
   }
 
 
   /**
   /**

+ 1 - 15
src/server/util/slack.js

@@ -218,21 +218,7 @@ module.exports = function(crowi) {
   };
   };
 
 
   const slackPost = (messageObj) => {
   const slackPost = (messageObj) => {
-    console.log('hoge');
-    // when incoming Webhooks is prioritized
-    if (configManager.getConfig('notification', 'slack:isIncomingWebhookPrioritized')) {
-      // if (configManager.getConfig('notification', 'slack:incomingWebhookUrl')) {
-      //   debug('posting message with IncomingWebhook');
-      //   return postWithIwh(messageObj);
-      // }
-      if (configManager.getConfig('crowi', 'slackbot:token')) {
-        return postWithSlackBot(messageObj);
-      }
-    }
-    // else
-    else if (configManager.getConfig('crowi', 'slackbot:token')) {
-      return postWithSlackBot(messageObj);
-    }
+    return postWithSlackBot(messageObj);
   };
   };
 
 
   return slack;
   return slack;