diff options
Diffstat (limited to 'src/channel/repo/broadcast.rs')
| -rw-r--r-- | src/channel/repo/broadcast.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/channel/repo/broadcast.rs b/src/channel/repo/broadcast.rs index ff16cd0..182203a 100644 --- a/src/channel/repo/broadcast.rs +++ b/src/channel/repo/broadcast.rs @@ -68,6 +68,20 @@ impl<'c> Broadcast<'c> { Ok(message) } + pub async fn expire(&mut self, expire_at: &DateTime) -> Result<(), sqlx::Error> { + sqlx::query!( + r#" + delete from message + where sent_at < $1 + "#, + expire_at, + ) + .execute(&mut *self.0) + .await?; + + Ok(()) + } + pub async fn replay( &mut self, channel: &Channel, |
