diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-09-29 13:40:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-29 13:40:29 +0100 |
commit | 738b829a23d4e50e68f98acb72f7d10a16009f8b (patch) | |
tree | be4f86b0a3b39f10856499d869721c914d56b65f /roomserver/api | |
parent | 4ff7ac7b6574d6adec775057dc2c798a1fe10248 (diff) |
Fetch missing auth events, implement QueryMissingAuthPrevEvents, try other servers in room for /event and /get_missing_events (#1450)
* Try to ask other servers in the room for missing events if the origin won't provide them
* Logging
* More logging
* Implement QueryMissingAuthPrevEvents
* Try to get missing auth events badly
* Use processEvent
* Logging
* Update QueryMissingAuthPrevEvents
* Try to find missing auth events
* Patchy fix for test
* Logging tweaks
* Send auth events as outliers
* Update check in QueryMissingAuthPrevEvents
* Error responses
* More return codes
* Don't return error on reject/soft-fail since it was ultimately handled
* More tweaks
* More error tweaks
Diffstat (limited to 'roomserver/api')
-rw-r--r-- | roomserver/api/api.go | 7 | ||||
-rw-r--r-- | roomserver/api/api_trace.go | 10 | ||||
-rw-r--r-- | roomserver/api/query.go | 23 |
3 files changed, 40 insertions, 0 deletions
diff --git a/roomserver/api/api.go b/roomserver/api/api.go index 159c1829..043f7222 100644 --- a/roomserver/api/api.go +++ b/roomserver/api/api.go @@ -68,6 +68,13 @@ type RoomserverInternalAPI interface { response *QueryStateAfterEventsResponse, ) error + // Query whether the roomserver is missing any auth or prev events. + QueryMissingAuthPrevEvents( + ctx context.Context, + request *QueryMissingAuthPrevEventsRequest, + response *QueryMissingAuthPrevEventsResponse, + ) error + // Query a list of events by event ID. QueryEventsByID( ctx context.Context, diff --git a/roomserver/api/api_trace.go b/roomserver/api/api_trace.go index 5fabbc21..f4eaddc1 100644 --- a/roomserver/api/api_trace.go +++ b/roomserver/api/api_trace.go @@ -104,6 +104,16 @@ func (t *RoomserverInternalAPITrace) QueryStateAfterEvents( return err } +func (t *RoomserverInternalAPITrace) QueryMissingAuthPrevEvents( + ctx context.Context, + req *QueryMissingAuthPrevEventsRequest, + res *QueryMissingAuthPrevEventsResponse, +) error { + err := t.Impl.QueryMissingAuthPrevEvents(ctx, req, res) + util.GetLogger(ctx).WithError(err).Infof("QueryMissingAuthPrevEvents req=%+v res=%+v", js(req), js(res)) + return err +} + func (t *RoomserverInternalAPITrace) QueryEventsByID( ctx context.Context, req *QueryEventsByIDRequest, diff --git a/roomserver/api/query.go b/roomserver/api/query.go index 5d61e862..aff6ee07 100644 --- a/roomserver/api/query.go +++ b/roomserver/api/query.go @@ -82,6 +82,27 @@ type QueryStateAfterEventsResponse struct { StateEvents []gomatrixserverlib.HeaderedEvent `json:"state_events"` } +type QueryMissingAuthPrevEventsRequest struct { + // The room ID to query the state in. + RoomID string `json:"room_id"` + // The list of auth events to check the existence of. + AuthEventIDs []string `json:"auth_event_ids"` + // The list of previous events to check the existence of. + PrevEventIDs []string `json:"prev_event_ids"` +} + +type QueryMissingAuthPrevEventsResponse struct { + // Does the room exist on this roomserver? + // If the room doesn't exist all other fields will be empty. + RoomExists bool `json:"room_exists"` + // The room version of the room. + RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"` + // The event IDs of the auth events that we don't know locally. + MissingAuthEventIDs []string `json:"missing_auth_event_ids"` + // The event IDs of the previous events that we don't know locally. + MissingPrevEventIDs []string `json:"missing_prev_event_ids"` +} + // QueryEventsByIDRequest is a request to QueryEventsByID type QueryEventsByIDRequest struct { // The event IDs to look up. @@ -154,6 +175,8 @@ type QueryServerJoinedToRoomResponse struct { RoomExists bool `json:"room_exists"` // True if we still believe that we are participating in the room IsInRoom bool `json:"is_in_room"` + // List of servers that are also in the room + ServerNames []gomatrixserverlib.ServerName `json:"server_names"` } // QueryServerAllowedToSeeEventRequest is a request to QueryServerAllowedToSeeEvent |