Dav Push: Logic to register subscriptions

This commit is contained in:
Lennart
2025-01-12 20:39:53 +01:00
parent 185eb8bddd
commit 5b418ec583
12 changed files with 261 additions and 15 deletions

View File

@@ -0,0 +1,19 @@
use crate::Error;
use async_trait::async_trait;
use chrono::NaiveDateTime;
pub struct Subscription {
pub id: String,
pub topic: String,
pub expiration: NaiveDateTime,
pub push_resource: String,
}
#[async_trait(?Send)]
pub trait SubscriptionStore: Send + Sync + 'static {
async fn get_subscriptions(&self, topic: &str) -> Result<Vec<Subscription>, Error>;
async fn get_subscription(&self, id: &str) -> Result<Subscription, Error>;
/// Returns whether a subscription under the id already existed
async fn upsert_subscription(&self, sub: Subscription) -> Result<bool, Error>;
async fn delete_subscription(&self, id: &str) -> Result<(), Error>;
}