Try to recursively find auth events (to a point) if they are missing (#881)

* Try to recursively find auth events (to a point) if they are missing

* Remove recursion limit for now and other review fixes

* Simplify error handling for recursion

* Pass room version 1 only to MakeJoin until room version support comes later
This commit is contained in:
Neil Alexander 2020-03-06 16:58:10 +00:00 committed by GitHub
parent 87283e9de7
commit 6a1111c3d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 15 deletions

View file

@ -211,7 +211,24 @@ func (t *txnReq) processEventWithMissingState(e gomatrixserverlib.Event) error {
return err
}
// Check that the event is allowed by the state.
retryAllowedState:
if err := checkAllowedByState(e, state.StateEvents); err != nil {
switch missing := err.(type) {
case gomatrixserverlib.MissingAuthEventError:
// An auth event was missing so let's look up that event over federation
for _, s := range state.StateEvents {
if s.EventID() != missing.AuthEventID {
continue
}
err = t.processEventWithMissingState(s)
// If there was no error retrieving the event from federation then
// we assume that it succeeded, so retry the original state check
if err == nil {
goto retryAllowedState
}
}
default:
}
return err
}
// pass the event along with the state to the roomserver