summaryrefslogtreecommitdiff
path: root/src/message/history.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/message/history.rs')
-rw-r--r--src/message/history.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/message/history.rs b/src/message/history.rs
index d4d4500..2abdf2c 100644
--- a/src/message/history.rs
+++ b/src/message/history.rs
@@ -1,7 +1,7 @@
use itertools::Itertools as _;
use super::{
- Id, Message,
+ Message,
event::{Deleted, Event, Sent},
};
use crate::event::Sequence;
@@ -13,10 +13,6 @@ pub struct History {
// 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
@@ -26,6 +22,15 @@ impl History {
self.message.clone()
}
+ pub fn as_of<S>(&self, sequence: S) -> Option<Message>
+ where
+ S: Into<Sequence>,
+ {
+ self.events()
+ .filter(Sequence::up_to(sequence.into()))
+ .collect()
+ }
+
// Snapshot of this message as of all events recorded in this history.
pub fn as_snapshot(&self) -> Option<Message> {
self.events().collect()