Procházet zdrojové kódy

abolish hasSlackToken

mizozobu před 6 roky
rodič
revize
b893aa0083

+ 0 - 8
src/server/models/config.js

@@ -395,14 +395,6 @@ module.exports = function(crowi) {
     return (!!config.notification['slack:isIncomingWebhookPrioritized']);
     return (!!config.notification['slack:isIncomingWebhookPrioritized']);
   };
   };
 
 
-  configSchema.statics.hasSlackToken = function(config) {
-    if (!config.notification) {
-      return false;
-    }
-
-    return (!!config.notification['slack:token']);
-  };
-
   configSchema.statics.getLocalconfig = function() { // CONF.RF: これも別のメソッドにする
   configSchema.statics.getLocalconfig = function() { // CONF.RF: これも別のメソッドにする
     const env = process.env;
     const env = process.env;
 
 

+ 1 - 2
src/server/routes/admin.js

@@ -216,11 +216,10 @@ module.exports = function(crowi, app) {
   // app.get('/admin/notification'               , admin.notification.index);
   // app.get('/admin/notification'               , admin.notification.index);
   actions.notification = {};
   actions.notification = {};
   actions.notification.index = async(req, res) => {
   actions.notification.index = async(req, res) => {
-    const config = crowi.getConfig();
     const UpdatePost = crowi.model('UpdatePost');
     const UpdatePost = crowi.model('UpdatePost');
     let slackSetting = configManager.getConfigByPrefix('notification', 'slack:');
     let slackSetting = configManager.getConfigByPrefix('notification', 'slack:');
     const hasSlackIwhUrl = !!configManager.getConfig('notification', 'slack:incomingWebhookUrl');
     const hasSlackIwhUrl = !!configManager.getConfig('notification', 'slack:incomingWebhookUrl');
-    const hasSlackToken = Config.hasSlackToken(config);
+    const hasSlackToken = !!configManager.getConfig('notification', 'slack:token');
 
 
     if (!hasSlackIwhUrl) {
     if (!hasSlackIwhUrl) {
       slackSetting['slack:incomingWebhookUrl'] = '';
       slackSetting['slack:incomingWebhookUrl'] = '';

+ 2 - 2
src/server/util/slack.js

@@ -211,14 +211,14 @@ module.exports = function(crowi) {
         debug('posting message with IncomingWebhook');
         debug('posting message with IncomingWebhook');
         return postWithIwh(messageObj);
         return postWithIwh(messageObj);
       }
       }
-      if (Config.hasSlackToken(config)) {
+      if (configManager.getConfig('notification', 'slack:token')) {
         debug('posting message with Web API');
         debug('posting message with Web API');
         return postWithWebApi(messageObj);
         return postWithWebApi(messageObj);
       }
       }
     }
     }
     // else
     // else
     else {
     else {
-      if (Config.hasSlackToken(config)) {
+      if (configManager.getConfig('notification', 'slack:token')) {
         debug('posting message with Web API');
         debug('posting message with Web API');
         return postWithWebApi(messageObj);
         return postWithWebApi(messageObj);
       }
       }