Browse Source

fix: activities job never completed

Kristian Vos 4 years ago
parent
commit
03fbc099d5
1 changed files with 14 additions and 5 deletions
  1. 14 5
      backend/logic/activities.js

+ 14 - 5
backend/logic/activities.js

@@ -50,18 +50,27 @@ class ActivitiesModule extends CoreClass {
                             .runJob("SOCKETS_FROM_USER", {
                                 userId: activity.userId,
                             })
-                            .then((response) =>
+                            .then((response) => {
                                 response.sockets.forEach((socket) => {
                                     socket.emit(
                                         "event:activity.create",
                                         activity
                                     );
-                                })
-                            );
+                                });
+                                next();
+                            })
+                            .catch(next);
                     },
                 ],
-                (err, activity) => {
-                    // cb(err, activity);
+                async (err, activity) => {
+                    if (err) {
+                        err = await this.utils.runJob("GET_ERROR", {
+                            error: err,
+                        });
+                        reject(new Error(err));
+                    } else {
+                        resolve({ activity });
+                    }
                 }
             );
         });