mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-15 11:02:20 +00:00
Add status code to multistatus element
This commit is contained in:
@@ -44,7 +44,13 @@ pub async fn route_propfind<A: CheckAuthentication, R: ResourceService + ?Sized>
|
|||||||
prefix: Data<ServicePrefix>,
|
prefix: Data<ServicePrefix>,
|
||||||
auth: AuthInfoExtractor<A>,
|
auth: AuthInfoExtractor<A>,
|
||||||
depth: Depth,
|
depth: Depth,
|
||||||
) -> Result<MultistatusElement<PropstatWrapper<<R::File as Resource>::Prop>, String>, R::Error> {
|
) -> Result<
|
||||||
|
MultistatusElement<
|
||||||
|
PropstatWrapper<<R::File as Resource>::Prop>,
|
||||||
|
PropstatWrapper<<R::MemberType as Resource>::Prop>,
|
||||||
|
>,
|
||||||
|
R::Error,
|
||||||
|
> {
|
||||||
debug!("{body}");
|
debug!("{body}");
|
||||||
let auth_info = auth.inner;
|
let auth_info = auth.inner;
|
||||||
let prefix = prefix.0.to_owned();
|
let prefix = prefix.0.to_owned();
|
||||||
@@ -86,6 +92,7 @@ pub async fn route_propfind<A: CheckAuthentication, R: ResourceService + ?Sized>
|
|||||||
|
|
||||||
Ok(MultistatusElement {
|
Ok(MultistatusElement {
|
||||||
responses: vec![response],
|
responses: vec![response],
|
||||||
|
member_responses,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ pub async fn route_proppatch<A: CheckAuthentication, R: ResourceService + ?Sized
|
|||||||
status: format!("HTTP/1.1 {}", StatusCode::CONFLICT),
|
status: format!("HTTP/1.1 {}", StatusCode::CONFLICT),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
..Default::default()
|
||||||
}],
|
}],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ impl<R: Resource> HandlePropfind for R {
|
|||||||
prop: TagList::from(props),
|
prop: TagList::from(props),
|
||||||
status: format!("HTTP/1.1 {}", StatusCode::OK),
|
status: format!("HTTP/1.1 {}", StatusCode::OK),
|
||||||
})],
|
})],
|
||||||
|
..Default::default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if props.contains(&"allprop") {
|
if props.contains(&"allprop") {
|
||||||
@@ -155,6 +156,7 @@ impl<R: Resource> HandlePropfind for R {
|
|||||||
Ok(ResponseElement {
|
Ok(ResponseElement {
|
||||||
href: path,
|
href: path,
|
||||||
propstat: propstats,
|
propstat: propstats,
|
||||||
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,21 @@ pub enum PropstatWrapper<T: Serialize> {
|
|||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct ResponseElement<PropstatType: Serialize> {
|
pub struct ResponseElement<PropstatType: Serialize> {
|
||||||
pub href: String,
|
pub href: String,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub status: Option<String>,
|
||||||
pub propstat: Vec<PropstatType>,
|
pub propstat: Vec<PropstatType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<PT: Serialize> Default for ResponseElement<PT> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
href: String::new(),
|
||||||
|
status: None,
|
||||||
|
propstat: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// RFC 2518
|
// RFC 2518
|
||||||
// <!ELEMENT multistatus (response+, responsedescription?) >
|
// <!ELEMENT multistatus (response+, responsedescription?) >
|
||||||
// Extended by sync-token as specified in RFC 6578
|
// Extended by sync-token as specified in RFC 6578
|
||||||
@@ -55,6 +67,7 @@ pub struct MultistatusElement<T1: Serialize, T2: Serialize> {
|
|||||||
pub ns_caldav: &'static str,
|
pub ns_caldav: &'static str,
|
||||||
#[serde(rename = "@xmlns:IC")]
|
#[serde(rename = "@xmlns:IC")]
|
||||||
pub ns_ical: &'static str,
|
pub ns_ical: &'static str,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub sync_token: Option<String>,
|
pub sync_token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user