Explorar el Código

create put /enabled

zahmis hace 5 años
padre
commit
39ed814817
Se han modificado 1 ficheros con 16 adiciones y 3 borrados
  1. 16 3
      src/server/routes/apiv3/slack-bot-setting.js

+ 16 - 3
src/server/routes/apiv3/slack-bot-setting.js

@@ -44,7 +44,7 @@ module.exports = (crowi) => {
     ],
   };
 
-  async function updateCustomBotSettings(params) {
+  async function updateBotSettings(params) {
     const { configManager } = crowi;
     // update config without publishing S2sMessage
     return configManager.updateConfigsInTheSameNamespace('crowi', params, true);
@@ -115,7 +115,7 @@ module.exports = (crowi) => {
       };
 
       try {
-        await updateCustomBotSettings(requestParams);
+        await updateBotSettings(requestParams);
         const slackBotSettingParams = {
           slackSigningSecret: await crowi.configManager.getConfig('crowi', 'slackbot:signingSecret'),
           slackBotToken: await crowi.configManager.getConfig('crowi', 'slackbot:token'),
@@ -131,7 +131,20 @@ module.exports = (crowi) => {
 
   router.put('/enabled', async(req, res) => {
     const { isEnabled, botType } = req.body;
-    const enableParams = { [`slackbot:${botType}:isEnabled`]: isEnabled };
+    const enableParams = {
+      [`slackbot:${botType}:Enabled`]: JSON.parse(isEnabled),
+    };
+
+    try {
+      await updateBotSettings(enableParams);
+      const responseParams = {
+        [`slackbot:${botType}:Enabled`]:  await crowi.configManager.getConfig('crowi', `slackbot:${botType}:Enabled`),
+      };
+      return res.apiv3({ responseParams });
+    }
+    catch (error) {
+      console.log('errormatu');
+    }
 
 
   });