summaryrefslogtreecommitdiff
path: root/src/channel/history.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-07-01 01:42:38 -0400
committerOwen Jacobson <owen@grimoire.ca>2025-07-03 21:47:41 -0400
commitb4db819ef8daa583a165aed01eb3d70d98e37fc8 (patch)
tree81f18139d11f6f197f90958a7a28a83aab6c14cf /src/channel/history.rs
parentb3ce81945621e9026e687b590e7aa541008575ac (diff)
Prevent sending messages to deleted channels.
I've opted to make it clear in the error message which scenario - deleted vs. non-existant - a channel falls into. This isn't particularly consistent with the rest of the API, so we might need to review this decision later, but it's at least relatively harmless if it's mistaken. (Formally, they're both 404s, so clients that go by error code won't notice.)
Diffstat (limited to 'src/channel/history.rs')
-rw-r--r--src/channel/history.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/channel/history.rs b/src/channel/history.rs
index 7f18e45..85da5a5 100644
--- a/src/channel/history.rs
+++ b/src/channel/history.rs
@@ -27,6 +27,15 @@ impl History {
self.channel.clone()
}
+ pub fn as_of<S>(&self, sequence: S) -> Option<Channel>
+ where
+ S: Into<Sequence>,
+ {
+ self.events()
+ .filter(Sequence::up_to(sequence.into()))
+ .collect()
+ }
+
// Snapshot of this channel as of all events recorded in this history.
pub fn as_snapshot(&self) -> Option<Channel> {
self.events().collect()