mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 18:12:27 +00:00
dav: Make reusable for other projects
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
use crate::privileges::UserPrivilegeSet;
|
||||
use crate::xml::multistatus::{PropTagWrapper, PropstatElement, PropstatWrapper};
|
||||
use crate::xml::Resourcetype;
|
||||
use crate::xml::{multistatus::ResponseElement, TagList};
|
||||
use crate::Error;
|
||||
use crate::xml::multistatus::{PropTagWrapper, PropstatElement, PropstatWrapper};
|
||||
use crate::xml::{TagList, multistatus::ResponseElement};
|
||||
use crate::{Error, Principal};
|
||||
use actix_web::dev::ResourceMap;
|
||||
use actix_web::http::header::{EntityTag, IfMatch, IfNoneMatch};
|
||||
use actix_web::{http::StatusCode, ResponseError};
|
||||
use actix_web::{ResponseError, http::StatusCode};
|
||||
use itertools::Itertools;
|
||||
use quick_xml::name::Namespace;
|
||||
pub use resource_service::ResourceService;
|
||||
use rustical_store::auth::User;
|
||||
use rustical_xml::{EnumUnitVariants, EnumVariants, XmlDeserialize, XmlSerialize};
|
||||
use std::str::FromStr;
|
||||
|
||||
@@ -28,6 +27,7 @@ pub trait Resource: Clone + 'static {
|
||||
type Prop: ResourceProp + PartialEq + Clone + EnumVariants + EnumUnitVariants;
|
||||
type Error: ResponseError + From<crate::Error>;
|
||||
type PrincipalResource: Resource + NamedRoute;
|
||||
type Principal: Principal;
|
||||
|
||||
fn get_resourcetype(&self) -> Resourcetype;
|
||||
|
||||
@@ -38,7 +38,7 @@ pub trait Resource: Clone + 'static {
|
||||
fn get_prop(
|
||||
&self,
|
||||
rmap: &ResourceMap,
|
||||
user: &User,
|
||||
principal: &Self::Principal,
|
||||
prop: &<Self::Prop as EnumUnitVariants>::UnitVariants,
|
||||
) -> Result<Self::Prop, Self::Error>;
|
||||
|
||||
@@ -93,13 +93,16 @@ pub trait Resource: Clone + 'static {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_user_privileges(&self, user: &User) -> Result<UserPrivilegeSet, Self::Error>;
|
||||
fn get_user_privileges(
|
||||
&self,
|
||||
principal: &Self::Principal,
|
||||
) -> Result<UserPrivilegeSet, Self::Error>;
|
||||
|
||||
fn propfind(
|
||||
&self,
|
||||
path: &str,
|
||||
props: &[&str],
|
||||
user: &User,
|
||||
principal: &Self::Principal,
|
||||
rmap: &ResourceMap,
|
||||
) -> Result<ResponseElement<Self::Prop>, Self::Error> {
|
||||
let mut props = props.to_vec();
|
||||
@@ -152,7 +155,7 @@ pub trait Resource: Clone + 'static {
|
||||
|
||||
let prop_responses = valid_props
|
||||
.into_iter()
|
||||
.map(|prop| self.get_prop(rmap, user, &prop))
|
||||
.map(|prop| self.get_prop(rmap, principal, &prop))
|
||||
.collect::<Result<Vec<_>, Self::Error>>()?;
|
||||
|
||||
let mut propstats = vec![PropstatWrapper::Normal(PropstatElement {
|
||||
|
||||
Reference in New Issue
Block a user