diff --git a/.changeset/witty-apples-pretend.md b/.changeset/witty-apples-pretend.md deleted file mode 100644 index cb4dd696983d..000000000000 --- a/.changeset/witty-apples-pretend.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@rocket.chat/meteor": patch ---- - -Fixes async E2EE key exchange in development environments where change streams are no longer used diff --git a/apps/meteor/app/e2e/server/functions/handleSuggestedGroupKey.ts b/apps/meteor/app/e2e/server/functions/handleSuggestedGroupKey.ts index 9d74144517fd..7be79f63ee08 100644 --- a/apps/meteor/app/e2e/server/functions/handleSuggestedGroupKey.ts +++ b/apps/meteor/app/e2e/server/functions/handleSuggestedGroupKey.ts @@ -1,7 +1,7 @@ import { Rooms, Subscriptions } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { notifyOnSubscriptionChangedById, notifyOnRoomChangedById } from '../../../lib/server/lib/notifyListener'; +import { notifyOnSubscriptionChangedById } from '../../../lib/server/lib/notifyListener'; export async function handleSuggestedGroupKey( handle: 'accept' | 'reject', @@ -28,17 +28,11 @@ export async function handleSuggestedGroupKey( // If a user already has oldRoomKeys, we will ignore the suggested ones const oldKeys = sub.oldRoomKeys ? undefined : sub.suggestedOldRoomKeys; await Subscriptions.setGroupE2EKeyAndOldRoomKeys(sub._id, suggestedKey, oldKeys); - const { modifiedCount } = await Rooms.removeUsersFromE2EEQueueByRoomId(sub.rid, [userId]); - if (modifiedCount) { - void notifyOnRoomChangedById(sub.rid); - } + await Rooms.removeUsersFromE2EEQueueByRoomId(sub.rid, [userId]); } if (handle === 'reject') { - const { modifiedCount } = await Rooms.addUserIdToE2EEQueueByRoomIds([sub.rid], userId); - if (modifiedCount) { - void notifyOnRoomChangedById(sub.rid); - } + await Rooms.addUserIdToE2EEQueueByRoomIds([sub.rid], userId); } const { modifiedCount } = await Subscriptions.unsetGroupE2ESuggestedKeyAndOldRoomKeys(sub._id); diff --git a/apps/meteor/app/e2e/server/methods/setUserPublicAndPrivateKeys.ts b/apps/meteor/app/e2e/server/methods/setUserPublicAndPrivateKeys.ts index 45a00886af1e..6ef35a063a28 100644 --- a/apps/meteor/app/e2e/server/methods/setUserPublicAndPrivateKeys.ts +++ b/apps/meteor/app/e2e/server/methods/setUserPublicAndPrivateKeys.ts @@ -2,8 +2,6 @@ import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Rooms, Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { notifyOnRoomChangedById } from '../../../lib/server/lib/notifyListener'; - declare module '@rocket.chat/ddp-client' { // eslint-disable-next-line @typescript-eslint/naming-convention interface ServerMethods { @@ -38,7 +36,5 @@ Meteor.methods({ const subscribedRoomIds = await Rooms.getSubscribedRoomIdsWithoutE2EKeys(userId); await Rooms.addUserIdToE2EEQueueByRoomIds(subscribedRoomIds, userId); - - void notifyOnRoomChangedById(subscribedRoomIds); }, }); diff --git a/apps/meteor/app/lib/server/functions/addUserToRoom.ts b/apps/meteor/app/lib/server/functions/addUserToRoom.ts index 2e74bf66cf4a..e6ca7b2a8b4d 100644 --- a/apps/meteor/app/lib/server/functions/addUserToRoom.ts +++ b/apps/meteor/app/lib/server/functions/addUserToRoom.ts @@ -97,6 +97,8 @@ export const addUserToRoom = async function ( void notifyOnSubscriptionChangedById(insertedId, 'inserted'); } + void notifyOnRoomChangedById(rid); + if (!userToBeAdded.username) { throw new Meteor.Error('error-invalid-user', 'Cannot add an user to a room without a username'); } @@ -145,6 +147,5 @@ export const addUserToRoom = async function ( await Rooms.addUserIdToE2EEQueueByRoomIds([room._id], userToBeAdded._id); } - void notifyOnRoomChangedById(rid); return true; };