Skip to content
Merged
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
13 changes: 7 additions & 6 deletions packages/room/src/state_resolution/definitions/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@ export async function getAuthChain(
const eventId = event.eventId;

if (eventIdToAuthChainMap.has(eventId)) {
return eventIdToAuthChainMap.get(eventId);
return eventIdToAuthChainMap.get(eventId)!;
}

const authEvents = await event.getAuthorizationEvents(store);

if (authEvents.length === 0) {
eventIdToAuthChainMap.set(eventId, existingAuthChainPart);
return existingAuthChainPart;
Expand All @@ -130,8 +129,7 @@ export async function getAuthChain(
return newAuthChainPart;
};

const result = await _getAuthChain(event, new Set([event.eventId]));
return result || new Set<EventID>([event.eventId]);
return _getAuthChain(event, new Set([]));
}

// Auth difference
Expand All @@ -151,8 +149,11 @@ export async function getAuthChainDifference(
console.warn('event not found in store or remote', eventid);
continue;
}

for (const authChainEventId of await getAuthChain(event, store)) {
// TODO: deb check this I changed to keep the function behaving as the spec
for (const authChainEventId of [
...(await getAuthChain(event, store)),
event.eventId,
]) {
authChainForState.add(authChainEventId);
}
}
Expand Down