mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 21:42:34 +00:00
Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7138b5f8c | ||
|
|
84af24a2b7 | ||
|
|
4bd6271e33 | ||
|
|
d817c1384c | ||
|
|
f8abc22e63 | ||
|
|
b7b5ca4f91 | ||
|
|
caca2d28ed | ||
|
|
3db2f13c1b | ||
|
|
db01024682 | ||
|
|
b2f15f2d77 | ||
|
|
89dd94904b | ||
|
|
5d0263abc1 | ||
|
|
0ef3e19bd3 | ||
|
|
44912057fc | ||
|
|
c4f613a803 | ||
|
|
eb8f301e45 | ||
|
|
d59ae25eba | ||
|
|
d4daa35df6 | ||
|
|
ea43876410 | ||
|
|
18af1b9aa2 | ||
|
|
e69c75102c | ||
|
|
09f1bd20ae | ||
|
|
72f970a857 | ||
|
|
08c250657e | ||
|
|
b8ef2f1ba2 | ||
|
|
c8adf60f48 | ||
|
|
507cb77e85 | ||
|
|
8881ea2a05 | ||
|
|
119e17a8e1 | ||
|
|
8b01c5388b | ||
|
|
35f423d4ca | ||
|
|
a827b40b47 | ||
|
|
16f9ce6f38 | ||
|
|
34839aa2ed | ||
|
|
2724154ed3 | ||
|
|
c490c413ec | ||
|
|
994864c6ef | ||
|
|
92fd28cdbb | ||
|
|
d7e871f0e6 | ||
|
|
a0fc073bd2 | ||
|
|
c8dffb4f9e | ||
|
|
b6d1899636 | ||
|
|
81f1767efa | ||
|
|
54eb9ddfcc | ||
|
|
60a0f16557 | ||
|
|
e4f188d299 | ||
|
|
69163404a1 | ||
|
|
0b7cfea79c | ||
|
|
455b4c405f | ||
|
|
2774d092ac | ||
|
|
32b616fd75 | ||
|
|
b02f7c427a | ||
|
|
eae8e7d768 | ||
|
|
105718a4ca | ||
|
|
0e68f1bdce | ||
|
|
aa744fcea2 | ||
|
|
4a51a669cd | ||
|
|
07fca05e50 | ||
|
|
509cc8d7a1 | ||
|
|
4134ab0520 | ||
|
|
d8803a38a2 | ||
|
|
b5bff08b08 | ||
|
|
3ca02d9792 | ||
|
|
ee2cc2174c |
454
Cargo.lock
generated
454
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
|||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.4.9"
|
version = "0.7.0"
|
||||||
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"
|
||||||
@@ -96,7 +96,7 @@ strum_macros = "0.27"
|
|||||||
serde_json = { version = "1.0", features = ["raw_value"] }
|
serde_json = { version = "1.0", features = ["raw_value"] }
|
||||||
sqlx-sqlite = { version = "0.8", features = ["bundled"] }
|
sqlx-sqlite = { version = "0.8", features = ["bundled"] }
|
||||||
ical = { version = "0.11", features = ["generator", "serde"] }
|
ical = { version = "0.11", features = ["generator", "serde"] }
|
||||||
toml = "0.8"
|
toml = "0.9"
|
||||||
tower = "0.5"
|
tower = "0.5"
|
||||||
tower-http = { version = "0.6", features = [
|
tower-http = { version = "0.6", features = [
|
||||||
"trace",
|
"trace",
|
||||||
@@ -126,7 +126,7 @@ syn = { version = "2.0", features = ["full"] }
|
|||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
heck = "0.5"
|
heck = "0.5"
|
||||||
darling = "0.20"
|
darling = "0.21"
|
||||||
reqwest = { version = "0.12", features = [
|
reqwest = { version = "0.12", features = [
|
||||||
"rustls-tls",
|
"rustls-tls",
|
||||||
"charset",
|
"charset",
|
||||||
@@ -135,6 +135,7 @@ reqwest = { version = "0.12", features = [
|
|||||||
openidconnect = "4.0"
|
openidconnect = "4.0"
|
||||||
clap = { version = "4.5", features = ["derive", "env"] }
|
clap = { version = "4.5", features = ["derive", "env"] }
|
||||||
matchit-serde = { git = "https://github.com/lennart-k/matchit-serde", rev = "f0591d13" }
|
matchit-serde = { git = "https://github.com/lennart-k/matchit-serde", rev = "f0591d13" }
|
||||||
|
vtimezones-rs = "0.1"
|
||||||
ece = { version = "2.3", default-features = false, features = [
|
ece = { version = "2.3", default-features = false, features = [
|
||||||
"backend-openssl",
|
"backend-openssl",
|
||||||
] }
|
] }
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
22
compose.oidc.yml
Normal file
22
compose.oidc.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
services:
|
||||||
|
rustical:
|
||||||
|
image: ghcr.io/lennart-k/rustical:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
RUSTICAL_FRONTEND__ALLOW_PASSWORD_LOGIN: "false"
|
||||||
|
RUSTICAL_OIDC__NAME: "Authelia"
|
||||||
|
RUSTICAL_OIDC__ISSUER: "https://auth.example.com"
|
||||||
|
RUSTICAL_OIDC__CLIENT_ID: "{{ rustical_oidc_client_id }}"
|
||||||
|
RUSTICAL_OIDC__CLIENT_SECRET: "{{ rustical_oidc_client_secret }}"
|
||||||
|
RUSTICAL_OIDC__CLAIM_USERID: "preferred_username"
|
||||||
|
RUSTICAL_OIDC__SCOPES: '["openid", "profile", "groups"]'
|
||||||
|
RUSTICAL_OIDC__REQUIRE_GROUP: "app:rustical" # optional
|
||||||
|
RUSTICAL_OIDC__ALLOW_SIGN_UP: "true"
|
||||||
|
volumes:
|
||||||
|
- data:/var/lib/rustical
|
||||||
|
# Here you probably want to you expose instead
|
||||||
|
ports:
|
||||||
|
- 4000:4000
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
data:
|
||||||
@@ -42,3 +42,4 @@ headers.workspace = true
|
|||||||
tower-http.workspace = true
|
tower-http.workspace = true
|
||||||
strum.workspace = true
|
strum.workspace = true
|
||||||
strum_macros.workspace = true
|
strum_macros.workspace = true
|
||||||
|
vtimezones-rs.workspace = true
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use axum::body::Body;
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use axum::{extract::Path, response::Response};
|
use axum::{extract::Path, response::Response};
|
||||||
use headers::{ContentType, HeaderMapExt};
|
use headers::{ContentType, HeaderMapExt};
|
||||||
use http::{HeaderValue, StatusCode, header};
|
use http::{HeaderValue, Method, StatusCode, header};
|
||||||
use ical::generator::{Emitter, IcalCalendarBuilder};
|
use ical::generator::{Emitter, IcalCalendarBuilder};
|
||||||
use ical::property::Property;
|
use ical::property::Property;
|
||||||
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
||||||
@@ -19,6 +19,7 @@ pub async fn route_get<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
Path((principal, calendar_id)): Path<(String, String)>,
|
Path((principal, calendar_id)): Path<(String, String)>,
|
||||||
State(CalendarResourceService { cal_store, .. }): State<CalendarResourceService<C, S>>,
|
State(CalendarResourceService { cal_store, .. }): State<CalendarResourceService<C, S>>,
|
||||||
user: Principal,
|
user: Principal,
|
||||||
|
method: Method,
|
||||||
) -> Result<Response, Error> {
|
) -> Result<Response, Error> {
|
||||||
if !user.is_principal(&principal) {
|
if !user.is_principal(&principal) {
|
||||||
return Err(crate::Error::Unauthorized);
|
return Err(crate::Error::Unauthorized);
|
||||||
@@ -96,5 +97,9 @@ pub async fn route_get<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
if matches!(method, Method::HEAD) {
|
||||||
|
Ok(resp.body(Body::empty()).unwrap())
|
||||||
|
} else {
|
||||||
Ok(resp.body(Body::new(ical_calendar.generate())).unwrap())
|
Ok(resp.body(Body::new(ical_calendar.generate())).unwrap())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -82,12 +82,25 @@ pub async fn route_mkcalendar<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
request.displayname = None
|
request.displayname = None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut timezone = request.calendar_timezone;
|
||||||
|
if let Some(tzid) = request.calendar_timezone_id.as_ref() {
|
||||||
|
// Validate timezone id and set timezone accordingly
|
||||||
|
timezone = Some(
|
||||||
|
vtimezones_rs::VTIMEZONES
|
||||||
|
.get(tzid)
|
||||||
|
.ok_or(rustical_dav::Error::BadRequest(format!(
|
||||||
|
"Invalid timezone-id: {tzid}"
|
||||||
|
)))?
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let calendar = Calendar {
|
let calendar = Calendar {
|
||||||
id: cal_id.to_owned(),
|
id: cal_id.to_owned(),
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
order: request.calendar_order.unwrap_or(0),
|
order: request.calendar_order.unwrap_or(0),
|
||||||
displayname: request.displayname,
|
displayname: request.displayname,
|
||||||
timezone: request.calendar_timezone,
|
timezone,
|
||||||
timezone_id: request.calendar_timezone_id,
|
timezone_id: request.calendar_timezone_id,
|
||||||
color: request.calendar_color,
|
color: request.calendar_color,
|
||||||
description: request.calendar_description,
|
description: request.calendar_description,
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ fn objects_response(
|
|||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, prop, puri, user)?,
|
.propfind(&path, prop, None, puri, user)?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ pub async fn handle_sync_collection<C: CalendarStore>(
|
|||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, &sync_collection.prop, puri, user)?,
|
.propfind(&path, &sync_collection.prop, None, puri, user)?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ use rustical_store::Calendar;
|
|||||||
use rustical_store::auth::Principal;
|
use rustical_store::auth::Principal;
|
||||||
use rustical_xml::{EnumVariants, PropName};
|
use rustical_xml::{EnumVariants, PropName};
|
||||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumVariants, PropName)]
|
||||||
#[xml(unit_variants_ident = "CalendarPropName")]
|
#[xml(unit_variants_ident = "CalendarPropName")]
|
||||||
@@ -34,7 +33,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),
|
||||||
@@ -193,20 +192,22 @@ impl Resource for CalendarResource {
|
|||||||
}
|
}
|
||||||
CalendarProp::CalendarTimezone(timezone) => {
|
CalendarProp::CalendarTimezone(timezone) => {
|
||||||
// TODO: Ensure that timezone-id is also updated
|
// TODO: Ensure that timezone-id is also updated
|
||||||
|
// We probably want to prohibit non-IANA timezones
|
||||||
self.cal.timezone = timezone;
|
self.cal.timezone = timezone;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
CalendarProp::TimezoneServiceSet(_) => Err(rustical_dav::Error::PropReadOnly),
|
CalendarProp::TimezoneServiceSet(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||||
CalendarProp::CalendarTimezoneId(timezone_id) => {
|
CalendarProp::CalendarTimezoneId(timezone_id) => {
|
||||||
if let Some(tzid) = &timezone_id {
|
if let Some(tzid) = &timezone_id {
|
||||||
// Validate timezone id
|
// Validate timezone id and set timezone accordingly
|
||||||
chrono_tz::Tz::from_str(tzid).map_err(|_| {
|
self.cal.timezone = Some(
|
||||||
rustical_dav::Error::BadRequest(format!(
|
vtimezones_rs::VTIMEZONES
|
||||||
"Invalid timezone-id: {}",
|
.get(tzid)
|
||||||
tzid
|
.ok_or(rustical_dav::Error::BadRequest(format!(
|
||||||
))
|
"Invalid timezone-id: {tzid}"
|
||||||
})?;
|
)))?
|
||||||
// TODO: Ensure that timezone is also updated (For now hope that clients play nice)
|
.to_string(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self.cal.timezone_id = timezone_id;
|
self.cal.timezone_id = timezone_id;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -308,3 +309,15 @@ impl Resource for CalendarResource {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_tzdb_version() {
|
||||||
|
// Ensure that both chrono_tz and vzic_rs use the same tzdb version
|
||||||
|
assert_eq!(
|
||||||
|
chrono_tz::IANA_TZDB_VERSION,
|
||||||
|
vtimezones_rs::IANA_TZDB_VERSION
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ impl<C: CalendarStore, S: SubscriptionStore> ResourceService for CalendarResourc
|
|||||||
type Principal = Principal;
|
type Principal = Principal;
|
||||||
type PrincipalUri = CalDavPrincipalUri;
|
type PrincipalUri = CalDavPrincipalUri;
|
||||||
|
|
||||||
const DAV_HEADER: &str = "1, 3, access-control, calendar-access, calendar-proxy, webdav-push";
|
const DAV_HEADER: &str = "1, 3, access-control, calendar-access, webdav-push";
|
||||||
|
|
||||||
async fn get_resource(
|
async fn get_resource(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use axum::extract::{Path, State};
|
|||||||
use axum::response::{IntoResponse, Response};
|
use axum::response::{IntoResponse, Response};
|
||||||
use axum_extra::TypedHeader;
|
use axum_extra::TypedHeader;
|
||||||
use headers::{ContentType, ETag, HeaderMapExt, IfNoneMatch};
|
use headers::{ContentType, ETag, HeaderMapExt, IfNoneMatch};
|
||||||
use http::{HeaderMap, StatusCode};
|
use http::{HeaderMap, Method, StatusCode};
|
||||||
use rustical_ical::CalendarObject;
|
use rustical_ical::CalendarObject;
|
||||||
use rustical_store::CalendarStore;
|
use rustical_store::CalendarStore;
|
||||||
use rustical_store::auth::Principal;
|
use rustical_store::auth::Principal;
|
||||||
@@ -22,6 +22,7 @@ pub async fn get_event<C: CalendarStore>(
|
|||||||
}): Path<CalendarObjectPathComponents>,
|
}): Path<CalendarObjectPathComponents>,
|
||||||
State(CalendarObjectResourceService { cal_store }): State<CalendarObjectResourceService<C>>,
|
State(CalendarObjectResourceService { cal_store }): State<CalendarObjectResourceService<C>>,
|
||||||
user: Principal,
|
user: Principal,
|
||||||
|
method: Method,
|
||||||
) -> Result<Response, Error> {
|
) -> Result<Response, Error> {
|
||||||
if !user.is_principal(&principal) {
|
if !user.is_principal(&principal) {
|
||||||
return Err(crate::Error::Unauthorized);
|
return Err(crate::Error::Unauthorized);
|
||||||
@@ -42,8 +43,12 @@ pub async fn get_event<C: CalendarStore>(
|
|||||||
let hdrs = resp.headers_mut().unwrap();
|
let hdrs = resp.headers_mut().unwrap();
|
||||||
hdrs.typed_insert(ETag::from_str(&event.get_etag()).unwrap());
|
hdrs.typed_insert(ETag::from_str(&event.get_etag()).unwrap());
|
||||||
hdrs.typed_insert(ContentType::from_str("text/calendar").unwrap());
|
hdrs.typed_insert(ContentType::from_str("text/calendar").unwrap());
|
||||||
|
if matches!(method, Method::HEAD) {
|
||||||
|
Ok(resp.body(Body::empty()).unwrap())
|
||||||
|
} else {
|
||||||
Ok(resp.body(Body::new(event.get_ics().to_owned())).unwrap())
|
Ok(resp.body(Body::new(event.get_ics().to_owned())).unwrap())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[instrument(skip(cal_store))]
|
#[instrument(skip(cal_store))]
|
||||||
pub async fn put_event<C: CalendarStore>(
|
pub async fn put_event<C: CalendarStore>(
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ impl Resource for CalendarObjectResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_displayname(&self) -> Option<&str> {
|
fn get_displayname(&self) -> Option<&str> {
|
||||||
// TODO: Extract summary from object
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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(
|
||||||
|
prefix,
|
||||||
|
RootResourceService::<_, Principal, CalDavPrincipalUri>::new(PrincipalResourceService {
|
||||||
auth_provider: auth_provider.clone(),
|
auth_provider: auth_provider.clone(),
|
||||||
sub_store: subscription_store.clone(),
|
sub_store: subscription_store.clone(),
|
||||||
cal_store: store.clone(),
|
cal_store: store.clone(),
|
||||||
};
|
simplified_home_set,
|
||||||
|
})
|
||||||
Router::new()
|
|
||||||
.nest(
|
|
||||||
prefix,
|
|
||||||
RootResourceService::<_, Principal, CalDavPrincipalUri>::new(principal_service.clone())
|
|
||||||
.axum_router()
|
.axum_router()
|
||||||
.layer(AuthenticationLayer::new(auth_provider))
|
.layer(AuthenticationLayer::new(auth_provider))
|
||||||
.layer(Extension(CalDavPrincipalUri(prefix))),
|
.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 {
|
||||||
@@ -39,11 +41,6 @@ impl Resource for PrincipalResource {
|
|||||||
Resourcetype(&[
|
Resourcetype(&[
|
||||||
ResourcetypeInner(Some(rustical_dav::namespace::NS_DAV), "collection"),
|
ResourcetypeInner(Some(rustical_dav::namespace::NS_DAV), "collection"),
|
||||||
ResourcetypeInner(Some(rustical_dav::namespace::NS_DAV), "principal"),
|
ResourcetypeInner(Some(rustical_dav::namespace::NS_DAV), "principal"),
|
||||||
// https://github.com/apple/ccs-calendarserver/blob/13c706b985fb728b9aab42dc0fef85aae21921c3/doc/Extensions/caldav-proxy.txt
|
|
||||||
// ResourcetypeInner(
|
|
||||||
// Some(rustical_dav::namespace::NS_CALENDARSERVER),
|
|
||||||
// "calendar-proxy-write",
|
|
||||||
// ),
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,9 +61,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())
|
||||||
}
|
}
|
||||||
@@ -116,7 +121,7 @@ impl Resource for PrincipalResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_user_privileges(&self, user: &Principal) -> Result<UserPrivilegeSet, Self::Error> {
|
fn get_user_privileges(&self, user: &Principal) -> Result<UserPrivilegeSet, Self::Error> {
|
||||||
Ok(UserPrivilegeSet::owner_read(
|
Ok(UserPrivilegeSet::owner_only(
|
||||||
user.is_principal(&self.principal.id),
|
user.is_principal(&self.principal.id),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,7 +46,7 @@ impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Resour
|
|||||||
type Principal = Principal;
|
type Principal = Principal;
|
||||||
type PrincipalUri = CalDavPrincipalUri;
|
type PrincipalUri = CalDavPrincipalUri;
|
||||||
|
|
||||||
const DAV_HEADER: &str = "1, 3, access-control, calendar-access, calendar-proxy";
|
const DAV_HEADER: &str = "1, 3, access-control, calendar-access";
|
||||||
|
|
||||||
async fn get_resource(
|
async fn get_resource(
|
||||||
&self,
|
&self,
|
||||||
@@ -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!(
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use axum::extract::{Path, State};
|
|||||||
use axum::response::{IntoResponse, Response};
|
use axum::response::{IntoResponse, Response};
|
||||||
use axum_extra::TypedHeader;
|
use axum_extra::TypedHeader;
|
||||||
use axum_extra::headers::{ContentType, ETag, HeaderMapExt, IfNoneMatch};
|
use axum_extra::headers::{ContentType, ETag, HeaderMapExt, IfNoneMatch};
|
||||||
|
use http::Method;
|
||||||
use http::{HeaderMap, StatusCode};
|
use http::{HeaderMap, StatusCode};
|
||||||
use rustical_dav::privileges::UserPrivilege;
|
use rustical_dav::privileges::UserPrivilege;
|
||||||
use rustical_dav::resource::Resource;
|
use rustical_dav::resource::Resource;
|
||||||
@@ -25,6 +26,7 @@ pub async fn get_object<AS: AddressbookStore>(
|
|||||||
}): Path<AddressObjectPathComponents>,
|
}): Path<AddressObjectPathComponents>,
|
||||||
State(AddressObjectResourceService { addr_store }): State<AddressObjectResourceService<AS>>,
|
State(AddressObjectResourceService { addr_store }): State<AddressObjectResourceService<AS>>,
|
||||||
user: Principal,
|
user: Principal,
|
||||||
|
method: Method,
|
||||||
) -> Result<Response, Error> {
|
) -> Result<Response, Error> {
|
||||||
if !user.is_principal(&principal) {
|
if !user.is_principal(&principal) {
|
||||||
return Err(Error::Unauthorized);
|
return Err(Error::Unauthorized);
|
||||||
@@ -49,8 +51,12 @@ pub async fn get_object<AS: AddressbookStore>(
|
|||||||
let hdrs = resp.headers_mut().unwrap();
|
let hdrs = resp.headers_mut().unwrap();
|
||||||
hdrs.typed_insert(ETag::from_str(&object.get_etag()).unwrap());
|
hdrs.typed_insert(ETag::from_str(&object.get_etag()).unwrap());
|
||||||
hdrs.typed_insert(ContentType::from_str("text/vcard").unwrap());
|
hdrs.typed_insert(ContentType::from_str("text/vcard").unwrap());
|
||||||
|
if matches!(method, Method::HEAD) {
|
||||||
|
Ok(resp.body(Body::empty()).unwrap())
|
||||||
|
} else {
|
||||||
Ok(resp.body(Body::new(object.get_vcf().to_owned())).unwrap())
|
Ok(resp.body(Body::new(object.get_vcf().to_owned())).unwrap())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[instrument(skip(addr_store, body))]
|
#[instrument(skip(addr_store, body))]
|
||||||
pub async fn put_object<AS: AddressbookStore>(
|
pub async fn put_object<AS: AddressbookStore>(
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use axum::body::Body;
|
|||||||
use axum::extract::{Path, State};
|
use axum::extract::{Path, State};
|
||||||
use axum::response::Response;
|
use axum::response::Response;
|
||||||
use axum_extra::headers::{ContentType, HeaderMapExt};
|
use axum_extra::headers::{ContentType, HeaderMapExt};
|
||||||
use http::{HeaderValue, StatusCode, header};
|
use http::{HeaderValue, Method, StatusCode, header};
|
||||||
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
||||||
use rustical_dav::privileges::UserPrivilege;
|
use rustical_dav::privileges::UserPrivilege;
|
||||||
use rustical_dav::resource::Resource;
|
use rustical_dav::resource::Resource;
|
||||||
@@ -20,6 +20,7 @@ pub async fn route_get<AS: AddressbookStore, S: SubscriptionStore>(
|
|||||||
Path((principal, addressbook_id)): Path<(String, String)>,
|
Path((principal, addressbook_id)): Path<(String, String)>,
|
||||||
State(AddressbookResourceService { addr_store, .. }): State<AddressbookResourceService<AS, S>>,
|
State(AddressbookResourceService { addr_store, .. }): State<AddressbookResourceService<AS, S>>,
|
||||||
user: Principal,
|
user: Principal,
|
||||||
|
method: Method,
|
||||||
) -> Result<Response, Error> {
|
) -> Result<Response, Error> {
|
||||||
if !user.is_principal(&principal) {
|
if !user.is_principal(&principal) {
|
||||||
return Err(Error::Unauthorized);
|
return Err(Error::Unauthorized);
|
||||||
@@ -46,7 +47,7 @@ pub async fn route_get<AS: AddressbookStore, S: SubscriptionStore>(
|
|||||||
let mut resp = Response::builder().status(StatusCode::OK);
|
let mut resp = Response::builder().status(StatusCode::OK);
|
||||||
let hdrs = resp.headers_mut().unwrap();
|
let hdrs = resp.headers_mut().unwrap();
|
||||||
hdrs.typed_insert(ContentType::from_str("text/vcard").unwrap());
|
hdrs.typed_insert(ContentType::from_str("text/vcard").unwrap());
|
||||||
let filename = format!("{}_{}.vcf", principal, addressbook_id);
|
let filename = format!("{principal}_{addressbook_id}.vcf");
|
||||||
let filename = utf8_percent_encode(&filename, CONTROLS);
|
let filename = utf8_percent_encode(&filename, CONTROLS);
|
||||||
hdrs.insert(
|
hdrs.insert(
|
||||||
header::CONTENT_DISPOSITION,
|
header::CONTENT_DISPOSITION,
|
||||||
@@ -55,5 +56,9 @@ pub async fn route_get<AS: AddressbookStore, S: SubscriptionStore>(
|
|||||||
))
|
))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
if matches!(method, Method::HEAD) {
|
||||||
|
Ok(resp.body(Body::empty()).unwrap())
|
||||||
|
} else {
|
||||||
Ok(resp.body(Body::new(vcf)).unwrap())
|
Ok(resp.body(Body::new(vcf)).unwrap())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -88,15 +88,8 @@ pub async fn route_mkcol<AS: AddressbookStore, S: SubscriptionStore>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match addr_store.insert_addressbook(addressbook).await {
|
addr_store.insert_addressbook(addressbook).await?;
|
||||||
// TODO: The spec says we should return a mkcol-response.
|
Ok(StatusCode::CREATED.into_response())
|
||||||
// However, it works without one but breaks on iPadOS when using an empty one :)
|
|
||||||
Ok(()) => Ok(StatusCode::CREATED.into_response()),
|
|
||||||
Err(err) => {
|
|
||||||
dbg!(err.to_string());
|
|
||||||
Err(err.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ pub async fn handle_addressbook_multiget<AS: AddressbookStore>(
|
|||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, prop, puri, user)?,
|
.propfind(&path, prop, None, puri, user)?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ pub async fn handle_sync_collection<AS: AddressbookStore>(
|
|||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, &sync_collection.prop, puri, user)?,
|
.propfind(&path, &sync_collection.prop, None, puri, user)?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -18,11 +18,6 @@ pub trait AxumMethods: Sized + Send + Sync + 'static {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn head() -> Option<MethodFunction<Self>> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn post() -> Option<MethodFunction<Self>> {
|
fn post() -> Option<MethodFunction<Self>> {
|
||||||
None
|
None
|
||||||
@@ -58,8 +53,6 @@ pub trait AxumMethods: Sized + Send + Sync + 'static {
|
|||||||
}
|
}
|
||||||
if Self::get().is_some() {
|
if Self::get().is_some() {
|
||||||
allow.push(Method::GET);
|
allow.push(Method::GET);
|
||||||
}
|
|
||||||
if Self::head().is_some() {
|
|
||||||
allow.push(Method::HEAD);
|
allow.push(Method::HEAD);
|
||||||
}
|
}
|
||||||
if Self::post().is_some() {
|
if Self::post().is_some() {
|
||||||
|
|||||||
@@ -72,16 +72,11 @@ where
|
|||||||
return svc(self.resource_service.clone(), req);
|
return svc(self.resource_service.clone(), req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"GET" => {
|
"GET" | "HEAD" => {
|
||||||
if let Some(svc) = RS::get() {
|
if let Some(svc) = RS::get() {
|
||||||
return svc(self.resource_service.clone(), req);
|
return svc(self.resource_service.clone(), req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"HEAD" => {
|
|
||||||
if let Some(svc) = RS::head() {
|
|
||||||
return svc(self.resource_service.clone(), req);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"POST" => {
|
"POST" => {
|
||||||
if let Some(svc) = RS::post() {
|
if let Some(svc) = RS::post() {
|
||||||
return svc(self.resource_service.clone(), req);
|
return svc(self.resource_service.clone(), req);
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ pub(crate) async fn route_propfind<R: ResourceService>(
|
|||||||
} else {
|
} else {
|
||||||
PropfindElement {
|
PropfindElement {
|
||||||
prop: PropfindType::Allprop,
|
prop: PropfindType::Allprop,
|
||||||
|
include: None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let propfind_member: PropfindElement<<<R::MemberType as Resource>::Prop as PropName>::Names> =
|
let propfind_member: PropfindElement<<<R::MemberType as Resource>::Prop as PropName>::Names> =
|
||||||
@@ -72,6 +73,7 @@ pub(crate) async fn route_propfind<R: ResourceService>(
|
|||||||
} else {
|
} else {
|
||||||
PropfindElement {
|
PropfindElement {
|
||||||
prop: PropfindType::Allprop,
|
prop: PropfindType::Allprop,
|
||||||
|
include: None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,13 +84,20 @@ pub(crate) async fn route_propfind<R: ResourceService>(
|
|||||||
member_responses.push(member.propfind(
|
member_responses.push(member.propfind(
|
||||||
&format!("{}/{}", path.trim_end_matches('/'), member.get_name()),
|
&format!("{}/{}", path.trim_end_matches('/'), member.get_name()),
|
||||||
&propfind_member.prop,
|
&propfind_member.prop,
|
||||||
|
propfind_member.include.as_ref(),
|
||||||
puri,
|
puri,
|
||||||
principal,
|
principal,
|
||||||
)?);
|
)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = resource.propfind(path, &propfind_self.prop, puri, principal)?;
|
let response = resource.propfind(
|
||||||
|
path,
|
||||||
|
&propfind_self.prop,
|
||||||
|
propfind_self.include.as_ref(),
|
||||||
|
puri,
|
||||||
|
principal,
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(MultistatusElement {
|
Ok(MultistatusElement {
|
||||||
responses: vec![response],
|
responses: vec![response],
|
||||||
|
|||||||
@@ -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,17 +99,17 @@ 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),
|
||||||
}) => {
|
}) => {
|
||||||
|
for property in properties {
|
||||||
match property {
|
match property {
|
||||||
SetPropertyPropWrapper::Valid(prop) => {
|
SetPropertyPropWrapper::Valid(prop) => {
|
||||||
let propname: <<R::Resource as Resource>::Prop as PropName>::Names =
|
let propname: <<R::Resource as Resource>::Prop as PropName>::Names =
|
||||||
prop.clone().into();
|
prop.clone().into();
|
||||||
let (ns, propname): (Option<Namespace>, &str) = propname.into();
|
let (ns, propname): (Option<Namespace>, &str) = propname.into();
|
||||||
match resource.set_prop(prop) {
|
match resource.set_prop(prop) {
|
||||||
Ok(()) => {
|
Ok(()) => props_ok
|
||||||
props_ok.push((ns.map(NamespaceOwned::from), propname.to_owned()))
|
.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()),
|
||||||
@@ -139,9 +138,12 @@ pub(crate) async fn route_proppatch<R: ResourceService>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
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;
|
||||||
|
match <<R::Resource as Resource>::Prop as PropName>::Names::from_str(&propname)
|
||||||
|
{
|
||||||
Ok(prop) => match resource.remove_prop(&prop) {
|
Ok(prop) => match resource.remove_prop(&prop) {
|
||||||
Ok(()) => props_ok.push((None, propname)),
|
Ok(()) => props_ok.push((None, propname)),
|
||||||
Err(Error::PropReadOnly) => props_conflict.push({
|
Err(Error::PropReadOnly) => props_conflict.push({
|
||||||
@@ -156,6 +158,7 @@ pub(crate) async fn route_proppatch<R: ResourceService>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if props_not_found.is_empty() && props_conflict.is_empty() {
|
if props_not_found.is_empty() && props_conflict.is_empty() {
|
||||||
// Only save if no errors occured
|
// Only save if no errors occured
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ pub trait Resource: Clone + Send + 'static {
|
|||||||
&self,
|
&self,
|
||||||
path: &str,
|
path: &str,
|
||||||
prop: &PropfindType<<Self::Prop as PropName>::Names>,
|
prop: &PropfindType<<Self::Prop as PropName>::Names>,
|
||||||
|
include: Option<&PropElement<<Self::Prop as PropName>::Names>>,
|
||||||
principal_uri: &impl PrincipalUri,
|
principal_uri: &impl PrincipalUri,
|
||||||
principal: &Self::Principal,
|
principal: &Self::Principal,
|
||||||
) -> Result<ResponseElement<Self::Prop>, Self::Error> {
|
) -> Result<ResponseElement<Self::Prop>, Self::Error> {
|
||||||
@@ -115,9 +116,8 @@ pub trait Resource: Clone + Send + 'static {
|
|||||||
path.push('/');
|
path.push('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Support include element
|
let (mut props, mut invalid_props): (HashSet<<Self::Prop as PropName>::Names>, Vec<_>) =
|
||||||
let (props, invalid_props): (HashSet<<Self::Prop as PropName>::Names>, Vec<_>) = match prop
|
match prop {
|
||||||
{
|
|
||||||
PropfindType::Propname => {
|
PropfindType::Propname => {
|
||||||
let props = Self::list_props()
|
let props = Self::list_props()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -146,6 +146,11 @@ pub trait Resource: Clone + Send + 'static {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(PropElement(valid_tags, invalid_tags)) = include {
|
||||||
|
props.extend(valid_tags.clone());
|
||||||
|
invalid_props.extend(invalid_tags.to_owned());
|
||||||
|
}
|
||||||
|
|
||||||
let prop_responses = props
|
let prop_responses = props
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|prop| self.get_prop(principal_uri, principal, &prop))
|
.map(|prop| self.get_prop(principal_uri, principal, &prop))
|
||||||
|
|||||||
@@ -11,10 +11,11 @@ use rustical_xml::XmlRootTag;
|
|||||||
pub struct PropfindElement<PN: XmlDeserialize> {
|
pub struct PropfindElement<PN: XmlDeserialize> {
|
||||||
#[xml(ty = "untagged")]
|
#[xml(ty = "untagged")]
|
||||||
pub prop: PropfindType<PN>,
|
pub prop: PropfindType<PN>,
|
||||||
|
#[xml(ns = "crate::namespace::NS_DAV")]
|
||||||
|
pub include: Option<PropElement<PN>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
// pub struct PropElement<PN: XmlDeserialize = Propname>(#[xml(ty = "untagged", flatten)] pub Vec<PN>);
|
|
||||||
pub struct PropElement<PN: XmlDeserialize>(
|
pub struct PropElement<PN: XmlDeserialize>(
|
||||||
// valid
|
// valid
|
||||||
pub Vec<PN>,
|
pub Vec<PN>,
|
||||||
|
|||||||
@@ -33,7 +33,13 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out,
|
out,
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<document><resourcetype><displayname xmlns=\"DAV:\"/><calendar-color xmlns=\"http://calendarserver.org/ns/\"/></resourcetype></document>"
|
r#"<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<document>
|
||||||
|
<resourcetype>
|
||||||
|
<displayname xmlns="DAV:"/>
|
||||||
|
<calendar-color xmlns="http://calendarserver.org/ns/"/>
|
||||||
|
</resourcetype>
|
||||||
|
</document>"#
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ rustical_dav.workspace = true
|
|||||||
rustical_store.workspace = true
|
rustical_store.workspace = true
|
||||||
http.workspace = true
|
http.workspace = true
|
||||||
base64.workspace = true
|
base64.workspace = true
|
||||||
rand.workspace = true
|
|
||||||
ece.workspace = true
|
ece.workspace = true
|
||||||
axum.workspace = true
|
axum.workspace = true
|
||||||
openssl.workspace = true
|
openssl.workspace = true
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { html, LitElement } from "lit";
|
import { html, LitElement } from "lit";
|
||||||
import { customElement, property } from "lit/decorators.js";
|
import { customElement, property } from "lit/decorators.js";
|
||||||
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
||||||
import { createClient } from "webdav";
|
import { escapeXml } from ".";
|
||||||
|
|
||||||
@customElement("create-addressbook-form")
|
@customElement("create-addressbook-form")
|
||||||
export class CreateAddressbookForm extends LitElement {
|
export class CreateAddressbookForm extends LitElement {
|
||||||
@@ -14,18 +14,16 @@ export class CreateAddressbookForm extends LitElement {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
client = createClient("/carddav")
|
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
user: String = ''
|
user: string = ''
|
||||||
@property()
|
@property()
|
||||||
principal: String = ''
|
principal: string = ''
|
||||||
@property()
|
@property()
|
||||||
addr_id: String = ''
|
addr_id: string = self.crypto.randomUUID()
|
||||||
@property()
|
@property()
|
||||||
displayname: String = ''
|
displayname: string = ''
|
||||||
@property()
|
@property()
|
||||||
description: String = ''
|
description: string = ''
|
||||||
|
|
||||||
dialog: Ref<HTMLDialogElement> = createRef()
|
dialog: Ref<HTMLDialogElement> = createRef()
|
||||||
form: Ref<HTMLFormElement> = createRef()
|
form: Ref<HTMLFormElement> = createRef()
|
||||||
@@ -38,12 +36,17 @@ export class CreateAddressbookForm extends LitElement {
|
|||||||
<form @submit=${this.submit} ${ref(this.form)}>
|
<form @submit=${this.submit} ${ref(this.form)}>
|
||||||
<label>
|
<label>
|
||||||
principal (for group addressbooks)
|
principal (for group addressbooks)
|
||||||
<input type="text" name="principal" value=${this.user} @change=${e => this.principal = e.target.value} />
|
<select name="principal" value=${this.user} @change=${e => this.principal = e.target.value}>
|
||||||
|
<option value=${this.user}>${this.user}</option>
|
||||||
|
${window.rusticalUser.memberships.map(membership => html`
|
||||||
|
<option value=${membership}>${membership}</option>
|
||||||
|
`)}
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
id
|
id
|
||||||
<input type="text" name="id" @change=${e => this.addr_id = e.target.value} />
|
<input type="text" name="id" value=${this.addr_id} @change=${e => this.addr_id = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
@@ -74,19 +77,29 @@ export class CreateAddressbookForm extends LitElement {
|
|||||||
alert("Empty displayname")
|
alert("Empty displayname")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// TODO: Escape user input: There's not really a security risk here but would be nicer
|
let response = await fetch(`/carddav/principal/${this.principal || this.user}/${this.addr_id}`, {
|
||||||
await this.client.createDirectory(`/principal/${this.principal || this.user}/${this.addr_id}`, {
|
method: 'MKCOL',
|
||||||
data: `
|
headers: {
|
||||||
|
'Content-Type': 'application/xml'
|
||||||
|
},
|
||||||
|
body: `
|
||||||
<mkcol xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">
|
<mkcol xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">
|
||||||
<set>
|
<set>
|
||||||
<prop>
|
<prop>
|
||||||
<displayname>${this.displayname}</displayname>
|
<displayname>${escapeXml(this.displayname)}</displayname>
|
||||||
${this.description ? `<CARD:addressbook-description>${this.description}</CARD:addressbook-description>` : ''}
|
${this.description ? `<CARD:addressbook-description>${escapeXml(this.description)}</CARD:addressbook-description>` : ''}
|
||||||
</prop>
|
</prop>
|
||||||
</set>
|
</set>
|
||||||
</mkcol>
|
</mkcol>
|
||||||
`
|
`
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (response.status >= 400) {
|
||||||
|
alert(`Error ${response.status}: ${await response.text()}`)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { html, LitElement } from "lit";
|
import { html, LitElement } from "lit";
|
||||||
import { customElement, property } from "lit/decorators.js";
|
import { customElement, property } from "lit/decorators.js";
|
||||||
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
||||||
import { createClient } from "webdav";
|
import { escapeXml } from ".";
|
||||||
|
|
||||||
@customElement("create-calendar-form")
|
@customElement("create-calendar-form")
|
||||||
export class CreateCalendarForm extends LitElement {
|
export class CreateCalendarForm extends LitElement {
|
||||||
@@ -13,29 +13,30 @@ export class CreateCalendarForm extends LitElement {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
client = createClient("/caldav")
|
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
user: String = ''
|
user: string = ''
|
||||||
@property()
|
@property()
|
||||||
principal: String = ''
|
principal: string = ''
|
||||||
@property()
|
@property()
|
||||||
cal_id: String = ''
|
cal_id: string = self.crypto.randomUUID()
|
||||||
@property()
|
@property()
|
||||||
displayname: String = ''
|
displayname: string = ''
|
||||||
@property()
|
@property()
|
||||||
description: String = ''
|
description: string = ''
|
||||||
@property()
|
@property()
|
||||||
color: String = ''
|
timezone_id: string = ''
|
||||||
@property()
|
@property()
|
||||||
subscriptionUrl: String = ''
|
color: string = ''
|
||||||
|
@property()
|
||||||
|
isSubscription: boolean = false
|
||||||
|
@property()
|
||||||
|
subscriptionUrl: string = ''
|
||||||
@property()
|
@property()
|
||||||
components: Set<"VEVENT" | "VTODO" | "VJOURNAL"> = new Set()
|
components: Set<"VEVENT" | "VTODO" | "VJOURNAL"> = new Set()
|
||||||
|
|
||||||
dialog: Ref<HTMLDialogElement> = createRef()
|
dialog: Ref<HTMLDialogElement> = createRef()
|
||||||
form: Ref<HTMLFormElement> = createRef()
|
form: Ref<HTMLFormElement> = createRef()
|
||||||
|
|
||||||
|
|
||||||
override render() {
|
override render() {
|
||||||
return html`
|
return html`
|
||||||
<button @click=${() => this.dialog.value.showModal()}>Create calendar</button>
|
<button @click=${() => this.dialog.value.showModal()}>Create calendar</button>
|
||||||
@@ -43,13 +44,18 @@ export class CreateCalendarForm extends LitElement {
|
|||||||
<h3>Create calendar</h3>
|
<h3>Create calendar</h3>
|
||||||
<form @submit=${this.submit} ${ref(this.form)}>
|
<form @submit=${this.submit} ${ref(this.form)}>
|
||||||
<label>
|
<label>
|
||||||
principal (for group calendar)
|
principal (for group calendars)
|
||||||
<input type="text" name="principal" value=${this.user} @change=${e => this.principal = e.target.value} />
|
<select name="principal" value=${this.user} @change=${e => this.principal = e.target.value}>
|
||||||
|
<option value=${this.user}>${this.user}</option>
|
||||||
|
${window.rusticalUser.memberships.map(membership => html`
|
||||||
|
<option value=${membership}>${membership}</option>
|
||||||
|
`)}
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
id
|
id
|
||||||
<input type="text" name="id" @change=${e => this.cal_id = e.target.value} />
|
<input type="text" name="id" value=${this.cal_id} @change=${e => this.cal_id = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
@@ -57,6 +63,11 @@ export class CreateCalendarForm extends LitElement {
|
|||||||
<input type="text" name="displayname" value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
<input type="text" name="displayname" value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
|
<label>
|
||||||
|
Timezone (optional)
|
||||||
|
<input type="text" name="timezone" .value=${this.timezone_id} @change=${e => this.timezone_id = e.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
<label>
|
<label>
|
||||||
Description
|
Description
|
||||||
<input type="text" name="description" @change=${e => this.description = e.target.value} />
|
<input type="text" name="description" @change=${e => this.description = e.target.value} />
|
||||||
@@ -67,11 +78,20 @@ export class CreateCalendarForm extends LitElement {
|
|||||||
<input type="color" name="color" @change=${e => this.color = e.target.value} />
|
<input type="color" name="color" @change=${e => this.color = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Calendar is subscription to external calendar
|
||||||
|
<input type="checkbox" name="is_subscription" @change=${e => this.isSubscription = e.target.checked} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
${this.isSubscription ? html`
|
||||||
<label>
|
<label>
|
||||||
Subscription URL
|
Subscription URL
|
||||||
<input type="text" name="subscription_url" @change=${e => this.subscriptionUrl = e.target.value} />
|
<input type="text" name="subscription_url" @change=${e => this.subscriptionUrl = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
|
`: html``}
|
||||||
|
<br>
|
||||||
${["VEVENT", "VTODO", "VJOURNAL"].map(comp => html`
|
${["VEVENT", "VTODO", "VJOURNAL"].map(comp => html`
|
||||||
<label>
|
<label>
|
||||||
Support ${comp}
|
Support ${comp}
|
||||||
@@ -102,23 +122,34 @@ export class CreateCalendarForm extends LitElement {
|
|||||||
alert("No calendar components selected")
|
alert("No calendar components selected")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await this.client.createDirectory(`/principal/${this.principal || this.user}/${this.cal_id}`, {
|
|
||||||
data: `
|
let response = await fetch(`/caldav/principal/${this.principal || this.user}/${this.cal_id}`, {
|
||||||
|
method: 'MKCOL',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/xml'
|
||||||
|
},
|
||||||
|
body: `
|
||||||
<mkcol xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/" xmlns:ICAL="http://apple.com/ns/ical/">
|
<mkcol xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/" xmlns:ICAL="http://apple.com/ns/ical/">
|
||||||
<set>
|
<set>
|
||||||
<prop>
|
<prop>
|
||||||
<displayname>${this.displayname}</displayname>
|
<displayname>${escapeXml(this.displayname)}</displayname>
|
||||||
${this.description ? `<CAL:calendar-description>${this.description}</CAL:calendar-description>` : ''}
|
${this.timezone_id ? `<CAL:calendar-timezone-id>${escapeXml(this.timezone_id)}</CAL:calendar-timezone-id>` : ''}
|
||||||
${this.color ? `<ICAL:calendar-color>${this.color}</ICAL:calendar-color>` : ''}
|
${this.description ? `<CAL:calendar-description>${escapeXml(this.description)}</CAL:calendar-description>` : ''}
|
||||||
${this.subscriptionUrl ? `<CS:source><href>${this.subscriptionUrl}</href></CS:source>` : ''}
|
${this.color ? `<ICAL:calendar-color>${escapeXml(this.color)}</ICAL:calendar-color>` : ''}
|
||||||
|
${(this.isSubscription && this.subscriptionUrl) ? `<CS:source><href>${escapeXml(this.subscriptionUrl)}</href></CS:source>` : ''}
|
||||||
<CAL:supported-calendar-component-set>
|
<CAL:supported-calendar-component-set>
|
||||||
${Array.from(this.components.keys()).map(comp => `<CAL:comp name="${comp}" />`).join('\n')}
|
${Array.from(this.components.keys()).map(comp => `<CAL:comp name="${escapeXml(comp)}" />`).join('\n')}
|
||||||
</CAL:supported-calendar-component-set>
|
</CAL:supported-calendar-component-set>
|
||||||
</prop>
|
</prop>
|
||||||
</set>
|
</set>
|
||||||
</mkcol>
|
</mkcol>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (response.status >= 400) {
|
||||||
|
alert(`Error ${response.status}: ${await response.text()}`)
|
||||||
|
return null
|
||||||
|
}
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { html, LitElement } from "lit";
|
import { html, LitElement } from "lit";
|
||||||
import { customElement, property } from "lit/decorators.js";
|
import { customElement, property } from "lit/decorators.js";
|
||||||
import { createClient } from "webdav";
|
|
||||||
|
|
||||||
@customElement("delete-button")
|
@customElement("delete-button")
|
||||||
export class DeleteButton extends LitElement {
|
export class DeleteButton extends LitElement {
|
||||||
|
|||||||
103
crates/frontend/js-components/lib/edit-addressbook-form.ts
Normal file
103
crates/frontend/js-components/lib/edit-addressbook-form.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
let response = 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>
|
||||||
|
`
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response.status >= 400) {
|
||||||
|
alert(`Error ${response.status}: ${await response.text()}`)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.reload()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'edit-addressbook-form': EditAddressbookForm
|
||||||
|
}
|
||||||
|
}
|
||||||
142
crates/frontend/js-components/lib/edit-calendar-form.ts
Normal file
142
crates/frontend/js-components/lib/edit-calendar-form.ts
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
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()
|
||||||
|
timezone_id: 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>
|
||||||
|
Timezone (optional)
|
||||||
|
<input type="text" name="timezone" .value=${this.timezone_id} @change=${e => this.timezone_id = 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
|
||||||
|
}
|
||||||
|
let response = 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.timezone_id ? `<CAL:calendar-timezone-id>${escapeXml(this.timezone_id)}</CAL:calendar-timezone-id>` : ''}
|
||||||
|
${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>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response.status >= 400) {
|
||||||
|
alert(`Error ${response.status}: ${await response.text()}`)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.reload()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'edit-calendar-form': EditCalendarForm
|
||||||
|
}
|
||||||
|
}
|
||||||
9
crates/frontend/js-components/lib/global.d.ts
vendored
Normal file
9
crates/frontend/js-components/lib/global.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
interface Window {
|
||||||
|
rusticalUser: {
|
||||||
|
id: String,
|
||||||
|
displayname: String | null,
|
||||||
|
memberships: Array<String>,
|
||||||
|
principal_type: "individual" | "group" | "room" | String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export function escapeXml(unsafe: string): string {
|
||||||
|
return unsafe.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, ''')
|
||||||
|
}
|
||||||
|
|||||||
@@ -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: {
|
||||||
@@ -23,7 +25,7 @@ export default defineConfig({
|
|||||||
format: "es",
|
format: "es",
|
||||||
manualChunks: {
|
manualChunks: {
|
||||||
lit: ["lit"],
|
lit: ["lit"],
|
||||||
webdav: ["webdav"],
|
// webdav: ["webdav"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { i, x } from "./lit-z6_uA4GX.mjs";
|
import { i, x } from "./lit-z6_uA4GX.mjs";
|
||||||
import { n as n$1, t } from "./property-D0NJdseG.mjs";
|
import { n as n$1, t } from "./property-D0NJdseG.mjs";
|
||||||
import { e, n } from "./ref-CPp9J0V5.mjs";
|
import { e, n, a as escapeXml } from "./index-b86iLJlP.mjs";
|
||||||
import { a as an } from "./webdav-D0R7xCzX.mjs";
|
|
||||||
var __defProp = Object.defineProperty;
|
var __defProp = Object.defineProperty;
|
||||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
var __decorateClass = (decorators, target, key, kind) => {
|
var __decorateClass = (decorators, target, key, kind) => {
|
||||||
@@ -15,10 +14,9 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|||||||
let CreateAddressbookForm = class extends i {
|
let CreateAddressbookForm = class extends i {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.client = an("/carddav");
|
|
||||||
this.user = "";
|
this.user = "";
|
||||||
this.principal = "";
|
this.principal = "";
|
||||||
this.addr_id = "";
|
this.addr_id = self.crypto.randomUUID();
|
||||||
this.displayname = "";
|
this.displayname = "";
|
||||||
this.description = "";
|
this.description = "";
|
||||||
this.dialog = e();
|
this.dialog = e();
|
||||||
@@ -35,12 +33,17 @@ let CreateAddressbookForm = class extends i {
|
|||||||
<form @submit=${this.submit} ${n(this.form)}>
|
<form @submit=${this.submit} ${n(this.form)}>
|
||||||
<label>
|
<label>
|
||||||
principal (for group addressbooks)
|
principal (for group addressbooks)
|
||||||
<input type="text" name="principal" value=${this.user} @change=${(e2) => this.principal = e2.target.value} />
|
<select name="principal" value=${this.user} @change=${(e2) => this.principal = e2.target.value}>
|
||||||
|
<option value=${this.user}>${this.user}</option>
|
||||||
|
${window.rusticalUser.memberships.map((membership) => x`
|
||||||
|
<option value=${membership}>${membership}</option>
|
||||||
|
`)}
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
id
|
id
|
||||||
<input type="text" name="id" @change=${(e2) => this.addr_id = e2.target.value} />
|
<input type="text" name="id" value=${this.addr_id} @change=${(e2) => this.addr_id = e2.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
@@ -74,18 +77,26 @@ let CreateAddressbookForm = class extends i {
|
|||||||
alert("Empty displayname");
|
alert("Empty displayname");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.client.createDirectory(`/principal/${this.principal || this.user}/${this.addr_id}`, {
|
let response = await fetch(`/carddav/principal/${this.principal || this.user}/${this.addr_id}`, {
|
||||||
data: `
|
method: "MKCOL",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/xml"
|
||||||
|
},
|
||||||
|
body: `
|
||||||
<mkcol xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">
|
<mkcol xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">
|
||||||
<set>
|
<set>
|
||||||
<prop>
|
<prop>
|
||||||
<displayname>${this.displayname}</displayname>
|
<displayname>${escapeXml(this.displayname)}</displayname>
|
||||||
${this.description ? `<CARD:addressbook-description>${this.description}</CARD:addressbook-description>` : ""}
|
${this.description ? `<CARD:addressbook-description>${escapeXml(this.description)}</CARD:addressbook-description>` : ""}
|
||||||
</prop>
|
</prop>
|
||||||
</set>
|
</set>
|
||||||
</mkcol>
|
</mkcol>
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
|
if (response.status >= 400) {
|
||||||
|
alert(`Error ${response.status}: ${await response.text()}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { i, x } from "./lit-z6_uA4GX.mjs";
|
import { i, x } from "./lit-z6_uA4GX.mjs";
|
||||||
import { n as n$1, t } from "./property-D0NJdseG.mjs";
|
import { n as n$1, t } from "./property-D0NJdseG.mjs";
|
||||||
import { e, n } from "./ref-CPp9J0V5.mjs";
|
import { e, n, a as escapeXml } from "./index-b86iLJlP.mjs";
|
||||||
import { a as an } from "./webdav-D0R7xCzX.mjs";
|
|
||||||
var __defProp = Object.defineProperty;
|
var __defProp = Object.defineProperty;
|
||||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
var __decorateClass = (decorators, target, key, kind) => {
|
var __decorateClass = (decorators, target, key, kind) => {
|
||||||
@@ -15,13 +14,14 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|||||||
let CreateCalendarForm = class extends i {
|
let CreateCalendarForm = class extends i {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.client = an("/caldav");
|
|
||||||
this.user = "";
|
this.user = "";
|
||||||
this.principal = "";
|
this.principal = "";
|
||||||
this.cal_id = "";
|
this.cal_id = self.crypto.randomUUID();
|
||||||
this.displayname = "";
|
this.displayname = "";
|
||||||
this.description = "";
|
this.description = "";
|
||||||
|
this.timezone_id = "";
|
||||||
this.color = "";
|
this.color = "";
|
||||||
|
this.isSubscription = false;
|
||||||
this.subscriptionUrl = "";
|
this.subscriptionUrl = "";
|
||||||
this.components = /* @__PURE__ */ new Set();
|
this.components = /* @__PURE__ */ new Set();
|
||||||
this.dialog = e();
|
this.dialog = e();
|
||||||
@@ -37,13 +37,18 @@ let CreateCalendarForm = class extends i {
|
|||||||
<h3>Create calendar</h3>
|
<h3>Create calendar</h3>
|
||||||
<form @submit=${this.submit} ${n(this.form)}>
|
<form @submit=${this.submit} ${n(this.form)}>
|
||||||
<label>
|
<label>
|
||||||
principal (for group calendar)
|
principal (for group calendars)
|
||||||
<input type="text" name="principal" value=${this.user} @change=${(e2) => this.principal = e2.target.value} />
|
<select name="principal" value=${this.user} @change=${(e2) => this.principal = e2.target.value}>
|
||||||
|
<option value=${this.user}>${this.user}</option>
|
||||||
|
${window.rusticalUser.memberships.map((membership) => x`
|
||||||
|
<option value=${membership}>${membership}</option>
|
||||||
|
`)}
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
id
|
id
|
||||||
<input type="text" name="id" @change=${(e2) => this.cal_id = e2.target.value} />
|
<input type="text" name="id" value=${this.cal_id} @change=${(e2) => this.cal_id = e2.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
@@ -51,6 +56,11 @@ let CreateCalendarForm = class extends i {
|
|||||||
<input type="text" name="displayname" value=${this.displayname} @change=${(e2) => this.displayname = e2.target.value} />
|
<input type="text" name="displayname" value=${this.displayname} @change=${(e2) => this.displayname = e2.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
|
<label>
|
||||||
|
Timezone (optional)
|
||||||
|
<input type="text" name="timezone" .value=${this.timezone_id} @change=${(e2) => this.timezone_id = e2.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
<label>
|
<label>
|
||||||
Description
|
Description
|
||||||
<input type="text" name="description" @change=${(e2) => this.description = e2.target.value} />
|
<input type="text" name="description" @change=${(e2) => this.description = e2.target.value} />
|
||||||
@@ -61,11 +71,20 @@ let CreateCalendarForm = class extends i {
|
|||||||
<input type="color" name="color" @change=${(e2) => this.color = e2.target.value} />
|
<input type="color" name="color" @change=${(e2) => this.color = e2.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Calendar is subscription to external calendar
|
||||||
|
<input type="checkbox" name="is_subscription" @change=${(e2) => this.isSubscription = e2.target.checked} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
${this.isSubscription ? x`
|
||||||
<label>
|
<label>
|
||||||
Subscription URL
|
Subscription URL
|
||||||
<input type="text" name="subscription_url" @change=${(e2) => this.subscriptionUrl = e2.target.value} />
|
<input type="text" name="subscription_url" @change=${(e2) => this.subscriptionUrl = e2.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
|
` : x``}
|
||||||
|
<br>
|
||||||
${["VEVENT", "VTODO", "VJOURNAL"].map((comp) => x`
|
${["VEVENT", "VTODO", "VJOURNAL"].map((comp) => x`
|
||||||
<label>
|
<label>
|
||||||
Support ${comp}
|
Support ${comp}
|
||||||
@@ -99,23 +118,32 @@ let CreateCalendarForm = class extends i {
|
|||||||
alert("No calendar components selected");
|
alert("No calendar components selected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.client.createDirectory(`/principal/${this.principal || this.user}/${this.cal_id}`, {
|
let response = await fetch(`/caldav/principal/${this.principal || this.user}/${this.cal_id}`, {
|
||||||
data: `
|
method: "MKCOL",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/xml"
|
||||||
|
},
|
||||||
|
body: `
|
||||||
<mkcol xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/" xmlns:ICAL="http://apple.com/ns/ical/">
|
<mkcol xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/" xmlns:ICAL="http://apple.com/ns/ical/">
|
||||||
<set>
|
<set>
|
||||||
<prop>
|
<prop>
|
||||||
<displayname>${this.displayname}</displayname>
|
<displayname>${escapeXml(this.displayname)}</displayname>
|
||||||
${this.description ? `<CAL:calendar-description>${this.description}</CAL:calendar-description>` : ""}
|
${this.timezone_id ? `<CAL:calendar-timezone-id>${escapeXml(this.timezone_id)}</CAL:calendar-timezone-id>` : ""}
|
||||||
${this.color ? `<ICAL:calendar-color>${this.color}</ICAL:calendar-color>` : ""}
|
${this.description ? `<CAL:calendar-description>${escapeXml(this.description)}</CAL:calendar-description>` : ""}
|
||||||
${this.subscriptionUrl ? `<CS:source><href>${this.subscriptionUrl}</href></CS:source>` : ""}
|
${this.color ? `<ICAL:calendar-color>${escapeXml(this.color)}</ICAL:calendar-color>` : ""}
|
||||||
|
${this.isSubscription && this.subscriptionUrl ? `<CS:source><href>${escapeXml(this.subscriptionUrl)}</href></CS:source>` : ""}
|
||||||
<CAL:supported-calendar-component-set>
|
<CAL:supported-calendar-component-set>
|
||||||
${Array.from(this.components.keys()).map((comp) => `<CAL:comp name="${comp}" />`).join("\n")}
|
${Array.from(this.components.keys()).map((comp) => `<CAL:comp name="${escapeXml(comp)}" />`).join("\n")}
|
||||||
</CAL:supported-calendar-component-set>
|
</CAL:supported-calendar-component-set>
|
||||||
</prop>
|
</prop>
|
||||||
</set>
|
</set>
|
||||||
</mkcol>
|
</mkcol>
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
|
if (response.status >= 400) {
|
||||||
|
alert(`Error ${response.status}: ${await response.text()}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -135,9 +163,15 @@ __decorateClass([
|
|||||||
__decorateClass([
|
__decorateClass([
|
||||||
n$1()
|
n$1()
|
||||||
], CreateCalendarForm.prototype, "description", 2);
|
], CreateCalendarForm.prototype, "description", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], CreateCalendarForm.prototype, "timezone_id", 2);
|
||||||
__decorateClass([
|
__decorateClass([
|
||||||
n$1()
|
n$1()
|
||||||
], CreateCalendarForm.prototype, "color", 2);
|
], CreateCalendarForm.prototype, "color", 2);
|
||||||
|
__decorateClass([
|
||||||
|
n$1()
|
||||||
|
], CreateCalendarForm.prototype, "isSubscription", 2);
|
||||||
__decorateClass([
|
__decorateClass([
|
||||||
n$1()
|
n$1()
|
||||||
], CreateCalendarForm.prototype, "subscriptionUrl", 2);
|
], CreateCalendarForm.prototype, "subscriptionUrl", 2);
|
||||||
|
|||||||
113
crates/frontend/public/assets/js/edit-addressbook-form.mjs
Normal file
113
crates/frontend/public/assets/js/edit-addressbook-form.mjs
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
let response = 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>
|
||||||
|
`
|
||||||
|
});
|
||||||
|
if (response.status >= 400) {
|
||||||
|
alert(`Error ${response.status}: ${await response.text()}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
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
|
||||||
|
};
|
||||||
156
crates/frontend/public/assets/js/edit-calendar-form.mjs
Normal file
156
crates/frontend/public/assets/js/edit-calendar-form.mjs
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
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.timezone_id = "";
|
||||||
|
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>
|
||||||
|
Timezone (optional)
|
||||||
|
<input type="text" name="timezone" .value=${this.timezone_id} @change=${(e2) => this.timezone_id = 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;
|
||||||
|
}
|
||||||
|
let response = 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.timezone_id ? `<CAL:calendar-timezone-id>${escapeXml(this.timezone_id)}</CAL:calendar-timezone-id>` : ""}
|
||||||
|
${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>
|
||||||
|
`
|
||||||
|
});
|
||||||
|
if (response.status >= 400) {
|
||||||
|
alert(`Error ${response.status}: ${await response.text()}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
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, "timezone_id", 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
|
||||||
|
};
|
||||||
@@ -122,7 +122,11 @@ const o = /* @__PURE__ */ new WeakMap(), n = e$1(class extends f {
|
|||||||
this.rt(this.ct);
|
this.rt(this.ct);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
function escapeXml(unsafe) {
|
||||||
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
||||||
|
}
|
||||||
export {
|
export {
|
||||||
|
escapeXml as a,
|
||||||
e,
|
e,
|
||||||
n
|
n
|
||||||
};
|
};
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -205,33 +205,48 @@ ul.collection-list {
|
|||||||
|
|
||||||
li.collection-list-item {
|
li.collection-list-item {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
display: contents;
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
background: color-mix(in srgb, var(--background-color), var(--dilute-color) 5%);
|
||||||
|
border: 2px solid var(--border-color);
|
||||||
|
border-radius: 12px;
|
||||||
|
margin: 12px 0;
|
||||||
|
box-shadow: 4px 2px 12px -6px black;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
background: color-mix(in srgb, var(--background-color), var(--dilute-color) 5%);
|
position: absolute;
|
||||||
|
inset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inner {
|
||||||
display: grid;
|
display: grid;
|
||||||
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;
|
||||||
padding-left: 12px;
|
padding-left: 12px;
|
||||||
|
|
||||||
border: 2px solid var(--border-color);
|
position: relative;
|
||||||
border-radius: 12px;
|
z-index: 1;
|
||||||
margin: 12px;
|
pointer-events: none;
|
||||||
box-shadow: 4px 2px 12px -6px black;
|
|
||||||
overflow: hidden;
|
a,
|
||||||
|
button {
|
||||||
|
pointer-events: all;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -245,7 +260,7 @@ ul.collection-list {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.comps {
|
.comps {
|
||||||
grid-area: comps;
|
display: inline;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
margin: 0 2px;
|
margin: 0 2px;
|
||||||
@@ -278,18 +293,19 @@ ul.collection-list {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
|
pointer-events: all;
|
||||||
grid-area: actions;
|
grid-area: actions;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: color-mix(in srgb, var(--background-color), var(--dilute-color) 10%);
|
background: color-mix(in srgb, var(--background-color), var(--dilute-color) 10%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -310,12 +326,20 @@ footer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input[type="text"],
|
input[type="text"],
|
||||||
input[type="password"] {
|
input[type="password"],
|
||||||
|
input[type="color"],
|
||||||
|
select {
|
||||||
background: color-mix(in srgb, var(--background-color), var(--dilute-color) 10%);
|
background: color-mix(in srgb, var(--background-color), var(--dilute-color) 10%);
|
||||||
border: 2px solid var(--border-color);
|
border: 2px solid var(--border-color);
|
||||||
padding: 6px 6px;
|
padding: 6px 6px;
|
||||||
color: var(--text-on-background-color);
|
color: var(--text-on-background-color);
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
|
border-radius: 8px;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
background: color-mix(in srgb, var(--background-color), var(--dilute-color) 20%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
svg.icon {
|
svg.icon {
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
<ul class="collection-list">
|
<ul class="collection-list">
|
||||||
{% for (meta, addressbook) in addressbooks %}
|
{% for (meta, addressbook) in addressbooks %}
|
||||||
<li class="collection-list-item">
|
<li class="collection-list-item">
|
||||||
<a href="/frontend/user/{{ addressbook.principal }}/addressbook/{{ addressbook.id}}">
|
<a href="/frontend/user/{{ addressbook.principal }}/addressbook/{{ addressbook.id}}"></a>
|
||||||
|
<div class="inner">
|
||||||
<span class="title">
|
<span class="title">
|
||||||
{%- if addressbook.principal != user.id -%}{{ addressbook.principal }}/{%- endif -%}
|
{%- if addressbook.principal != user.id -%}{{ addressbook.principal }}/{%- endif -%}
|
||||||
{{ addressbook.displayname.to_owned().unwrap_or(addressbook.id.to_owned()) }}
|
{{ addressbook.displayname.to_owned().unwrap_or(addressbook.id.to_owned()) }}
|
||||||
@@ -15,13 +16,19 @@
|
|||||||
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>
|
||||||
<div class="metadata">
|
<div class="metadata">
|
||||||
{{ meta.len }} ({{ meta.size | filesizeformat }}) objects, {{ meta.deleted_len }} ({{ meta.deleted_size | filesizeformat }}) deleted objects
|
{{ meta.len }} ({{ meta.size | filesizeformat }}) objects, {{ meta.deleted_len }} ({{ meta.deleted_size | filesizeformat }}) deleted objects
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
You do not have any addressbooks yet
|
You do not have any addressbooks yet
|
||||||
@@ -32,7 +39,8 @@
|
|||||||
<ul class="collection-list">
|
<ul class="collection-list">
|
||||||
{% for (meta, addressbook) in deleted_addressbooks %}
|
{% for (meta, addressbook) in deleted_addressbooks %}
|
||||||
<li class="collection-list-item">
|
<li class="collection-list-item">
|
||||||
<a href="/frontend/user/{{ addressbook.principal }}/addressbook/{{ addressbook.id}}">
|
<a href="/frontend/user/{{ addressbook.principal }}/addressbook/{{ addressbook.id}}"></a>
|
||||||
|
<div class="inner">
|
||||||
<span class="title">
|
<span class="title">
|
||||||
{%- if addressbook.principal != user.id -%}{{ addressbook.principal }}/{%- endif -%}
|
{%- if addressbook.principal != user.id -%}{{ addressbook.principal }}/{%- endif -%}
|
||||||
{{ addressbook.displayname.to_owned().unwrap_or(addressbook.id.to_owned()) }}
|
{{ addressbook.displayname.to_owned().unwrap_or(addressbook.id.to_owned()) }}
|
||||||
@@ -50,7 +58,7 @@
|
|||||||
<div class="metadata">
|
<div class="metadata">
|
||||||
{{ meta.len }} ({{ meta.size | filesizeformat }}) objects, {{ meta.deleted_len }} ({{ meta.deleted_size | filesizeformat }}) deleted objects
|
{{ meta.len }} ({{ meta.size | filesizeformat }}) objects, {{ meta.deleted_len }} ({{ meta.deleted_size | filesizeformat }}) deleted objects
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -3,16 +3,17 @@
|
|||||||
{% for (meta, calendar) in calendars %}
|
{% for (meta, calendar) in calendars %}
|
||||||
{% let color = calendar.color.to_owned().unwrap_or("transparent".to_owned()) %}
|
{% let color = calendar.color.to_owned().unwrap_or("transparent".to_owned()) %}
|
||||||
<li class="collection-list-item" style="--color: {{ color }}">
|
<li class="collection-list-item" style="--color: {{ color }}">
|
||||||
<a href="/frontend/user/{{ calendar.principal }}/calendar/{{ calendar.id }}">
|
<a href="/frontend/user/{{ calendar.principal }}/calendar/{{ calendar.id }}"></a>
|
||||||
|
<div class="inner">
|
||||||
<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()) }}
|
||||||
</span>
|
|
||||||
<div class="comps">
|
<div class="comps">
|
||||||
{% for comp in calendar.components %}
|
{% for comp in calendar.components %}
|
||||||
<span>{{ comp }}</span>
|
<span>{{ comp }}</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</span>
|
||||||
<span class="description">
|
<span class="description">
|
||||||
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
|
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
|
||||||
</span>
|
</span>
|
||||||
@@ -24,6 +25,15 @@
|
|||||||
<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 }}"
|
||||||
|
timezone_id="{{ calendar.timezone_id.as_deref().unwrap_or_default() }}"
|
||||||
|
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>
|
||||||
@@ -31,7 +41,7 @@
|
|||||||
{{ meta.len }} ({{ meta.size | filesizeformat }}) objects, {{ meta.deleted_len }} ({{ meta.deleted_size | filesizeformat }}) deleted objects
|
{{ meta.len }} ({{ meta.size | filesizeformat }}) objects, {{ meta.deleted_len }} ({{ meta.deleted_size | filesizeformat }}) deleted objects
|
||||||
</div>
|
</div>
|
||||||
<div class="color-chip"></div>
|
<div class="color-chip"></div>
|
||||||
</a>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
You do not have any calendars yet
|
You do not have any calendars yet
|
||||||
@@ -43,16 +53,17 @@
|
|||||||
{% for (meta, calendar) in deleted_calendars %}
|
{% for (meta, calendar) in deleted_calendars %}
|
||||||
{% let color = calendar.color.to_owned().unwrap_or("transparent".to_owned()) %}
|
{% let color = calendar.color.to_owned().unwrap_or("transparent".to_owned()) %}
|
||||||
<li class="collection-list-item" style="--color: {{ color }}">
|
<li class="collection-list-item" style="--color: {{ color }}">
|
||||||
<a href="/frontend/user/{{ calendar.principal }}/calendar/{{ calendar.id}}">
|
<a href="/frontend/user/{{ calendar.principal }}/calendar/{{ calendar.id}}"></a>
|
||||||
|
<div class="inner">
|
||||||
<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()) }}
|
||||||
</span>
|
|
||||||
<div class="comps">
|
<div class="comps">
|
||||||
{% for comp in calendar.components %}
|
{% for comp in calendar.components %}
|
||||||
<span>{{ comp }}</span>
|
<span>{{ comp }}</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</span>
|
||||||
<span class="description">
|
<span class="description">
|
||||||
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
|
{% if let Some(description) = calendar.description %}{{ description }}{% endif %}
|
||||||
</span>
|
</span>
|
||||||
@@ -67,7 +78,7 @@
|
|||||||
{{ meta.len }} ({{ meta.size | filesizeformat }}) objects, {{ meta.deleted_len }} ({{ meta.deleted_size | filesizeformat }}) deleted objects
|
{{ meta.len }} ({{ meta.size | filesizeformat }}) objects, {{ meta.deleted_len }} ({{ meta.deleted_size | filesizeformat }}) deleted objects
|
||||||
</div>
|
</div>
|
||||||
<div class="color-chip"></div>
|
<div class="color-chip"></div>
|
||||||
</a>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -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>
|
||||||
</body>
|
|
||||||
<footer>
|
<footer>
|
||||||
<a href="{{ env!("CARGO_PKG_REPOSITORY") }}" target="_blank">RustiCal {{ env!("CARGO_PKG_VERSION") }}</a>
|
<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>
|
<a href="/frontend/assets/licenses.html" target="_blank">Open Source Licenses</a>
|
||||||
</footer>
|
</footer>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
{% extends "layouts/default.html" %}
|
{% extends "layouts/default.html" %}
|
||||||
|
|
||||||
{% block imports %}
|
{% block imports %}
|
||||||
|
<template id="data-rustical-user">{{ user|json }}</template>
|
||||||
|
<script>
|
||||||
|
window.rusticalUser = JSON.parse(document.querySelector('#data-rustical-user').innerHTML)
|
||||||
|
</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 %}
|
||||||
|
|||||||
@@ -148,8 +148,7 @@ async fn unauthorized_handler(mut request: Request, next: Next) -> Response {
|
|||||||
<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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,15 +56,19 @@ pub async fn route_post_app_token<AP: AuthenticationProvider>(
|
|||||||
assert!(!name.is_empty());
|
assert!(!name.is_empty());
|
||||||
assert_eq!(user_id, user.id);
|
assert_eq!(user_id, user.id);
|
||||||
let token = generate_app_token();
|
let token = generate_app_token();
|
||||||
auth_provider
|
let mut token_id = auth_provider
|
||||||
.add_app_token(&user.id, name.to_owned(), token.clone())
|
.add_app_token(&user.id, name.to_owned(), token.clone())
|
||||||
.await?;
|
.await?;
|
||||||
|
// Get first 4 characters of token identifier
|
||||||
|
token_id.truncate(4);
|
||||||
|
// This will be a hint for the token validator which app token hash to verify against
|
||||||
|
let token = format!("{token_id}_{token}");
|
||||||
if apple {
|
if apple {
|
||||||
let profile = AppleConfig {
|
let profile = AppleConfig {
|
||||||
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 +83,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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ impl CalDateTime {
|
|||||||
matches!(&self, Self::Date(_, _))
|
matches!(&self, Self::Date(_, _))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_datetime(&self) -> Cow<DateTime<CalTimezone>> {
|
pub fn as_datetime(&self) -> Cow<'_, DateTime<CalTimezone>> {
|
||||||
match self {
|
match self {
|
||||||
Self::DateTime(datetime) => Cow::Borrowed(datetime),
|
Self::DateTime(datetime) => Cow::Borrowed(datetime),
|
||||||
Self::Date(date, tz) => Cow::Owned(
|
Self::Date(date, tz) => Cow::Owned(
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ chrono-tz = { workspace = true }
|
|||||||
derive_more = { workspace = true, features = ["as_ref"] }
|
derive_more = { workspace = true, features = ["as_ref"] }
|
||||||
rustical_xml.workspace = true
|
rustical_xml.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
rand.workspace = true
|
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
rustical_dav.workspace = true
|
rustical_dav.workspace = true
|
||||||
rustical_ical.workspace = true
|
rustical_ical.workspace = true
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ pub struct Principal {
|
|||||||
pub displayname: Option<String>,
|
pub displayname: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub principal_type: PrincipalType,
|
pub principal_type: PrincipalType,
|
||||||
|
#[serde(skip_serializing)]
|
||||||
pub password: Option<Secret<String>>,
|
pub password: Option<Secret<String>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub memberships: Vec<String>,
|
pub memberships: Vec<String>,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub enum PrincipalType {
|
|||||||
Resource,
|
Resource,
|
||||||
Room,
|
Room,
|
||||||
Unknown,
|
Unknown,
|
||||||
// TODO: X-Name, IANA-token
|
// X-Name, IANA-token
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&str> for PrincipalType {
|
impl TryFrom<&str> for PrincipalType {
|
||||||
|
|||||||
@@ -149,8 +149,23 @@ impl AuthenticationProvider for SqlitePrincipalStore {
|
|||||||
user_id: &str,
|
user_id: &str,
|
||||||
token: &str,
|
token: &str,
|
||||||
) -> Result<Option<Principal>, Error> {
|
) -> Result<Option<Principal>, Error> {
|
||||||
|
#[instrument(skip(password))]
|
||||||
|
fn verify_password(password: &str, hash: &str) -> Result<(), password_auth::VerifyError> {
|
||||||
|
password_auth::verify_password(password, hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow to specify the token id to use to make validation faster
|
||||||
|
// Doesn't match the whole length of the token id to keep the length in bounds
|
||||||
|
// Example: asd_selgkh
|
||||||
|
// where the app token id starts with asd and its value is selgkh
|
||||||
|
let (token_id_prefix, token) = token.split_once('_').unwrap_or(("", token));
|
||||||
|
|
||||||
for app_token in &self.get_app_tokens(user_id).await? {
|
for app_token in &self.get_app_tokens(user_id).await? {
|
||||||
if password_auth::verify_password(token, app_token.token.as_ref()).is_ok() {
|
// Wrong token id
|
||||||
|
if !app_token.id.starts_with(token_id_prefix) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if verify_password(token, app_token.token.as_ref()).is_ok() {
|
||||||
return self.get_principal(user_id).await;
|
return self.get_principal(user_id).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,7 +221,10 @@ impl AuthenticationProvider for SqlitePrincipalStore {
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
Params {
|
Params {
|
||||||
rounds: 100,
|
// The app token has a high entropy so we are quite safe from quessing attacks
|
||||||
|
// Also if an attacker got access to the hashes they'd have already gotten
|
||||||
|
// access to the whole database.
|
||||||
|
rounds: 2,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
&salt,
|
&salt,
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ impl SubscriptionStore for SqliteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn upsert_subscription(&self, sub: Subscription) -> Result<bool, Error> {
|
async fn upsert_subscription(&self, sub: Subscription) -> Result<bool, Error> {
|
||||||
|
let already_exists = match self.get_subscription(&sub.id).await {
|
||||||
|
Ok(_) => true,
|
||||||
|
Err(Error::NotFound) => false,
|
||||||
|
Err(err) => return Err(err),
|
||||||
|
};
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"INSERT OR REPLACE INTO davpush_subscriptions (id, topic, expiration, push_resource, public_key, public_key_type, auth_secret) VALUES (?, ?, ?, ?, ?, ?, ?)"#,
|
r#"INSERT OR REPLACE INTO davpush_subscriptions (id, topic, expiration, push_resource, public_key, public_key_type, auth_secret) VALUES (?, ?, ?, ?, ?, ?, ?)"#,
|
||||||
sub.id,
|
sub.id,
|
||||||
@@ -41,8 +46,7 @@ impl SubscriptionStore for SqliteStore {
|
|||||||
sub.public_key_type,
|
sub.public_key_type,
|
||||||
sub.auth_secret
|
sub.auth_secret
|
||||||
).execute(&self.db).await.map_err(crate::Error::from)?;
|
).execute(&self.db).await.map_err(crate::Error::from)?;
|
||||||
// TODO: Correctly return whether a subscription already existed
|
Ok(already_exists)
|
||||||
Ok(false)
|
|
||||||
}
|
}
|
||||||
async fn delete_subscription(&self, id: &str) -> Result<(), Error> {
|
async fn delete_subscription(&self, id: &str) -> Result<(), Error> {
|
||||||
sqlx::query!(r#"DELETE FROM davpush_subscriptions WHERE id = ? "#, id)
|
sqlx::query!(r#"DELETE FROM davpush_subscriptions WHERE id = ? "#, id)
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ pub trait XmlSerializeRoot {
|
|||||||
|
|
||||||
fn serialize_to_string(&self) -> std::io::Result<String> {
|
fn serialize_to_string(&self) -> std::io::Result<String> {
|
||||||
let mut buf: Vec<_> = b"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".into();
|
let mut buf: Vec<_> = b"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".into();
|
||||||
let mut writer = quick_xml::Writer::new(&mut buf);
|
let mut writer = quick_xml::Writer::new_with_indent(&mut buf, b' ', 4);
|
||||||
self.serialize_root(&mut writer)?;
|
self.serialize_root(&mut writer)?;
|
||||||
Ok(String::from_utf8_lossy(&buf).to_string())
|
Ok(String::from_utf8_lossy(&buf).to_string())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ fn test_struct_value_tagged() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out,
|
out,
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<propfind><prop><test>asd</test></prop></propfind>"
|
r#"<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<propfind>
|
||||||
|
<prop>
|
||||||
|
<test>asd</test>
|
||||||
|
</prop>
|
||||||
|
</propfind>"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,11 @@ fn test_struct_value_tagged() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out,
|
out,
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<document><href>okay</href><num>123</num></document>"
|
r#"<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<document>
|
||||||
|
<href>okay</href>
|
||||||
|
<num>123</num>
|
||||||
|
</document>"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +95,8 @@ fn test_struct_value_untagged() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out,
|
out,
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<document>okays</document>"
|
r#"<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<document>okays</document>"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +116,11 @@ fn test_struct_vec() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out,
|
out,
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<document><href>okay</href><href>wow</href></document>"
|
r#"<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<document>
|
||||||
|
<href>okay</href>
|
||||||
|
<href>wow</href>
|
||||||
|
</document>"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +150,10 @@ fn test_struct_serialize_with() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out,
|
out,
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<document><href>OKAY</href></document>"
|
r#"<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<document>
|
||||||
|
<href>OKAY</href>
|
||||||
|
</document>"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@ a CalDAV/CardDAV server
|
|||||||
you'd still be one of the first testers so expect bugs and rough edges.
|
you'd still be one of the first testers so expect bugs and rough edges.
|
||||||
If you still want to play around with it in its current state, absolutely feel free to do so and to open up an issue if something is not working. :)
|
If you still want to play around with it in its current state, absolutely feel free to do so and to open up an issue if something is not working. :)
|
||||||
|
|
||||||
|
[Installation](installation/index.md){ .md-button }
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- 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.
|
||||||
|
|||||||
80
docs/setup/client.md
Normal file
80
docs/setup/client.md
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# Client Setup
|
||||||
|
|
||||||
|
## Common
|
||||||
|
|
||||||
|
Following resources are available.
|
||||||
|
|
||||||
|
```
|
||||||
|
/.well-known/caldav
|
||||||
|
# CalDAV root
|
||||||
|
/caldav
|
||||||
|
# Principal home
|
||||||
|
/caldav/principal/<user_id>
|
||||||
|
# Calendar home
|
||||||
|
/caldav/principal/<user_id>/<calendar_id>
|
||||||
|
/caldav/principal/<user_id>/_birthdays_<addressbook_id>
|
||||||
|
|
||||||
|
# CalDAV root
|
||||||
|
/caldav-compat
|
||||||
|
/caldav-compat/principal...
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
/.well-known/carddav
|
||||||
|
# CardDAV root
|
||||||
|
/carddav
|
||||||
|
# Principal home
|
||||||
|
/carddav/principal/<user_id>
|
||||||
|
# Addressbook home
|
||||||
|
/carddav/principal/<user_id>/<addressbook_id>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Authentication
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
You can set up DAVx5 through the Nextcloud login flow. Collections including group collections will automatically be discovered.
|
||||||
|
|
||||||
|
## Apple Calendar
|
||||||
|
|
||||||
|
You can download a configuration profile from the frontend in the app token section.
|
||||||
|
|
||||||
|
**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
|
||||||
|
|
||||||
|
Set up a collection account in the account settings.
|
||||||
|
Evolution correctly uses all calendar homes so group collections work properly.
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
```
|
||||||
|
https://<your-host>/caldav-compat
|
||||||
|
```
|
||||||
|
|
||||||
|
For group collections explicitly specify
|
||||||
|
|
||||||
|
```
|
||||||
|
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
|
||||||
@@ -68,6 +68,7 @@ nav:
|
|||||||
- Installation:
|
- Installation:
|
||||||
- installation/index.md
|
- installation/index.md
|
||||||
- Configuration: installation/configuration.md
|
- Configuration: installation/configuration.md
|
||||||
|
- Client Setup: setup/client.md
|
||||||
- OpenID Connect: setup/oidc.md
|
- OpenID Connect: setup/oidc.md
|
||||||
- Developers:
|
- Developers:
|
||||||
- developers/index.md
|
- developers/index.md
|
||||||
|
|||||||
48
src/app.rs
48
src/app.rs
@@ -1,10 +1,13 @@
|
|||||||
use crate::config::NextcloudLoginConfig;
|
use crate::config::NextcloudLoginConfig;
|
||||||
use axum::Router;
|
use axum::Router;
|
||||||
use axum::body::Body;
|
use axum::body::{Body, HttpBody};
|
||||||
use axum::extract::Request;
|
use axum::extract::Request;
|
||||||
use axum::response::Response;
|
use axum::middleware::Next;
|
||||||
use axum::routing::options;
|
use axum::response::{Redirect, Response};
|
||||||
|
use axum::routing::{any, options};
|
||||||
|
use axum_extra::TypedHeader;
|
||||||
use headers::{HeaderMapExt, UserAgent};
|
use headers::{HeaderMapExt, UserAgent};
|
||||||
|
use http::header::CONNECTION;
|
||||||
use http::{HeaderValue, StatusCode};
|
use http::{HeaderValue, StatusCode};
|
||||||
use rustical_caldav::caldav_router;
|
use rustical_caldav::caldav_router;
|
||||||
use rustical_carddav::carddav_router;
|
use rustical_carddav::carddav_router;
|
||||||
@@ -47,7 +50,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") || ua.as_str().contains("dataaccessd") {
|
||||||
|
// 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(),
|
||||||
@@ -155,4 +180,21 @@ pub fn make_app<AS: AddressbookStore, CS: CalendarStore, S: SubscriptionStore>(
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.layer(axum::middleware::from_fn(
|
||||||
|
async |req: Request, next: Next| {
|
||||||
|
// Closes the connection if the request body might've not been fully consumed
|
||||||
|
// Otherwise subsequent requests reusing the connection might fail.
|
||||||
|
// See https://github.com/lennart-k/rustical/issues/77
|
||||||
|
let body_empty = req.body().is_end_stream();
|
||||||
|
let mut response = next.run(req).await;
|
||||||
|
if !body_empty
|
||||||
|
&& (response.status().is_server_error() || response.status().is_client_error())
|
||||||
|
{
|
||||||
|
response
|
||||||
|
.headers_mut()
|
||||||
|
.insert(CONNECTION, HeaderValue::from_static("close"));
|
||||||
|
}
|
||||||
|
response
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user