fix: revert status websocket payload changes (#31823)

pull/31550/head^2
Diego Sampaio 2 years ago committed by GitHub
parent f577751d02
commit cd5cbe2ac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      .changeset/strange-lamps-taste.md
  2. 9
      apps/meteor/app/notifications/client/lib/Presence.ts
  3. 14
      apps/meteor/server/modules/listeners/listeners.module.ts
  4. 4
      apps/meteor/server/modules/notifications/notifications.module.ts
  5. 5
      ee/packages/ddp-client/src/types/streams.ts

@ -0,0 +1,6 @@
---
'@rocket.chat/ddp-client': patch
'@rocket.chat/meteor': patch
---
Revert unintentional changes real time presence data payload

@ -1,4 +1,4 @@
import type { UserStatus } from '@rocket.chat/core-typings';
import { UserStatus } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';
import { Presence } from '../../../../client/lib/presence';
@ -10,6 +10,11 @@ new Meteor.Streamer('user-presence');
type args = [username: string, statusChanged?: UserStatus, statusText?: string];
export const STATUS_MAP = [UserStatus.OFFLINE, UserStatus.ONLINE, UserStatus.AWAY, UserStatus.BUSY, UserStatus.DISABLED];
Meteor.StreamerCentral.on('stream-user-presence', (uid: string, [username, statusChanged, statusText]: args) => {
Presence.notify({ _id: uid, username, status: statusChanged, statusText });
if (!statusChanged) {
return;
}
Presence.notify({ _id: uid, username, status: STATUS_MAP[statusChanged as any], statusText });
});

@ -2,7 +2,7 @@ import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
import type { ISetting as AppsSetting } from '@rocket.chat/apps-engine/definition/settings';
import type { IServiceClass } from '@rocket.chat/core-services';
import { EnterpriseSettings } from '@rocket.chat/core-services';
import { isSettingColor, isSettingEnterprise } from '@rocket.chat/core-typings';
import { isSettingColor, isSettingEnterprise, UserStatus } from '@rocket.chat/core-typings';
import type { IUser, IRoom, VideoConference, ISetting, IOmnichannelRoom } from '@rocket.chat/core-typings';
import { Logger } from '@rocket.chat/logger';
import { parse } from '@rocket.chat/message-parser';
@ -12,6 +12,14 @@ import type { NotificationsModule } from '../notifications/notifications.module'
const isMessageParserDisabled = process.env.DISABLE_MESSAGE_PARSER === 'true';
const STATUS_MAP: Record<UserStatus, 0 | 1 | 2 | 3> = {
[UserStatus.OFFLINE]: 0,
[UserStatus.ONLINE]: 1,
[UserStatus.AWAY]: 2,
[UserStatus.BUSY]: 3,
[UserStatus.DISABLED]: 0,
} as const;
const minimongoChangeMap: Record<string, string> = {
inserted: 'added',
updated: 'changed',
@ -145,10 +153,10 @@ export class ListenersModule {
return;
}
notifications.notifyLoggedInThisInstance('user-status', [_id, username, status, statusText, name, roles]);
notifications.notifyLoggedInThisInstance('user-status', [_id, username, STATUS_MAP[status], statusText, name, roles]);
if (_id) {
notifications.sendPresence(_id, username, status, statusText);
notifications.sendPresence(_id, username, STATUS_MAP[status], statusText);
}
});

@ -1,5 +1,5 @@
import { Authorization, VideoConf } from '@rocket.chat/core-services';
import type { ISubscription, IOmnichannelRoom, IUser, UserStatus } from '@rocket.chat/core-typings';
import type { ISubscription, IOmnichannelRoom, IUser } from '@rocket.chat/core-typings';
import { Rooms, Subscriptions, Users, Settings } from '@rocket.chat/models';
import type { StreamerCallbackArgs, StreamKeys, StreamNames } from '@rocket.chat/ui-contexts';
import type { IStreamer, IStreamerConstructor, IPublication } from 'meteor/rocketchat:streamer';
@ -531,7 +531,7 @@ export class NotificationsModule {
return this.streamUser.emitWithoutBroadcast(`${userId}/${eventName}`, ...args);
}
sendPresence(uid: string, ...args: [username: string, status?: UserStatus, statusText?: string]): void {
sendPresence(uid: string, ...args: [username: string, status?: 0 | 1 | 2 | 3, statusText?: string]): void {
emit(uid, [args]);
return this.streamPresence.emitWithoutBroadcast(uid, args);
}

@ -23,7 +23,6 @@ import type {
IBanner,
LicenseLimitKind,
ICustomUserStatus,
UserStatus,
IWebdavAccount,
} from '@rocket.chat/core-typings';
import type * as UiKit from '@rocket.chat/ui-kit';
@ -243,7 +242,7 @@ export interface StreamerEvents {
[
uid: IUser['_id'],
username: IUser['username'],
status: UserStatus,
status: 0 | 1 | 2 | 3,
statusText: IUser['statusText'],
name: IUser['name'],
roles: IUser['roles'],
@ -325,7 +324,7 @@ export interface StreamerEvents {
},
];
'user-presence': [{ key: string; args: [[username: string, statusChanged?: UserStatus, statusText?: string]] }];
'user-presence': [{ key: string; args: [[username: string, statusChanged?: 0 | 1 | 2 | 3, statusText?: string]] }];
// TODO: rename to 'integration-history'
'integrationHistory': [

Loading…
Cancel
Save