edits as standalone timeline events with old_body/new_body

This commit is contained in:
Damocles 2026-05-01 13:50:52 +02:00
parent bc3a4782cc
commit 9171290ae7
4 changed files with 137 additions and 34 deletions

View file

@ -43,6 +43,16 @@ pub enum WireEvent {
target_event_id_short: String,
key: String,
},
Edit {
sender: String,
is_self: bool,
ts: i64,
ts_human: String,
target_event_id: String,
target_event_id_short: String,
old_body: String,
new_body: String,
},
/// Synthetic event from the daemon (not a Matrix event). Currently used
/// to tell the shard "you were rate-limited; events held for X seconds."
Notice {
@ -123,31 +133,46 @@ pub enum TimelineItem {
is_self: bool,
ts: i64,
},
/// A single edit applied to a message. Surfaced as its own chronological
/// event so the shard sees edits as they happen. The target message also
/// has its `edit_history` updated for at-a-glance reference.
Edit {
sender: OwnedUserId,
target_event_id: OwnedEventId,
old_body: String,
new_body: String,
is_self: bool,
ts: i64,
},
}
impl TimelineItem {
pub fn ts(&self) -> i64 {
match self {
Self::Message { ts, .. } | Self::Reaction { ts, .. } => *ts,
Self::Message { ts, .. } | Self::Reaction { ts, .. } | Self::Edit { ts, .. } => *ts,
}
}
pub fn event_id(&self) -> Option<&OwnedEventId> {
match self {
Self::Message { event_id, .. } => Some(event_id),
Self::Reaction { .. } => None,
Self::Reaction { .. } | Self::Edit { .. } => None,
}
}
pub fn sender(&self) -> &OwnedUserId {
match self {
Self::Message { sender, .. } | Self::Reaction { sender, .. } => sender,
Self::Message { sender, .. }
| Self::Reaction { sender, .. }
| Self::Edit { sender, .. } => sender,
}
}
pub fn is_self(&self) -> bool {
match self {
Self::Message { is_self, .. } | Self::Reaction { is_self, .. } => *is_self,
Self::Message { is_self, .. }
| Self::Reaction { is_self, .. }
| Self::Edit { is_self, .. } => *is_self,
}
}
}