Skip to content

Commit

Permalink
cr
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Oct 10, 2024
1 parent 301ce5c commit 1b6c68e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
4 changes: 4 additions & 0 deletions apps/meteor/app/e2e/client/rocketchat.e2e.room.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ export class E2ERoom extends Emitter {
}

async exportOldRoomKeys(oldKeys) {
this.log('exportOldRoomKeys starting');
if (!oldKeys || oldKeys.length === 0) {
this.log('exportOldRoomKeys nothing to do');
return;
}

Expand All @@ -269,6 +271,7 @@ export class E2ERoom extends Emitter {
}
}

this.log(`exportOldRoomKeys Done: ${keys.length} keys exported`);
return keys;
}

Expand Down Expand Up @@ -424,6 +427,7 @@ export class E2ERoom extends Emitter {
this.groupSessionKey = undefined;
this.sessionKeyExportedString = undefined;
this.sessionKeyExported = undefined;
this.oldKeys = undefined;
}

async encryptKeyForOtherParticipants() {
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/e2e/server/functions/resetRoomKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function replicateMongoSlice(keyId: string, sub: ISubscription) {
return [{ e2eKeyId: keyId, ts: new Date(), E2EKey: sub.E2EKey }];
}

const keys = sub.oldRoomKeys;
keys.sort((a, b) => b.ts.getTime() - a.ts.getTime());
keys.unshift({ e2eKeyId: keyId, ts: new Date(), E2EKey: sub.E2EKey });
return keys.slice(0, 10);
const sortedKeys = sub.oldRoomKeys.toSorted((a, b) => b.ts.getTime() - a.ts.getTime());
sortedKeys.unshift({ e2eKeyId: keyId, ts: new Date(), E2EKey: sub.E2EKey });

return sortedKeys.slice(0, 10);
}
14 changes: 0 additions & 14 deletions apps/meteor/server/models/raw/Rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1139,20 +1139,6 @@ export class RoomsRaw extends BaseRaw<IRoom> implements IRoomsModel {
return this.updateOne(query, update, options);
}

unsetE2eKeyId(_id: IRoom['_id'], options: UpdateOptions = {}): Promise<UpdateResult> {
const query: Filter<IRoom> = {
_id,
};

const update: UpdateFilter<IRoom> = {
$unset: {
e2eKeyId: 1,
},
};

return this.updateOne(query, update, options);
}

findOneByImportId(_id: IRoom['_id'], options: FindOptions<IRoom> = {}): Promise<IRoom | null> {
const query: Filter<IRoom> = { importIds: _id };

Expand Down
1 change: 0 additions & 1 deletion packages/model-typings/src/models/IRoomsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export interface IRoomsModel extends IBaseModel<IRoom> {
unsetAvatarData(roomId: string): Promise<UpdateResult>;
setSystemMessagesById(roomId: string, systemMessages: IRoom['sysMes']): Promise<UpdateResult>;
setE2eKeyId(roomId: string, e2eKeyId: string, options?: FindOptions<IRoom>): Promise<UpdateResult>;
unsetE2eKeyId(_id: IRoom['_id'], options?: UpdateOptions): Promise<UpdateResult>;
findOneByImportId(importId: string, options?: FindOptions<IRoom>): Promise<IRoom | null>;
findOneByNameAndNotId(name: string, rid: string): Promise<IRoom | null>;
findOneByIdAndType(roomId: IRoom['_id'], type: IRoom['t'], options?: FindOptions<IRoom>): Promise<IRoom | null>;
Expand Down

0 comments on commit 1b6c68e

Please sign in to comment.