dav: Add namespace to propname

This commit is contained in:
Lennart
2025-05-10 13:13:51 +02:00
parent 37eb6df64a
commit 8f69bc839a
5 changed files with 33 additions and 18 deletions

View File

@@ -73,7 +73,7 @@ impl ReportRequest {
PropfindType::Prop(PropElement(prop_tags)) => prop_tags
.iter()
.map(|propname| match propname {
ReportPropName::Propname(propname) => propname.0.as_str(),
ReportPropName::Propname(propname) => propname.name.as_str(),
ReportPropName::CalendarData(_) => "calendar-data",
})
.collect(),
@@ -165,8 +165,8 @@ mod tests {
report_request,
ReportRequest::CalendarMultiget(CalendarMultigetRequest {
prop: rustical_dav::xml::PropfindType::Prop(PropElement(vec![
ReportPropName::Propname(Propname("getetag".to_owned())),
ReportPropName::Propname(Propname("displayname".to_owned())),
ReportPropName::Propname(Propname{name: "getetag".to_owned(), ns: Some("DAV:".to_owned())}),
ReportPropName::Propname(Propname{name: "displayname".to_owned(), ns: Some("DAV:".to_owned())}),
ReportPropName::CalendarData(CalendarData { comp: None, expand: Some(ExpandElement { start: "20250426T220000Z".to_owned(), end: "20250503T220000Z".to_owned() }), limit_recurrence_set: None, limit_freebusy_set: None })
])),
href: vec![
@@ -198,9 +198,10 @@ mod tests {
assert_eq!(
report_request,
ReportRequest::CalendarQuery(CalendarQueryRequest {
prop: PropfindType::Prop(PropElement(vec![ReportPropName::Propname(Propname(
"getetag".to_owned()
))])),
prop: PropfindType::Prop(PropElement(vec![ReportPropName::Propname(Propname {
name: "getetag".to_owned(),
ns: Some("DAV:".to_owned())
})])),
filter: Some(FilterElement {
comp_filter: CompFilterElement {
is_not_defined: None,
@@ -247,8 +248,8 @@ mod tests {
report_request,
ReportRequest::CalendarMultiget(CalendarMultigetRequest {
prop: rustical_dav::xml::PropfindType::Prop(PropElement(vec![
ReportPropName::Propname(Propname("getetag".to_owned())),
ReportPropName::Propname(Propname("displayname".to_owned()))
ReportPropName::Propname(Propname{name: "getetag".to_owned(), ns: Some("DAV:".to_owned())}),
ReportPropName::Propname(Propname{name: "displayname".to_owned(), ns: Some("DAV:".to_owned())})
])),
href: vec![
"/caldav/user/user/6f787542-5256-401a-8db97003260da/ae7a998fdfd1d84a20391168962c62b".to_owned()

View File

@@ -37,7 +37,7 @@ impl ReportRequest {
}
PropfindType::Prop(PropElement(prop_tags)) => prop_tags
.iter()
.map(|propname| propname.0.as_str())
.map(|propname| propname.name.as_str())
.collect(),
}
}
@@ -112,9 +112,10 @@ mod tests {
ReportRequest::SyncCollection(SyncCollectionRequest {
sync_token: "".to_owned(),
sync_level: SyncLevel::One,
prop: rustical_dav::xml::PropfindType::Prop(PropElement(vec![Propname(
"getetag".to_owned()
)])),
prop: rustical_dav::xml::PropfindType::Prop(PropElement(vec![Propname {
name: "getetag".to_owned(),
ns: Some("DAV:".to_owned())
}])),
limit: None
})
)
@@ -137,8 +138,8 @@ mod tests {
report_request,
ReportRequest::AddressbookMultiget(AddressbookMultigetRequest {
prop: rustical_dav::xml::PropfindType::Prop(PropElement(vec![
Propname("getetag".to_owned()),
Propname("address-data".to_owned())
Propname{name: "getetag".to_owned(), ns: Some("DAV:".to_owned())},
Propname{name: "address-data".to_owned(), ns: Some("urn:ietf:params:xml:ns:carddav".to_owned())}
])),
href: vec![
"/carddav/user/user/6f787542-5256-401a-8db97003260da/ae7a998fdfd1d84a20391168962c62b".to_owned()

View File

@@ -43,13 +43,15 @@ pub(crate) async fn route_propfind<R: ResourceService>(
}
};
dbg!(&propfind);
// TODO: respect namespaces?
let props = match &propfind.prop {
PropfindType::Allprop => vec!["allprop"],
PropfindType::Propname => vec!["propname"],
PropfindType::Prop(PropElement(prop_tags)) => prop_tags
.iter()
.map(|propname| propname.0.as_str())
.map(|propname| propname.name.as_str())
.collect(),
};

View File

@@ -12,7 +12,12 @@ pub struct PropfindElement {
pub struct PropElement<PN: XmlDeserialize = Propname>(#[xml(ty = "untagged", flatten)] pub Vec<PN>);
#[derive(Debug, Clone, XmlDeserialize, PartialEq)]
pub struct Propname(#[xml(ty = "tag_name")] pub String);
pub struct Propname {
#[xml(ty = "namespace")]
pub ns: Option<String>,
#[xml(ty = "tag_name")]
pub name: String,
}
#[derive(Debug, Clone, XmlDeserialize, PartialEq)]
pub enum PropfindType<PN: XmlDeserialize = Propname> {

View File

@@ -54,8 +54,14 @@ fn propfind_prop() {
propfind,
PropfindElement {
prop: PropfindType::Prop(PropElement(vec![
Propname("displayname".to_owned()),
Propname("color".to_owned()),
Propname {
name: "displayname".to_owned(),
ns: Some("DAV:".to_owned())
},
Propname {
name: "color".to_owned(),
ns: Some("DAV:".to_owned())
},
]))
}
);