From 2507a450df4bfe12d163a8141a2e47932c1ee21c Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Mon, 1 Jul 2024 12:51:56 +0200 Subject: [PATCH] send queue: add useful logs when aborting/editing a local echo --- crates/matrix-sdk/src/send_queue.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/matrix-sdk/src/send_queue.rs b/crates/matrix-sdk/src/send_queue.rs index a9edd7c55a5..2cfb3dc3e7f 100644 --- a/crates/matrix-sdk/src/send_queue.rs +++ b/crates/matrix-sdk/src/send_queue.rs @@ -863,14 +863,21 @@ impl SendHandle { /// /// Returns true if the sending could be aborted, false if not (i.e. the /// event had already been sent). + #[instrument(skip(self), fields(room_id = %self.room.inner.room.room_id(), txn_id = %self.transaction_id))] pub async fn abort(self) -> Result { + trace!("received an abort request"); + if self.room.inner.queue.cancel(&self.transaction_id).await? { + trace!("successful abort"); + // Propagate a cancelled update too. let _ = self.room.inner.updates.send(RoomSendQueueUpdate::CancelledLocalEvent { transaction_id: self.transaction_id.clone(), }); + Ok(true) } else { + debug!("event was being sent, can't abort"); Ok(false) } } @@ -879,21 +886,28 @@ impl SendHandle { /// /// Returns true if the event to be sent was replaced, false if not (i.e. /// the event had already been sent). + #[instrument(skip(self, new_content), fields(room_id = %self.room.inner.room.room_id(), txn_id = %self.transaction_id))] pub async fn edit_raw( &self, new_content: Raw, event_type: String, ) -> Result { + trace!("received an edit request"); + let serializable = SerializableEventContent::from_raw(new_content, event_type); if self.room.inner.queue.replace(&self.transaction_id, serializable.clone()).await? { + trace!("successful edit"); + // Propagate a replaced update too. let _ = self.room.inner.updates.send(RoomSendQueueUpdate::ReplacedLocalEvent { transaction_id: self.transaction_id.clone(), new_content: serializable, }); + Ok(true) } else { + debug!("event was being sent, can't edit"); Ok(false) } }