Review comments

This commit is contained in:
Neil Alexander 2022-02-09 12:00:38 +00:00
parent a38b3a3d1b
commit 1d6b620081
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 5 additions and 5 deletions

View file

@ -255,20 +255,20 @@ func (r *Inputer) processRoomEvent(
hadEvents: map[string]bool{},
haveEvents: map[string]*gomatrixserverlib.HeaderedEvent{},
}
if override, err := missingState.processEventWithMissingState(ctx, event, headered.RoomVersion); err != nil {
if stateSnapshot, err := missingState.processEventWithMissingState(ctx, event, headered.RoomVersion); err != nil {
// Something went wrong with retrieving the missing state, so we can't
// really do anything with the event other than reject it at this point.
isRejected = true
rejectionErr = fmt.Errorf("missingState.processEventWithMissingState: %w", err)
} else if override != nil {
} else if stateSnapshot != nil {
// We retrieved some state and we ended up having to call /state_ids for
// the new event in question (probably because closing the gap by using
// /get_missing_events didn't do what we hoped) so we'll instead overwrite
// the state snapshot with the newly resolved state.
missingPrev = false
input.HasState = true
input.StateEventIDs = make([]string, 0, len(override.StateEvents))
for _, e := range override.StateEvents {
input.StateEventIDs = make([]string, 0, len(stateSnapshot.StateEvents))
for _, e := range stateSnapshot.StateEvents {
input.StateEventIDs = append(input.StateEventIDs, e.EventID())
}
} else {

View file

@ -150,7 +150,7 @@ func (r *Queryer) QueryMissingAuthPrevEvents(
for _, prevEventID := range request.PrevEventIDs {
state, err := r.DB.StateAtEventIDs(ctx, []string{prevEventID})
if err != nil || len(state) == 0 || state[0].BeforeStateSnapshotNID == 0 {
if err != nil || len(state) == 0 || (state[0].EventTypeNID != types.MRoomCreateNID && state[0].EventStateKeyNID == types.EmptyStateKeyNID && state[0].BeforeStateSnapshotNID == 0) {
response.MissingPrevEventIDs = append(response.MissingPrevEventIDs, prevEventID)
}
}