Skip to content

Commit 67e0601

Browse files
authored
Use stable identifiers from MSC3706 (Faster joins) (#350)
I haven't made any effort to maintain backwards compatibility (unlike in matrix-org/synapse#14832). I'm happy to do so if needed, but might need some guidance. Synapse issue: matrix-org/synapse#14828 Synapse PR: matrix-org/synapse#14832 Complement PR: matrix-org/complement#583 GMSL PR: #350 MSC: matrix-org/matrix-spec-proposals#3706 Spec diff: matrix-org/matrix-spec#1393 ### Pull Request Checklist * [x] Pull request includes a [sign off](https://github.com/matrix-org/dendrite/blob/master/docs/CONTRIBUTING.md#sign-off) Signed-off-by: `David Robertson <[email protected]>`
1 parent c6b15eb commit 67e0601

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

federationclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (ac *FederationClient) sendJoin(
147147
url.PathEscape(event.RoomID()) + "/" +
148148
url.PathEscape(event.EventID())
149149
if partialState {
150-
path += "?org.matrix.msc3706.partial_state=true"
150+
path += "?omit_members=true"
151151
}
152152

153153
req := NewFederationRequest("PUT", origin, s, path)

federationtypes.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ type RespSendJoin struct {
444444
// but not guaranteed to be present as it's only since MSC3083.
445445
Event RawJSON `json:"event,omitempty"`
446446
// true if the state is incomplete
447-
PartialState bool `json:"org.matrix.msc3706.partial_state"`
447+
MembersOmitted bool `json:"members_omitted"`
448448
// a list of servers in the room. Only returned if partial_state is set.
449-
ServersInRoom []string `json:"org.matrix.msc3706.servers_in_room"`
449+
ServersInRoom []string `json:"servers_in_room"`
450450
}
451451

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

467-
if !r.PartialState {
467+
if !r.MembersOmitted {
468468
return json.Marshal(fields)
469469
}
470470

471471
partialJoinFields := respSendJoinPartialStateFields{
472472
respSendJoinFields: fields,
473-
PartialState: true,
473+
MembersOmitted: true,
474474
ServersInRoom: r.ServersInRoom,
475475
}
476476
return json.Marshal(partialJoinFields)
@@ -517,8 +517,8 @@ type respSendJoinFields struct {
517517
// when the response has incomplete state.
518518
type respSendJoinPartialStateFields struct {
519519
respSendJoinFields
520-
PartialState bool `json:"org.matrix.msc3706.partial_state"`
521-
ServersInRoom []string `json:"org.matrix.msc3706.servers_in_room"`
520+
MembersOmitted bool `json:"members_omitted"`
521+
ServersInRoom []string `json:"servers_in_room"`
522522
}
523523

524524
// ToRespState returns a new RespState with the same data from the given RespSendJoin

federationtypes_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ func TestRespSendJoinMarshalJSON(t *testing.T) {
123123
func TestRespSendJoinMarshalJSONPartialState(t *testing.T) {
124124
inputData := `{
125125
"state":[],"auth_chain":[],"origin":"o1",
126-
"org.matrix.msc3706.partial_state":true,
127-
"org.matrix.msc3706.servers_in_room":["s1", "s2"]
126+
"members_omitted":true,
127+
"servers_in_room":["s1", "s2"]
128128
}`
129129

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

135135
want := RespSendJoin{
136-
StateEvents: []RawJSON{},
137-
AuthEvents: []RawJSON{},
138-
Origin: "o1",
139-
PartialState: true,
140-
ServersInRoom: []string{"s1", "s2"},
136+
StateEvents: []RawJSON{},
137+
AuthEvents: []RawJSON{},
138+
Origin: "o1",
139+
MembersOmitted: true,
140+
ServersInRoom: []string{"s1", "s2"},
141141
}
142142
if !cmp.Equal(input, want, cmp.AllowUnexported(RespSendJoin{})) {
143143
t.Errorf("json.Unmarshal(%s): wanted %+v, got %+v", inputData, want, input)

0 commit comments

Comments
 (0)