diff --git a/.changeset/strange-lamps-taste.md b/.changeset/strange-lamps-taste.md new file mode 100644 index 00000000000..88b61f5e5de --- /dev/null +++ b/.changeset/strange-lamps-taste.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/ddp-client': patch +'@rocket.chat/meteor': patch +--- + +Revert unintentional changes real time presence data payload diff --git a/apps/meteor/app/notifications/client/lib/Presence.ts b/apps/meteor/app/notifications/client/lib/Presence.ts index 8cff2ed84f6..dff4ecb0392 100644 --- a/apps/meteor/app/notifications/client/lib/Presence.ts +++ b/apps/meteor/app/notifications/client/lib/Presence.ts @@ -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 }); }); diff --git a/apps/meteor/server/modules/listeners/listeners.module.ts b/apps/meteor/server/modules/listeners/listeners.module.ts index 49a3017af81..ecaab84b2fa 100644 --- a/apps/meteor/server/modules/listeners/listeners.module.ts +++ b/apps/meteor/server/modules/listeners/listeners.module.ts @@ -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.OFFLINE]: 0, + [UserStatus.ONLINE]: 1, + [UserStatus.AWAY]: 2, + [UserStatus.BUSY]: 3, + [UserStatus.DISABLED]: 0, +} as const; + const minimongoChangeMap: Record = { 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); } }); diff --git a/apps/meteor/server/modules/notifications/notifications.module.ts b/apps/meteor/server/modules/notifications/notifications.module.ts index 73cede2cd36..75a2935d561 100644 --- a/apps/meteor/server/modules/notifications/notifications.module.ts +++ b/apps/meteor/server/modules/notifications/notifications.module.ts @@ -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); } diff --git a/ee/packages/ddp-client/src/types/streams.ts b/ee/packages/ddp-client/src/types/streams.ts index 87a3c0352c1..8d9d3b5302d 100644 --- a/ee/packages/ddp-client/src/types/streams.ts +++ b/ee/packages/ddp-client/src/types/streams.ts @@ -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': [