@@ -57,7 +57,7 @@ func TestRoomForget(t *testing.T) {
57
57
})
58
58
})
59
59
// sytest: Forgetting room does not show up in v2 /sync
60
- t .Run ("Forgetting room does not show up in v2 /sync" , func (t * testing.T ) {
60
+ t .Run ("Forgetting room does not show up in v2 initial /sync" , func (t * testing.T ) {
61
61
t .Parallel ()
62
62
roomID := alice .CreateRoom (t , map [string ]interface {}{"preset" : "public_chat" })
63
63
bob .JoinRoom (t , roomID , []string {})
@@ -98,6 +98,47 @@ func TestRoomForget(t *testing.T) {
98
98
t .Errorf ("Did not expect room %s in left" , roomID )
99
99
}
100
100
})
101
+ t .Run ("Leave for forgotten room shows up in v2 incremental /sync" , func (t * testing.T ) {
102
+ // Note that this test runs counter to the wording of the spec. At the time of writing,
103
+ // the spec says that forgotten rooms should not show up in any /sync responses, but
104
+ // that would make it impossible for other devices to determine that a room has been
105
+ // left if it is forgotten quickly. This is arguably a bug in the spec.
106
+ t .Parallel ()
107
+ roomID := alice .CreateRoom (t , map [string ]interface {}{"preset" : "public_chat" })
108
+ bob .JoinRoom (t , roomID , []string {})
109
+ alice .SendEventSynced (t , roomID , b.Event {
110
+ Type : "m.room.message" ,
111
+ Content : map [string ]interface {}{
112
+ "msgtype" : "m.text" ,
113
+ "body" : "Hello world!" ,
114
+ },
115
+ })
116
+ tokenBeforeLeave := alice .MustSyncUntil (t , client.SyncReq {}, client .SyncJoinedTo (alice .UserID , roomID ))
117
+ alice .LeaveRoom (t , roomID )
118
+ // Ensure Alice left the room
119
+ bob .MustSyncUntil (t , client.SyncReq {}, client .SyncLeftFrom (alice .UserID , roomID ))
120
+ alice .MustDoFunc (t , "POST" , []string {"_matrix" , "client" , "v3" , "rooms" , roomID , "forget" })
121
+ bob .SendEventSynced (t , roomID , b.Event {
122
+ Type : "m.room.message" ,
123
+ Content : map [string ]interface {}{
124
+ "msgtype" : "m.text" ,
125
+ "body" : "Hello world!" ,
126
+ },
127
+ })
128
+ // The leave for the room is expected to show up in the next incremental /sync.
129
+ includeLeaveFilter , _ := json .Marshal (map [string ]interface {}{
130
+ "room" : map [string ]interface {}{
131
+ "include_leave" : true ,
132
+ },
133
+ })
134
+ result , _ := alice .MustSync (t , client.SyncReq {
135
+ Since : tokenBeforeLeave ,
136
+ Filter : string (includeLeaveFilter ),
137
+ })
138
+ if ! result .Get ("rooms.leave." + client .GjsonEscape (roomID )).Exists () {
139
+ t .Errorf ("Did not see room %s in left" , roomID )
140
+ }
141
+ })
101
142
// sytest: Can forget room you've been kicked from
102
143
t .Run ("Can forget room you've been kicked from" , func (t * testing.T ) {
103
144
t .Parallel ()
0 commit comments