|
|
@@ -213,11 +213,15 @@ module.exports = (crowi) => {
|
|
|
* type: object
|
|
|
* description: deleted notification
|
|
|
*/
|
|
|
- router.delete('/user-notification/:id', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
|
|
|
+ router.delete('/user-notification/:id', loginRequiredStrictly, adminRequired, csrf, addActivity, async(req, res) => {
|
|
|
const { id } = req.params;
|
|
|
|
|
|
try {
|
|
|
const deletedNotificaton = await UpdatePost.findOneAndRemove({ _id: id });
|
|
|
+
|
|
|
+ const parameters = { action: SupportedAction.ACTION_ADMIN_USER_NOTIFICATION_SETTINGS_DELETE };
|
|
|
+ activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
+
|
|
|
return res.apiv3(deletedNotificaton);
|
|
|
}
|
|
|
catch (err) {
|
|
|
@@ -253,7 +257,8 @@ module.exports = (crowi) => {
|
|
|
* type: object
|
|
|
* description: notification param created
|
|
|
*/
|
|
|
- router.post('/global-notification', loginRequiredStrictly, adminRequired, csrf, validator.globalNotification, apiV3FormValidator, async(req, res) => {
|
|
|
+ // eslint-disable-next-line max-len
|
|
|
+ router.post('/global-notification', loginRequiredStrictly, adminRequired, csrf, addActivity, validator.globalNotification, apiV3FormValidator, async(req, res) => {
|
|
|
|
|
|
const {
|
|
|
notifyToType, toEmail, slackChannels, triggerPath, triggerEvents,
|
|
|
@@ -275,6 +280,10 @@ module.exports = (crowi) => {
|
|
|
|
|
|
try {
|
|
|
const createdNotification = await notification.save();
|
|
|
+
|
|
|
+ const parameters = { action: SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_ADD };
|
|
|
+ activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
+
|
|
|
return res.apiv3({ createdNotification }, 201);
|
|
|
}
|
|
|
catch (err) {
|
|
|
@@ -316,7 +325,8 @@ module.exports = (crowi) => {
|
|
|
* type: object
|
|
|
* description: notification param updated
|
|
|
*/
|
|
|
- router.put('/global-notification/:id', loginRequiredStrictly, adminRequired, csrf, validator.globalNotification, apiV3FormValidator, async(req, res) => {
|
|
|
+ // eslint-disable-next-line max-len
|
|
|
+ router.put('/global-notification/:id', loginRequiredStrictly, adminRequired, csrf, addActivity, validator.globalNotification, apiV3FormValidator, async(req, res) => {
|
|
|
const { id } = req.params;
|
|
|
const {
|
|
|
notifyToType, toEmail, slackChannels, triggerPath, triggerEvents,
|
|
|
@@ -355,6 +365,10 @@ module.exports = (crowi) => {
|
|
|
setting.triggerEvents = triggerEvents || [];
|
|
|
|
|
|
const createdNotification = await setting.save();
|
|
|
+
|
|
|
+ const parameters = { action: SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_UPDATE };
|
|
|
+ activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
+
|
|
|
return res.apiv3({ createdNotification });
|
|
|
}
|
|
|
catch (err) {
|
|
|
@@ -387,7 +401,8 @@ module.exports = (crowi) => {
|
|
|
* schema:
|
|
|
* $ref: '#/components/schemas/NotifyForPageGrant'
|
|
|
*/
|
|
|
- router.put('/notify-for-page-grant', loginRequiredStrictly, adminRequired, csrf, validator.notifyForPageGrant, apiV3FormValidator, async(req, res) => {
|
|
|
+ // eslint-disable-next-line max-len
|
|
|
+ router.put('/notify-for-page-grant', loginRequiredStrictly, adminRequired, csrf, addActivity, validator.notifyForPageGrant, apiV3FormValidator, async(req, res) => {
|
|
|
|
|
|
let requestParams = {
|
|
|
'notification:owner-page:isEnabled': req.body.isNotificationForOwnerPageEnabled,
|
|
|
@@ -402,6 +417,10 @@ module.exports = (crowi) => {
|
|
|
isNotificationForOwnerPageEnabled: await crowi.configManager.getConfig('notification', 'notification:owner-page:isEnabled'),
|
|
|
isNotificationForGroupPageEnabled: await crowi.configManager.getConfig('notification', 'notification:group-page:isEnabled'),
|
|
|
};
|
|
|
+
|
|
|
+ const parameters = { action: SupportedAction.ACTION_ADMIN_NOTIFICATION_GRANT_SETTINGS_UPDATE };
|
|
|
+ activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
+
|
|
|
return res.apiv3({ responseParams });
|
|
|
}
|
|
|
catch (err) {
|
|
|
@@ -409,7 +428,9 @@ module.exports = (crowi) => {
|
|
|
logger.error('Error', err);
|
|
|
return res.apiv3Err(new ErrorV3(msg, 'update-notify-for-page-grant-failed'));
|
|
|
}
|
|
|
+
|
|
|
});
|
|
|
+
|
|
|
/**
|
|
|
* @swagger
|
|
|
*
|
|
|
@@ -444,7 +465,7 @@ module.exports = (crowi) => {
|
|
|
* type: object
|
|
|
* description: notification id for updated
|
|
|
*/
|
|
|
- router.put('/global-notification/:id/enabled', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
|
|
|
+ router.put('/global-notification/:id/enabled', loginRequiredStrictly, adminRequired, csrf, addActivity, async(req, res) => {
|
|
|
const { id } = req.params;
|
|
|
const { isEnabled } = req.body;
|
|
|
|
|
|
@@ -456,6 +477,13 @@ module.exports = (crowi) => {
|
|
|
await GlobalNotificationSetting.disable(id);
|
|
|
}
|
|
|
|
|
|
+ const parameters = {
|
|
|
+ action: isEnabled
|
|
|
+ ? SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_ENABLED
|
|
|
+ : SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_DISABLED,
|
|
|
+ };
|
|
|
+ activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
+
|
|
|
return res.apiv3({ id });
|
|
|
|
|
|
}
|
|
|
@@ -492,11 +520,15 @@ module.exports = (crowi) => {
|
|
|
* type: object
|
|
|
* description: deleted notification
|
|
|
*/
|
|
|
- router.delete('/global-notification/:id', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
|
|
|
+ router.delete('/global-notification/:id', loginRequiredStrictly, adminRequired, csrf, addActivity, async(req, res) => {
|
|
|
const { id } = req.params;
|
|
|
|
|
|
try {
|
|
|
const deletedNotificaton = await GlobalNotificationSetting.findOneAndRemove({ _id: id });
|
|
|
+
|
|
|
+ const parameters = { action: SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_DELETE };
|
|
|
+ activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
+
|
|
|
return res.apiv3(deletedNotificaton);
|
|
|
}
|
|
|
catch (err) {
|
|
|
@@ -505,7 +537,6 @@ module.exports = (crowi) => {
|
|
|
return res.apiv3Err(new ErrorV3(msg, 'delete-globalNotification-failed'));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
});
|
|
|
|
|
|
return router;
|