mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 19:22:26 +00:00
addressbook_store, add option to not return deleted objects with get_object
#61
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
use crate::{
|
||||
addressbook::{AddressObject, Addressbook},
|
||||
Error,
|
||||
addressbook::{AddressObject, Addressbook},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
|
||||
#[async_trait]
|
||||
pub trait AddressbookStore: Send + Sync + 'static {
|
||||
async fn get_addressbook(&self, principal: &str, id: &str) -> Result<Addressbook, Error>;
|
||||
async fn get_addressbook(
|
||||
&self,
|
||||
principal: &str,
|
||||
id: &str,
|
||||
show_deleted: bool,
|
||||
) -> Result<Addressbook, Error>;
|
||||
async fn get_addressbooks(&self, principal: &str) -> Result<Vec<Addressbook>, Error>;
|
||||
async fn get_deleted_addressbooks(&self, principal: &str) -> Result<Vec<Addressbook>, Error>;
|
||||
|
||||
@@ -42,6 +47,7 @@ pub trait AddressbookStore: Send + Sync + 'static {
|
||||
principal: &str,
|
||||
addressbook_id: &str,
|
||||
object_id: &str,
|
||||
show_deleted: bool,
|
||||
) -> Result<AddressObject, Error>;
|
||||
async fn put_object(
|
||||
&self,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::{
|
||||
calendar::CalendarObjectType, AddressObject, Addressbook, AddressbookStore, Calendar,
|
||||
CalendarObject, CalendarStore, Error,
|
||||
AddressObject, Addressbook, AddressbookStore, Calendar, CalendarObject, CalendarStore, Error,
|
||||
calendar::CalendarObjectType,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use derive_more::derive::Constructor;
|
||||
@@ -39,7 +39,7 @@ fn birthday_calendar(addressbook: Addressbook) -> Calendar {
|
||||
#[async_trait]
|
||||
impl<AS: AddressbookStore> CalendarStore for ContactBirthdayStore<AS> {
|
||||
async fn get_calendar(&self, principal: &str, id: &str) -> Result<Calendar, Error> {
|
||||
let addressbook = self.0.get_addressbook(principal, id).await?;
|
||||
let addressbook = self.0.get_addressbook(principal, id, false).await?;
|
||||
Ok(birthday_calendar(addressbook))
|
||||
}
|
||||
async fn get_calendars(&self, principal: &str) -> Result<Vec<Calendar>, Error> {
|
||||
@@ -122,7 +122,7 @@ impl<AS: AddressbookStore> CalendarStore for ContactBirthdayStore<AS> {
|
||||
) -> Result<CalendarObject, Error> {
|
||||
let (addressobject_id, date_type) = object_id.rsplit_once("-").ok_or(Error::NotFound)?;
|
||||
self.0
|
||||
.get_object(principal, cal_id, addressobject_id)
|
||||
.get_object(principal, cal_id, addressobject_id, false)
|
||||
.await?
|
||||
.get_significant_dates()?
|
||||
.remove(date_type)
|
||||
|
||||
Reference in New Issue
Block a user