Browse Source

fix global notification. use getSlackLegacy

zahmis 5 years ago
parent
commit
f251be3a02

+ 2 - 1
src/server/service/global-notification/global-notification-slack.js

@@ -9,6 +9,7 @@ class GlobalNotificationSlackService {
   constructor(crowi) {
     this.crowi = crowi;
     this.slack = crowi.getSlack();
+    this.slackLegacy = crowi.getSlackLegacy();
     this.type = crowi.model('GlobalNotificationSetting').TYPE.SLACK;
     this.event = crowi.model('GlobalNotificationSetting').EVENT;
   }
@@ -31,7 +32,7 @@ class GlobalNotificationSlackService {
     const attachmentBody = this.generateAttachmentBody(event, path, triggeredBy, vars);
 
     await Promise.all(notifications.map((notification) => {
-      return this.slack.sendGlobalNotification(messageBody, attachmentBody, notification.slackChannels);
+      return this.slackLegacy.sendGlobalNotification(messageBody, attachmentBody, notification.slackChannels);
     }));
   }
 

+ 4 - 1
src/server/util/slack-legacy.js

@@ -1,5 +1,5 @@
 const debug = require('debug')('growi:util:slack');
-const slack = require('./slack');
+// const slack = require('./slack');
 
 /**
  * slack
@@ -11,6 +11,8 @@ module.exports = function(crowi) {
   const Slack = require('slack-node');
 
   const { configManager } = crowi;
+  const slack = crowi.getSlack();
+
   const slackLegacy = {};
 
   const postWithIwh = function(messageObj) {
@@ -66,6 +68,7 @@ module.exports = function(crowi) {
   };
 
   const slackPost = (messageObj) => {
+    console.log('fuga');
     // when incoming Webhooks is prioritized
     if (configManager.getConfig('notification', 'slack:isIncomingWebhookPrioritized')) {
       if (configManager.getConfig('notification', 'slack:incomingWebhookUrl')) {