java-topology/defects/rocketchat/patch/0003.patch

28 lines
1.3 KiB
Diff

# UNDF: UNDF-2026-000001150
--- a/apps/meteor/server/services/video-conference/service.ts
+++ b/apps/meteor/server/services/video-conference/service.ts
@@ -529,12 +529,14 @@ export class VideoConferenceService extends ServiceClassInternal implements IVid
private async endDirectCall(call: IDirectVideoConference): Promise<void> {
const params = { rid: call.rid, uid: call.createdBy._id, callId: call._id };
// Notify the caller that the call was ended by the server
this.notifyUser(call.createdBy._id, 'end', params);
// If the callee hasn't joined the call yet, notify them that it has already ended
const subscriptions = await Subscriptions.findByRoomIdAndNotUserId(call.rid, call.createdBy._id, {
projection: { 'u._id': 1, '_id': 0 },
}).toArray();
+ // Build a Set so the joined-user lookup is O(1) per subscription
+ // instead of O(U) per subscription (O(S*U) overall) via Array.find().
+ const joinedUserIds = new Set(call.users.map(({ _id }) => _id));
for (const subscription of subscriptions) {
// Skip notifying users that already joined the call
- if (call.users.find(({ _id }) => _id === subscription.u._id)) {
+ if (joinedUserIds.has(subscription.u._id)) {
continue;
}
this.notifyUser(subscription.u._id, 'end', params);
}
}