mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 21:42:34 +00:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8ef2f1ba2 | ||
|
|
c8adf60f48 | ||
|
|
507cb77e85 | ||
|
|
8881ea2a05 | ||
|
|
119e17a8e1 | ||
|
|
8b01c5388b | ||
|
|
35f423d4ca | ||
|
|
a827b40b47 | ||
|
|
16f9ce6f38 | ||
|
|
34839aa2ed | ||
|
|
2724154ed3 | ||
|
|
c490c413ec | ||
|
|
994864c6ef | ||
|
|
92fd28cdbb | ||
|
|
d7e871f0e6 | ||
|
|
a0fc073bd2 | ||
|
|
c8dffb4f9e | ||
|
|
b6d1899636 | ||
|
|
81f1767efa | ||
|
|
54eb9ddfcc | ||
|
|
60a0f16557 | ||
|
|
e4f188d299 | ||
|
|
69163404a1 | ||
|
|
0b7cfea79c |
22
Cargo.lock
generated
22
Cargo.lock
generated
@@ -2999,7 +2999,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical"
|
name = "rustical"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argon2",
|
"argon2",
|
||||||
@@ -3042,7 +3042,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_caldav"
|
name = "rustical_caldav"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -3080,7 +3080,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_carddav"
|
name = "rustical_carddav"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3112,7 +3112,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_dav"
|
name = "rustical_dav"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3137,7 +3137,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_dav_push"
|
name = "rustical_dav_push"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3163,7 +3163,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_frontend"
|
name = "rustical_frontend"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"askama_web",
|
"askama_web",
|
||||||
@@ -3196,7 +3196,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_ical"
|
name = "rustical_ical"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -3214,7 +3214,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_oidc"
|
name = "rustical_oidc"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3229,7 +3229,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_store"
|
name = "rustical_store"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -3263,7 +3263,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_store_sqlite"
|
name = "rustical_store_sqlite"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -3284,7 +3284,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_xml"
|
name = "rustical_xml"
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.4.13"
|
version = "0.6.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
description = "A CalDAV server"
|
description = "A CalDAV server"
|
||||||
repository = "https://github.com/lennart-k/rustical"
|
repository = "https://github.com/lennart-k/rustical"
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ a CalDAV/CardDAV server
|
|||||||
|
|
||||||
- easy to backup, everything saved in one SQLite database
|
- easy to backup, everything saved in one SQLite database
|
||||||
- also export feature in the frontend
|
- also export feature in the frontend
|
||||||
- [WebDAV Push](https://github.com/bitfireAT/webdav-push/) support, so near-instant synchronisation to DAVx5
|
- **[WebDAV Push](https://github.com/bitfireAT/webdav-push/)** support, so near-instant synchronisation to DAVx5
|
||||||
- lightweight (the container image contains only one binary)
|
- lightweight (the container image contains only one binary)
|
||||||
- adequately fast (I'd love to say blazingly fast™ :fire: but I don't have any benchmarks)
|
- adequately fast (I'd love to say blazingly fast™ :fire: but I don't have any benchmarks)
|
||||||
- deleted calendars are recoverable
|
- deleted calendars are recoverable
|
||||||
- Nextcloud login flow (In DAVx5 you can login through the Nextcloud flow and automatically generate an app token)
|
- Nextcloud login flow (In DAVx5 you can login through the Nextcloud flow and automatically generate an app token)
|
||||||
- Apple configuration profiles (skip copy-pasting passwords and instead generate the configuration in the frontend)
|
- Apple configuration profiles (skip copy-pasting passwords and instead generate the configuration in the frontend)
|
||||||
- OpenID Connect support (with option to disable password login)
|
- **OpenID Connect** support (with option to disable password login)
|
||||||
|
- Group-based **sharing**
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ pub(crate) struct TimeRangeElement {
|
|||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
// https://www.rfc-editor.org/rfc/rfc4791#section-9.7.3
|
||||||
struct ParamFilterElement {
|
struct ParamFilterElement {
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
is_not_defined: Option<()>,
|
is_not_defined: Option<()>,
|
||||||
@@ -32,11 +33,13 @@ struct TextMatchElement {
|
|||||||
#[xml(ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
collation: String,
|
collation: String,
|
||||||
#[xml(ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
negate_collation: String,
|
// "yes" or "no", default: "no"
|
||||||
|
negate_condition: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
// https://www.rfc-editor.org/rfc/rfc4791#section-9.7.2
|
||||||
pub(crate) struct PropFilterElement {
|
pub(crate) struct PropFilterElement {
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
is_not_defined: Option<()>,
|
is_not_defined: Option<()>,
|
||||||
@@ -46,6 +49,9 @@ pub(crate) struct PropFilterElement {
|
|||||||
text_match: Option<TextMatchElement>,
|
text_match: Option<TextMatchElement>,
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
||||||
param_filter: Vec<ParamFilterElement>,
|
param_filter: Vec<ParamFilterElement>,
|
||||||
|
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
||||||
@@ -61,7 +67,7 @@ pub(crate) struct CompFilterElement {
|
|||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
||||||
pub(crate) comp_filter: Vec<CompFilterElement>,
|
pub(crate) comp_filter: Vec<CompFilterElement>,
|
||||||
|
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,3 +209,102 @@ pub async fn get_objects_calendar_query<C: CalendarStore>(
|
|||||||
}
|
}
|
||||||
Ok(objects)
|
Ok(objects)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use rustical_dav::xml::PropElement;
|
||||||
|
use rustical_xml::XmlDocument;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
calendar::methods::report::{
|
||||||
|
ReportRequest,
|
||||||
|
calendar_query::{
|
||||||
|
CalendarQueryRequest, CompFilterElement, FilterElement, ParamFilterElement,
|
||||||
|
PropFilterElement, TextMatchElement,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
calendar_object::{CalendarObjectPropName, CalendarObjectPropWrapperName},
|
||||||
|
};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn calendar_query_7_8_7() {
|
||||||
|
const INPUT: &str = r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<D:prop xmlns:D="DAV:">
|
||||||
|
<D:getetag/>
|
||||||
|
<C:calendar-data/>
|
||||||
|
</D:prop>
|
||||||
|
<C:filter>
|
||||||
|
<C:comp-filter name="VCALENDAR">
|
||||||
|
<C:comp-filter name="VEVENT">
|
||||||
|
<C:prop-filter name="ATTENDEE">
|
||||||
|
<C:text-match collation="i;ascii-casemap">mailto:lisa@example.com</C:text-match>
|
||||||
|
<C:param-filter name="PARTSTAT">
|
||||||
|
<C:text-match collation="i;ascii-casemap">NEEDS-ACTION</C:text-match>
|
||||||
|
</C:param-filter>
|
||||||
|
</C:prop-filter>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:filter>
|
||||||
|
</C:calendar-query>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let report = ReportRequest::parse_str(INPUT).unwrap();
|
||||||
|
let calendar_query: CalendarQueryRequest =
|
||||||
|
if let ReportRequest::CalendarQuery(query) = report {
|
||||||
|
query
|
||||||
|
} else {
|
||||||
|
panic!()
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
calendar_query,
|
||||||
|
CalendarQueryRequest {
|
||||||
|
prop: rustical_dav::xml::PropfindType::Prop(PropElement(
|
||||||
|
vec![
|
||||||
|
CalendarObjectPropWrapperName::CalendarObject(
|
||||||
|
CalendarObjectPropName::Getetag,
|
||||||
|
),
|
||||||
|
CalendarObjectPropWrapperName::CalendarObject(
|
||||||
|
CalendarObjectPropName::CalendarData(Default::default())
|
||||||
|
),
|
||||||
|
],
|
||||||
|
vec![]
|
||||||
|
)),
|
||||||
|
filter: Some(FilterElement {
|
||||||
|
comp_filter: CompFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![CompFilterElement {
|
||||||
|
prop_filter: vec![PropFilterElement {
|
||||||
|
name: "ATTENDEE".to_owned(),
|
||||||
|
text_match: Some(TextMatchElement {
|
||||||
|
collation: "i;ascii-casemap".to_owned(),
|
||||||
|
negate_condition: None
|
||||||
|
}),
|
||||||
|
is_not_defined: None,
|
||||||
|
param_filter: vec![ParamFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "PARTSTAT".to_owned(),
|
||||||
|
text_match: Some(TextMatchElement {
|
||||||
|
collation: "i;ascii-casemap".to_owned(),
|
||||||
|
negate_condition: None
|
||||||
|
}),
|
||||||
|
}],
|
||||||
|
time_range: None
|
||||||
|
}],
|
||||||
|
comp_filter: vec![],
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "VEVENT".to_owned(),
|
||||||
|
time_range: None
|
||||||
|
}],
|
||||||
|
name: "VCALENDAR".to_owned()
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
timezone: None,
|
||||||
|
timezone_id: None
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub enum CalendarProp {
|
|||||||
CalendarTimezoneId(Option<String>),
|
CalendarTimezoneId(Option<String>),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_ICAL")]
|
#[xml(ns = "rustical_dav::namespace::NS_ICAL")]
|
||||||
CalendarOrder(Option<i64>),
|
CalendarOrder(Option<i64>),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
SupportedCalendarComponentSet(SupportedCalendarComponentSet),
|
SupportedCalendarComponentSet(SupportedCalendarComponentSet),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
||||||
SupportedCalendarData(SupportedCalendarData),
|
SupportedCalendarData(SupportedCalendarData),
|
||||||
@@ -201,10 +201,7 @@ impl Resource for CalendarResource {
|
|||||||
if let Some(tzid) = &timezone_id {
|
if let Some(tzid) = &timezone_id {
|
||||||
// Validate timezone id
|
// Validate timezone id
|
||||||
chrono_tz::Tz::from_str(tzid).map_err(|_| {
|
chrono_tz::Tz::from_str(tzid).map_err(|_| {
|
||||||
rustical_dav::Error::BadRequest(format!(
|
rustical_dav::Error::BadRequest(format!("Invalid timezone-id: {tzid}"))
|
||||||
"Invalid timezone-id: {}",
|
|
||||||
tzid
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
// TODO: Ensure that timezone is also updated (For now hope that clients play nice)
|
// TODO: Ensure that timezone is also updated (For now hope that clients play nice)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use axum::response::Redirect;
|
|
||||||
use axum::routing::any;
|
|
||||||
use axum::{Extension, Router};
|
use axum::{Extension, Router};
|
||||||
use derive_more::Constructor;
|
use derive_more::Constructor;
|
||||||
use principal::PrincipalResourceService;
|
use principal::PrincipalResourceService;
|
||||||
@@ -14,7 +12,6 @@ pub mod calendar;
|
|||||||
pub mod calendar_object;
|
pub mod calendar_object;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod principal;
|
pub mod principal;
|
||||||
|
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Constructor)]
|
#[derive(Debug, Clone, Constructor)]
|
||||||
@@ -34,23 +31,18 @@ pub fn caldav_router<AP: AuthenticationProvider, C: CalendarStore, S: Subscripti
|
|||||||
auth_provider: Arc<AP>,
|
auth_provider: Arc<AP>,
|
||||||
store: Arc<C>,
|
store: Arc<C>,
|
||||||
subscription_store: Arc<S>,
|
subscription_store: Arc<S>,
|
||||||
|
simplified_home_set: bool,
|
||||||
) -> Router {
|
) -> Router {
|
||||||
let principal_service = PrincipalResourceService {
|
Router::new().nest(
|
||||||
auth_provider: auth_provider.clone(),
|
prefix,
|
||||||
sub_store: subscription_store.clone(),
|
RootResourceService::<_, Principal, CalDavPrincipalUri>::new(PrincipalResourceService {
|
||||||
cal_store: store.clone(),
|
auth_provider: auth_provider.clone(),
|
||||||
};
|
sub_store: subscription_store.clone(),
|
||||||
|
cal_store: store.clone(),
|
||||||
Router::new()
|
simplified_home_set,
|
||||||
.nest(
|
})
|
||||||
prefix,
|
.axum_router()
|
||||||
RootResourceService::<_, Principal, CalDavPrincipalUri>::new(principal_service.clone())
|
.layer(AuthenticationLayer::new(auth_provider))
|
||||||
.axum_router()
|
.layer(Extension(CalDavPrincipalUri(prefix))),
|
||||||
.layer(AuthenticationLayer::new(auth_provider))
|
)
|
||||||
.layer(Extension(CalDavPrincipalUri(prefix))),
|
|
||||||
)
|
|
||||||
.route(
|
|
||||||
"/.well-known/caldav",
|
|
||||||
any(async || Redirect::permanent(prefix)),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ pub mod tests;
|
|||||||
pub struct PrincipalResource {
|
pub struct PrincipalResource {
|
||||||
principal: Principal,
|
principal: Principal,
|
||||||
members: Vec<String>,
|
members: Vec<String>,
|
||||||
|
// If true only return the principal as the calendar home set, otherwise also groups
|
||||||
|
simplified_home_set: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for PrincipalResource {
|
impl ResourceName for PrincipalResource {
|
||||||
@@ -64,9 +66,17 @@ impl Resource for PrincipalResource {
|
|||||||
PrincipalPropName::PrincipalUrl => {
|
PrincipalPropName::PrincipalUrl => {
|
||||||
PrincipalProp::PrincipalUrl(principal_url.into())
|
PrincipalProp::PrincipalUrl(principal_url.into())
|
||||||
}
|
}
|
||||||
PrincipalPropName::CalendarHomeSet => {
|
PrincipalPropName::CalendarHomeSet => PrincipalProp::CalendarHomeSet(
|
||||||
PrincipalProp::CalendarHomeSet(principal_url.into())
|
CalendarHomeSet(if self.simplified_home_set {
|
||||||
}
|
vec![principal_url.into()]
|
||||||
|
} else {
|
||||||
|
self.principal
|
||||||
|
.memberships()
|
||||||
|
.iter()
|
||||||
|
.map(|principal| puri.principal_uri(principal).into())
|
||||||
|
.collect()
|
||||||
|
}),
|
||||||
|
),
|
||||||
PrincipalPropName::CalendarUserAddressSet => {
|
PrincipalPropName::CalendarUserAddressSet => {
|
||||||
PrincipalProp::CalendarUserAddressSet(principal_url.into())
|
PrincipalProp::CalendarUserAddressSet(principal_url.into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,12 @@ pub enum PrincipalProp {
|
|||||||
|
|
||||||
// CalDAV (RFC 4791)
|
// CalDAV (RFC 4791)
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
CalendarHomeSet(HrefElement),
|
CalendarHomeSet(CalendarHomeSet),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
|
pub struct CalendarHomeSet(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumVariants, PropName)]
|
||||||
#[xml(unit_variants_ident = "PrincipalPropWrapperName", untagged)]
|
#[xml(unit_variants_ident = "PrincipalPropWrapperName", untagged)]
|
||||||
pub enum PrincipalPropWrapper {
|
pub enum PrincipalPropWrapper {
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ pub struct PrincipalResourceService<
|
|||||||
pub(crate) auth_provider: Arc<AP>,
|
pub(crate) auth_provider: Arc<AP>,
|
||||||
pub(crate) sub_store: Arc<S>,
|
pub(crate) sub_store: Arc<S>,
|
||||||
pub(crate) cal_store: Arc<CS>,
|
pub(crate) cal_store: Arc<CS>,
|
||||||
|
// If true only return the principal as the calendar home set, otherwise also groups
|
||||||
|
pub(crate) simplified_home_set: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Clone
|
impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Clone
|
||||||
@@ -28,6 +30,7 @@ impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Clone
|
|||||||
auth_provider: self.auth_provider.clone(),
|
auth_provider: self.auth_provider.clone(),
|
||||||
sub_store: self.sub_store.clone(),
|
sub_store: self.sub_store.clone(),
|
||||||
cal_store: self.cal_store.clone(),
|
cal_store: self.cal_store.clone(),
|
||||||
|
simplified_home_set: self.simplified_home_set,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,6 +61,7 @@ impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Resour
|
|||||||
Ok(PrincipalResource {
|
Ok(PrincipalResource {
|
||||||
members: self.auth_provider.list_members(&user.id).await?,
|
members: self.auth_provider.list_members(&user.id).await?,
|
||||||
principal: user,
|
principal: user,
|
||||||
|
simplified_home_set: self.simplified_home_set,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ async fn test_principal_resource(
|
|||||||
cal_store: Arc::new(cal_store.await),
|
cal_store: Arc::new(cal_store.await),
|
||||||
sub_store: Arc::new(sub_store.await),
|
sub_store: Arc::new(sub_store.await),
|
||||||
auth_provider: Arc::new(auth_provider.await),
|
auth_provider: Arc::new(auth_provider.await),
|
||||||
|
simplified_home_set: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
|
|||||||
@@ -53,7 +53,13 @@ impl Resource for PrincipalResource {
|
|||||||
PrincipalPropWrapper::Principal(match prop {
|
PrincipalPropWrapper::Principal(match prop {
|
||||||
PrincipalPropName::PrincipalUrl => PrincipalProp::PrincipalUrl(principal_href),
|
PrincipalPropName::PrincipalUrl => PrincipalProp::PrincipalUrl(principal_href),
|
||||||
PrincipalPropName::AddressbookHomeSet => {
|
PrincipalPropName::AddressbookHomeSet => {
|
||||||
PrincipalProp::AddressbookHomeSet(principal_href)
|
PrincipalProp::AddressbookHomeSet(AddressbookHomeSet(
|
||||||
|
self.principal
|
||||||
|
.memberships()
|
||||||
|
.iter()
|
||||||
|
.map(|principal| puri.principal_uri(principal).into())
|
||||||
|
.collect(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
PrincipalPropName::PrincipalAddress => PrincipalProp::PrincipalAddress(None),
|
PrincipalPropName::PrincipalAddress => PrincipalProp::PrincipalAddress(None),
|
||||||
PrincipalPropName::GroupMembership => {
|
PrincipalPropName::GroupMembership => {
|
||||||
|
|||||||
@@ -22,11 +22,14 @@ pub enum PrincipalProp {
|
|||||||
|
|
||||||
// CardDAV (RFC 6352)
|
// CardDAV (RFC 6352)
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
AddressbookHomeSet(HrefElement),
|
AddressbookHomeSet(AddressbookHomeSet),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
PrincipalAddress(Option<HrefElement>),
|
PrincipalAddress(Option<HrefElement>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||||
|
pub struct AddressbookHomeSet(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumVariants, PropName)]
|
||||||
#[xml(unit_variants_ident = "PrincipalPropWrapperName", untagged)]
|
#[xml(unit_variants_ident = "PrincipalPropWrapperName", untagged)]
|
||||||
pub enum PrincipalPropWrapper {
|
pub enum PrincipalPropWrapper {
|
||||||
|
|||||||
@@ -26,21 +26,21 @@ enum SetPropertyPropWrapper<T: XmlDeserialize> {
|
|||||||
// We are <prop>
|
// We are <prop>
|
||||||
#[derive(XmlDeserialize, Clone, Debug)]
|
#[derive(XmlDeserialize, Clone, Debug)]
|
||||||
struct SetPropertyPropWrapperWrapper<T: XmlDeserialize>(
|
struct SetPropertyPropWrapperWrapper<T: XmlDeserialize>(
|
||||||
#[xml(ty = "untagged")] SetPropertyPropWrapper<T>,
|
#[xml(ty = "untagged", flatten)] Vec<SetPropertyPropWrapper<T>>,
|
||||||
);
|
);
|
||||||
|
|
||||||
// We are <set>
|
// We are <set>
|
||||||
#[derive(XmlDeserialize, Clone, Debug)]
|
#[derive(XmlDeserialize, Clone, Debug)]
|
||||||
struct SetPropertyElement<T: XmlDeserialize> {
|
struct SetPropertyElement<T: XmlDeserialize> {
|
||||||
#[xml(ns = "crate::namespace::NS_DAV")]
|
#[xml(ns = "crate::namespace::NS_DAV")]
|
||||||
prop: T,
|
prop: SetPropertyPropWrapperWrapper<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug)]
|
#[derive(XmlDeserialize, Clone, Debug)]
|
||||||
struct TagName(#[xml(ty = "tag_name")] String);
|
struct TagName(#[xml(ty = "tag_name")] String);
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug)]
|
#[derive(XmlDeserialize, Clone, Debug)]
|
||||||
struct PropertyElement(#[xml(ty = "untagged")] TagName);
|
struct PropertyElement(#[xml(ty = "untagged", flatten)] Vec<TagName>);
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug)]
|
#[derive(XmlDeserialize, Clone, Debug)]
|
||||||
struct RemovePropertyElement {
|
struct RemovePropertyElement {
|
||||||
@@ -81,9 +81,8 @@ pub(crate) async fn route_proppatch<R: ResourceService>(
|
|||||||
let href = path.to_owned();
|
let href = path.to_owned();
|
||||||
|
|
||||||
// Extract operations
|
// Extract operations
|
||||||
let PropertyupdateElement::<SetPropertyPropWrapperWrapper<<R::Resource as Resource>::Prop>>(
|
let PropertyupdateElement::<<R::Resource as Resource>::Prop>(operations) =
|
||||||
operations,
|
XmlDocument::parse_str(body).map_err(Error::XmlError)?;
|
||||||
) = XmlDocument::parse_str(body).map_err(Error::XmlError)?;
|
|
||||||
|
|
||||||
let mut resource = resource_service
|
let mut resource = resource_service
|
||||||
.get_resource(path_components, false)
|
.get_resource(path_components, false)
|
||||||
@@ -100,59 +99,63 @@ pub(crate) async fn route_proppatch<R: ResourceService>(
|
|||||||
for operation in operations.into_iter() {
|
for operation in operations.into_iter() {
|
||||||
match operation {
|
match operation {
|
||||||
Operation::Set(SetPropertyElement {
|
Operation::Set(SetPropertyElement {
|
||||||
prop: SetPropertyPropWrapperWrapper(property),
|
prop: SetPropertyPropWrapperWrapper(properties),
|
||||||
}) => {
|
}) => {
|
||||||
match property {
|
for property in properties {
|
||||||
SetPropertyPropWrapper::Valid(prop) => {
|
match property {
|
||||||
let propname: <<R::Resource as Resource>::Prop as PropName>::Names =
|
SetPropertyPropWrapper::Valid(prop) => {
|
||||||
prop.clone().into();
|
let propname: <<R::Resource as Resource>::Prop as PropName>::Names =
|
||||||
let (ns, propname): (Option<Namespace>, &str) = propname.into();
|
prop.clone().into();
|
||||||
match resource.set_prop(prop) {
|
let (ns, propname): (Option<Namespace>, &str) = propname.into();
|
||||||
Ok(()) => {
|
match resource.set_prop(prop) {
|
||||||
props_ok.push((ns.map(NamespaceOwned::from), propname.to_owned()))
|
Ok(()) => props_ok
|
||||||
}
|
.push((ns.map(NamespaceOwned::from), propname.to_owned())),
|
||||||
Err(Error::PropReadOnly) => props_conflict
|
Err(Error::PropReadOnly) => props_conflict
|
||||||
.push((ns.map(NamespaceOwned::from), propname.to_owned())),
|
.push((ns.map(NamespaceOwned::from), propname.to_owned())),
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => return Err(err.into()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
SetPropertyPropWrapper::Invalid(invalid) => {
|
SetPropertyPropWrapper::Invalid(invalid) => {
|
||||||
let propname = invalid.tag_name();
|
let propname = invalid.tag_name();
|
||||||
|
|
||||||
if let Some(full_propname) = <R::Resource as Resource>::list_props()
|
if let Some(full_propname) = <R::Resource as Resource>::list_props()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.find_map(|(ns, tag)| {
|
.find_map(|(ns, tag)| {
|
||||||
if tag == propname.as_str() {
|
if tag == propname.as_str() {
|
||||||
Some((ns.map(NamespaceOwned::from), tag.to_owned()))
|
Some((ns.map(NamespaceOwned::from), tag.to_owned()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
// This happens in following cases:
|
// This happens in following cases:
|
||||||
// - read-only properties with #[serde(skip_deserializing)]
|
// - read-only properties with #[serde(skip_deserializing)]
|
||||||
// - internal properties
|
// - internal properties
|
||||||
props_conflict.push(full_propname)
|
props_conflict.push(full_propname)
|
||||||
} else {
|
} else {
|
||||||
props_not_found.push((None, propname));
|
props_not_found.push((None, propname));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Operation::Remove(remove_el) => {
|
Operation::Remove(remove_el) => {
|
||||||
let propname = remove_el.prop.0.0;
|
for tagname in remove_el.prop.0 {
|
||||||
match <<R::Resource as Resource>::Prop as PropName>::Names::from_str(&propname) {
|
let propname = tagname.0;
|
||||||
Ok(prop) => match resource.remove_prop(&prop) {
|
match <<R::Resource as Resource>::Prop as PropName>::Names::from_str(&propname)
|
||||||
Ok(()) => props_ok.push((None, propname)),
|
{
|
||||||
Err(Error::PropReadOnly) => props_conflict.push({
|
Ok(prop) => match resource.remove_prop(&prop) {
|
||||||
let (ns, tag) = prop.into();
|
Ok(()) => props_ok.push((None, propname)),
|
||||||
(ns.map(NamespaceOwned::from), tag.to_owned())
|
Err(Error::PropReadOnly) => props_conflict.push({
|
||||||
}),
|
let (ns, tag) = prop.into();
|
||||||
Err(err) => return Err(err.into()),
|
(ns.map(NamespaceOwned::from), tag.to_owned())
|
||||||
},
|
}),
|
||||||
// I guess removing a nonexisting property should be successful :)
|
Err(err) => return Err(err.into()),
|
||||||
Err(_) => props_ok.push((None, propname)),
|
},
|
||||||
};
|
// I guess removing a nonexisting property should be successful :)
|
||||||
|
Err(_) => props_ok.push((None, propname)),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
97
crates/frontend/js-components/lib/edit-addressbook-form.ts
Normal file
97
crates/frontend/js-components/lib/edit-addressbook-form.ts
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import { html, LitElement } from "lit";
|
||||||
|
import { customElement, property } from "lit/decorators.js";
|
||||||
|
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
||||||
|
import { escapeXml } from ".";
|
||||||
|
|
||||||
|
@customElement("edit-addressbook-form")
|
||||||
|
export class EditAddressbookForm extends LitElement {
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override createRenderRoot() {
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
@property()
|
||||||
|
principal: string = ''
|
||||||
|
@property()
|
||||||
|
addr_id: string = ''
|
||||||
|
@property()
|
||||||
|
displayname: string = ''
|
||||||
|
@property()
|
||||||
|
description: string = ''
|
||||||
|
|
||||||
|
dialog: Ref<HTMLDialogElement> = createRef()
|
||||||
|
form: Ref<HTMLFormElement> = createRef()
|
||||||
|
|
||||||
|
override render() {
|
||||||
|
return html`
|
||||||
|
<button @click=${() => this.dialog.value.showModal()}>Edit addressbook</button>
|
||||||
|
<dialog ${ref(this.dialog)}>
|
||||||
|
<h3>Create addressbook</h3>
|
||||||
|
<form @submit=${this.submit} ${ref(this.form)}>
|
||||||
|
<label>
|
||||||
|
Displayname
|
||||||
|
<input type="text" name="displayname" .value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Description
|
||||||
|
<input type="text" name="description" .value=${this.description} @change=${e => this.description = e.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
<button type="submit" @click=${event => { event.preventDefault(); this.dialog.value.close(); this.form.value.reset() }} class="cancel">Cancel</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
async submit(e: SubmitEvent) {
|
||||||
|
e.preventDefault()
|
||||||
|
if (!this.principal) {
|
||||||
|
alert("Empty principal")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.addr_id) {
|
||||||
|
alert("Empty id")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.displayname) {
|
||||||
|
alert("Empty displayname")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await fetch(`/carddav/principal/${this.principal}/${this.addr_id}`, {
|
||||||
|
method: 'PROPPATCH',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/xml'
|
||||||
|
},
|
||||||
|
body: `
|
||||||
|
<propertyupdate xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">
|
||||||
|
<set>
|
||||||
|
<prop>
|
||||||
|
<displayname>${escapeXml(this.displayname)}</displayname>
|
||||||
|
${this.description ? `<CARD:addressbook-description>${escapeXml(this.description)}</CARD:addressbook-description>` : ''}
|
||||||
|
</prop>
|
||||||
|
</set>
|
||||||
|
<remove>
|
||||||
|
<prop>
|
||||||
|
${!this.description ? '<CARD:calendar-description />' : ''}
|
||||||
|
</prop>
|
||||||
|
</remove>
|
||||||
|
</propertyupdate>
|
||||||
|
`
|
||||||
|
|
||||||
|
})
|
||||||
|
window.location.reload()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'edit-addressbook-form': EditAddressbookForm
|
||||||
|
}
|
||||||
|
}
|
||||||
128
crates/frontend/js-components/lib/edit-calendar-form.ts
Normal file
128
crates/frontend/js-components/lib/edit-calendar-form.ts
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
import { html, LitElement } from "lit";
|
||||||
|
import { customElement, property } from "lit/decorators.js";
|
||||||
|
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
||||||
|
import { escapeXml } from ".";
|
||||||
|
|
||||||
|
@customElement("edit-calendar-form")
|
||||||
|
export class EditCalendarForm extends LitElement {
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override createRenderRoot() {
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
@property()
|
||||||
|
principal: string
|
||||||
|
@property()
|
||||||
|
cal_id: string
|
||||||
|
|
||||||
|
@property()
|
||||||
|
displayname: string = ''
|
||||||
|
@property()
|
||||||
|
description: string = ''
|
||||||
|
@property()
|
||||||
|
color: string = ''
|
||||||
|
@property({
|
||||||
|
converter: {
|
||||||
|
fromAttribute: (value, _type) => new Set(value ? JSON.parse(value) : []),
|
||||||
|
toAttribute: (value, _type) => JSON.stringify(value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
components: Set<"VEVENT" | "VTODO" | "VJOURNAL"> = new Set()
|
||||||
|
|
||||||
|
dialog: Ref<HTMLDialogElement> = createRef()
|
||||||
|
form: Ref<HTMLFormElement> = createRef()
|
||||||
|
|
||||||
|
|
||||||
|
override render() {
|
||||||
|
return html`
|
||||||
|
<button @click=${() => this.dialog.value.showModal()}>Edit calendar</button>
|
||||||
|
<dialog ${ref(this.dialog)}>
|
||||||
|
<h3>Create calendar</h3>
|
||||||
|
<form @submit=${this.submit} ${ref(this.form)}>
|
||||||
|
<label>
|
||||||
|
Displayname
|
||||||
|
<input type="text" name="displayname" .value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Description
|
||||||
|
<input type="text" name="description" .value=${this.description} @change=${e => this.description = e.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Color
|
||||||
|
<input type="color" name="color" .value=${this.color} @change=${e => this.color = e.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
${["VEVENT", "VTODO", "VJOURNAL"].map(comp => html`
|
||||||
|
<label>
|
||||||
|
Support ${comp}
|
||||||
|
<input type="checkbox" value=${comp} ?checked=${this.components.has(comp)} @change=${e => e.target.checked ? this.components.add(e.target.value) : this.components.delete(e.target.value)} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
`)}
|
||||||
|
<br>
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
<button type="submit" @click=${event => { event.preventDefault(); this.dialog.value.close(); this.form.value.reset() }} class="cancel">Cancel</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
async submit(e: SubmitEvent) {
|
||||||
|
e.preventDefault()
|
||||||
|
if (!this.principal) {
|
||||||
|
alert("Empty principal")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.cal_id) {
|
||||||
|
alert("Empty id")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.displayname) {
|
||||||
|
alert("Empty displayname")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.components.size) {
|
||||||
|
alert("No calendar components selected")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await fetch(`/caldav/principal/${this.principal}/${this.cal_id}`, {
|
||||||
|
method: 'PROPPATCH',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/xml'
|
||||||
|
},
|
||||||
|
body: `
|
||||||
|
<propertyupdate xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/" xmlns:ICAL="http://apple.com/ns/ical/">
|
||||||
|
<set>
|
||||||
|
<prop>
|
||||||
|
<displayname>${escapeXml(this.displayname)}</displayname>
|
||||||
|
${this.description ? `<CAL:calendar-description>${escapeXml(this.description)}</CAL:calendar-description>` : ''}
|
||||||
|
${this.color ? `<ICAL:calendar-color>${escapeXml(this.color)}</ICAL:calendar-color>` : ''}
|
||||||
|
<CAL:supported-calendar-component-set>
|
||||||
|
${Array.from(this.components.keys()).map(comp => `<CAL:comp name="${escapeXml(comp)}" />`).join('\n')}
|
||||||
|
</CAL:supported-calendar-component-set>
|
||||||
|
</prop>
|
||||||
|
</set>
|
||||||
|
<remove>
|
||||||
|
<prop>
|
||||||
|
${!this.description ? '<CAL:calendar-description />' : ''}
|
||||||
|
${!this.color ? '<ICAL:calendar-color />' : ''}
|
||||||
|
</prop>
|
||||||
|
</remove>
|
||||||
|
</propertyupdate>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
window.location.reload()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'edit-calendar-form': EditCalendarForm
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,9 @@ export default defineConfig({
|
|||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: [
|
input: [
|
||||||
"lib/create-calendar-form.ts",
|
"lib/create-calendar-form.ts",
|
||||||
|
"lib/edit-calendar-form.ts",
|
||||||
"lib/create-addressbook-form.ts",
|
"lib/create-addressbook-form.ts",
|
||||||
|
"lib/edit-addressbook-form.ts",
|
||||||
"lib/delete-button.ts",
|
"lib/delete-button.ts",
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
109
crates/frontend/public/assets/js/edit-addressbook-form.mjs
Normal file
109
crates/frontend/public/assets/js/edit-addressbook-form.mjs
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import { i, x } from "./lit-z6_uA4GX.mjs";
|
||||||
|
import { n as n$1, t } from "./property-D0NJdseG.mjs";
|
||||||
|
import { e, n, a as escapeXml } from "./index-b86iLJlP.mjs";
|
||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
|
var __decorateClass = (decorators, target, key, kind) => {
|
||||||
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
||||||
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
||||||
|
if (decorator = decorators[i2])
|
||||||
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
||||||
|
if (kind && result) __defProp(target, key, result);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
let EditAddressbookForm = class extends i {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.principal = "";
|
||||||
|
this.addr_id = "";
|
||||||
|
this.displayname = "";
|
||||||
|
this.description = "";
|
||||||
|
this.dialog = e();
|
||||||
|
this.form = e();
|
||||||
|
}
|
||||||
|
createRenderRoot() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
return x`
|
||||||
|
<button @click=${() => this.dialog.value.showModal()}>Edit addressbook</button>
|
||||||
|
<dialog ${n(this.dialog)}>
|
||||||
|
<h3>Create addressbook</h3>
|
||||||
|
<form @submit=${this.submit} ${n(this.form)}>
|
||||||
|
<label>
|
||||||
|
Displayname
|
||||||
|
<input type="text" name="displayname" .value=${this.displayname} @change=${(e2) => this.displayname = e2.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Description
|
||||||
|
<input type="text" name="description" .value=${this.description} @change=${(e2) => this.description = e2.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
<button type="submit" @click=${(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
this.dialog.value.close();
|
||||||
|
this.form.value.reset();
|
||||||
|
}} class="cancel">Cancel</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
async submit(e2) {
|
||||||
|
e2.preventDefault();
|
||||||
|
if (!this.principal) {
|
||||||
|
alert("Empty principal");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.addr_id) {
|
||||||
|
alert("Empty id");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.displayname) {
|
||||||
|
alert("Empty displayname");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await fetch(`/carddav/principal/${this.principal}/${this.addr_id}`, {
|
||||||
|
method: "PROPPATCH",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/xml"
|
||||||
|
},
|
||||||
|
body: `
|
||||||
|
<propertyupdate xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">
|
||||||
|
<set>
|
||||||
|
<prop>
|
||||||
|
<displayname>${escapeXml(this.displayname)}</displayname>
|
||||||
|
${this.description ? `<CARD:addressbook-description>${escapeXml(this.description)}</CARD:addressbook-description>` : ""}
|
||||||
|
</prop>
|
||||||
|
</set>
|
||||||
|
<remove>
|
||||||
|
<prop>
|
||||||
|
${!this.description ? "<CARD:calendar-description />" : ""}
|
||||||
|
</prop>
|
||||||
|
</remove>
|
||||||
|
</propertyupdate>
|
||||||
|
`
|
||||||
|
});
|
||||||
|
window.location.reload();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], EditAddressbookForm.prototype, "principal", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], EditAddressbookForm.prototype, "addr_id", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], EditAddressbookForm.prototype, "displayname", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], EditAddressbookForm.prototype, "description", 2);
|
||||||
|
EditAddressbookForm = __decorateClass([
|
||||||
|
t("edit-addressbook-form")
|
||||||
|
], EditAddressbookForm);
|
||||||
|
export {
|
||||||
|
EditAddressbookForm
|
||||||
|
};
|
||||||
142
crates/frontend/public/assets/js/edit-calendar-form.mjs
Normal file
142
crates/frontend/public/assets/js/edit-calendar-form.mjs
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
import { i, x } from "./lit-z6_uA4GX.mjs";
|
||||||
|
import { n as n$1, t } from "./property-D0NJdseG.mjs";
|
||||||
|
import { e, n, a as escapeXml } from "./index-b86iLJlP.mjs";
|
||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
|
var __decorateClass = (decorators, target, key, kind) => {
|
||||||
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
||||||
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
||||||
|
if (decorator = decorators[i2])
|
||||||
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
||||||
|
if (kind && result) __defProp(target, key, result);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
let EditCalendarForm = class extends i {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.displayname = "";
|
||||||
|
this.description = "";
|
||||||
|
this.color = "";
|
||||||
|
this.components = /* @__PURE__ */ new Set();
|
||||||
|
this.dialog = e();
|
||||||
|
this.form = e();
|
||||||
|
}
|
||||||
|
createRenderRoot() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
return x`
|
||||||
|
<button @click=${() => this.dialog.value.showModal()}>Edit calendar</button>
|
||||||
|
<dialog ${n(this.dialog)}>
|
||||||
|
<h3>Create calendar</h3>
|
||||||
|
<form @submit=${this.submit} ${n(this.form)}>
|
||||||
|
<label>
|
||||||
|
Displayname
|
||||||
|
<input type="text" name="displayname" .value=${this.displayname} @change=${(e2) => this.displayname = e2.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Description
|
||||||
|
<input type="text" name="description" .value=${this.description} @change=${(e2) => this.description = e2.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Color
|
||||||
|
<input type="color" name="color" .value=${this.color} @change=${(e2) => this.color = e2.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
${["VEVENT", "VTODO", "VJOURNAL"].map((comp) => x`
|
||||||
|
<label>
|
||||||
|
Support ${comp}
|
||||||
|
<input type="checkbox" value=${comp} ?checked=${this.components.has(comp)} @change=${(e2) => e2.target.checked ? this.components.add(e2.target.value) : this.components.delete(e2.target.value)} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
`)}
|
||||||
|
<br>
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
<button type="submit" @click=${(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
this.dialog.value.close();
|
||||||
|
this.form.value.reset();
|
||||||
|
}} class="cancel">Cancel</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
async submit(e2) {
|
||||||
|
e2.preventDefault();
|
||||||
|
if (!this.principal) {
|
||||||
|
alert("Empty principal");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.cal_id) {
|
||||||
|
alert("Empty id");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.displayname) {
|
||||||
|
alert("Empty displayname");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.components.size) {
|
||||||
|
alert("No calendar components selected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await fetch(`/caldav/principal/${this.principal}/${this.cal_id}`, {
|
||||||
|
method: "PROPPATCH",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/xml"
|
||||||
|
},
|
||||||
|
body: `
|
||||||
|
<propertyupdate xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/" xmlns:ICAL="http://apple.com/ns/ical/">
|
||||||
|
<set>
|
||||||
|
<prop>
|
||||||
|
<displayname>${escapeXml(this.displayname)}</displayname>
|
||||||
|
${this.description ? `<CAL:calendar-description>${escapeXml(this.description)}</CAL:calendar-description>` : ""}
|
||||||
|
${this.color ? `<ICAL:calendar-color>${escapeXml(this.color)}</ICAL:calendar-color>` : ""}
|
||||||
|
<CAL:supported-calendar-component-set>
|
||||||
|
${Array.from(this.components.keys()).map((comp) => `<CAL:comp name="${escapeXml(comp)}" />`).join("\n")}
|
||||||
|
</CAL:supported-calendar-component-set>
|
||||||
|
</prop>
|
||||||
|
</set>
|
||||||
|
<remove>
|
||||||
|
<prop>
|
||||||
|
${!this.description ? "<CAL:calendar-description />" : ""}
|
||||||
|
${!this.color ? "<ICAL:calendar-color />" : ""}
|
||||||
|
</prop>
|
||||||
|
</remove>
|
||||||
|
</propertyupdate>
|
||||||
|
`
|
||||||
|
});
|
||||||
|
window.location.reload();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], EditCalendarForm.prototype, "principal", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], EditCalendarForm.prototype, "cal_id", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], EditCalendarForm.prototype, "displayname", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], EditCalendarForm.prototype, "description", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], EditCalendarForm.prototype, "color", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1({
|
||||||
|
converter: {
|
||||||
|
fromAttribute: (value, _type) => new Set(value ? JSON.parse(value) : []),
|
||||||
|
toAttribute: (value, _type) => JSON.stringify(value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
], EditCalendarForm.prototype, "components", 2);
|
||||||
|
EditCalendarForm = __decorateClass([
|
||||||
|
t("edit-calendar-form")
|
||||||
|
], EditCalendarForm);
|
||||||
|
export {
|
||||||
|
EditCalendarForm
|
||||||
|
};
|
||||||
@@ -224,15 +224,15 @@ ul.collection-list {
|
|||||||
min-height: 80px;
|
min-height: 80px;
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
". . color-chip"
|
". color-chip"
|
||||||
"title comps color-chip"
|
"title color-chip"
|
||||||
"description description color-chip"
|
"description color-chip"
|
||||||
"subscription-url subscription-url color-chip"
|
"subscription-url color-chip"
|
||||||
"metadata metadata color-chip"
|
"metadata color-chip"
|
||||||
"actions actions color-chip"
|
"actions color-chip"
|
||||||
". . color-chip";
|
". color-chip";
|
||||||
grid-template-rows: 12px auto auto auto auto auto 12px;
|
grid-template-rows: 12px auto auto auto auto auto 12px;
|
||||||
grid-template-columns: min-content auto 80px;
|
grid-template-columns: auto 80px;
|
||||||
row-gap: 4px;
|
row-gap: 4px;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@@ -260,7 +260,7 @@ ul.collection-list {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.comps {
|
.comps {
|
||||||
grid-area: comps;
|
display: inline;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
margin: 0 2px;
|
margin: 0 2px;
|
||||||
@@ -293,6 +293,7 @@ ul.collection-list {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
|
pointer-events: all;
|
||||||
grid-area: actions;
|
grid-area: actions;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -16,6 +16,12 @@
|
|||||||
method="GET">
|
method="GET">
|
||||||
<button type="submit">Download</button>
|
<button type="submit">Download</button>
|
||||||
</form>
|
</form>
|
||||||
|
<edit-addressbook-form
|
||||||
|
principal="{{ addressbook.principal }}"
|
||||||
|
addr_id="{{ addressbook.id }}"
|
||||||
|
displayname="{{ addressbook.displayname.as_deref().unwrap_or_default() }}"
|
||||||
|
description="{{ addressbook.description.as_deref().unwrap_or_default() }}"
|
||||||
|
></edit-addressbook-form>
|
||||||
<delete-button trash
|
<delete-button trash
|
||||||
href="/carddav/principal/{{ addressbook.principal }}/{{ addressbook.id }}"></delete-button>
|
href="/carddav/principal/{{ addressbook.principal }}/{{ addressbook.id }}"></delete-button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
<span class="title">
|
<span class="title">
|
||||||
{%- if calendar.principal != user.id -%}{{ calendar.principal }}/{%- endif -%}
|
{%- if calendar.principal != user.id -%}{{ calendar.principal }}/{%- endif -%}
|
||||||
{{ calendar.displayname.to_owned().unwrap_or(calendar.id.to_owned()) }}
|
{{ calendar.displayname.to_owned().unwrap_or(calendar.id.to_owned()) }}
|
||||||
|
<div class="comps">
|
||||||
|
{% for comp in calendar.components %}
|
||||||
|
<span>{{ comp }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
</span>
|
</span>
|
||||||
<div class="comps">
|
|
||||||
{% for comp in calendar.components %}
|
|
||||||
<span>{{ comp }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
<span class="description">
|
<span class="description">
|
||||||
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
|
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
|
||||||
</span>
|
</span>
|
||||||
@@ -25,6 +25,14 @@
|
|||||||
<button type="submit">Download</button>
|
<button type="submit">Download</button>
|
||||||
</form>
|
</form>
|
||||||
{% if !calendar.id.starts_with("_birthdays_") %}
|
{% if !calendar.id.starts_with("_birthdays_") %}
|
||||||
|
<edit-calendar-form
|
||||||
|
principal="{{ calendar.principal }}"
|
||||||
|
cal_id="{{ calendar.id }}"
|
||||||
|
displayname="{{ calendar.displayname.as_deref().unwrap_or_default() }}"
|
||||||
|
description="{{ calendar.description.as_deref().unwrap_or_default() }}"
|
||||||
|
color="{{ calendar.color.as_deref().unwrap_or_default() }}"
|
||||||
|
components="{{ calendar.components | json }}"
|
||||||
|
></edit-calendar-form>
|
||||||
<delete-button trash href="/caldav/principal/{{ calendar.principal }}/{{ calendar.id }}"></delete-button>
|
<delete-button trash href="/caldav/principal/{{ calendar.principal }}/{{ calendar.id }}"></delete-button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
@@ -49,12 +57,12 @@
|
|||||||
<span class="title">
|
<span class="title">
|
||||||
{%- if calendar.principal != user.id -%}{{ calendar.principal }}/{%- endif -%}
|
{%- if calendar.principal != user.id -%}{{ calendar.principal }}/{%- endif -%}
|
||||||
{{ calendar.displayname.to_owned().unwrap_or(calendar.id.to_owned()) }}
|
{{ calendar.displayname.to_owned().unwrap_or(calendar.id.to_owned()) }}
|
||||||
|
<div class="comps">
|
||||||
|
{% for comp in calendar.components %}
|
||||||
|
<span>{{ comp }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
</span>
|
</span>
|
||||||
<div class="comps">
|
|
||||||
{% for comp in calendar.components %}
|
|
||||||
<span>{{ comp }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
<span class="description">
|
<span class="description">
|
||||||
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
|
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<!-- Adapted from https://iconoir.com/ -->
|
<!-- Adapted from https://iconoir.com/ -->
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon">
|
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon">
|
||||||
<path d="M15 4V2M15 4V6M15 4H10.5M3 10V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V10H3Z" stroke-linecap="round" stroke-linejoin="round"></path>
|
<path d="M15 4V2M15 4V6M15 4H10.5M3 10V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V10H3Z" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||||
<path d="M3 10V6C3 4.89543 3.89543 4 5 4H7" stroke-linecap="round" stroke-linejoin="round"></path>
|
<path d="M3 10V6C3 4.89543 3.89543 4 5 4H7" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 647 B After Width: | Height: | Size: 608 B |
@@ -1,5 +1,4 @@
|
|||||||
<!-- Adapted from https://iconoir.com/ -->
|
<!-- Adapted from https://iconoir.com/ -->
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon">
|
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon">
|
||||||
<path d="M1 20V19C1 15.134 4.13401 12 8 12V12C11.866 12 15 15.134 15 19V20" stroke-linecap="round"></path>
|
<path d="M1 20V19C1 15.134 4.13401 12 8 12V12C11.866 12 15 15.134 15 19V20" stroke-linecap="round"></path>
|
||||||
<path d="M13 14V14C13 11.2386 15.2386 9 18 9V9C20.7614 9 23 11.2386 23 14V14.5" stroke-linecap="round"></path>
|
<path d="M13 14V14C13 11.2386 15.2386 9 18 9V9C20.7614 9 23 11.2386 23 14V14.5" stroke-linecap="round"></path>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 778 B After Width: | Height: | Size: 739 B |
@@ -1,5 +1,4 @@
|
|||||||
<!-- Adapted from https://iconoir.com/ -->
|
<!-- Adapted from https://iconoir.com/ -->
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon">
|
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon">
|
||||||
<path d="M5 20V19C5 15.134 8.13401 12 12 12V12C15.866 12 19 15.134 19 19V20" stroke-linecap="round" stroke-linejoin="round"></path>
|
<path d="M5 20V19C5 15.134 8.13401 12 12 12V12C15.866 12 19 15.134 19 19V20" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||||
<path d="M12 12C14.2091 12 16 10.2091 16 8C16 5.79086 14.2091 4 12 4C9.79086 4 8 5.79086 8 8C8 10.2091 9.79086 12 12 12Z" stroke-linecap="round" stroke-linejoin="round"></path>
|
<path d="M12 12C14.2091 12 16 10.2091 16 8C16 5.79086 14.2091 4 12 4C9.79086 4 8 5.79086 8 8C8 10.2091 9.79086 12 12 12Z" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 515 B After Width: | Height: | Size: 476 B |
@@ -22,9 +22,9 @@
|
|||||||
<div id="app">
|
<div id="app">
|
||||||
{% block content %}<p>Placeholder</p>{% endblock %}
|
{% block content %}<p>Placeholder</p>{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
<footer>
|
||||||
|
<a href="{{ env!("CARGO_PKG_REPOSITORY") }}" target="_blank">RustiCal {{ env!("CARGO_PKG_VERSION") }}</a>
|
||||||
|
<a href="/frontend/assets/licenses.html" target="_blank">Open Source Licenses</a>
|
||||||
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
<footer>
|
|
||||||
<a href="{{ env!("CARGO_PKG_REPOSITORY") }}" target="_blank">RustiCal {{ env!("CARGO_PKG_VERSION") }}</a>
|
|
||||||
<a href="/frontend/assets/licenses.html" target="_blank">Open Source Licenses</a>
|
|
||||||
</footer>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
window.rusticalUser = JSON.parse(document.querySelector('#data-rustical-user').innerHTML)
|
window.rusticalUser = JSON.parse(document.querySelector('#data-rustical-user').innerHTML)
|
||||||
</script>
|
</script>
|
||||||
<script type="module" src="/frontend/assets/js/create-calendar-form.mjs" async></script>
|
<script type="module" src="/frontend/assets/js/create-calendar-form.mjs" async></script>
|
||||||
|
<script type="module" src="/frontend/assets/js/edit-calendar-form.mjs" async></script>
|
||||||
<script type="module" src="/frontend/assets/js/create-addressbook-form.mjs" async></script>
|
<script type="module" src="/frontend/assets/js/create-addressbook-form.mjs" async></script>
|
||||||
|
<script type="module" src="/frontend/assets/js/edit-addressbook-form.mjs" async></script>
|
||||||
<script type="module" src="/frontend/assets/js/delete-button.mjs" async></script>
|
<script type="module" src="/frontend/assets/js/delete-button.mjs" async></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block header_center %}
|
{% block header_center %}
|
||||||
|
|||||||
@@ -141,15 +141,14 @@ async fn unauthorized_handler(mut request: Request, next: Next) -> Response {
|
|||||||
return resp
|
return resp
|
||||||
.body(Body::new(format!(
|
.body(Body::new(format!(
|
||||||
r#"<!Doctype html>
|
r#"<!Doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="refresh" content="1; url={login_url}" />
|
<meta http-equiv="refresh" content="1; url={login_url}" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
Unauthorized, redirecting to <a href="{login_url}">login page</a>
|
Unauthorized, redirecting to <a href="{login_url}">login page</a>
|
||||||
</body>
|
</body>
|
||||||
<html>
|
</html>"#,
|
||||||
"#,
|
|
||||||
)))
|
)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ pub async fn route_post_app_token<AP: AuthenticationProvider>(
|
|||||||
token_name: name,
|
token_name: name,
|
||||||
account_description: format!("{}@{}", &user.id, &hostname),
|
account_description: format!("{}@{}", &user.id, &hostname),
|
||||||
hostname: hostname.clone(),
|
hostname: hostname.clone(),
|
||||||
caldav_principal_url: format!("https://{hostname}/caldav/principal/{user_id}"),
|
caldav_principal_url: format!("https://{hostname}/caldav-compat/principal/{user_id}"),
|
||||||
carddav_principal_url: format!("https://{hostname}/carddav/principal/{user_id}"),
|
carddav_principal_url: format!("https://{hostname}/carddav/principal/{user_id}"),
|
||||||
user: user.id.to_owned(),
|
user: user.id.to_owned(),
|
||||||
token,
|
token,
|
||||||
@@ -79,13 +79,12 @@ pub async fn route_post_app_token<AP: AuthenticationProvider>(
|
|||||||
hdrs.typed_insert(
|
hdrs.typed_insert(
|
||||||
ContentType::from_str("application/x-apple-aspen-config; charset=utf-8").unwrap(),
|
ContentType::from_str("application/x-apple-aspen-config; charset=utf-8").unwrap(),
|
||||||
);
|
);
|
||||||
let filename = format!("rustical-{}.mobileconfig", user_id);
|
let filename = format!("rustical-{user_id}.mobileconfig");
|
||||||
let filename = utf8_percent_encode(&filename, CONTROLS);
|
let filename = utf8_percent_encode(&filename, CONTROLS);
|
||||||
hdrs.insert(
|
hdrs.insert(
|
||||||
header::CONTENT_DISPOSITION,
|
header::CONTENT_DISPOSITION,
|
||||||
HeaderValue::from_str(&format!(
|
HeaderValue::from_str(&format!(
|
||||||
"attachement; filename*=UTF-8''{} filename={}",
|
"attachement; filename*=UTF-8''{filename} filename={filename}",
|
||||||
filename, filename
|
|
||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ use std::{collections::HashMap, io::BufReader};
|
|||||||
#[derive(Debug, Clone, Serialize, PartialEq, Eq, Display)]
|
#[derive(Debug, Clone, Serialize, PartialEq, Eq, Display)]
|
||||||
// specified in https://datatracker.ietf.org/doc/html/rfc5545#section-3.6
|
// specified in https://datatracker.ietf.org/doc/html/rfc5545#section-3.6
|
||||||
pub enum CalendarObjectType {
|
pub enum CalendarObjectType {
|
||||||
|
#[serde(rename = "VEVENT")]
|
||||||
Event = 0,
|
Event = 0,
|
||||||
|
#[serde(rename = "VTODO")]
|
||||||
Todo = 1,
|
Todo = 1,
|
||||||
|
#[serde(rename = "VJOURNAL")]
|
||||||
Journal = 2,
|
Journal = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ impl Enum {
|
|||||||
quote! {
|
quote! {
|
||||||
impl #impl_generics ::rustical_xml::XmlDeserialize for #name #type_generics #where_clause {
|
impl #impl_generics ::rustical_xml::XmlDeserialize for #name #type_generics #where_clause {
|
||||||
fn deserialize<R: ::std::io::BufRead>(
|
fn deserialize<R: ::std::io::BufRead>(
|
||||||
reader: &mut quick_xml::NsReader<R>,
|
reader: &mut ::quick_xml::NsReader<R>,
|
||||||
start: &quick_xml::events::BytesStart,
|
start: &::quick_xml::events::BytesStart,
|
||||||
empty: bool
|
empty: bool
|
||||||
) -> Result<Self, rustical_xml::XmlError> {
|
) -> Result<Self, rustical_xml::XmlError> {
|
||||||
#(#variant_branches);*
|
#(#variant_branches);*
|
||||||
@@ -37,8 +37,8 @@ impl Enum {
|
|||||||
quote! {
|
quote! {
|
||||||
impl #impl_generics ::rustical_xml::XmlDeserialize for #name #type_generics #where_clause {
|
impl #impl_generics ::rustical_xml::XmlDeserialize for #name #type_generics #where_clause {
|
||||||
fn deserialize<R: std::io::BufRead>(
|
fn deserialize<R: std::io::BufRead>(
|
||||||
reader: &mut quick_xml::NsReader<R>,
|
reader: &mut ::quick_xml::NsReader<R>,
|
||||||
start: &quick_xml::events::BytesStart,
|
start: &::quick_xml::events::BytesStart,
|
||||||
empty: bool
|
empty: bool
|
||||||
) -> Result<Self, rustical_xml::XmlError> {
|
) -> Result<Self, rustical_xml::XmlError> {
|
||||||
let (_ns, name) = reader.resolve_element(start.name());
|
let (_ns, name) = reader.resolve_element(start.name());
|
||||||
|
|||||||
@@ -118,8 +118,8 @@ impl NamedStruct {
|
|||||||
quote! {
|
quote! {
|
||||||
impl #impl_generics ::rustical_xml::XmlDeserialize for #ident #type_generics #where_clause {
|
impl #impl_generics ::rustical_xml::XmlDeserialize for #ident #type_generics #where_clause {
|
||||||
fn deserialize<R: ::std::io::BufRead>(
|
fn deserialize<R: ::std::io::BufRead>(
|
||||||
reader: &mut quick_xml::NsReader<R>,
|
reader: &mut ::quick_xml::NsReader<R>,
|
||||||
start: &quick_xml::events::BytesStart,
|
start: &::quick_xml::events::BytesStart,
|
||||||
empty: bool
|
empty: bool
|
||||||
) -> Result<Self, rustical_xml::XmlError> {
|
) -> Result<Self, rustical_xml::XmlError> {
|
||||||
use quick_xml::events::Event;
|
use quick_xml::events::Event;
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ a CalDAV/CardDAV server
|
|||||||
|
|
||||||
- easy to backup, everything saved in one SQLite database
|
- easy to backup, everything saved in one SQLite database
|
||||||
- also export feature in the frontend
|
- also export feature in the frontend
|
||||||
- [WebDAV Push](https://github.com/bitfireAT/webdav-push/) support, so near-instant synchronisation to DAVx5
|
- **[WebDAV Push](https://github.com/bitfireAT/webdav-push/)** support, so near-instant synchronisation to DAVx5
|
||||||
- lightweight (the container image contains only one binary)
|
- lightweight (the container image contains only one binary)
|
||||||
- adequately fast (I'd love to say blazingly fast™ :fire: but I don't have any benchmarks)
|
- adequately fast (I'd love to say blazingly fast™ :fire: but I don't have any benchmarks)
|
||||||
- deleted calendars are recoverable
|
- deleted calendars are recoverable
|
||||||
- Nextcloud login flow (In DAVx5 you can login through the Nextcloud flow and automatically generate an app token)
|
- Nextcloud login flow (In DAVx5 you can login through the Nextcloud flow and automatically generate an app token)
|
||||||
- Apple configuration profiles (skip copy-pasting passwords and instead generate the configuration in the frontend)
|
- Apple configuration profiles (skip copy-pasting passwords and instead generate the configuration in the frontend)
|
||||||
- [OpenID Connect](setup/oidc.md) support (with option to disable password login)
|
- **[OpenID Connect](setup/oidc.md)** support (with option to disable password login)
|
||||||
|
- Group-based **sharing**
|
||||||
|
|
||||||
## Tested Clients
|
## Tested Clients
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ docker run \
|
|||||||
1. Mount config file
|
1. Mount config file
|
||||||
2. Alternatively specify configuration using environment variables
|
2. Alternatively specify configuration using environment variables
|
||||||
|
|
||||||
|
!!! info
|
||||||
|
Note that you are expected to run RustiCal behind a reverse proxy with HTTPS. (The frontend will only work on non-localhost addresses with https) and clients like Apple Calendar also expect HTTPS.
|
||||||
|
|
||||||
## User management
|
## User management
|
||||||
|
|
||||||
In case you already have an OIDC server set up, see [here](setup/oidc.md) how to set up OIDC login and maybe skip this section.
|
In case you already have an OIDC server set up, see [here](setup/oidc.md) how to set up OIDC login and maybe skip this section.
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ Following resources are available.
|
|||||||
# Calendar home
|
# Calendar home
|
||||||
/caldav/principal/<user_id>/<calendar_id>
|
/caldav/principal/<user_id>/<calendar_id>
|
||||||
/caldav/principal/<user_id>/_birthdays_<addressbook_id>
|
/caldav/principal/<user_id>/_birthdays_<addressbook_id>
|
||||||
|
|
||||||
|
# CalDAV root
|
||||||
|
/caldav-compat
|
||||||
|
/caldav-compat/principal...
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -29,6 +33,14 @@ Following resources are available.
|
|||||||
|
|
||||||
Authenticate with HTTP Basic authentication using your user id and a generated app token.
|
Authenticate with HTTP Basic authentication using your user id and a generated app token.
|
||||||
|
|
||||||
|
## `/caldav` vs `/caldav-compat` (relevant for group sharing)
|
||||||
|
|
||||||
|
To discover shared calendars the `calendar-home-set` property is used to list all principals the user has access to.
|
||||||
|
However, some clients don't support `calendar-home-set` containing multiple paths (e.g. Apple Calendar).
|
||||||
|
|
||||||
|
As a workaround `/caldav-compat` offers the same endpoints as `/caldav` with the only difference being that it does not return all calendar homes in `calendar-home-set`.
|
||||||
|
This means that clients under this path will probably not auto-discover group calendars so you can instead add them one-by-one using the principal path `/caldav-compat/principal/<principal_id>`.
|
||||||
|
|
||||||
## DAVx5
|
## DAVx5
|
||||||
|
|
||||||
You can set up DAVx5 through the Nextcloud login flow. Collections including group collections will automatically be discovered.
|
You can set up DAVx5 through the Nextcloud login flow. Collections including group collections will automatically be discovered.
|
||||||
@@ -37,24 +49,32 @@ You can set up DAVx5 through the Nextcloud login flow. Collections including gro
|
|||||||
|
|
||||||
You can download a configuration profile from the frontend in the app token section.
|
You can download a configuration profile from the frontend in the app token section.
|
||||||
|
|
||||||
**Limitation**: Group collections are not automatically discovered, for these you need to set up separate CalDAV configurations using the corresponding principal homes (but your own user id).
|
**Note**: Since Apple Calendar does not properly support the `calendar-home-set` property the `/caldav-compat` endpoints should be used.
|
||||||
|
That also means that Apple Calendar is not able to automatically discover group collections so in that case you'll have to manually add all principals with `/caldav-compat/principal/<principal_id>`.
|
||||||
|
|
||||||
## Evolution
|
## Evolution
|
||||||
|
|
||||||
Set up a collection account in the account settings.
|
Set up a collection account in the account settings.
|
||||||
|
Evolution correctly uses all calendar homes so group collections work properly.
|
||||||
**Limitation**: Group collections are not discovered. It seems as if currently you have to add each group collection manually.
|
|
||||||
|
|
||||||
## Home Assistant CalDAV integration
|
## Home Assistant CalDAV integration
|
||||||
|
|
||||||
|
The underlying library `python-caldav` does not support multiple calendar homes so you should use the `/caldav-compat` endpoints.
|
||||||
|
|
||||||
As URL specify
|
As URL specify
|
||||||
|
|
||||||
```
|
```
|
||||||
https://<your-host>/.well-known/caldav
|
https://<your-host>/caldav-compat
|
||||||
```
|
```
|
||||||
|
|
||||||
For goup collections explicitly specify
|
For group collections explicitly specify
|
||||||
|
|
||||||
```
|
```
|
||||||
https://<your-host>/caldav/principal/<principal>
|
https://<your-host>/caldav-compat/principal/<principal>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Thunderbird
|
||||||
|
|
||||||
|
- Go to `New Account -> Calendar -> On The Network`
|
||||||
|
- Specify the root path of RustiCal
|
||||||
|
- Thunderbird will properly discover group calendars
|
||||||
|
|||||||
27
src/app.rs
27
src/app.rs
@@ -2,8 +2,9 @@ use crate::config::NextcloudLoginConfig;
|
|||||||
use axum::Router;
|
use axum::Router;
|
||||||
use axum::body::Body;
|
use axum::body::Body;
|
||||||
use axum::extract::Request;
|
use axum::extract::Request;
|
||||||
use axum::response::Response;
|
use axum::response::{Redirect, Response};
|
||||||
use axum::routing::options;
|
use axum::routing::{any, options};
|
||||||
|
use axum_extra::TypedHeader;
|
||||||
use headers::{HeaderMapExt, UserAgent};
|
use headers::{HeaderMapExt, UserAgent};
|
||||||
use http::{HeaderValue, StatusCode};
|
use http::{HeaderValue, StatusCode};
|
||||||
use rustical_caldav::caldav_router;
|
use rustical_caldav::caldav_router;
|
||||||
@@ -47,7 +48,29 @@ pub fn make_app<AS: AddressbookStore, CS: CalendarStore, S: SubscriptionStore>(
|
|||||||
auth_provider.clone(),
|
auth_provider.clone(),
|
||||||
combined_cal_store.clone(),
|
combined_cal_store.clone(),
|
||||||
subscription_store.clone(),
|
subscription_store.clone(),
|
||||||
|
false,
|
||||||
))
|
))
|
||||||
|
.merge(caldav_router(
|
||||||
|
"/caldav-compat",
|
||||||
|
auth_provider.clone(),
|
||||||
|
combined_cal_store.clone(),
|
||||||
|
subscription_store.clone(),
|
||||||
|
true,
|
||||||
|
))
|
||||||
|
.route(
|
||||||
|
"/.well-known/caldav",
|
||||||
|
any(async |TypedHeader(ua): TypedHeader<UserAgent>| {
|
||||||
|
if ua.as_str().contains("remindd") {
|
||||||
|
// remindd is an Apple Calendar User Agent
|
||||||
|
// Even when explicitly configuring a principal URL in Apple Calendar Apple
|
||||||
|
// will not respect that configuration but call /.well-known/caldav,
|
||||||
|
// so sadly we have to do this user-agent filtering. :(
|
||||||
|
// (I should have never gotten an Apple device)
|
||||||
|
return Redirect::permanent("/caldav-compat");
|
||||||
|
}
|
||||||
|
Redirect::permanent("/caldav")
|
||||||
|
}),
|
||||||
|
)
|
||||||
.merge(carddav_router(
|
.merge(carddav_router(
|
||||||
"/carddav",
|
"/carddav",
|
||||||
auth_provider.clone(),
|
auth_provider.clone(),
|
||||||
|
|||||||
Reference in New Issue
Block a user