don't withhold member event for call just because we don't have profile

This commit is contained in:
Bruno Windels 2022-06-03 12:43:51 +02:00
parent f8b01ac3cc
commit ed5fdb8154

View file

@ -102,13 +102,18 @@ export class CallHandler implements RoomStateHandler {
// TODO: don't load all members until we need them // TODO: don't load all members until we need them
const callsMemberEvents = await txn.roomState.getAllForType(roomId, EventType.GroupCallMember); const callsMemberEvents = await txn.roomState.getAllForType(roomId, EventType.GroupCallMember);
await Promise.all(callsMemberEvents.map(async entry => { await Promise.all(callsMemberEvents.map(async entry => {
const roomMemberState = await txn.roomState.get(roomId, MEMBER_EVENT_TYPE, entry.event.sender); const userId = entry.event.sender;
const roomMemberState = await txn.roomState.get(roomId, MEMBER_EVENT_TYPE, userId);
let roomMember;
if (roomMemberState) { if (roomMemberState) {
const roomMember = RoomMember.fromMemberEvent(roomMemberState.event); roomMember = RoomMember.fromMemberEvent(roomMemberState.event);
if (roomMember) {
this.handleCallMemberEvent(entry.event, roomMember, roomId, log);
}
} }
if (!roomMember) {
// we'll be missing the member here if we received a call and it's members
// as pre-gap state and the members weren't active in the timeline we got.
roomMember = RoomMember.fromUserId(roomId, userId, "join");
}
this.handleCallMemberEvent(entry.event, roomMember, roomId, log);
})); }));
})); }));
log.set("newSize", this._calls.size); log.set("newSize", this._calls.size);
@ -153,10 +158,13 @@ export class CallHandler implements RoomStateHandler {
this.handleCallEvent(event, room.id, txn, log); this.handleCallEvent(event, room.id, txn, log);
} }
if (event.type === EventType.GroupCallMember) { if (event.type === EventType.GroupCallMember) {
const member: RoomMember | undefined = await memberSync.lookupMemberAtEvent(event.sender, event, txn); let member = await memberSync.lookupMemberAtEvent(event.sender, event, txn);
if (member) { // should always have a member? if (!member) {
this.handleCallMemberEvent(event, member, room.id, log); // we'll be missing the member here if we received a call and it's members
// as pre-gap state and the members weren't active in the timeline we got.
member = RoomMember.fromUserId(room.id, event.sender, "join");
} }
this.handleCallMemberEvent(event, member, room.id, log);
} }
} }