addressbook_store, add option to not return deleted objects with get_object

#61
This commit is contained in:
Lennart
2025-04-27 18:32:17 +02:00
parent df5f19faab
commit 99388cf992
12 changed files with 71 additions and 46 deletions

View File

@@ -1,7 +1,7 @@
use crate::Error;
use actix_web::web::Path;
use actix_web::{web::Data, HttpResponse};
use rustical_store::{auth::User, Addressbook, AddressbookStore};
use actix_web::{HttpResponse, web::Data};
use rustical_store::{Addressbook, AddressbookStore, auth::User};
use rustical_xml::{XmlDeserialize, XmlDocument, XmlRootTag};
use tracing::instrument;
use tracing_actix_web::RootSpan;
@@ -65,7 +65,10 @@ pub async fn route_mkcol<AS: AddressbookStore>(
push_topic: uuid::Uuid::new_v4().to_string(),
};
match store.get_addressbook(&principal, &addressbook_id).await {
match store
.get_addressbook(&principal, &addressbook_id, true)
.await
{
Err(rustical_store::Error::NotFound) => {
// No conflict, no worries
}

View File

@@ -24,7 +24,9 @@ pub async fn route_post<A: AddressbookStore, S: SubscriptionStore>(
return Err(Error::Unauthorized);
}
let addressbook = store.get_addressbook(&principal, &addressbook_id).await?;
let addressbook = store
.get_addressbook(&principal, &addressbook_id, false)
.await?;
let request = PushRegister::parse_str(&body)?;
let sub_id = uuid::Uuid::new_v4().to_string();

View File

@@ -1,17 +1,17 @@
use crate::{
address_object::resource::{AddressObjectPropWrapper, AddressObjectResource},
Error,
address_object::resource::{AddressObjectPropWrapper, AddressObjectResource},
};
use actix_web::{
HttpRequest,
dev::{Path, ResourceDef},
http::StatusCode,
HttpRequest,
};
use rustical_dav::{
resource::Resource,
xml::{multistatus::ResponseElement, MultistatusElement, PropElement, PropfindType},
xml::{MultistatusElement, PropElement, PropfindType, multistatus::ResponseElement},
};
use rustical_store::{auth::User, AddressObject, AddressbookStore};
use rustical_store::{AddressObject, AddressbookStore, auth::User};
use rustical_xml::XmlDeserialize;
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
@@ -42,7 +42,10 @@ pub async fn get_objects_addressbook_multiget<AS: AddressbookStore>(
not_found.push(href.to_owned());
};
let object_id = path.get("object_id").unwrap();
match store.get_object(principal, addressbook_id, object_id).await {
match store
.get_object(principal, addressbook_id, object_id, false)
.await
{
Ok(object) => result.push(object),
Err(rustical_store::Error::NotFound) => not_found.push(href.to_owned()),
// TODO: Maybe add error handling on a per-object basis