From 287d1dcb376a4613c9c2d6f5b9c22f3699891d2e Mon Sep 17 00:00:00 2001 From: Felipe Parreira Date: Mon, 21 Sep 2020 15:45:25 -0300 Subject: [PATCH] [FIX] API call users.setStatus does not trigger status update of clients (#18961) --- app/api/server/v1/users.js | 7 +++++-- imports/users-presence/server/activeUsers.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/api/server/v1/users.js b/app/api/server/v1/users.js index 789848739e5b..b4adea3365d3 100644 --- a/app/api/server/v1/users.js +++ b/app/api/server/v1/users.js @@ -22,6 +22,7 @@ import { setStatusText } from '../../../lib/server'; import { findUsersToAutocomplete } from '../lib/users'; import { getUserForCheck, emailCheck } from '../../../2fa/server/code'; import { resetUserE2EEncriptionKey } from '../../../../server/lib/resetUserE2EKey'; +import { setUserStatus } from '../../../../imports/users-presence/server/activeUsers'; API.v1.addRoute('users.create', { authRequired: true }, { post() { @@ -417,12 +418,14 @@ API.v1.addRoute('users.setStatus', { authRequired: true }, { if (this.bodyParams.status) { const validStatus = ['online', 'away', 'offline', 'busy']; if (validStatus.includes(this.bodyParams.status)) { + const { status } = this.bodyParams; Meteor.users.update(user._id, { $set: { - status: this.bodyParams.status, - statusDefault: this.bodyParams.status, + status, + statusDefault: status, }, }); + setUserStatus(user, status); } else { throw new Meteor.Error('error-invalid-status', 'Valid status types include online, away, offline, and busy.', { method: 'users.setStatus', diff --git a/imports/users-presence/server/activeUsers.js b/imports/users-presence/server/activeUsers.js index 1dab7ff4c8bf..53c543009084 100644 --- a/imports/users-presence/server/activeUsers.js +++ b/imports/users-presence/server/activeUsers.js @@ -11,7 +11,7 @@ export const STATUS_MAP = { busy: 3, }; -const setUserStatus = (user, status/* , statusConnection*/) => { +export const setUserStatus = (user, status/* , statusConnection*/) => { const { _id, username,