kaori 4 лет назад
Родитель
Сommit
1e0191bb16
1 измененных файлов с 22 добавлено и 15 удалено
  1. 22 15
      packages/app/src/server/service/in-app-notification.ts

+ 22 - 15
packages/app/src/server/service/in-app-notification.ts

@@ -72,21 +72,28 @@ export default class InAppNotificationService {
 
   getLatestNotificationsByUser = async(userId, limitNum, offset) => {
 
-    const paginatedInAppNotificationResult = await InAppNotification.paginate(
-      { user: userId },
-      {
-        sort: { createdAt: -1 },
-        offset,
-        limit: limitNum || 10,
-        populate: [
-          { path: 'user' },
-          { path: 'target' },
-          { path: 'activities', populate: { path: 'user' } },
-        ],
-      },
-    );
-
-    return paginatedInAppNotificationResult;
+    try {
+      const pagenatedInAppNotifications = await InAppNotification.paginate(
+        { user: userId },
+        {
+          sort: { createdAt: -1 },
+          offset,
+          limit: limitNum || 10,
+          populate: [
+            { path: 'user' },
+            { path: 'target' },
+            { path: 'activities', populate: { path: 'user' } },
+          ],
+        },
+      );
+
+      console.log('pagenatedInAppNotifications', pagenatedInAppNotifications);
+      return pagenatedInAppNotifications;
+
+    }
+    catch (err) {
+      throw new Error(err);
+    }
   }
 
   // inAppNotificationSchema.virtual('actionUsers').get(function(this: InAppNotificationDocument) {