CalDAV: support for supported-calendar-component-set (closes #1893)
This commit is contained in:
@@ -25,7 +25,7 @@ use dav_proto::{
|
||||
};
|
||||
use groupware::{
|
||||
cache::GroupwareCache,
|
||||
calendar::{Calendar, CalendarEvent, Timezone},
|
||||
calendar::{Calendar, CalendarEvent, SupportedComponent, Timezone},
|
||||
};
|
||||
use http_proto::HttpResponse;
|
||||
use hyper::StatusCode;
|
||||
@@ -36,6 +36,7 @@ use types::{
|
||||
acl::Acl,
|
||||
collection::{Collection, SyncCollection},
|
||||
};
|
||||
use utils::map::bitmap::Bitmap;
|
||||
|
||||
pub(crate) trait CalendarPropPatchRequestHandler: Sync + Send {
|
||||
fn handle_calendar_proppatch_request(
|
||||
@@ -340,6 +341,39 @@ impl CalendarPropPatchRequestHandler for Server {
|
||||
items.insert_ok(property.property);
|
||||
}
|
||||
}
|
||||
(
|
||||
DavProperty::CalDav(CalDavProperty::SupportedCalendarComponentSet),
|
||||
DavValue::Components(components),
|
||||
) => {
|
||||
if !is_update {
|
||||
calendar.supported_components = Bitmap::<SupportedComponent>::from_iter(
|
||||
components
|
||||
.0
|
||||
.into_iter()
|
||||
.map(|v| SupportedComponent::from(v.0)),
|
||||
)
|
||||
.into_inner();
|
||||
if calendar.supported_components != 0 {
|
||||
items.insert_ok(property.property);
|
||||
} else {
|
||||
items.insert_precondition_failed_with_description(
|
||||
property.property,
|
||||
StatusCode::PRECONDITION_FAILED,
|
||||
CalCondition::SupportedCalendarComponent,
|
||||
"At least one supported component must be specified",
|
||||
);
|
||||
has_errors = true;
|
||||
}
|
||||
} else {
|
||||
items.insert_precondition_failed_with_description(
|
||||
property.property,
|
||||
StatusCode::PRECONDITION_FAILED,
|
||||
CalCondition::SupportedCalendarComponent,
|
||||
"Property cannot be modified",
|
||||
);
|
||||
has_errors = true;
|
||||
}
|
||||
}
|
||||
(DavProperty::DeadProperty(dead), DavValue::DeadProperty(values))
|
||||
if self.core.groupware.dead_property_size.is_some() =>
|
||||
{
|
||||
@@ -362,7 +396,7 @@ impl CalendarPropPatchRequestHandler for Server {
|
||||
has_errors = true;
|
||||
}
|
||||
}
|
||||
(_, DavValue::Null | DavValue::Components(_)) => {
|
||||
(_, DavValue::Null) => {
|
||||
items.insert_ok(property.property);
|
||||
}
|
||||
_ => {
|
||||
|
||||
@@ -27,7 +27,7 @@ use crate::{
|
||||
propfind::{PrincipalPropFind, build_home_set},
|
||||
},
|
||||
};
|
||||
use calcard::common::timezone::Tz;
|
||||
use calcard::{common::timezone::Tz, icalendar::ICalendarComponentType};
|
||||
use common::{DavResourcePath, DavResources, Server, auth::AccessToken};
|
||||
use dav_proto::{
|
||||
Depth, RequestHeaders,
|
||||
@@ -36,9 +36,9 @@ use dav_proto::{
|
||||
schema::{
|
||||
Collation, Namespace,
|
||||
property::{
|
||||
ActiveLock, CalDavProperty, CardDavProperty, DavProperty, DavValue, PrincipalProperty,
|
||||
Privilege, ReportSet, ResourceType, Rfc1123DateTime, SupportedCollation, SupportedLock,
|
||||
WebDavProperty,
|
||||
ActiveLock, CalDavProperty, CardDavProperty, Comp, DavProperty, DavValue,
|
||||
PrincipalProperty, Privilege, ReportSet, ResourceType, Rfc1123DateTime,
|
||||
SupportedCollation, SupportedLock, WebDavProperty,
|
||||
},
|
||||
request::{DavDeadProperty, DavPropertyValue, PropFind},
|
||||
response::{
|
||||
@@ -48,7 +48,7 @@ use dav_proto::{
|
||||
},
|
||||
};
|
||||
use directory::{Permission, Type, backend::internal::manage::ManageDirectory};
|
||||
use groupware::calendar::SCHEDULE_INBOX_ID;
|
||||
use groupware::calendar::{SCHEDULE_INBOX_ID, SupportedComponent};
|
||||
use groupware::{
|
||||
DavCalendarResource, DavResourceName, cache::GroupwareCache, calendar::ArchivedTimezone,
|
||||
};
|
||||
@@ -67,6 +67,7 @@ use types::{
|
||||
collection::{Collection, SyncCollection},
|
||||
dead_property::DeadProperty,
|
||||
};
|
||||
use utils::map::bitmap::Bitmap;
|
||||
|
||||
pub(crate) trait PropFindRequestHandler: Sync + Send {
|
||||
fn handle_propfind_request(
|
||||
@@ -898,11 +899,23 @@ impl PropFindRequestHandler for Server {
|
||||
}
|
||||
(
|
||||
CalDavProperty::SupportedCalendarComponentSet,
|
||||
ArchivedResource::Calendar(_),
|
||||
ArchivedResource::Calendar(calendar),
|
||||
) => {
|
||||
let supported_components =
|
||||
calendar.inner.supported_components.to_native();
|
||||
fields.push(DavPropertyValue::new(
|
||||
property.clone(),
|
||||
DavValue::SupportedCalendarComponentSet,
|
||||
if supported_components != 0 {
|
||||
DavValue::Components(List(
|
||||
Bitmap::<SupportedComponent>::from(supported_components)
|
||||
.into_iter()
|
||||
.map(ICalendarComponentType::from)
|
||||
.map(Comp)
|
||||
.collect(),
|
||||
))
|
||||
} else {
|
||||
DavValue::all_calendar_components()
|
||||
},
|
||||
));
|
||||
}
|
||||
(CalDavProperty::SupportedCalendarData, ArchivedResource::Calendar(_)) => {
|
||||
|
||||
Reference in New Issue
Block a user