|
@@ -1,6 +1,6 @@
|
|
|
const mongoose = require('mongoose');
|
|
const mongoose = require('mongoose');
|
|
|
const express = require('express');
|
|
const express = require('express');
|
|
|
-const { body, query } = require('express-validator');
|
|
|
|
|
|
|
+const { body, query, param } = require('express-validator');
|
|
|
const axios = require('axios');
|
|
const axios = require('axios');
|
|
|
const urljoin = require('url-join');
|
|
const urljoin = require('url-join');
|
|
|
const loggerFactory = require('@alias/logger');
|
|
const loggerFactory = require('@alias/logger');
|
|
@@ -59,6 +59,11 @@ module.exports = (crowi) => {
|
|
|
body('proxyUri').if(value => value !== '').trim().matches(/^(https?:\/\/)/)
|
|
body('proxyUri').if(value => value !== '').trim().matches(/^(https?:\/\/)/)
|
|
|
.isURL({ require_tld: false }),
|
|
.isURL({ require_tld: false }),
|
|
|
],
|
|
],
|
|
|
|
|
+ updateSupportedCommands: [
|
|
|
|
|
+ body('supportedCommandsForSingleUse').toArray(),
|
|
|
|
|
+ body('supportedCommandsForBroadcastUse').toArray(),
|
|
|
|
|
+ param('id').isMongoId().withMessage('id is required'),
|
|
|
|
|
+ ],
|
|
|
RelationTest: [
|
|
RelationTest: [
|
|
|
body('slackAppIntegrationId').isMongoId(),
|
|
body('slackAppIntegrationId').isMongoId(),
|
|
|
body('channel').trim().isString(),
|
|
body('channel').trim().isString(),
|
|
@@ -491,6 +496,34 @@ module.exports = (crowi) => {
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @swagger
|
|
|
|
|
+ *
|
|
|
|
|
+ * /slack-integration-settings/:id/supported-commands:
|
|
|
|
|
+ * put:
|
|
|
|
|
+ * tags: [SlackIntegration]
|
|
|
|
|
+ * operationId: putSupportedCommands
|
|
|
|
|
+ * summary: /slack-integration-settings/:id/supported-commands
|
|
|
|
|
+ * description: update supported commands
|
|
|
|
|
+ * responses:
|
|
|
|
|
+ * 200:
|
|
|
|
|
+ * description: Succeeded to update supported commands
|
|
|
|
|
+ */
|
|
|
|
|
+ router.put('/:id/supported-commands', loginRequiredStrictly, adminRequired, csrf, validator.updateSupportedCommands, apiV3FormValidator, async(req, res) => {
|
|
|
|
|
+ const { supportedCommandsForBroadcastUse, supportedCommandsForSingleUse } = req.body;
|
|
|
|
|
+ const { id } = req.params;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const slackAppIntegration = await SlackAppIntegration.findByIdAndUpdate(id, { supportedCommandsForBroadcastUse, supportedCommandsForSingleUse });
|
|
|
|
|
+ return res.apiv3({ slackAppIntegration });
|
|
|
|
|
+ }
|
|
|
|
|
+ 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
|
|
* @swagger
|
|
|
*
|
|
*
|