diff --git a/crates/store/src/calendar.rs b/crates/store/src/calendar.rs index 357b29c..579bc8c 100644 --- a/crates/store/src/calendar.rs +++ b/crates/store/src/calendar.rs @@ -18,6 +18,7 @@ pub trait CalendarStore: Send + Sync + 'static { async fn get_calendar(&self, id: &str) -> Result; async fn get_calendars(&self, owner: &str) -> Result>; async fn insert_calendar(&mut self, cid: String, calendar: Calendar) -> Result<()>; + async fn delete_calendar(&mut self, cid: &str) -> Result<()>; async fn get_events(&self, cid: &str) -> Result>; async fn get_event(&self, cid: &str, uid: &str) -> Result; diff --git a/crates/store/src/sqlite_store.rs b/crates/store/src/sqlite_store.rs index e2a51c7..115da45 100644 --- a/crates/store/src/sqlite_store.rs +++ b/crates/store/src/sqlite_store.rs @@ -66,6 +66,13 @@ impl CalendarStore for SqliteCalendarStore { Ok(()) } + async fn delete_calendar(&mut self, cid: &str) -> Result<()> { + sqlx::query!("DELETE FROM calendars WHERE id = ?", cid) + .execute(&self.db) + .await?; + Ok(()) + } + async fn get_events(&self, cid: &str) -> Result> { let events = sqlx::query_as!(EventRow, "SELECT uid, ics FROM events WHERE cid = ?", cid) .fetch_all(&self.db) diff --git a/crates/store/src/toml_store.rs b/crates/store/src/toml_store.rs index d5b24d9..6d28a55 100644 --- a/crates/store/src/toml_store.rs +++ b/crates/store/src/toml_store.rs @@ -66,6 +66,11 @@ impl CalendarStore for TomlCalendarStore { } } + async fn delete_calendar(&mut self, cid: &str) -> Result<()> { + self.events.remove(cid); + Ok(()) + } + async fn get_events(&self, cid: &str) -> Result> { if let Some(events) = self.events.get(cid) { Ok(events.values().cloned().collect())