Просмотр исходного кода

Merge pull request #6007 from weseek/fix/in-app-notification-event-does-not-fire

fix: InAppNotification event does not fire
Shun Miyazawa 3 лет назад
Родитель
Сommit
52a70e8b50
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      packages/app/src/server/service/in-app-notification.ts

+ 6 - 1
packages/app/src/server/service/in-app-notification.ts

@@ -46,12 +46,17 @@ export default class InAppNotificationService {
     this.upsertByActivity = this.upsertByActivity.bind(this);
     this.getUnreadCountByUser = this.getUnreadCountByUser.bind(this);
     this.createInAppNotification = this.createInAppNotification.bind(this);
+
+    this.initActivityEventListeners();
   }
 
   initActivityEventListeners(): void {
     this.activityEvent.on('updated', async(activity: ActivityDocument, target: IPage) => {
       try {
-        await this.createInAppNotification(activity, target);
+        const shouldNotification = activity != null && target != null && (AllSupportedActionToNotifiedType as ReadonlyArray<string>).includes(activity.action);
+        if (shouldNotification) {
+          await this.createInAppNotification(activity, target);
+        }
       }
       catch (err) {
         logger.error('Create InAppNotification failed', err);