@@ -100,7 +100,6 @@ pub use self::{
100100 virtual_item:: VirtualTimelineItem ,
101101} ;
102102use self :: {
103- event_item:: EventTimelineItemKind ,
104103 futures:: SendAttachment ,
105104 inner:: { ReactionAction , TimelineInner } ,
106105 reactions:: ReactionToggleResult ,
@@ -791,25 +790,39 @@ impl Timeline {
791790 event : & EventTimelineItem ,
792791 reason : Option < & str > ,
793792 ) -> Result < bool , RedactEventError > {
794- match & event. kind {
795- EventTimelineItemKind :: Local ( local) => {
793+ let event_id = match event. identifier ( ) {
794+ TimelineEventItemId :: TransactionId ( txn_id) => {
795+ let local = event. as_local ( ) . unwrap ( ) ;
796+
796797 if let Some ( handle) = local. send_handle . clone ( ) {
797- Ok ( handle. abort ( ) . await . map_err ( RedactEventError :: RoomQueueError ) ?)
798+ if handle. abort ( ) . await . map_err ( RedactEventError :: RoomQueueError ) ? {
799+ return Ok ( true ) ;
800+ }
801+
802+ if let Some ( event_id) = self . find_remote_by_transaction_id ( & txn_id) . await {
803+ event_id
804+ } else {
805+ warn ! ( "Couldn't find the local echo anymore, nor a matching remote echo" ) ;
806+ return Ok ( false ) ;
807+ }
798808 } else {
799809 // No abort handle; theoretically unreachable for regular usage of the
800810 // timeline, but this may happen in testing contexts.
801- Err ( RedactEventError :: UnsupportedRedactLocal ( local. transaction_id . clone ( ) ) )
811+ return Err ( RedactEventError :: UnsupportedRedactLocal (
812+ local. transaction_id . clone ( ) ,
813+ ) ) ;
802814 }
803815 }
804816
805- EventTimelineItemKind :: Remote ( remote) => {
806- self . room ( )
807- . redact ( & remote. event_id , reason, None )
808- . await
809- . map_err ( |err| RedactEventError :: SdkError ( err. into ( ) ) ) ?;
810- Ok ( true )
811- }
812- }
817+ TimelineEventItemId :: EventId ( event_id) => event_id,
818+ } ;
819+
820+ self . room ( )
821+ . redact ( & event_id, reason, None )
822+ . await
823+ . map_err ( |err| RedactEventError :: SdkError ( err. into ( ) ) ) ?;
824+
825+ Ok ( true )
813826 }
814827
815828 /// Fetch unavailable details about the event with the given ID.
0 commit comments