Browse Source

fix/ both comming notification from growi

zahmis 5 years ago
parent
commit
380355654f

+ 8 - 12
src/server/service/global-notification/global-notification-slack.js

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

+ 4 - 10
src/server/service/user-notification/index.js

@@ -25,7 +25,7 @@ class UserNotificationService {
    */
   async fire(page, user, slackChannelsStr, mode, option, comment = {}) {
     const {
-      slackNotificationService, configManager, slackLegacy, slack,
+      slackNotificationService, slackLegacy, slack,
     } = this.crowi;
 
     const opt = option || {};
@@ -43,17 +43,11 @@ class UserNotificationService {
     const promises = slackChannels.map(async(chan) => {
       let res;
       if (mode === 'comment') {
-        if (configManager.getConfig('crowi', 'slackbot:token')) {
-          res = await slack.postComment(comment, user, chan, page.path);
-        }
-        else {
-          res = await slackLegacy.postComment(comment, user, chan, page.path);
-        }
-      }
-      else if (configManager.getConfig('crowi', 'slackbot:token')) {
-        res = await slack.postPage(page, user, chan, mode, previousRevision);
+        res = await slack.postComment(comment, user, chan, page.path);
+        res = await slackLegacy.postComment(comment, user, chan, page.path);
       }
       else {
+        res = await slack.postPage(page, user, chan, mode, previousRevision);
         res = await slackLegacy.postPage(page, user, chan, mode, previousRevision);
       }
       if (res.status !== 'ok') {