[federation] Implement get missing events api#516
[federation] Implement get missing events api#516APwhitehat merged 4 commits intomatrix-org:masterfrom
Conversation
Does not check whether server is allowed to see the events
erikjohnston
left a comment
There was a problem hiding this comment.
Looks good! Just a couple of minor things.
|
|
||
| func filterEvents( | ||
| events []gomatrixserverlib.Event, minDepth int64, roomID string, | ||
| ) []gomatrixserverlib.Event { |
There was a problem hiding this comment.
Can you add a quick docstring explaining what this does, as its not immediately obvious from the name nor return type.
| return util.JSONResponse{ | ||
| Code: http.StatusBadRequest, | ||
| JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()), | ||
| } |
There was a problem hiding this comment.
We should probably log an error too
There was a problem hiding this comment.
We don't usually log badJSON errors, should I do it still ?
| AllowedToSeeEvent bool `json:"can_see_event"` | ||
| } | ||
|
|
||
| // QueryMissingEventsRequest is request to QueryMissingEvents |
| MinDepth int64 `json:"min_depth"` | ||
| } | ||
|
|
||
| // GetMissingEvents returns missing event between earliest_events & latest_events. |
|
|
||
| // QueryMissingEventsRequest is request to QueryMissingEvents | ||
| type QueryMissingEventsRequest struct { | ||
| // Events which are known previous to the gap in timeline. |
| ServerName gomatrixserverlib.ServerName `json:"server_name"` | ||
| } | ||
|
|
||
| // QueryMissingEventsResponse is response to QueryMissingEvents |
|
|
||
| import "github.com/matrix-org/gomatrixserverlib" | ||
|
|
||
| // IsServerAllowed checks if a server has a client as member in authEvents |
There was a problem hiding this comment.
Not quite sure what this means?
| } | ||
|
|
||
| if domain == serverName { | ||
| isInRoom = true |
There was a problem hiding this comment.
Presumably you could just return true here, and return false after the for loop?
| response.AllowedToSeeEvent = false | ||
| return nil | ||
| var err error | ||
| response.Events, err = r.loadEvents(ctx, resultNIDs) |
There was a problem hiding this comment.
Can remove the var err error line and just change ... err = r.loadEvents to ... err := r.loadEvents.
There was a problem hiding this comment.
response.Events is a declared variable. :/
There was a problem hiding this comment.
Oh, turns out you can't := assign to non-identifiers. My bad :p
Might be unnecessarily inefficient, suggestions are welcome.
fixes #492
Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>