@@ -78,8 +78,13 @@ pub struct EventTimelineItem {
7878 pub ( super ) forwarder_profile : Option < TimelineDetails < Profile > > ,
7979 /// The timestamp of the event.
8080 pub ( super ) timestamp : MilliSecondsSinceUnixEpoch ,
81- /// The content of the event.
81+ /// The content of the event. Might be redacted if a redaction for this
82+ /// event is currently being sent or has been received from the server.
8283 pub ( super ) content : TimelineItemContent ,
84+ /// If a redaction for this event is currently being sent but the server
85+ /// hasn't yet acknowledged it via its remote echo, the original content
86+ /// before redaction. Otherwise, None.
87+ pub ( super ) unredacted_content : Option < TimelineItemContent > ,
8388 /// The kind of event timeline item, local or remote.
8489 pub ( super ) kind : EventTimelineItemKind ,
8590 /// Whether or not the event belongs to an encrypted room.
@@ -125,6 +130,7 @@ impl EventTimelineItem {
125130 forwarder_profile : Option < TimelineDetails < Profile > > ,
126131 timestamp : MilliSecondsSinceUnixEpoch ,
127132 content : TimelineItemContent ,
133+ unredacted_content : Option < TimelineItemContent > ,
128134 kind : EventTimelineItemKind ,
129135 is_room_encrypted : bool ,
130136 ) -> Self {
@@ -135,6 +141,7 @@ impl EventTimelineItem {
135141 forwarder_profile,
136142 timestamp,
137143 content,
144+ unredacted_content,
138145 kind,
139146 is_room_encrypted,
140147 }
@@ -478,7 +485,7 @@ impl EventTimelineItem {
478485 }
479486
480487 /// Create a clone of the current item, with content that's been redacted.
481- pub ( super ) fn redact ( & self , rules : & RedactionRules ) -> Self {
488+ pub ( super ) fn redact ( & self , rules : & RedactionRules , is_local : bool ) -> Self {
482489 let content = self . content . redact ( rules) ;
483490 let kind = match & self . kind {
484491 EventTimelineItemKind :: Local ( l) => EventTimelineItemKind :: Local ( l. clone ( ) ) ,
@@ -491,6 +498,26 @@ impl EventTimelineItem {
491498 forwarder_profile : self . forwarder_profile . clone ( ) ,
492499 timestamp : self . timestamp ,
493500 content,
501+ unredacted_content : is_local. then_some ( self . content . clone ( ) ) ,
502+ kind,
503+ is_room_encrypted : self . is_room_encrypted ,
504+ }
505+ }
506+
507+ pub ( super ) fn unredact ( & self ) -> Self {
508+ let Some ( content) = & self . unredacted_content else { return self . clone ( ) } ;
509+ let kind = match & self . kind {
510+ EventTimelineItemKind :: Local ( l) => EventTimelineItemKind :: Local ( l. clone ( ) ) ,
511+ EventTimelineItemKind :: Remote ( r) => EventTimelineItemKind :: Remote ( r. redact ( ) ) ,
512+ } ;
513+ Self {
514+ sender : self . sender . clone ( ) ,
515+ sender_profile : self . sender_profile . clone ( ) ,
516+ forwarder : self . forwarder . clone ( ) ,
517+ forwarder_profile : self . forwarder_profile . clone ( ) ,
518+ timestamp : self . timestamp ,
519+ content : content. clone ( ) ,
520+ unredacted_content : None ,
494521 kind,
495522 is_room_encrypted : self . is_room_encrypted ,
496523 }
0 commit comments