itizawa 5 лет назад
Родитель
Сommit
f07d5632d5
2 измененных файлов с 10 добавлено и 6 удалено
  1. 7 2
      src/server/routes/apiv3/pages.js
  2. 3 4
      src/server/service/user-notification/index.js

+ 7 - 2
src/server/routes/apiv3/pages.js

@@ -72,13 +72,18 @@ module.exports = (crowi) => {
         await globalNotificationService.fire(GlobalNotificationSetting.EVENT.PAGE_CREATE, createdPage, req.user);
         await globalNotificationService.fire(GlobalNotificationSetting.EVENT.PAGE_CREATE, createdPage, req.user);
       }
       }
       catch (err) {
       catch (err) {
-        logger.error('Create notification failed', err);
+        logger.error('Create grobal notification failed', err);
       }
       }
     }
     }
 
 
     // user notification
     // user notification
     if (isSlackEnabled && userNotificationService != null) {
     if (isSlackEnabled && userNotificationService != null) {
-      await userNotificationService.fire(createdPage, req.user, slackChannels, 'create', false);
+      try {
+        await userNotificationService.fire(createdPage, req.user, slackChannels, 'create', false);
+      }
+      catch (err) {
+        logger.error('Create user notification failed', err);
+      }
     }
     }
 
 
     return res.apiv3(result);
     return res.apiv3(result);

+ 3 - 4
src/server/service/user-notification/index.js

@@ -1,6 +1,6 @@
 const logger = require('@alias/logger')('growi:service:UserNotificationService');
 const logger = require('@alias/logger')('growi:service:UserNotificationService');
 
 
-const toArrayFromCsv = require('@commons/util/toArrayFromCsv');
+const toArrayFromCsv = require('@commons/util/to-array-from-csv');
 
 
 /**
 /**
  * service class of UserNotification
  * service class of UserNotification
@@ -31,10 +31,9 @@ class UserNotificationService {
       await page.updateSlackChannel(slackChannelsStr);
       await page.updateSlackChannel(slackChannelsStr);
     }
     }
     catch (err) {
     catch (err) {
-      logger.error('Error occured in updating slack channels: ', err);
+      throw new Error(err);
     }
     }
 
 
-
     if (!slackNotificationService.hasSlackConfig()) {
     if (!slackNotificationService.hasSlackConfig()) {
       return;
       return;
     }
     }
@@ -46,7 +45,7 @@ class UserNotificationService {
       return slack.postPage(page, user, chan, updateOrCreate, previousRevision);
       return slack.postPage(page, user, chan, updateOrCreate, previousRevision);
     });
     });
 
 
-    Promise.all(promises)
+    Promise.allSettled(promises)
       .catch((err) => {
       .catch((err) => {
         logger.error('Error occured in sending slack notification: ', err);
         logger.error('Error occured in sending slack notification: ', err);
       });
       });