diff --git a/.changeset/shaggy-cars-watch.md b/.changeset/shaggy-cars-watch.md new file mode 100644 index 0000000000000..56db9fd9b4e74 --- /dev/null +++ b/.changeset/shaggy-cars-watch.md @@ -0,0 +1,6 @@ +--- +"@rocket.chat/meteor": patch +"@rocket.chat/ui-contexts": patch +--- + +Fixes a mismatch in the room icons on the sidebar items, ABAC Managed rooms were not displaying the correct icon diff --git a/apps/meteor/client/cachedStores/RoomsCachedStore.ts b/apps/meteor/client/cachedStores/RoomsCachedStore.ts index f5ee93b9701b7..85e78c9041b4f 100644 --- a/apps/meteor/client/cachedStores/RoomsCachedStore.ts +++ b/apps/meteor/client/cachedStores/RoomsCachedStore.ts @@ -1,5 +1,5 @@ import type { IOmnichannelRoom, IRoom, IRoomWithRetentionPolicy } from '@rocket.chat/core-typings'; -import { DEFAULT_SLA_CONFIG, isRoomNativeFederated, LivechatPriorityWeight } from '@rocket.chat/core-typings'; +import { DEFAULT_SLA_CONFIG, isABACManagedRoom, isRoomNativeFederated, LivechatPriorityWeight } from '@rocket.chat/core-typings'; import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts'; import { PrivateCachedStore } from '../lib/cachedStores/CachedStore'; @@ -53,7 +53,9 @@ class RoomsCachedStore extends PrivateCachedStore { source: (room as IOmnichannelRoom | undefined)?.source, queuedAt: (room as IOmnichannelRoom | undefined)?.queuedAt, federated: room.federated, - + ...(isABACManagedRoom(room) && { + abacAttributes: room.abacAttributes, + }), ...(isRoomNativeFederated(room) && { federation: room.federation, }), diff --git a/apps/meteor/client/views/root/hooks/loggedIn/useForceLogout.ts b/apps/meteor/client/views/root/hooks/loggedIn/useForceLogout.ts index 228d453952b3e..07390ddb0d4aa 100644 --- a/apps/meteor/client/views/root/hooks/loggedIn/useForceLogout.ts +++ b/apps/meteor/client/views/root/hooks/loggedIn/useForceLogout.ts @@ -1,5 +1,4 @@ import { useStream, useSessionDispatch } from '@rocket.chat/ui-contexts'; -import { Meteor } from 'meteor/meteor'; import { useEffect } from 'react'; export const useForceLogout = (userId: string) => { @@ -9,13 +8,7 @@ export const useForceLogout = (userId: string) => { useEffect(() => { setForceLogout(false); - const unsubscribe = getNotifyUserStream(`${userId}/force_logout`, (sessionId) => { - const currentSessionId = Meteor.connection._lastSessionId; - - if (sessionId === currentSessionId) { - window.location.reload(); - } - + const unsubscribe = getNotifyUserStream(`${userId}/force_logout`, () => { setForceLogout(true); }); diff --git a/apps/meteor/definition/externals/meteor/meteor.d.ts b/apps/meteor/definition/externals/meteor/meteor.d.ts index 8fdf903914b72..477107d55d338 100644 --- a/apps/meteor/definition/externals/meteor/meteor.d.ts +++ b/apps/meteor/definition/externals/meteor/meteor.d.ts @@ -40,7 +40,7 @@ declare module 'meteor/meteor' { } const server: { - sessions: Map; + sessions: Map; publish_handlers: { meteor_autoupdate_clientVersions(): void; }; @@ -118,7 +118,6 @@ declare module 'meteor/meteor' { }, ] ): SubscriptionHandle; - _lastSessionId: string; call(methodName: string, ...args: [...unknown, callback?: (error: Error | null, result: unknown) => void]): void; } diff --git a/apps/meteor/server/services/meteor/service.ts b/apps/meteor/server/services/meteor/service.ts index 9ee6940f283c6..7a4283e5020a2 100644 --- a/apps/meteor/server/services/meteor/service.ts +++ b/apps/meteor/server/services/meteor/service.ts @@ -39,6 +39,19 @@ export class MeteorService extends ServiceClassInternal implements IMeteor { new ListenersModule(this, notifications); + this.onEvent('user.forceLogout', (uid: string, sessionId?: string) => { + if (sessionId) { + const sessions = Meteor.server.sessions.get(sessionId); + sessions?.connectionHandle.close(); + return; + } + Meteor.server.sessions.forEach((session) => { + if (session.userId === uid) { + session.connectionHandle.close(); + } + }); + }); + this.onEvent('watch.settings', async ({ clientAction, setting }): Promise => { if (clientAction !== 'removed') { settings.set(setting); diff --git a/ee/apps/ddp-streamer/src/DDPStreamer.ts b/ee/apps/ddp-streamer/src/DDPStreamer.ts index 832f606b390d0..9b9a475b6900c 100644 --- a/ee/apps/ddp-streamer/src/DDPStreamer.ts +++ b/ee/apps/ddp-streamer/src/DDPStreamer.ts @@ -50,9 +50,13 @@ export class DDPStreamer extends ServiceClass { } }); - this.onEvent('user.forceLogout', (uid: string) => { + this.onEvent('user.forceLogout', (uid: string, sessionId?: string) => { this.wss?.clients.forEach((ws) => { const client = clientMap.get(ws); + if (sessionId && client?.connection.id === sessionId) { + ws.close(); + return; + } if (client?.userId === uid) { ws.terminate(); } diff --git a/packages/core-typings/src/IRoom.ts b/packages/core-typings/src/IRoom.ts index fb243a8f92e52..d3db0f7680a5a 100644 --- a/packages/core-typings/src/IRoom.ts +++ b/packages/core-typings/src/IRoom.ts @@ -132,6 +132,9 @@ export const isPublicDiscussion = (room: Partial): room is IRoom => isDis export const isPublicRoom = (room: Partial): room is IRoom => room.t === 'c'; export const isPrivateRoom = (room: Partial): room is IRoom => room.t === 'p'; +export const isABACManagedRoom = (room: Partial): room is IRoom & { abacAttributes: IAbacAttributeDefinition[] } => + Array.isArray(room?.abacAttributes) && room.abacAttributes.length > 0; + export interface IDirectMessageRoom extends Omit { t: 'd'; uids: Array; diff --git a/packages/ui-contexts/src/types/SubscriptionWithRoom.ts b/packages/ui-contexts/src/types/SubscriptionWithRoom.ts index efffc6ca2791a..d641007a0a067 100644 --- a/packages/ui-contexts/src/types/SubscriptionWithRoom.ts +++ b/packages/ui-contexts/src/types/SubscriptionWithRoom.ts @@ -15,6 +15,7 @@ export type SubscriptionWithRoom = ISubscription & | 'muted' | 'federated' | 'lm' + | 'abacAttributes' > & Pick< IOmnichannelRoom,