-
-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[federation] Implement get missing events api #516
Conversation
Does not check whether server is allowed to see the events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably log an error too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't usually log badJSON errors, should I do it still ?
@@ -154,6 +154,24 @@ type QueryServerAllowedToSeeEventResponse struct { | |||
AllowedToSeeEvent bool `json:"can_see_event"` | |||
} | |||
|
|||
// QueryMissingEventsRequest is request to QueryMissingEvents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is a request"
MinDepth int64 `json:"min_depth"` | ||
} | ||
|
||
// GetMissingEvents returns missing event between earliest_events & latest_events. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"returns missing events"
@@ -154,6 +154,24 @@ type QueryServerAllowedToSeeEventResponse struct { | |||
AllowedToSeeEvent bool `json:"can_see_event"` | |||
} | |||
|
|||
// QueryMissingEventsRequest is request to QueryMissingEvents | |||
type QueryMissingEventsRequest struct { | |||
// Events which are known previous to the gap in timeline. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"gap in the timeline"
ServerName gomatrixserverlib.ServerName `json:"server_name"` | ||
} | ||
|
||
// QueryMissingEventsResponse is response to QueryMissingEvents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is a response"
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure what this means?
} | ||
|
||
if domain == serverName { | ||
isInRoom = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove the var err error
line and just change ... err = r.loadEvents
to ... err := r.loadEvents
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response.Events
is a declared variable. :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>