Skip to content

Commit

Permalink
Revert "fix: Async E2EE key exchange not working on develop (#33378)"
Browse files Browse the repository at this point in the history
This reverts commit dcc98fbeb8ec2f4c09982aebb665382577394720.
  • Loading branch information
KevLehman committed Sep 30, 2024
1 parent 0f1d256 commit 0d7a6b3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
5 changes: 0 additions & 5 deletions .changeset/witty-apples-pretend.md

This file was deleted.

12 changes: 3 additions & 9 deletions apps/meteor/app/e2e/server/functions/handleSuggestedGroupKey.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -38,7 +36,5 @@ Meteor.methods<ServerMethods>({

const subscribedRoomIds = await Rooms.getSubscribedRoomIdsWithoutE2EKeys(userId);
await Rooms.addUserIdToE2EEQueueByRoomIds(subscribedRoomIds, userId);

void notifyOnRoomChangedById(subscribedRoomIds);
},
});
3 changes: 2 additions & 1 deletion apps/meteor/app/lib/server/functions/addUserToRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -145,6 +147,5 @@ export const addUserToRoom = async function (
await Rooms.addUserIdToE2EEQueueByRoomIds([room._id], userToBeAdded._id);
}

void notifyOnRoomChangedById(rid);
return true;
};

0 comments on commit 0d7a6b3

Please sign in to comment.