|
@@ -15,11 +15,6 @@ const { body } = require('express-validator');
|
|
|
const ErrorV3 = require('../../models/vo/error-apiv3');
|
|
const ErrorV3 = require('../../models/vo/error-apiv3');
|
|
|
|
|
|
|
|
const validator = {
|
|
const validator = {
|
|
|
- slackConfiguration: [
|
|
|
|
|
- body('webhookUrl').if(value => value != null).isString().trim(),
|
|
|
|
|
- body('isIncomingWebhookPrioritized').isBoolean(),
|
|
|
|
|
- body('slackToken').if(value => value != null).isString().trim(),
|
|
|
|
|
- ],
|
|
|
|
|
userNotification: [
|
|
userNotification: [
|
|
|
body('pathPattern').isString().trim(),
|
|
body('pathPattern').isString().trim(),
|
|
|
body('channel').isString().trim(),
|
|
body('channel').isString().trim(),
|
|
@@ -52,18 +47,6 @@ const validator = {
|
|
|
*
|
|
*
|
|
|
* components:
|
|
* components:
|
|
|
* schemas:
|
|
* schemas:
|
|
|
- * SlackConfigurationParams:
|
|
|
|
|
- * type: object
|
|
|
|
|
- * properties:
|
|
|
|
|
- * webhookUrl:
|
|
|
|
|
- * type: string
|
|
|
|
|
- * description: incoming webhooks url
|
|
|
|
|
- * isIncomingWebhookPrioritized:
|
|
|
|
|
- * type: boolean
|
|
|
|
|
- * description: use incoming webhooks even if Slack App settings are enabled
|
|
|
|
|
- * slackToken:
|
|
|
|
|
- * type: string
|
|
|
|
|
- * description: OAuth access token
|
|
|
|
|
* UserNotificationParams:
|
|
* UserNotificationParams:
|
|
|
* type: object
|
|
* type: object
|
|
|
* properties:
|
|
* properties:
|
|
@@ -135,9 +118,6 @@ module.exports = (crowi) => {
|
|
|
router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
|
|
router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
|
|
|
|
|
|
|
|
const notificationParams = {
|
|
const notificationParams = {
|
|
|
- webhookUrl: await crowi.configManager.getConfig('notification', 'slack:incomingWebhookUrl'),
|
|
|
|
|
- isIncomingWebhookPrioritized: await crowi.configManager.getConfig('notification', 'slack:isIncomingWebhookPrioritized'),
|
|
|
|
|
- slackToken: await crowi.configManager.getConfig('notification', 'slack:token'),
|
|
|
|
|
userNotifications: await UpdatePost.findAll(),
|
|
userNotifications: await UpdatePost.findAll(),
|
|
|
isNotificationForOwnerPageEnabled: await crowi.configManager.getConfig('notification', 'notification:owner-page:isEnabled'),
|
|
isNotificationForOwnerPageEnabled: await crowi.configManager.getConfig('notification', 'notification:owner-page:isEnabled'),
|
|
|
isNotificationForGroupPageEnabled: await crowi.configManager.getConfig('notification', 'notification:group-page:isEnabled'),
|
|
isNotificationForGroupPageEnabled: await crowi.configManager.getConfig('notification', 'notification:group-page:isEnabled'),
|
|
@@ -146,52 +126,6 @@ module.exports = (crowi) => {
|
|
|
return res.apiv3({ notificationParams });
|
|
return res.apiv3({ notificationParams });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @swagger
|
|
|
|
|
- *
|
|
|
|
|
- * /notification-setting/slack-configuration:
|
|
|
|
|
- * put:
|
|
|
|
|
- * tags: [NotificationSetting]
|
|
|
|
|
- * description: Update slack configuration setting
|
|
|
|
|
- * requestBody:
|
|
|
|
|
- * required: true
|
|
|
|
|
- * content:
|
|
|
|
|
- * application/json:
|
|
|
|
|
- * schema:
|
|
|
|
|
- * $ref: '#/components/schemas/SlackConfigurationParams'
|
|
|
|
|
- * responses:
|
|
|
|
|
- * 200:
|
|
|
|
|
- * description: Succeeded to update slack configuration setting
|
|
|
|
|
- * content:
|
|
|
|
|
- * application/json:
|
|
|
|
|
- * schema:
|
|
|
|
|
- * $ref: '#/components/schemas/SlackConfigurationParams'
|
|
|
|
|
- */
|
|
|
|
|
- router.put('/slack-configuration', loginRequiredStrictly, adminRequired, csrf, validator.slackConfiguration, apiV3FormValidator, async(req, res) => {
|
|
|
|
|
-
|
|
|
|
|
- const requestParams = {
|
|
|
|
|
- 'slack:incomingWebhookUrl': req.body.webhookUrl,
|
|
|
|
|
- 'slack:isIncomingWebhookPrioritized': req.body.isIncomingWebhookPrioritized,
|
|
|
|
|
- 'slack:token': req.body.slackToken,
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- await crowi.configManager.updateConfigsInTheSameNamespace('notification', requestParams);
|
|
|
|
|
- const responseParams = {
|
|
|
|
|
- webhookUrl: await crowi.configManager.getConfig('notification', 'slack:incomingWebhookUrl'),
|
|
|
|
|
- isIncomingWebhookPrioritized: await crowi.configManager.getConfig('notification', 'slack:isIncomingWebhookPrioritized'),
|
|
|
|
|
- slackToken: await crowi.configManager.getConfig('notification', 'slack:token'),
|
|
|
|
|
- };
|
|
|
|
|
- return res.apiv3({ responseParams });
|
|
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
- const msg = 'Error occurred in updating slack configuration';
|
|
|
|
|
- logger.error('Error', err);
|
|
|
|
|
- return res.apiv3Err(new ErrorV3(msg, 'update-slackConfiguration-failed'));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* @swagger
|
|
* @swagger
|
|
|
*
|
|
*
|