Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/shaggy-cars-watch.md
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions apps/meteor/client/cachedStores/RoomsCachedStore.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -53,7 +53,9 @@ class RoomsCachedStore extends PrivateCachedStore<IRoom> {
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,
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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);
});

Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/definition/externals/meteor/meteor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare module 'meteor/meteor' {
}

const server: {
sessions: Map<string, { userId: string; heartbeat: DDPCommon.Heartbeat }>;
sessions: Map<string, { userId: string; heartbeat: DDPCommon.Heartbeat; connectionHandle: Meteor.Connection }>;
publish_handlers: {
meteor_autoupdate_clientVersions(): void;
};
Expand Down Expand Up @@ -118,7 +118,6 @@ declare module 'meteor/meteor' {
},
]
): SubscriptionHandle;
_lastSessionId: string;

call(methodName: string, ...args: [...unknown, callback?: (error: Error | null, result: unknown) => void]): void;
}
Expand Down
13 changes: 13 additions & 0 deletions apps/meteor/server/services/meteor/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
if (clientAction !== 'removed') {
settings.set(setting);
Expand Down
6 changes: 5 additions & 1 deletion ee/apps/ddp-streamer/src/DDPStreamer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
3 changes: 3 additions & 0 deletions packages/core-typings/src/IRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export const isPublicDiscussion = (room: Partial<IRoom>): room is IRoom => isDis
export const isPublicRoom = (room: Partial<IRoom>): room is IRoom => room.t === 'c';
export const isPrivateRoom = (room: Partial<IRoom>): room is IRoom => room.t === 'p';

export const isABACManagedRoom = (room: Partial<IRoom>): room is IRoom & { abacAttributes: IAbacAttributeDefinition[] } =>
Array.isArray(room?.abacAttributes) && room.abacAttributes.length > 0;

export interface IDirectMessageRoom extends Omit<IRoom, 'default' | 'featured' | 'u' | 'name'> {
t: 'd';
uids: Array<string>;
Expand Down
1 change: 1 addition & 0 deletions packages/ui-contexts/src/types/SubscriptionWithRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type SubscriptionWithRoom = ISubscription &
| 'muted'
| 'federated'
| 'lm'
| 'abacAttributes'
> &
Pick<
IOmnichannelRoom,
Expand Down
Loading