matrix-sdk-base: clean up recv/iter joined post rebase

The types for account data in a sync response have changed, no longer
Option. Re word comment in hoist prev_content test.
master
Devin R 2020-07-03 07:02:12 -04:00
parent b83b9dc59d
commit 2338d3e8fd
1 changed files with 15 additions and 17 deletions

View File

@ -713,20 +713,22 @@ impl BaseClient {
pub async fn receive_joined_timeline_event( pub async fn receive_joined_timeline_event(
&self, &self,
room_id: &RoomId, room_id: &RoomId,
event: &mut EventJson<RoomEvent>, event: &mut EventJson<AnyRoomEventStub>,
) -> Result<bool> { ) -> Result<bool> {
match event.deserialize() { match event.deserialize() {
#[allow(unused_mut)] #[allow(unused_mut)]
Ok(mut e) => { Ok(mut e) => {
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
{ {
if let RoomEvent::RoomEncrypted(ref mut encrypted_event) = e { if let AnyRoomEventStub::Message(AnyMessageEventStub::RoomEncrypted(
encrypted_event.room_id = Some(room_id.to_owned()); ref mut encrypted_event,
)) = e
{
let mut olm = self.olm.lock().await; let mut olm = self.olm.lock().await;
if let Some(o) = &mut *olm { if let Some(o) = &mut *olm {
if let Some(decrypted) = if let Some(decrypted) =
o.decrypt_room_event(&encrypted_event).await.ok() o.decrypt_room_event(&encrypted_event, room_id).await.ok()
{ {
if let Ok(d) = decrypted.deserialize() { if let Ok(d) = decrypted.deserialize() {
e = d e = d
@ -752,7 +754,7 @@ impl BaseClient {
Ok(changed) Ok(changed)
} else { } else {
Ok(room.receive_timeline_event(&e)) Ok(room.receive_timeline_event(&e, room_id))
} }
} }
_ => Ok(false), _ => Ok(false),
@ -1054,8 +1056,7 @@ impl BaseClient {
} }
// look at AccountData to further cut down users by collecting ignored users // look at AccountData to further cut down users by collecting ignored users
if let Some(account_data) = &joined_room.account_data { for account_data in &joined_room.account_data.events {
for account_data in &account_data.events {
{ {
// FIXME: receive_* and emit_* methods shouldn't be called in parallel. We // FIXME: receive_* and emit_* methods shouldn't be called in parallel. We
// should only pass events to receive_* methods and then let *them* emit. // should only pass events to receive_* methods and then let *them* emit.
@ -1066,9 +1067,6 @@ impl BaseClient {
self.emit_account_data_event(room_id, &e, RoomStateType::Joined) self.emit_account_data_event(room_id, &e, RoomStateType::Joined)
.await; .await;
} }
self.emit_account_data_event(room_id, &e, RoomStateType::Joined)
.await;
}
} }
} }
@ -2161,7 +2159,7 @@ mod test {
assert_eq!(*member.display_name.as_ref().unwrap(), "changed"); assert_eq!(*member.display_name.as_ref().unwrap(), "changed");
// The second part tests that the event is emitted correctly. If `prev_content` was // The second part tests that the event is emitted correctly. If `prev_content` was
// missing, this bool would had been flipped. // missing, this bool is reset to false.
assert!(passed.load(Ordering::SeqCst)) assert!(passed.load(Ordering::SeqCst))
} }