base: Put the decrypted event replacing in the correct place.
parent
cd9252cc3d
commit
b092ed0a82
|
@ -707,23 +707,25 @@ impl BaseClient {
|
||||||
&self,
|
&self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
event: &mut EventJson<RoomEvent>,
|
event: &mut EventJson<RoomEvent>,
|
||||||
) -> Result<(Option<EventJson<RoomEvent>>, bool)> {
|
) -> Result<bool> {
|
||||||
match event.deserialize() {
|
match event.deserialize() {
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
Ok(mut e) => {
|
Ok(mut e) => {
|
||||||
#[cfg(feature = "encryption")]
|
|
||||||
let mut decrypted_event = None;
|
|
||||||
#[cfg(not(feature = "encryption"))]
|
|
||||||
let decrypted_event = None;
|
|
||||||
|
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
{
|
{
|
||||||
if let RoomEvent::RoomEncrypted(ref mut e) = e {
|
if let RoomEvent::RoomEncrypted(ref mut encrypted_event) = e {
|
||||||
e.room_id = Some(room_id.to_owned());
|
encrypted_event.room_id = Some(room_id.to_owned());
|
||||||
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 {
|
||||||
decrypted_event = o.decrypt_room_event(&e).await.ok();
|
if let Some(decrypted) =
|
||||||
|
o.decrypt_room_event(&encrypted_event).await.ok()
|
||||||
|
{
|
||||||
|
if let Ok(d) = decrypted.deserialize() {
|
||||||
|
e = d
|
||||||
|
}
|
||||||
|
*event = decrypted;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -741,12 +743,12 @@ impl BaseClient {
|
||||||
self.invalidate_group_session(room_id).await;
|
self.invalidate_group_session(room_id).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((decrypted_event, changed))
|
Ok(changed)
|
||||||
} else {
|
} else {
|
||||||
Ok((decrypted_event, room.receive_timeline_event(&e)))
|
Ok(room.receive_timeline_event(&e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Ok((None, false)),
|
_ => Ok(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,19 +1016,12 @@ impl BaseClient {
|
||||||
.set_unread_notice_count(&joined_room.unread_notifications);
|
.set_unread_notice_count(&joined_room.unread_notifications);
|
||||||
|
|
||||||
for mut event in &mut joined_room.timeline.events {
|
for mut event in &mut joined_room.timeline.events {
|
||||||
let decrypted_event = {
|
let timeline_update = self
|
||||||
let (decrypt_ev, timeline_update) = self
|
|
||||||
.receive_joined_timeline_event(room_id, &mut event)
|
.receive_joined_timeline_event(room_id, &mut event)
|
||||||
.await?;
|
.await?;
|
||||||
if timeline_update {
|
if timeline_update {
|
||||||
updated = true;
|
updated = true;
|
||||||
};
|
};
|
||||||
decrypt_ev
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(e) = decrypted_event {
|
|
||||||
*event = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX: Related to `prev_content` and `unsigned`; see the doc comment of
|
// XXX: Related to `prev_content` and `unsigned`; see the doc comment of
|
||||||
// `hoist_room_event_prev_content`
|
// `hoist_room_event_prev_content`
|
||||||
|
|
Loading…
Reference in New Issue