Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch when CryptoClient can't find room members #341

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions src/e2ee/CryptoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,21 @@ export class CryptoClient {
* @param roomId The room ID.
* @param event The event.
*/
public async onRoomEvent(roomId: string, event: any) {
public async onRoomEvent(roomId: string, event: any): Promise<void> {
await this.roomTracker.onRoomEvent(roomId, event);
if (typeof event['state_key'] !== 'string') return;
if (event['type'] === 'm.room.member') {
const membership = new MembershipEvent(event);
if (membership.effectiveMembership !== 'join' && membership.effectiveMembership !== 'invite') return;
await this.engine.addTrackedUsers([membership.membershipFor]);
} else if (event['type'] === 'm.room.encryption') {
const members = await this.client.getRoomMembers(roomId, null, ['join', 'invite']);
let members: MembershipEvent[] | undefined;
try {
members = await this.client.getRoomMembers(roomId, null, ['join', 'invite']);
} catch (e) {
LogService.warn("CryptoClient", `Unable to get members of room ${roomId}`);
return;
}
await this.engine.addTrackedUsers(members.map(e => e.membershipFor));
}
}
Expand Down
Loading