Browse Source

added new endpoint for default settings

kaori 4 years ago
parent
commit
2a1c45734c
1 changed files with 21 additions and 0 deletions
  1. 21 0
      src/server/routes/apiv3/slack-integration-settings.js

+ 21 - 0
src/server/routes/apiv3/slack-integration-settings.js

@@ -166,6 +166,27 @@ module.exports = (crowi) => {
       }
     });
 
+  router.put('/defaults',
+    accessTokenParser, loginRequiredStrictly, adminRequired, csrf, apiV3FormValidator, async(req, res) => {
+
+      await resetAllBotSettings();
+      const params = { 'slackbot:currentBotType': '' };
+
+      try {
+        await updateSlackBotSettings(params);
+        crowi.slackBotService.publishUpdatedMessage();
+
+        // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
+        const slackBotTypeParam = { slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType') };
+        return res.apiv3({ slackBotTypeParam });
+      }
+      catch (error) {
+        const msg = 'Error occured in updating Custom bot setting';
+        logger.error('Error', error);
+        return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'), 500);
+      }
+    });
+
   /**
    * @swagger
    *