Add trash bin feature

This commit is contained in:
Lennart
2024-06-21 19:26:45 +02:00
parent c1cc12e2ac
commit aed6bcff63
9 changed files with 45 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ sqlx = { version = "0.7", features = [
tokio = { version = "1.35", features = ["sync", "full"] }
toml = "0.8"
ical = { version = "0.11", features = ["generator", "serde"] }
chrono = "0.4"
chrono = { version = "0.4", features = ["serde"] }
regex = "1.10"
lazy_static = "1.4"
rstest = "0.21"

View File

@@ -5,13 +5,15 @@ CREATE TABLE calendars (
description TEXT,
'order' INT DEFAULT 0 NOT NULL,
color TEXT,
timezone TEXT NOT NULL
timezone TEXT NOT NULL,
deleted_at DATETIME
);
CREATE TABLE events (
uid TEXT NOT NULL,
cid TEXT NOT NULL,
ics TEXT NOT NULL,
deleted_at DATETIME,
PRIMARY KEY (cid, uid),
FOREIGN KEY (cid) REFERENCES calendars(id)
);

View File

@@ -1,3 +1,4 @@
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Clone, Deserialize, Serialize)]
@@ -9,4 +10,5 @@ pub struct Calendar {
pub description: Option<String>,
pub color: Option<String>,
pub timezone: Option<String>,
pub deleted_at: Option<NaiveDateTime>,
}

View File

@@ -10,10 +10,13 @@ pub trait CalendarStore: Send + Sync + 'static {
async fn get_calendars(&self, owner: &str) -> Result<Vec<Calendar>, Error>;
async fn update_calendar(&mut self, cid: String, calendar: Calendar) -> Result<(), Error>;
async fn insert_calendar(&mut self, cid: String, calendar: Calendar) -> Result<(), Error>;
async fn delete_calendar(&mut self, cid: &str) -> Result<(), Error>;
async fn delete_calendar(&mut self, cid: &str, use_trashbin: bool) -> Result<(), Error>;
async fn restore_calendar(&mut self, cid: &str) -> Result<(), Error>;
async fn get_events(&self, cid: &str) -> Result<Vec<Event>, Error>;
async fn get_event(&self, cid: &str, uid: &str) -> Result<Event, Error>;
async fn put_event(&mut self, cid: String, uid: String, ics: String) -> Result<(), Error>;
async fn delete_event(&mut self, cid: &str, uid: &str) -> Result<(), Error>;
async fn delete_event(&mut self, cid: &str, uid: &str, use_trashbin: bool)
-> Result<(), Error>;
async fn restore_event(&mut self, cid: &str, uid: &str) -> Result<(), Error>;
}