Shun Miyazawa 3 years ago
parent
commit
814e8aa2db
1 changed files with 6 additions and 1 deletions
  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);