Skip to content

Commit

Permalink
Regression: Fix app user status change for non-existing user (#16458)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-gubert authored Feb 4, 2020
1 parent dc949ce commit e4ebac7
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/apps/server/bridges/activation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit e4ebac7

Please sign in to comment.