mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
feat: Add show_deleted to get_calendar
This commit is contained in:
@@ -11,7 +11,12 @@ pub struct CalendarQuery {
|
||||
|
||||
#[async_trait]
|
||||
pub trait CalendarStore: Send + Sync + 'static {
|
||||
async fn get_calendar(&self, principal: &str, id: &str) -> Result<Calendar, Error>;
|
||||
async fn get_calendar(
|
||||
&self,
|
||||
principal: &str,
|
||||
id: &str,
|
||||
show_deleted: bool,
|
||||
) -> Result<Calendar, Error>;
|
||||
async fn get_calendars(&self, principal: &str) -> Result<Vec<Calendar>, Error>;
|
||||
async fn get_deleted_calendars(&self, principal: &str) -> Result<Vec<Calendar>, Error>;
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use derive_more::Constructor;
|
||||
use rustical_ical::CalendarObject;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
Calendar, CalendarStore, Error, calendar_store::CalendarQuery,
|
||||
@@ -27,11 +26,20 @@ impl<CS: CalendarStore, BS: CalendarStore> Clone for CombinedCalendarStore<CS, B
|
||||
#[async_trait]
|
||||
impl<CS: CalendarStore, BS: CalendarStore> CalendarStore for CombinedCalendarStore<CS, BS> {
|
||||
#[inline]
|
||||
async fn get_calendar(&self, principal: &str, id: &str) -> Result<Calendar, Error> {
|
||||
async fn get_calendar(
|
||||
&self,
|
||||
principal: &str,
|
||||
id: &str,
|
||||
show_deleted: bool,
|
||||
) -> Result<Calendar, Error> {
|
||||
if id.starts_with(BIRTHDAYS_PREFIX) {
|
||||
self.birthday_store.get_calendar(principal, id).await
|
||||
self.birthday_store
|
||||
.get_calendar(principal, id, show_deleted)
|
||||
.await
|
||||
} else {
|
||||
self.cal_store.get_calendar(principal, id).await
|
||||
self.cal_store
|
||||
.get_calendar(principal, id, show_deleted)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,17 @@ fn birthday_calendar(addressbook: Addressbook) -> Calendar {
|
||||
/// Objects are all prefixed with BIRTHDAYS_PREFIX
|
||||
#[async_trait]
|
||||
impl<AS: AddressbookStore> CalendarStore for ContactBirthdayStore<AS> {
|
||||
async fn get_calendar(&self, principal: &str, id: &str) -> Result<Calendar, Error> {
|
||||
async fn get_calendar(
|
||||
&self,
|
||||
principal: &str,
|
||||
id: &str,
|
||||
show_deleted: bool,
|
||||
) -> Result<Calendar, Error> {
|
||||
let id = id.strip_prefix(BIRTHDAYS_PREFIX).ok_or(Error::NotFound)?;
|
||||
let addressbook = self.0.get_addressbook(principal, id, false).await?;
|
||||
let addressbook = self.0.get_addressbook(principal, id, show_deleted).await?;
|
||||
Ok(birthday_calendar(addressbook))
|
||||
}
|
||||
|
||||
async fn get_calendars(&self, principal: &str) -> Result<Vec<Calendar>, Error> {
|
||||
let addressbooks = self.0.get_addressbooks(principal).await?;
|
||||
Ok(addressbooks.into_iter().map(birthday_calendar).collect())
|
||||
|
||||
Reference in New Issue
Block a user