diff options
author | kegsay <kegan@matrix.org> | 2022-01-06 17:13:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 17:13:34 +0000 |
commit | 173b1e8d3e800c0029725bcda321a240b5352f7d (patch) | |
tree | cf65e96b8259f9e3e3462246308f47c85f8697f0 /roomserver | |
parent | 161f14517669410d3e8207dc41eea5c9695f7e17 (diff) |
Fix #2084 - incorrect /event_auth response (#2085)
* Fix #2084
* Return early
* Linting
Diffstat (limited to 'roomserver')
-rw-r--r-- | roomserver/api/query.go | 4 | ||||
-rw-r--r-- | roomserver/internal/query/query.go | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/roomserver/api/query.go b/roomserver/api/query.go index 599156bb..28321715 100644 --- a/roomserver/api/query.go +++ b/roomserver/api/query.go @@ -226,6 +226,10 @@ type QueryStateAndAuthChainRequest struct { PrevEventIDs []string `json:"prev_event_ids"` // The list of auth events for the event. Used to calculate the auth chain AuthEventIDs []string `json:"auth_event_ids"` + // If true, the auth chain events for the auth event IDs given will be fetched only. Prev event IDs are ignored. + // If false, state and auth chain events for the prev event IDs and entire current state will be included. + // TODO: not a great API shape. It serves 2 main uses: false=>response for send_join, true=>response for /event_auth + OnlyFetchAuthChain bool `json:"only_fetch_auth_chain"` // Should state resolution be ran on the result events? // TODO: check call sites and remove if we always want to do state res ResolveState bool `json:"resolve_state"` diff --git a/roomserver/internal/query/query.go b/roomserver/internal/query/query.go index b80f08ab..28b140c7 100644 --- a/roomserver/internal/query/query.go +++ b/roomserver/internal/query/query.go @@ -457,6 +457,21 @@ func (r *Queryer) QueryStateAndAuthChain( response.RoomExists = true response.RoomVersion = info.RoomVersion + // handle this entirely separately to the other case so we don't have to pull out + // the entire current state of the room + // TODO: this probably means it should be a different query operation... + if request.OnlyFetchAuthChain { + var authEvents []*gomatrixserverlib.Event + authEvents, err = GetAuthChain(ctx, r.DB.EventsFromIDs, request.AuthEventIDs) + if err != nil { + return err + } + for _, event := range authEvents { + response.AuthChainEvents = append(response.AuthChainEvents, event.Headered(info.RoomVersion)) + } + return nil + } + var stateEvents []*gomatrixserverlib.Event stateEvents, err = r.loadStateAtEventIDs(ctx, *info, request.PrevEventIDs) if err != nil { |