Exclude events we don't know state for

This commit is contained in:
Neil Alexander 2022-09-13 11:10:57 +01:00
parent c279229f6f
commit 7928138034
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 8 additions and 1 deletions

View file

@ -237,7 +237,11 @@ func (r *Queryer) QueryMembershipAtEvent(
}
for _, eventID := range request.EventIDs {
stateEntry := stateEntries[eventID]
stateEntry, ok := stateEntries[eventID]
if !ok {
response.Memberships[eventID] = []*gomatrixserverlib.HeaderedEvent{}
continue
}
memberships, err := helpers.GetMembershipsAtState(ctx, r.DB, stateEntry, false)
if err != nil {
return fmt.Errorf("unable to get memberships at state: %w", err)

View file

@ -139,6 +139,9 @@ func (v *StateResolution) LoadMembershipAtEvent(
return nil, fmt.Errorf("LoadStateAtEvent.SnapshotNIDFromEventID failed for event %s : %w", eventID, err)
}
if snapshotNID == 0 {
// If we don't know a state snapshot for this event then we can't calculate
// memberships at the time of the event, so skip over it. This means that
// it isn't guaranteed that the response map will contain every single event.
continue
}
snapshotNIDMap[snapshotNID] = append(snapshotNIDMap[snapshotNID], eventID)