Преглед изворни кода

change name slack to slackLegacy

zahmis пре 5 година
родитељ
комит
2c9bc9d997
2 измењених фајлова са 9 додато и 9 уклоњено
  1. 3 3
      src/server/service/user-notification/index.js
  2. 6 6
      src/server/util/slack-legacy.js

+ 3 - 3
src/server/service/user-notification/index.js

@@ -24,7 +24,7 @@ class UserNotificationService {
    * @param {Comment} comment
    * @param {Comment} comment
    */
    */
   async fire(page, user, slackChannelsStr, mode, option, comment = {}) {
   async fire(page, user, slackChannelsStr, mode, option, comment = {}) {
-    const { slackNotificationService, slack } = this.crowi;
+    const { slackNotificationService, slackLegacy } = this.crowi;
 
 
     const opt = option || {};
     const opt = option || {};
     const previousRevision = opt.previousRevision || '';
     const previousRevision = opt.previousRevision || '';
@@ -41,10 +41,10 @@ class UserNotificationService {
     const promises = slackChannels.map(async(chan) => {
     const promises = slackChannels.map(async(chan) => {
       let res;
       let res;
       if (mode === 'comment') {
       if (mode === 'comment') {
-        res = await slack.postComment(comment, user, chan, page.path);
+        res = await slackLegacy.postComment(comment, user, chan, page.path);
       }
       }
       else {
       else {
-        res = await slack.postPage(page, user, chan, mode, previousRevision);
+        res = await slackLegacy.postPage(page, user, chan, mode, previousRevision);
       }
       }
       if (res.status !== 'ok') {
       if (res.status !== 'ok') {
         throw new Error(`fail to send slack notification to #${chan} channel`);
         throw new Error(`fail to send slack notification to #${chan} channel`);

+ 6 - 6
src/server/util/slack-legacy.js

@@ -11,7 +11,7 @@ module.exports = function(crowi) {
   const Slack = require('slack-node');
   const Slack = require('slack-node');
 
 
   const { configManager } = crowi;
   const { configManager } = crowi;
-  const slack = {};
+  const slackLegacy = {};
 
 
   const postWithIwh = function(messageObj) {
   const postWithIwh = function(messageObj) {
     return new Promise((resolve, reject) => {
     return new Promise((resolve, reject) => {
@@ -217,20 +217,20 @@ module.exports = function(crowi) {
     return text;
     return text;
   };
   };
 
 
-  // slack.post = function (channel, message, opts) {
-  slack.postPage = (page, user, channel, updateType, previousRevision) => {
+  // slackLegacy.post = function (channel, message, opts) {
+  slackLegacy.postPage = (page, user, channel, updateType, previousRevision) => {
     const messageObj = prepareSlackMessageForPage(page, user, channel, updateType, previousRevision);
     const messageObj = prepareSlackMessageForPage(page, user, channel, updateType, previousRevision);
 
 
     return slackPost(messageObj);
     return slackPost(messageObj);
   };
   };
 
 
-  slack.postComment = (comment, user, channel, path) => {
+  slackLegacy.postComment = (comment, user, channel, path) => {
     const messageObj = prepareSlackMessageForComment(comment, user, channel, path);
     const messageObj = prepareSlackMessageForComment(comment, user, channel, path);
 
 
     return slackPost(messageObj);
     return slackPost(messageObj);
   };
   };
 
 
-  slack.sendGlobalNotification = async(messageBody, attachmentBody, slackChannel) => {
+  slackLegacy.sendGlobalNotification = async(messageBody, attachmentBody, slackChannel) => {
     const messageObj = await prepareSlackMessageForGlobalNotification(messageBody, attachmentBody, slackChannel);
     const messageObj = await prepareSlackMessageForGlobalNotification(messageBody, attachmentBody, slackChannel);
 
 
     return slackPost(messageObj);
     return slackPost(messageObj);
@@ -261,5 +261,5 @@ module.exports = function(crowi) {
     }
     }
   };
   };
 
 
-  return slack;
+  return slackLegacy;
 };
 };