notification-setting.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. import { ErrorV3 } from '@growi/core/dist/models';
  2. import express from 'express';
  3. import { SupportedAction } from '~/interfaces/activity';
  4. import { SCOPE } from '~/interfaces/scope';
  5. import { accessTokenParser } from '~/server/middlewares/access-token-parser';
  6. import { GlobalNotificationSettingType } from '~/server/models/GlobalNotificationSetting';
  7. import { configManager } from '~/server/service/config-manager';
  8. import loggerFactory from '~/utils/logger';
  9. import { removeNullPropertyFromObject } from '~/utils/object-utils';
  10. import { generateAddActivityMiddleware } from '../../middlewares/add-activity';
  11. import { apiV3FormValidator } from '../../middlewares/apiv3-form-validator';
  12. import UpdatePost from '../../models/update-post';
  13. // eslint-disable-next-line no-unused-vars
  14. const logger = loggerFactory('growi:routes:apiv3:notification-setting');
  15. const router = express.Router();
  16. const { body } = require('express-validator');
  17. const validator = {
  18. userNotification: [
  19. body('pathPattern').isString().trim(),
  20. body('channel').isString().trim(),
  21. ],
  22. globalNotification: [
  23. body('triggerPath').isString().trim().not()
  24. .isEmpty(),
  25. body('notifyType').isString().trim().isIn(['mail', 'slack']),
  26. body('toEmail').trim().custom((value, { req }) => {
  27. return (req.body.notifyType === 'mail') ? (!!value && value.match(/.+@.+\..+/)) : true;
  28. }),
  29. body('slackChannels').trim().custom((value, { req }) => {
  30. return (req.body.notifyType === 'slack') ? !!value : true;
  31. }),
  32. ],
  33. notifyForPageGrant: [
  34. body('isNotificationForOwnerPageEnabled').if(value => value != null).isBoolean(),
  35. body('isNotificationForGroupPageEnabled').if(value => value != null).isBoolean(),
  36. ],
  37. };
  38. /**
  39. * @swagger
  40. *
  41. * components:
  42. * schemas:
  43. * NotificationParams:
  44. * type: object
  45. * properties:
  46. * isSlackbotConfigured:
  47. * type: boolean
  48. * description: status of slack integration
  49. * isSlackLegacyConfigured:
  50. * type: boolean
  51. * description: status of slack legacy integration
  52. * currentBotType:
  53. * type: string
  54. * description: current bot type
  55. * userNotifications:
  56. * type: array
  57. * items:
  58. * $ref: '#/components/schemas/UserNotification'
  59. * isNotificationForOwnerPageEnabled:
  60. * type: boolean
  61. * description: Whether to notify on owner page
  62. * isNotificationForGroupPageEnabled:
  63. * type: boolean
  64. * description: Whether to notify on group page
  65. * globalNotifications:
  66. * type: array
  67. * items:
  68. * $ref: '#/components/schemas/GlobalNotificationParams'
  69. * description: global notifications
  70. * UserNotification:
  71. * type: object
  72. * properties:
  73. * channel:
  74. * type: string
  75. * description: slack channel name without '#'
  76. * pathPattern:
  77. * type: string
  78. * description: path name of wiki
  79. * createdAt:
  80. * type: string
  81. * description: created date
  82. * creator:
  83. * $ref: '#/components/schemas/User'
  84. * description: user who set notification
  85. * patternPrefix:
  86. * type: string
  87. * description: path pattern prefix
  88. * patternPrefix2:
  89. * type: string
  90. * description: path pattern prefix2
  91. * provider:
  92. * type: string
  93. * description: provider
  94. * updatedAt:
  95. * type: string
  96. * description: updated date
  97. * __v:
  98. * type: number
  99. * description: version
  100. * _id:
  101. * type: string
  102. * description: id
  103. * UserNotificationParams:
  104. * type: object
  105. * properties:
  106. * pathPattern:
  107. * type: string
  108. * description: path name of wiki
  109. * channel:
  110. * type: string
  111. * description: slack channel name without '#'
  112. * NotifyForPageGrant:
  113. * type: object
  114. * properties:
  115. * isNotificationForOwnerPageEnabled:
  116. * type: boolean
  117. * description: Whether to notify on owner page
  118. * isNotificationForGroupPageEnabled:
  119. * type: boolean
  120. * description: Whether to notify on group page
  121. * GlobalNotification:
  122. * type: object
  123. * properties:
  124. * _id:
  125. * type: string
  126. * description: id
  127. * isEnabled:
  128. * type: boolean
  129. * description: is notification enabled
  130. * triggerEvents:
  131. * type: array
  132. * items:
  133. * type: string
  134. * description: trigger events for notify
  135. * __t:
  136. * type: string
  137. * description: type of notification
  138. * slackChannels:
  139. * type: string
  140. * description: channels for notify
  141. * triggerPath:
  142. * type: string
  143. * description: trigger path for notify
  144. * __v:
  145. * type: number
  146. * description: version
  147. * GlobalNotificationParams:
  148. * type: object
  149. * properties:
  150. * notifyType:
  151. * type: string
  152. * description: What is type for notify
  153. * toEmail:
  154. * type: string
  155. * description: email for notify
  156. * slackChannels:
  157. * type: string
  158. * description: channels for notify
  159. * triggerPath:
  160. * type: string
  161. * description: trigger path for notify
  162. * triggerEvents:
  163. * type: array
  164. * items:
  165. * type: string
  166. * description: trigger events for notify
  167. */
  168. /** @param {import('~/server/crowi').default} crowi Crowi instance */
  169. module.exports = (crowi) => {
  170. const Strictly = require('../../middlewares/login-required')(crowi);
  171. const adminRequired = require('../../middlewares/admin-required')(crowi);
  172. const addActivity = generateAddActivityMiddleware(crowi);
  173. const activityEvent = crowi.event('activity');
  174. const GlobalNotificationSetting = crowi.model('GlobalNotificationSetting');
  175. const GlobalNotificationMailSetting = crowi.models.GlobalNotificationMailSetting;
  176. const GlobalNotificationSlackSetting = crowi.models.GlobalNotificationSlackSetting;
  177. /**
  178. * @swagger
  179. *
  180. * /notification-setting/:
  181. * get:
  182. * tags: [NotificationSetting]
  183. * security:
  184. * - cookieAuth: []
  185. * description: Get notification paramators
  186. * responses:
  187. * 200:
  188. * description: params of notification
  189. * content:
  190. * application/json:
  191. * schema:
  192. * properties:
  193. * notificationParams:
  194. * type: object
  195. * description: notification params
  196. * $ref: '#/components/schemas/NotificationParams'
  197. */
  198. router.get('/', accessTokenParser([SCOPE.READ.ADMIN.EXTERNAL_NOTIFICATION]), Strictly, adminRequired, async(req, res) => {
  199. const notificationParams = {
  200. // status of slack intagration
  201. isSlackbotConfigured: crowi.slackIntegrationService.isSlackbotConfigured,
  202. isSlackLegacyConfigured: crowi.slackIntegrationService.isSlackLegacyConfigured,
  203. currentBotType: await crowi.configManager.getConfig('slackbot:currentBotType'),
  204. userNotifications: await UpdatePost.findAll(),
  205. isNotificationForOwnerPageEnabled: await crowi.configManager.getConfig('notification:owner-page:isEnabled'),
  206. isNotificationForGroupPageEnabled: await crowi.configManager.getConfig('notification:group-page:isEnabled'),
  207. globalNotifications: await GlobalNotificationSetting.findAll(),
  208. };
  209. return res.apiv3({ notificationParams });
  210. });
  211. /**
  212. * @swagger
  213. *
  214. * /notification-setting/user-notification:
  215. * post:
  216. * tags: [NotificationSetting]
  217. * security:
  218. * - cookieAuth: []
  219. * description: add user notification setting
  220. * requestBody:
  221. * required: true
  222. * content:
  223. * application/json:
  224. * schema:
  225. * $ref: '#/components/schemas/UserNotificationParams'
  226. * responses:
  227. * 200:
  228. * description: Succeeded to add user notification setting
  229. * content:
  230. * application/json:
  231. * schema:
  232. * properties:
  233. * responseParams:
  234. * type: object
  235. * description: response params
  236. * properties:
  237. * createdUser:
  238. * $ref: '#/components/schemas/User'
  239. * description: user who set notification
  240. * userNotifications:
  241. * type: array
  242. * items:
  243. * $ref: '#/components/schemas/UserNotification'
  244. * description: user notification settings
  245. */
  246. // eslint-disable-next-line max-len
  247. router.post('/user-notification', accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]), Strictly, adminRequired, addActivity, validator.userNotification, apiV3FormValidator, async(req, res) => {
  248. const { pathPattern, channel } = req.body;
  249. try {
  250. logger.info('notification.add', pathPattern, channel);
  251. const responseParams = {
  252. createdUser: await UpdatePost.createUpdatePost(pathPattern, channel, req.user),
  253. userNotifications: await UpdatePost.findAll(),
  254. };
  255. const parameters = { action: SupportedAction.ACTION_ADMIN_USER_NOTIFICATION_SETTINGS_ADD };
  256. activityEvent.emit('update', res.locals.activity._id, parameters);
  257. return res.apiv3({ responseParams }, 201);
  258. }
  259. catch (err) {
  260. const msg = 'Error occurred in updating user notification';
  261. logger.error('Error', err);
  262. return res.apiv3Err(new ErrorV3(msg, 'update-userNotification-failed'));
  263. }
  264. });
  265. /**
  266. * @swagger
  267. *
  268. * /notification-setting/user-notification/{id}:
  269. * delete:
  270. * tags: [NotificationSetting]
  271. * security:
  272. * - cookieAuth: []
  273. * description: delete user trigger notification pattern
  274. * parameters:
  275. * - name: id
  276. * in: path
  277. * required: true
  278. * description: id of user trigger notification
  279. * schema:
  280. * type: string
  281. * responses:
  282. * 200:
  283. * description: Succeeded to delete user trigger notification pattern
  284. * content:
  285. * application/json:
  286. * schema:
  287. * $ref: '#/components/schemas/UserNotification'
  288. */
  289. router.delete('/user-notification/:id',
  290. accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
  291. Strictly,
  292. adminRequired,
  293. addActivity,
  294. async(req, res) => {
  295. const { id } = req.params;
  296. try {
  297. const deletedNotificaton = await UpdatePost.findOneAndRemove({ _id: id });
  298. const parameters = { action: SupportedAction.ACTION_ADMIN_USER_NOTIFICATION_SETTINGS_DELETE };
  299. activityEvent.emit('update', res.locals.activity._id, parameters);
  300. return res.apiv3(deletedNotificaton);
  301. }
  302. catch (err) {
  303. const msg = 'Error occurred in delete user trigger notification';
  304. logger.error('Error', err);
  305. return res.apiv3Err(new ErrorV3(msg, 'delete-userTriggerNotification-failed'));
  306. }
  307. });
  308. /**
  309. * @swagger
  310. *
  311. * /notification-setting/global-notification/{id}:
  312. * get:
  313. * tags: [NotificationSetting]
  314. * security:
  315. * - cookieAuth: []
  316. * description: get global notification setting
  317. * parameters:
  318. * - name: id
  319. * in: path
  320. * required: true
  321. * description: id of global notification
  322. * schema:
  323. * type: string
  324. * responses:
  325. * 200:
  326. * description: Succeeded to get global notification setting
  327. * content:
  328. * application/json:
  329. * schema:
  330. * properties:
  331. * globalNotification:
  332. * $ref: '#/components/schemas/GlobalNotification'
  333. */
  334. router.get('/global-notification/:id',
  335. accessTokenParser([SCOPE.READ.ADMIN.EXTERNAL_NOTIFICATION]),
  336. Strictly,
  337. adminRequired,
  338. validator.globalNotification,
  339. async(req, res) => {
  340. const notificationSettingId = req.params.id;
  341. let globalNotification;
  342. if (notificationSettingId) {
  343. try {
  344. globalNotification = await GlobalNotificationSetting.findOne({ _id: notificationSettingId });
  345. }
  346. catch (err) {
  347. logger.error(`Error in finding a global notification setting with {_id: ${notificationSettingId}}`);
  348. }
  349. }
  350. return res.apiv3({ globalNotification });
  351. });
  352. /**
  353. * @swagger
  354. *
  355. * /notification-setting/global-notification:
  356. * post:
  357. * tags: [NotificationSetting]
  358. * security:
  359. * - cookieAuth: []
  360. * description: add global notification
  361. * requestBody:
  362. * required: true
  363. * content:
  364. * application/json:
  365. * schema:
  366. * $ref: '#/components/schemas/GlobalNotificationParams'
  367. * responses:
  368. * 200:
  369. * description: Succeeded to add global notification
  370. * content:
  371. * application/json:
  372. * schema:
  373. * properties:
  374. * createdNotification:
  375. * type: object
  376. * description: notification param created
  377. * $ref: '#/components/schemas/GlobalNotification'
  378. */
  379. // eslint-disable-next-line max-len
  380. router.post('/global-notification',
  381. accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
  382. Strictly,
  383. adminRequired,
  384. addActivity,
  385. validator.globalNotification,
  386. apiV3FormValidator,
  387. async(req, res) => {
  388. const {
  389. notifyType, toEmail, slackChannels, triggerPath, triggerEvents,
  390. } = req.body;
  391. let notification;
  392. if (notifyType === GlobalNotificationSettingType.MAIL) {
  393. notification = new GlobalNotificationMailSetting(crowi);
  394. notification.toEmail = toEmail;
  395. }
  396. if (notifyType === GlobalNotificationSettingType.SLACK) {
  397. notification = new GlobalNotificationSlackSetting(crowi);
  398. notification.slackChannels = slackChannels;
  399. }
  400. notification.triggerPath = triggerPath;
  401. notification.triggerEvents = triggerEvents || [];
  402. try {
  403. const createdNotification = await notification.save();
  404. const parameters = { action: SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_ADD };
  405. activityEvent.emit('update', res.locals.activity._id, parameters);
  406. return res.apiv3({ createdNotification }, 201);
  407. }
  408. catch (err) {
  409. const msg = 'Error occurred in updating global notification';
  410. logger.error('Error', err);
  411. return res.apiv3Err(new ErrorV3(msg, 'post-globalNotification-failed'));
  412. }
  413. });
  414. /**
  415. * @swagger
  416. *
  417. * /notification-setting/global-notification/{id}:
  418. * put:
  419. * tags: [NotificationSetting]
  420. * description: update global notification
  421. * parameters:
  422. * - name: id
  423. * in: path
  424. * required: true
  425. * description: global notification id for updated
  426. * schema:
  427. * type: string
  428. * requestBody:
  429. * required: true
  430. * content:
  431. * application/json:
  432. * schema:
  433. * $ref: '#/components/schemas/GlobalNotificationParams'
  434. * responses:
  435. * 200:
  436. * description: Succeeded to update global notification
  437. * content:
  438. * application/json:
  439. * schema:
  440. * properties:
  441. * createdNotification:
  442. * type: object
  443. * description: notification param updated
  444. * $ref: '#/components/schemas/GlobalNotification'
  445. */
  446. // eslint-disable-next-line max-len
  447. router.put('/global-notification/:id',
  448. accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
  449. Strictly,
  450. adminRequired,
  451. addActivity,
  452. validator.globalNotification,
  453. apiV3FormValidator,
  454. async(req, res) => {
  455. const { id } = req.params;
  456. const {
  457. notifyType, toEmail, slackChannels, triggerPath, triggerEvents,
  458. } = req.body;
  459. const models = {
  460. [GlobalNotificationSettingType.MAIL]: GlobalNotificationMailSetting,
  461. [GlobalNotificationSettingType.SLACK]: GlobalNotificationSlackSetting,
  462. };
  463. try {
  464. let setting = await GlobalNotificationSetting.findOne({ _id: id });
  465. setting = setting.toObject();
  466. // when switching from one type to another,
  467. // remove toEmail from slack setting and slackChannels from mail setting
  468. if (setting.__t !== notifyType) {
  469. setting = models[setting.__t].hydrate(setting);
  470. setting.toEmail = undefined;
  471. setting.slackChannels = undefined;
  472. await setting.save();
  473. setting = setting.toObject();
  474. }
  475. if (notifyType === GlobalNotificationSettingType.MAIL) {
  476. setting = GlobalNotificationMailSetting.hydrate(setting);
  477. setting.toEmail = toEmail;
  478. }
  479. if (notifyType === GlobalNotificationSettingType.SLACK) {
  480. setting = GlobalNotificationSlackSetting.hydrate(setting);
  481. setting.slackChannels = slackChannels;
  482. }
  483. setting.__t = notifyType;
  484. setting.triggerPath = triggerPath;
  485. setting.triggerEvents = triggerEvents || [];
  486. const createdNotification = await setting.save();
  487. const parameters = { action: SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_UPDATE };
  488. activityEvent.emit('update', res.locals.activity._id, parameters);
  489. return res.apiv3({ createdNotification });
  490. }
  491. catch (err) {
  492. const msg = 'Error occurred in updating global notification';
  493. logger.error('Error', err);
  494. return res.apiv3Err(new ErrorV3(msg, 'post-globalNotification-failed'));
  495. }
  496. });
  497. /**
  498. * @swagger
  499. *
  500. * /notification-setting/notify-for-page-grant:
  501. * put:
  502. * tags: [NotificationSetting]
  503. * security:
  504. * - cookieAuth: []
  505. * description: Update settings for notify for page grant
  506. * requestBody:
  507. * required: true
  508. * content:
  509. * application/json:
  510. * schema:
  511. * $ref: '#/components/schemas/NotifyForPageGrant'
  512. * responses:
  513. * 200:
  514. * description: Succeeded to settings for notify for page grant
  515. * content:
  516. * application/json:
  517. * schema:
  518. * $ref: '#/components/schemas/NotifyForPageGrant'
  519. */
  520. // eslint-disable-next-line max-len
  521. router.put('/notify-for-page-grant',
  522. accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
  523. Strictly,
  524. adminRequired,
  525. addActivity,
  526. validator.notifyForPageGrant,
  527. apiV3FormValidator,
  528. async(req, res) => {
  529. let requestParams = {
  530. 'notification:owner-page:isEnabled': req.body.isNotificationForOwnerPageEnabled,
  531. 'notification:group-page:isEnabled': req.body.isNotificationForGroupPageEnabled,
  532. };
  533. requestParams = removeNullPropertyFromObject(requestParams);
  534. try {
  535. await configManager.updateConfigs(requestParams);
  536. const responseParams = {
  537. isNotificationForOwnerPageEnabled: await crowi.configManager.getConfig('notification:owner-page:isEnabled'),
  538. isNotificationForGroupPageEnabled: await crowi.configManager.getConfig('notification:group-page:isEnabled'),
  539. };
  540. const parameters = { action: SupportedAction.ACTION_ADMIN_NOTIFICATION_GRANT_SETTINGS_UPDATE };
  541. activityEvent.emit('update', res.locals.activity._id, parameters);
  542. return res.apiv3({ responseParams });
  543. }
  544. catch (err) {
  545. const msg = 'Error occurred in updating notify for page grant';
  546. logger.error('Error', err);
  547. return res.apiv3Err(new ErrorV3(msg, 'update-notify-for-page-grant-failed'));
  548. }
  549. });
  550. /**
  551. * @swagger
  552. *
  553. * /notification-setting/global-notification/{id}/enabled:
  554. * put:
  555. * tags: [NotificationSetting]
  556. * security:
  557. * - cookieAuth: []
  558. * description: toggle enabled global notification
  559. * parameters:
  560. * - name: id
  561. * in: path
  562. * required: true
  563. * description: notification id for updated
  564. * schema:
  565. * type: string
  566. * requestBody:
  567. * required: true
  568. * content:
  569. * application/json:
  570. * schema:
  571. * properties:
  572. * isEnabled:
  573. * type: boolean
  574. * description: is notification enabled
  575. * responses:
  576. * 200:
  577. * description: Succeeded to delete global notification pattern
  578. * content:
  579. * application/json:
  580. * schema:
  581. * properties:
  582. * id:
  583. * type: string
  584. * description: notification id
  585. */
  586. router.put('/global-notification/:id/enabled',
  587. accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
  588. Strictly,
  589. adminRequired,
  590. addActivity,
  591. async(req, res) => {
  592. const { id } = req.params;
  593. const { isEnabled } = req.body;
  594. try {
  595. if (isEnabled) {
  596. await GlobalNotificationSetting.enable(id);
  597. }
  598. else {
  599. await GlobalNotificationSetting.disable(id);
  600. }
  601. const parameters = {
  602. action: isEnabled
  603. ? SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_ENABLED
  604. : SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_DISABLED,
  605. };
  606. activityEvent.emit('update', res.locals.activity._id, parameters);
  607. return res.apiv3({ id });
  608. }
  609. catch (err) {
  610. const msg = 'Error occurred in toggle of global notification';
  611. logger.error('Error', err);
  612. return res.apiv3Err(new ErrorV3(msg, 'toggle-globalNotification-failed'));
  613. }
  614. });
  615. /**
  616. * @swagger
  617. *
  618. * /notification-setting/global-notification/{id}:
  619. * delete:
  620. * tags: [NotificationSetting]
  621. * security:
  622. * - cookieAuth: []
  623. * description: delete global notification pattern
  624. * parameters:
  625. * - name: id
  626. * in: path
  627. * required: true
  628. * description: id of global notification
  629. * schema:
  630. * type: string
  631. * responses:
  632. * 200:
  633. * description: Succeeded to delete global notification pattern
  634. * content:
  635. * application/json:
  636. * schema:
  637. * description: deleted notification
  638. * $ref: '#/components/schemas/GlobalNotification'
  639. */
  640. router.delete('/global-notification/:id',
  641. accessTokenParser([SCOPE.WRITE.ADMIN.EXTERNAL_NOTIFICATION]),
  642. Strictly,
  643. adminRequired,
  644. addActivity,
  645. async(req, res) => {
  646. const { id } = req.params;
  647. try {
  648. const deletedNotificaton = await GlobalNotificationSetting.findOneAndRemove({ _id: id });
  649. const parameters = { action: SupportedAction.ACTION_ADMIN_GLOBAL_NOTIFICATION_SETTINGS_DELETE };
  650. activityEvent.emit('update', res.locals.activity._id, parameters);
  651. return res.apiv3(deletedNotificaton);
  652. }
  653. catch (err) {
  654. const msg = 'Error occurred in delete global notification';
  655. logger.error('Error', err);
  656. return res.apiv3Err(new ErrorV3(msg, 'delete-globalNotification-failed'));
  657. }
  658. });
  659. return router;
  660. };