From 5bf3517acfea3694fbe586e69a0e02b94c61eb1b Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Mon, 18 Mar 2024 22:56:49 +0100 Subject: Pass thunderbird autodetect... --- aero-proto/src/dav.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'aero-proto/src/dav.rs') diff --git a/aero-proto/src/dav.rs b/aero-proto/src/dav.rs index b964760..c8e534e 100644 --- a/aero-proto/src/dav.rs +++ b/aero-proto/src/dav.rs @@ -212,7 +212,7 @@ async fn router(user: std::sync::Arc, req: Request) -> Result { tracing::warn!("HEAD+GET not correctly implemented"); return Ok(Response::builder() - .status(200) + .status(404) .body(text_body(""))?) }, "PROPFIND" => propfind(user, req, node).await, @@ -259,6 +259,7 @@ const ALLPROP: [dav::PropertyRequest; 10] = [ async fn propfind(user: std::sync::Arc, req: Request, node: Box) -> Result>> { let depth = depth(&req); + let status = hyper::StatusCode::from_u16(207)?; // A client may choose not to submit a request body. An empty PROPFIND // request body MUST be treated as if it were an 'allprop' request. @@ -268,7 +269,7 @@ async fn propfind(user: std::sync::Arc, req: Request, node: Box< tracing::debug!(recv=?propfind, "inferred propfind request"); if matches!(propfind, dav::PropFind::PropName) { - return serialize(node.multistatus_name(&user, depth)); + return serialize(status, node.multistatus_name(&user, depth)); } let propname = match propfind { @@ -281,7 +282,7 @@ async fn propfind(user: std::sync::Arc, req: Request, node: Box< dav::PropFind::Prop(inner) => inner, }; - serialize(node.multistatus_val(&user, propname, depth)) + serialize(status, node.multistatus_val(&user, propname, depth)) } // ---- HTTP DAV Binding @@ -308,7 +309,7 @@ fn text_body(txt: &'static str) -> BoxBody { BoxBody::new(Full::new(Bytes::from(txt)).map_err(|e| match e {})) } -fn serialize(elem: T) -> Result>> { +fn serialize(status_ok: hyper::StatusCode, elem: T) -> Result>> { let (tx, rx) = tokio::sync::mpsc::channel::(1); // Build the writer @@ -318,7 +319,7 @@ fn serialize(elem: T) -> Result (), Err(e) => tracing::error!(err=?e, "unable to write XML declaration "), @@ -336,7 +337,8 @@ fn serialize(elem: T) -> Result) -> Vec> { @@ -517,6 +520,8 @@ impl DavNode for HomeNode { dav::PropertyRequest::DisplayName => dav::AnyProperty::Value(dav::Property::DisplayName(format!("{} home", user.username))), dav::PropertyRequest::ResourceType => dav::AnyProperty::Value(dav::Property::ResourceType(vec![dav::ResourceType::Collection])), dav::PropertyRequest::GetContentType => dav::AnyProperty::Value(dav::Property::GetContentType("httpd/unix-directory".into())), + dav::PropertyRequest::Extension(cal::PropertyRequest::CalendarHomeSet) => + dav::AnyProperty::Value(dav::Property::Extension(cal::Property::CalendarHomeSet(dav::Href(CalendarListNode{}.path(user))))), v => dav::AnyProperty::Request(v), }).collect() } @@ -604,7 +609,9 @@ impl DavNode for CalendarNode { dav::ResourceType::Collection, dav::ResourceType::Extension(cal::ResourceType::Calendar), ])), - dav::PropertyRequest::GetContentType => dav::AnyProperty::Value(dav::Property::GetContentType("httpd/unix-directory".into())), + //dav::PropertyRequest::GetContentType => dav::AnyProperty::Value(dav::Property::GetContentType("httpd/unix-directory".into())), + //@FIXME seems wrong but seems to be what Thunderbird expects... + dav::PropertyRequest::GetContentType => dav::AnyProperty::Value(dav::Property::GetContentType("text/calendar".into())), v => dav::AnyProperty::Request(v), }).collect() } -- cgit v1.2.3