|
|
@@ -274,5 +274,37 @@ module.exports = (crowi) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ router.put('/update-settings', async(req, res) => {
|
|
|
+ if (req.body.currentBotType === 'customBotWithoutProxy') {
|
|
|
+ const { slackSigningSecret, slackBotToken, currentBotType } = req.body;
|
|
|
+ const requestParams = {
|
|
|
+ 'slackbot:signingSecret': slackSigningSecret,
|
|
|
+ 'slackbot:token': slackBotToken,
|
|
|
+ 'slackbot:currentBotType': currentBotType,
|
|
|
+ };
|
|
|
+ try {
|
|
|
+ await updateSlackBotSettings(requestParams);
|
|
|
+ crowi.slackBotService.publishUpdatedMessage();
|
|
|
+
|
|
|
+ // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
|
|
|
+ const customBotWithoutProxySettingParams = {
|
|
|
+ slackSigningSecret: crowi.configManager.getConfig('crowi', 'slackbot:signingSecret'),
|
|
|
+ slackBotToken: crowi.configManager.getConfig('crowi', 'slackbot:token'),
|
|
|
+ slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType'),
|
|
|
+ };
|
|
|
+ return res.apiv3({ customBotWithoutProxySettingParams });
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // TODO imple other botType action
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
return router;
|
|
|
};
|