mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 20:32:48 +00:00
some refactoring
This commit is contained in:
@@ -93,7 +93,7 @@ pub async fn handle_calendar_multiget<C: CalendarStore + ?Sized>(
|
|||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, props.clone(), user, req.resource_map())?,
|
.propfind(&path, &props, user, req.resource_map())?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ pub async fn handle_calendar_query<C: CalendarStore + ?Sized>(
|
|||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, props.clone(), user, req.resource_map())?,
|
.propfind(&path, &props, user, req.resource_map())?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ pub async fn handle_sync_collection<C: CalendarStore + ?Sized>(
|
|||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, props.clone(), user, req.resource_map())?,
|
.propfind(&path, &props, user, req.resource_map())?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ pub async fn handle_addressbook_multiget<AS: AddressbookStore + ?Sized>(
|
|||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, props.clone(), user, req.resource_map())?,
|
.propfind(&path, &props, user, req.resource_map())?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ pub async fn handle_sync_collection<AS: AddressbookStore + ?Sized>(
|
|||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, props.clone(), user, req.resource_map())?,
|
.propfind(&path, &props, user, req.resource_map())?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,29 +49,24 @@ pub(crate) async fn route_propfind<R: ResourceService>(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let props = match propfind.prop {
|
// TODO: respect namespaces?
|
||||||
PropfindType::Allprop => vec!["allprop".to_owned()],
|
let props = match &propfind.prop {
|
||||||
PropfindType::Propname => vec!["propname".to_owned()],
|
PropfindType::Allprop => vec!["allprop"],
|
||||||
|
PropfindType::Propname => vec!["propname"],
|
||||||
PropfindType::Prop(PropElement { prop: prop_tags }) => prop_tags
|
PropfindType::Prop(PropElement { prop: prop_tags }) => prop_tags
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|propname| propname.name)
|
.map(|propname| propname.name.as_str())
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
let props: Vec<&str> = props.iter().map(String::as_str).collect();
|
|
||||||
|
|
||||||
let mut member_responses = Vec::new();
|
let mut member_responses = Vec::new();
|
||||||
if depth != Depth::Zero {
|
if depth != Depth::Zero {
|
||||||
for (path, member) in resource_service.get_members(req.resource_map()).await? {
|
for (path, member) in resource_service.get_members(req.resource_map()).await? {
|
||||||
member_responses.push(member.propfind(
|
member_responses.push(member.propfind(&path, &props, &user, req.resource_map())?);
|
||||||
&path,
|
|
||||||
props.clone(),
|
|
||||||
&user,
|
|
||||||
req.resource_map(),
|
|
||||||
)?);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = resource.propfind(req.path(), props, &user, req.resource_map())?;
|
let response = resource.propfind(req.path(), &props, &user, req.resource_map())?;
|
||||||
|
|
||||||
Ok(MultistatusElement {
|
Ok(MultistatusElement {
|
||||||
responses: vec![response],
|
responses: vec![response],
|
||||||
|
|||||||
@@ -141,10 +141,12 @@ pub trait Resource: Clone + 'static {
|
|||||||
fn propfind(
|
fn propfind(
|
||||||
&self,
|
&self,
|
||||||
path: &str,
|
path: &str,
|
||||||
mut props: Vec<&str>,
|
props: &[&str],
|
||||||
user: &User,
|
user: &User,
|
||||||
rmap: &ResourceMap,
|
rmap: &ResourceMap,
|
||||||
) -> Result<ResponseElement<EitherProp<Self::Prop, CommonPropertiesProp>>, Self::Error> {
|
) -> Result<ResponseElement<EitherProp<Self::Prop, CommonPropertiesProp>>, Self::Error> {
|
||||||
|
let mut props = props.to_vec();
|
||||||
|
|
||||||
if props.contains(&"propname") {
|
if props.contains(&"propname") {
|
||||||
if props.len() != 1 {
|
if props.len() != 1 {
|
||||||
// propname MUST be the only queried prop per spec
|
// propname MUST be the only queried prop per spec
|
||||||
@@ -154,7 +156,7 @@ pub trait Resource: Clone + 'static {
|
|||||||
}
|
}
|
||||||
let props = Self::list_props()
|
let props = Self::list_props()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(str::to_owned)
|
.map(str::to_string)
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
return Ok(ResponseElement {
|
return Ok(ResponseElement {
|
||||||
@@ -186,7 +188,7 @@ pub trait Resource: Clone + 'static {
|
|||||||
} else if let Ok(internal_prop) = CommonPropertiesPropName::from_str(prop) {
|
} else if let Ok(internal_prop) = CommonPropertiesPropName::from_str(prop) {
|
||||||
internal_props.push(internal_prop);
|
internal_props.push(internal_prop);
|
||||||
} else {
|
} else {
|
||||||
invalid_props.push(prop)
|
invalid_props.push(prop.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,11 +214,7 @@ pub trait Resource: Clone + 'static {
|
|||||||
if !invalid_props.is_empty() {
|
if !invalid_props.is_empty() {
|
||||||
propstats.push(PropstatWrapper::TagList(PropstatElement {
|
propstats.push(PropstatWrapper::TagList(PropstatElement {
|
||||||
status: StatusCode::NOT_FOUND,
|
status: StatusCode::NOT_FOUND,
|
||||||
prop: invalid_props
|
prop: invalid_props.into(),
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.to_owned())
|
|
||||||
.collect_vec()
|
|
||||||
.into(),
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
Ok(ResponseElement {
|
Ok(ResponseElement {
|
||||||
|
|||||||
Reference in New Issue
Block a user