Skip to content

Commit 5b6f94b

Browse files
committed
refactor: streamline state ID retrieval in StateService and enhance auth chain handling in getAuthChain function for improved clarity
1 parent 21fcfbb commit 5b6f94b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

packages/federation-sdk/src/services/event.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ export class EventService {
758758
for (const [, event] of state.entries()) {
759759
// PersistentEventBase has an event getter that contains the actual event data
760760
pdus.push(event.event);
761+
761762
// Get the complete auth chain for this event
762763
try {
763764
const authChain = await getAuthChain(event, store);

packages/federation-sdk/src/services/state.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ export class StateService {
248248
}
249249

250250
// Retrieves a snapshot of a room's state at a given event, in the form of event IDs. This performs the same function as calling /state/{roomId}, however this returns just the event IDs rather than the full events.
251-
const stateId = !pdu.isState()
252-
? event.stateId
253-
: await this.findPreviousStateId(event.stateId);
251+
const { stateId } = event;
254252

255253
const { delta: lastStateDelta, prevStateIds = [] } =
256254
(await this.stateRepository.getStateById(stateId)) ?? {};

packages/room/src/state_resolution/definitions/definitions.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export async function getAuthChain(
129129
return newAuthChainPart;
130130
};
131131

132-
return _getAuthChain(event, new Set([event.eventId]));
132+
return _getAuthChain(event, new Set([]));
133133
}
134134

135135
// Auth difference
@@ -149,8 +149,11 @@ export async function getAuthChainDifference(
149149
console.warn('event not found in store or remote', eventid);
150150
continue;
151151
}
152-
153-
for (const authChainEventId of await getAuthChain(event, store)) {
152+
// TODO: deb check this I changed to keep the function behaving as the spec
153+
for (const authChainEventId of [
154+
...(await getAuthChain(event, store)),
155+
event.eventId,
156+
]) {
154157
authChainForState.add(authChainEventId);
155158
}
156159
}

0 commit comments

Comments
 (0)