فهرست منبع

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

fix: InAppNotification event does not fire
Shun Miyazawa 3 سال پیش
والد
کامیت
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.upsertByActivity = this.upsertByActivity.bind(this);
     this.getUnreadCountByUser = this.getUnreadCountByUser.bind(this);
     this.getUnreadCountByUser = this.getUnreadCountByUser.bind(this);
     this.createInAppNotification = this.createInAppNotification.bind(this);
     this.createInAppNotification = this.createInAppNotification.bind(this);
+
+    this.initActivityEventListeners();
   }
   }
 
 
   initActivityEventListeners(): void {
   initActivityEventListeners(): void {
     this.activityEvent.on('updated', async(activity: ActivityDocument, target: IPage) => {
     this.activityEvent.on('updated', async(activity: ActivityDocument, target: IPage) => {
       try {
       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) {
       catch (err) {
         logger.error('Create InAppNotification failed', err);
         logger.error('Create InAppNotification failed', err);