File tree 2 files changed +18
-10
lines changed
2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -1155,16 +1155,20 @@ impl Client {
1155
1155
} ;
1156
1156
1157
1157
if let Some ( room) = self . get_room ( & room_id) {
1158
- // The cached data can only be trusted if the room is joined: for invite and
1159
- // knock rooms, no updates will be received for the rooms after the invite/knock
1160
- // action took place so we may have very out to date data for important fields
1161
- // such as `join_rule`
1162
- if room. state ( ) == RoomState :: Joined {
1163
- return Ok ( RoomPreview :: from_joined ( & room) . await ) ;
1158
+ // The cached data can only be trusted if the room state is joined or
1159
+ // banned: for invite and knock rooms, no updates will be received
1160
+ // for the rooms after the invite/knock action took place so we may
1161
+ // have very out to date data for important fields such as
1162
+ // `join_rule`. For left rooms, the homeserver should return the latest info.
1163
+ match room. state ( ) {
1164
+ RoomState :: Joined | RoomState :: Banned => {
1165
+ return Ok ( RoomPreview :: from_known_room ( & room) . await ) ;
1166
+ }
1167
+ RoomState :: Left | RoomState :: Invited | RoomState :: Knocked => { }
1164
1168
}
1165
1169
}
1166
1170
1167
- RoomPreview :: from_not_joined ( self , room_id, room_or_alias_id, via) . await
1171
+ RoomPreview :: from_remote_room ( self , room_id, room_or_alias_id, via) . await
1168
1172
}
1169
1173
1170
1174
/// Resolve a room alias to a room id and a list of servers which know
Original file line number Diff line number Diff line change @@ -126,8 +126,12 @@ impl RoomPreview {
126
126
}
127
127
}
128
128
129
- /// Create a room preview from a known room we've joined.
130
- pub ( crate ) async fn from_joined ( room : & Room ) -> Self {
129
+ /// Create a room preview from a known room.
130
+ ///
131
+ /// Note this shouldn't be used with invited or knocked rooms, since the
132
+ /// local info may be out of date and no longer represent the latest room
133
+ /// state.
134
+ pub ( crate ) async fn from_known_room ( room : & Room ) -> Self {
131
135
let is_direct = room. is_direct ( ) . await . ok ( ) ;
132
136
133
137
let display_name = room. display_name ( ) . await . ok ( ) . map ( |name| name. to_string ( ) ) ;
@@ -143,7 +147,7 @@ impl RoomPreview {
143
147
}
144
148
145
149
#[ instrument( skip( client) ) ]
146
- pub ( crate ) async fn from_not_joined (
150
+ pub ( crate ) async fn from_remote_room (
147
151
client : & Client ,
148
152
room_id : OwnedRoomId ,
149
153
room_or_alias_id : & RoomOrAliasId ,
You can’t perform that action at this time.
0 commit comments