Skip to content

Commit

Permalink
[FIX] API call users.setStatus does not trigger status update of clie…
Browse files Browse the repository at this point in the history
…nts (#18961)
  • Loading branch information
Felipe Parreira authored Sep 21, 2020
1 parent 7a51a5e commit 287d1dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/api/server/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion imports/users-presence/server/activeUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const STATUS_MAP = {
busy: 3,
};

const setUserStatus = (user, status/* , statusConnection*/) => {
export const setUserStatus = (user, status/* , statusConnection*/) => {
const {
_id,
username,
Expand Down

0 comments on commit 287d1dc

Please sign in to comment.