summaryrefslogtreecommitdiff
path: root/src/message/history.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-10-04 14:10:55 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-10-04 14:10:55 -0400
commit9bd6d9862b1c243def02200bca2cfbf578ad2a2f (patch)
tree44d20c937eee728e9b33ff093b3945a3ab2593dd /src/message/history.rs
parent7f12fd41c2941a55a6437f24e4f780104a718790 (diff)
Clean up naming and semantics of history accessors.
Diffstat (limited to 'src/message/history.rs')
-rw-r--r--src/message/history.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/message/history.rs b/src/message/history.rs
index 89fc6b1..c44d954 100644
--- a/src/message/history.rs
+++ b/src/message/history.rs
@@ -1,6 +1,6 @@
use super::{
event::{Deleted, Event, Sent},
- Message,
+ Id, Message,
};
use crate::event::Instant;
@@ -10,6 +10,23 @@ pub struct History {
pub deleted: Option<Instant>,
}
+// State interface
+impl History {
+ pub fn id(&self) -> &Id {
+ &self.message.id
+ }
+
+ // Snapshot of this message as it was when sent. (Note to the future: it's okay
+ // if this returns a redacted or modified version of the message. If we
+ // implement message editing by redacting the original body, then this should
+ // return the edited message, not the original, even if that's not how it was
+ // "as sent.")
+ pub fn as_sent(&self) -> Message {
+ self.message.clone()
+ }
+}
+
+// Events interface
impl History {
fn sent(&self) -> Event {
Event {
@@ -34,8 +51,4 @@ impl History {
pub fn events(&self) -> impl Iterator<Item = Event> {
[self.sent()].into_iter().chain(self.deleted())
}
-
- pub fn snapshot(&self) -> Message {
- self.message.clone()
- }
}