zahmis 5 лет назад
Родитель
Сommit
e2e209a99c
2 измененных файлов с 11 добавлено и 27 удалено
  1. 7 11
      src/server/routes/apiv3/slack-bot-setting.js
  2. 4 16
      src/server/service/config-loader.js

+ 7 - 11
src/server/routes/apiv3/slack-bot-setting.js

@@ -67,11 +67,8 @@ module.exports = (crowi) => {
 
 
     const slackBotSettingParams = {
     const slackBotSettingParams = {
 
 
-      generalSlackBot: {
-        isOfficialEnabled: await crowi.configManager.getConfig('crowi', 'slackbot:isOfficial:Enabled'),
-        isCustomNonProxyEnabled: await crowi.configManager.getConfig('crowi', 'slackbot:isCustomNonProxy:Enabled'),
-        isCustomWithProxyEnabled: await crowi.configManager.getConfig('crowi', 'slackbot:isCustomWithProxy:Enabled'),
-      },
+      slackBotType: await crowi.configManager.getConfig('crowi', 'slackbot:type'),
+
       // TODO impl when creating official bot
       // TODO impl when creating official bot
       officialBotSettings: {
       officialBotSettings: {
       },
       },
@@ -130,15 +127,14 @@ module.exports = (crowi) => {
     });
     });
 
 
   router.put('/enabled', async(req, res) => {
   router.put('/enabled', async(req, res) => {
-    const { isEnabled, botType } = req.body;
-    const enableParams = {
-      [`slackbot:${botType}:Enabled`]: JSON.parse(isEnabled),
-    };
+    const { botType } = req.body;
+    console.log(botType);
+    const requestParams = { 'slackbot:type': botType };
 
 
     try {
     try {
-      await updateBotSettings(enableParams);
+      await updateBotSettings(requestParams);
       const responseParams = {
       const responseParams = {
-        [`slackbot:${botType}:Enabled`]:  await crowi.configManager.getConfig('crowi', `slackbot:${botType}:Enabled`),
+        'slackbot:type': await crowi.configManager.getConfig('crowi', 'slackbot:type'),
       };
       };
       return res.apiv3({ responseParams });
       return res.apiv3({ responseParams });
     }
     }

+ 4 - 16
src/server/service/config-loader.js

@@ -410,23 +410,11 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type:    TYPES.STRING,
     type:    TYPES.STRING,
     default: null,
     default: null,
   },
   },
-  OFFICIAL_BOT_ENABLED: {
+  SLACK_BOT_TYPE: {
     ns:      'crowi',
     ns:      'crowi',
-    key:     'slackbot:isOfficial:Enabled',
-    type:    TYPES.BOOLEAN,
-    default: true,
-  },
-  CUSTOM_BOT_NON_PROXY_ENABLED: {
-    ns:      'crowi',
-    key:     'slackbot:isCustomNonProxy:Enabled',
-    type:    TYPES.BOOLEAN,
-    default: false,
-  },
-  CUSTOM_BOT_WITH_PROXY_ENABLED: {
-    ns:      'crowi',
-    key:     'slackbot:isCustomWithProxy:Enabled',
-    type:    TYPES.BOOLEAN,
-    default: false,
+    key:     'slackbot:type', // official || nonProxy || withProxy
+    type:    TYPES.STRING,
+    default: 'custom',
   },
   },
 };
 };