itizawa 6 лет назад
Родитель
Сommit
bc0967aab9

+ 3 - 1
src/client/js/services/AdminNotificationContainer.js

@@ -106,10 +106,12 @@ export default class AdminNotificationContainer extends Container {
    * @memberOf SlackAppConfiguration
    */
   async addNotificationPattern(pathPattern, channel) {
-    return this.appContainer.apiv3.post('/notification-setting/user-notification', {
+    const response = await this.appContainer.apiv3.post('/notification-setting/user-notification', {
       pathPattern,
       channel,
     });
+
+    this.setState({ userNotifications: response.data.responseParams.userNotifications });
   }
 
 }

+ 14 - 3
src/server/routes/apiv3/notification-setting.js

@@ -162,7 +162,15 @@ module.exports = (crowi) => {
   *            content:
   *              application/json:
   *                schema:
-  *                  $ref: '#/components/schemas/UserNotificationParams'
+  *                  responseParams:
+  *                    type: object
+  *                    properties:
+  *                      createdUser:
+  *                        type: object
+  *                        description: user who set notification
+  *                      userNotifications:
+  *                        type: object
+  *                        description: user trigger notifications for updated
   */
   router.post('/user-notification', loginRequiredStrictly, adminRequired, csrf, validator.userNotification, ApiV3FormValidator, async(req, res) => {
     const { pathPattern, channel } = req.body;
@@ -170,8 +178,11 @@ module.exports = (crowi) => {
 
     try {
       logger.info('notification.add', pathPattern, channel);
-      const params = await UpdatePost.create(pathPattern, channel, req.user);
-      return res.apiv3({ params });
+      const responseParams = {
+        createdUser: await UpdatePost.create(pathPattern, channel, req.user),
+        userNotifications: await UpdatePost.findAll(),
+      };
+      return res.apiv3({ responseParams });
     }
     catch (err) {
       const msg = 'Error occurred in updating user notification';