Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/apps/server/bridges/activation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { STATUS_MAP } from '../../../../imports/users-presence/server/activeUsers';
import { Users } from '../../../models';
Comment thread
shiqimei marked this conversation as resolved.
Outdated
import { Notifications } from '../../../notifications/server';

export class AppActivationBridge {
constructor(orch) {
this.orch = orch;
Expand All @@ -16,6 +20,19 @@ export class AppActivationBridge {
}

async appStatusChanged(app, status) {
const { _id, username } = Users.findOne({ appId: app.getID() });
Comment thread
shiqimei marked this conversation as resolved.
Outdated

let userStatus = 'offline';
Comment thread
shiqimei marked this conversation as resolved.
Outdated
if (['auto_enabled', 'manually_enabled'].includes(status)) {
userStatus = 'online';
}
Users.update(_id, { $set: { status: userStatus } });
Comment thread
shiqimei marked this conversation as resolved.
Outdated
Notifications.notifyLogged('user-status', [
_id,
username,
STATUS_MAP[userStatus],
]);

await this.orch.getNotifier().appStatusUpdated(app.getID(), status);
}
}
2 changes: 1 addition & 1 deletion imports/users-presence/server/activeUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UserPresenceEvents } from 'meteor/konecty:user-presence';
import { Notifications } from '../../../app/notifications/server';

// mirror of object in /imports/startup/client/listenActiveUsers.js - keep updated
const STATUS_MAP = {
export const STATUS_MAP = {
offline: 0,
online: 1,
away: 2,
Expand Down