diff --git a/app/apps/server/bridges/activation.js b/app/apps/server/bridges/activation.js index a878a63a7048..b926061ed506 100644 --- a/app/apps/server/bridges/activation.js +++ b/app/apps/server/bridges/activation.js @@ -20,15 +20,19 @@ export class AppActivationBridge { } async appStatusChanged(app, status) { - const { _id, username } = Users.findOneByAppId(app.getID(), { fields: { username: 1 } }); - const userStatus = ['auto_enabled', 'manually_enabled'].includes(status) ? 'online' : 'offline'; - - Users.updateStatusById(_id, userStatus); - Notifications.notifyLogged('user-status', [ - _id, - username, - STATUS_MAP[userStatus], - ]); + const user = Users.findOneByAppId(app.getID(), { fields: { username: 1 } }); + + if (user) { + const { _id, username } = user; + const userStatus = ['auto_enabled', 'manually_enabled'].includes(status) ? 'online' : 'offline'; + + Users.updateStatusById(_id, userStatus); + Notifications.notifyLogged('user-status', [ + _id, + username, + STATUS_MAP[userStatus], + ]); + } await this.orch.getNotifier().appStatusUpdated(app.getID(), status); }