Skip to content
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

Use stable identifiers from MSC3706 (Faster joins) #350

Merged
merged 3 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion federationclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (ac *FederationClient) sendJoin(
url.PathEscape(event.RoomID()) + "/" +
url.PathEscape(event.EventID())
if partialState {
path += "?org.matrix.msc3706.partial_state=true"
path += "?omit_members=true"
}

req := NewFederationRequest("PUT", origin, s, path)
Expand Down
12 changes: 6 additions & 6 deletions federationtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ type RespSendJoin struct {
// but not guaranteed to be present as it's only since MSC3083.
Event RawJSON `json:"event,omitempty"`
// true if the state is incomplete
PartialState bool `json:"org.matrix.msc3706.partial_state"`
MembersOmitted bool `json:"members_omitted"`
// a list of servers in the room. Only returned if partial_state is set.
ServersInRoom []string `json:"org.matrix.msc3706.servers_in_room"`
ServersInRoom []string `json:"servers_in_room"`
}

// MarshalJSON implements json.Marshaller
Expand All @@ -464,13 +464,13 @@ func (r RespSendJoin) MarshalJSON() ([]byte, error) {
fields.StateEvents = EventJSONs{}
}

if !r.PartialState {
if !r.MembersOmitted {
return json.Marshal(fields)
}

partialJoinFields := respSendJoinPartialStateFields{
respSendJoinFields: fields,
PartialState: true,
MembersOmitted: true,
ServersInRoom: r.ServersInRoom,
}
return json.Marshal(partialJoinFields)
Expand Down Expand Up @@ -517,8 +517,8 @@ type respSendJoinFields struct {
// when the response has incomplete state.
type respSendJoinPartialStateFields struct {
respSendJoinFields
PartialState bool `json:"org.matrix.msc3706.partial_state"`
ServersInRoom []string `json:"org.matrix.msc3706.servers_in_room"`
MembersOmitted bool `json:"members_omitted"`
ServersInRoom []string `json:"servers_in_room"`
}

// ToRespState returns a new RespState with the same data from the given RespSendJoin
Expand Down
14 changes: 7 additions & 7 deletions federationtypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ func TestRespSendJoinMarshalJSON(t *testing.T) {
func TestRespSendJoinMarshalJSONPartialState(t *testing.T) {
inputData := `{
"state":[],"auth_chain":[],"origin":"o1",
"org.matrix.msc3706.partial_state":true,
"org.matrix.msc3706.servers_in_room":["s1", "s2"]
"members_omitted":true,
"servers_in_room":["s1", "s2"]
}`

var input RespSendJoin
Expand All @@ -133,11 +133,11 @@ func TestRespSendJoinMarshalJSONPartialState(t *testing.T) {
}

want := RespSendJoin{
StateEvents: []RawJSON{},
AuthEvents: []RawJSON{},
Origin: "o1",
PartialState: true,
ServersInRoom: []string{"s1", "s2"},
StateEvents: []RawJSON{},
AuthEvents: []RawJSON{},
Origin: "o1",
MembersOmitted: true,
ServersInRoom: []string{"s1", "s2"},
}
if !cmp.Equal(input, want, cmp.AllowUnexported(RespSendJoin{})) {
t.Errorf("json.Unmarshal(%s): wanted %+v, got %+v", inputData, want, input)
Expand Down