|
|
@@ -179,7 +179,7 @@ module.exports = (crowi) => {
|
|
|
settings.slackBotTokenEnvVars = configManager.getConfigFromEnvVars('crowi', 'slackbot:withoutProxy:botToken');
|
|
|
settings.slackSigningSecret = configManager.getConfig('crowi', 'slackbot:withoutProxy:signingSecret');
|
|
|
settings.slackBotToken = configManager.getConfig('crowi', 'slackbot:withoutProxy:botToken');
|
|
|
- settings.commandPermission = configManager.getConfig('crowi', 'slackbot:withoutProxy:commandPermission');
|
|
|
+ settings.commandPermission = JSON.parse(configManager.getConfig('crowi', 'slackbot:withoutProxy:commandPermission'));
|
|
|
}
|
|
|
else {
|
|
|
settings.proxyServerUri = crowi.configManager.getConfig('crowi', 'slackbot:proxyUri');
|
|
|
@@ -250,6 +250,25 @@ module.exports = (crowi) => {
|
|
|
await resetAllBotSettings(initializedBotType);
|
|
|
crowi.slackIntegrationService.publishUpdatedMessage();
|
|
|
|
|
|
+ if (initializedBotType === 'customBotWithoutProxy') {
|
|
|
+ // set without-proxy command permissions at bot type changing
|
|
|
+ const commandPermission = {};
|
|
|
+ [...defaultSupportedCommandsNameForBroadcastUse, ...defaultSupportedCommandsNameForSingleUse].forEach((commandName) => {
|
|
|
+ commandPermission[commandName] = true;
|
|
|
+ });
|
|
|
+
|
|
|
+ const requestParams = { 'slackbot:withoutProxy:commandPermission': JSON.stringify(commandPermission) };
|
|
|
+ try {
|
|
|
+ await updateSlackBotSettings(requestParams);
|
|
|
+ crowi.slackIntegrationService.publishUpdatedMessage();
|
|
|
+ }
|
|
|
+ catch (error) {
|
|
|
+ const msg = 'Error occured in updating command permission settigns';
|
|
|
+ logger.error('Error', error);
|
|
|
+ return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'), 500);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 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 });
|
|
|
@@ -362,6 +381,20 @@ module.exports = (crowi) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /slack-integration-settings/without-proxy/update-permissions/:
|
|
|
+ * put:
|
|
|
+ * tags: [UpdateWithoutProxyPermissions]
|
|
|
+ * operationId: putWithoutProxyPermissions
|
|
|
+ * summary: update customBotWithoutProxy permissions
|
|
|
+ * description: Update customBotWithoutProxy permissions.
|
|
|
+ * responses:
|
|
|
+ * 200:
|
|
|
+ * description: Succeeded to put CustomBotWithoutProxy permissions.
|
|
|
+ */
|
|
|
+
|
|
|
router.put('/without-proxy/update-permissions', async(req, res) => {
|
|
|
const currentBotType = crowi.configManager.getConfig('crowi', 'slackbot:currentBotType');
|
|
|
if (currentBotType !== SlackbotType.CUSTOM_WITHOUT_PROXY) {
|
|
|
@@ -371,7 +404,7 @@ module.exports = (crowi) => {
|
|
|
|
|
|
const { commandPermission } = req.body;
|
|
|
const requestParams = {
|
|
|
- 'slackbot:withouProxy:commandPermission': commandPermission,
|
|
|
+ 'slackbot:withoutProxy:commandPermission': commandPermission,
|
|
|
};
|
|
|
try {
|
|
|
await updateSlackBotSettings(requestParams);
|