mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 20:08:19 +00:00
Compare commits
124 Commits
v0.11.2
...
df3143cd4c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df3143cd4c | ||
|
|
92a3418f8e | ||
|
|
ea2f841269 | ||
|
|
15e1509fe3 | ||
|
|
0eef4ffabf | ||
|
|
303f9aff68 | ||
|
|
3460a2821e | ||
|
|
f73658b32f | ||
|
|
7e099bcd6e | ||
|
|
dde05d2f45 | ||
|
|
4adf1818d4 | ||
|
|
f503bf2bf7 | ||
|
|
7c15976a1a | ||
|
|
669d81aea0 | ||
|
|
967d18de95 | ||
|
|
63373ad525 | ||
|
|
2c67890343 | ||
|
|
5ec2787ecf | ||
|
|
7eecd95757 | ||
|
|
c165e761be | ||
|
|
5f68a5ae5c | ||
|
|
c77b59dcb0 | ||
|
|
276fdcacf5 | ||
|
|
43fff63008 | ||
|
|
977fd75500 | ||
|
|
5639127782 | ||
|
|
a2255bc7f1 | ||
|
|
758793a11a | ||
|
|
a9f3833a32 | ||
|
|
896e934c0a | ||
|
|
bb880aa403 | ||
|
|
69acde10ba | ||
|
|
d84158e8ad | ||
|
|
7ef566040a | ||
|
|
1c1f0c6da2 | ||
|
|
3fafbd22f4 | ||
|
|
e68dc921e6 | ||
|
|
60b45e70ad | ||
|
|
a0c33c82dd | ||
|
|
8ae5e46abf | ||
|
|
48b2e614a8 | ||
|
|
f26214abb9 | ||
|
|
276e65d41a | ||
|
|
7c3e9ecbc1 | ||
|
|
53f81a9433 | ||
|
|
55eabfde4a | ||
|
|
5d9d6e3fdf | ||
|
|
1567bc64ef | ||
|
|
44ae995f29 | ||
|
|
9c1cd24d32 | ||
|
|
ff0c5697cf | ||
|
|
6ccb5a67e4 | ||
|
|
da718dd290 | ||
|
|
4112347e24 | ||
|
|
f4fd1cdd21 | ||
|
|
5f0ca67e54 | ||
|
|
3aef9abe48 | ||
|
|
9784f2b53f | ||
|
|
271fdfd686 | ||
|
|
4fabf74333 | ||
|
|
7b154adec3 | ||
|
|
951a1e4bdc | ||
|
|
8c44733d0a | ||
|
|
829f7b727f | ||
|
|
037e6f5c92 | ||
|
|
311ceb6bc5 | ||
|
|
1174af3a4b | ||
|
|
845b3e61e3 | ||
|
|
e5d6541ffb | ||
|
|
b632ff6fe8 | ||
|
|
1ee873ac93 | ||
|
|
bf5bdb96bc | ||
|
|
47c2a55941 | ||
|
|
bfcd94f096 | ||
|
|
8cbb72719d | ||
|
|
ff0246c4fc | ||
|
|
15124a2fd5 | ||
|
|
5c6f63a5f3 | ||
|
|
17ba8faef2 | ||
|
|
578ddde36d | ||
|
|
9c3972e21c | ||
|
|
816c26565a | ||
|
|
4de0f9f665 | ||
|
|
cf31a51965 | ||
|
|
9fc099f6f4 | ||
|
|
498be172c9 | ||
|
|
b8c395e746 | ||
|
|
4b8a8c61f2 | ||
|
|
f778c470d0 | ||
|
|
d44a172261 | ||
|
|
e0ba34baea | ||
|
|
a7893ddbda | ||
|
|
ed7becffc2 | ||
|
|
c29400a799 | ||
|
|
047552a726 | ||
|
|
1cfc8e7c23 | ||
|
|
b0fdca1b64 | ||
|
|
b65cca9d17 | ||
|
|
55ecbdcd41 | ||
|
|
89d3d3b7a4 | ||
|
|
a74b74369c | ||
|
|
85c49a0bdf | ||
|
|
f2e4e2c1a7 | ||
|
|
28c925301e | ||
|
|
b50ea478db | ||
|
|
2c7748255c | ||
|
|
f40a23a1f1 | ||
|
|
2a4ba33e45 | ||
|
|
6bc4bd3fa3 | ||
|
|
7b32d478b8 | ||
|
|
fb0bd67176 | ||
|
|
ecad0d4490 | ||
|
|
e702e77656 | ||
|
|
141f881382 | ||
|
|
b8d2ac0654 | ||
|
|
16aae73cd1 | ||
|
|
120d45eb0a | ||
|
|
0bdfb786ff | ||
|
|
d9cca5a298 | ||
|
|
50a74e3a25 | ||
|
|
ed8a9e718a | ||
|
|
38b5a3812e | ||
|
|
d3e7ede93c | ||
|
|
4e90f725e0 |
19
.github/workflows/cicd.yml
vendored
19
.github/workflows/cicd.yml
vendored
@@ -5,6 +5,7 @@ permissions:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
RUST_VERSION: "1.92"
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -12,7 +13,9 @@ jobs:
|
|||||||
name: Check
|
name: Check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: rustup update
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- run: cargo check
|
- run: cargo check
|
||||||
@@ -21,7 +24,9 @@ jobs:
|
|||||||
name: Test Suite
|
name: Test Suite
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: rustup update
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- run: cargo test --all-features --verbose --workspace
|
- run: cargo test --all-features --verbose --workspace
|
||||||
@@ -30,7 +35,9 @@ jobs:
|
|||||||
name: Test Coverage
|
name: Test Coverage
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: rustup update
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
- name: Install tarpaulin
|
- name: Install tarpaulin
|
||||||
run: cargo install cargo-tarpaulin
|
run: cargo install cargo-tarpaulin
|
||||||
|
|
||||||
@@ -44,8 +51,10 @@ jobs:
|
|||||||
name: Lints
|
name: Lints
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: rustup update
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
- run: rustup component add rustfmt clippy
|
with:
|
||||||
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
|
components: rustfmt, clippy
|
||||||
|
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
14
.github/workflows/docker-publish.yml
vendored
14
.github/workflows/docker-publish.yml
vendored
@@ -2,7 +2,10 @@ name: Docker
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main"]
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
- feat/*
|
||||||
release:
|
release:
|
||||||
types: ["published"]
|
types: ["published"]
|
||||||
|
|
||||||
@@ -26,12 +29,12 @@ jobs:
|
|||||||
|
|
||||||
# https://github.com/docker/setup-buildx-action
|
# https://github.com/docker/setup-buildx-action
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# https://github.com/docker/login-action
|
# https://github.com/docker/login-action
|
||||||
- name: Log into registry ${{ env.REGISTRY }}
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -45,7 +48,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
${{ github.ref_name == 'main' && 'type=ref,event=branch' || '' }}
|
||||||
|
type=ref,event=branch,prefix=br-
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
@@ -54,7 +58,7 @@ jobs:
|
|||||||
# https://github.com/docker/build-push-action
|
# https://github.com/docker/build-push-action
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
id: build-and-push
|
id: build-and-push
|
||||||
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/arm64,linux/amd64
|
platforms: linux/arm64,linux/amd64
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,3 +16,5 @@ site
|
|||||||
# Frontend
|
# Frontend
|
||||||
**/node_modules
|
**/node_modules
|
||||||
**/.vite
|
**/.vite
|
||||||
|
|
||||||
|
**/*.snap.new
|
||||||
|
|||||||
12
.sqlx/query-146e23ae4e0eaae4d65ac7563c67d4f295ccc2534dcc4b3bd710de773ed137f9.json
generated
Normal file
12
.sqlx/query-146e23ae4e0eaae4d65ac7563c67d4f295ccc2534dcc4b3bd710de773ed137f9.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "DELETE FROM calendarobjectchangelog WHERE (principal, cal_id, object_id) = (?, ?, ?);",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 3
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "146e23ae4e0eaae4d65ac7563c67d4f295ccc2534dcc4b3bd710de773ed137f9"
|
||||||
|
}
|
||||||
12
.sqlx/query-354decac84758c88280f60fbf0f93dddc6c7ff92ac7b8ba44049d31df3c680e3.json
generated
Normal file
12
.sqlx/query-354decac84758c88280f60fbf0f93dddc6c7ff92ac7b8ba44049d31df3c680e3.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "UPDATE calendarobjects SET ics = ? WHERE (principal, cal_id, id) = (?, ?, ?);",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 4
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "354decac84758c88280f60fbf0f93dddc6c7ff92ac7b8ba44049d31df3c680e3"
|
||||||
|
}
|
||||||
38
.sqlx/query-bdaa4bee8b01d0e3773e34672ed4805d1e71d24888f2227045afd90bf080fc23.json
generated
Normal file
38
.sqlx/query-bdaa4bee8b01d0e3773e34672ed4805d1e71d24888f2227045afd90bf080fc23.json
generated
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "SELECT principal, cal_id, id, ics FROM calendarobjects WHERE ics LIKE '%VERSION:4.0%';",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "principal",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cal_id",
|
||||||
|
"ordinal": 1,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ics",
|
||||||
|
"ordinal": 3,
|
||||||
|
"type_info": "Text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 0
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "bdaa4bee8b01d0e3773e34672ed4805d1e71d24888f2227045afd90bf080fc23"
|
||||||
|
}
|
||||||
885
Cargo.lock
generated
885
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
40
Cargo.toml
40
Cargo.toml
@@ -2,8 +2,8 @@
|
|||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.11.2"
|
version = "0.11.17"
|
||||||
rust-version = "1.91"
|
rust-version = "1.92"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
description = "A CalDAV server"
|
description = "A CalDAV server"
|
||||||
documentation = "https://lennart-k.github.io/rustical/"
|
documentation = "https://lennart-k.github.io/rustical/"
|
||||||
@@ -32,12 +32,11 @@ opentelemetry = [
|
|||||||
"dep:tracing-opentelemetry",
|
"dep:tracing-opentelemetry",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
debug = 0
|
debug = 0
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
rustical_dav = { path = "./crates/dav/" }
|
rustical_dav = { path = "./crates/dav/", features = ["ical"] }
|
||||||
rustical_dav_push = { path = "./crates/dav_push/" }
|
rustical_dav_push = { path = "./crates/dav_push/" }
|
||||||
rustical_store = { path = "./crates/store/" }
|
rustical_store = { path = "./crates/store/" }
|
||||||
rustical_store_sqlite = { path = "./crates/store_sqlite/" }
|
rustical_store_sqlite = { path = "./crates/store_sqlite/" }
|
||||||
@@ -49,7 +48,7 @@ rustical_oidc = { path = "./crates/oidc/" }
|
|||||||
rustical_ical = { path = "./crates/ical/" }
|
rustical_ical = { path = "./crates/ical/" }
|
||||||
|
|
||||||
matchit = "0.9"
|
matchit = "0.9"
|
||||||
uuid = { version = "1.11", features = ["v4", "fast-rng"] }
|
uuid = { version = "1.19", features = ["v4", "fast-rng"] }
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
axum = "0.8"
|
axum = "0.8"
|
||||||
tracing = { version = "0.1", features = ["async-await"] }
|
tracing = { version = "0.1", features = ["async-await"] }
|
||||||
@@ -60,11 +59,11 @@ password-auth = { version = "1.0", features = ["argon2", "pbkdf2"] }
|
|||||||
pbkdf2 = { version = "0.12", features = ["simple"] }
|
pbkdf2 = { version = "0.12", features = ["simple"] }
|
||||||
rand_core = { version = "0.9", features = ["std"] }
|
rand_core = { version = "0.9", features = ["std"] }
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
regex = "1.10"
|
regex = "1.12"
|
||||||
rstest = "0.26"
|
rstest = "0.26"
|
||||||
rstest_reuse = "0.7"
|
rstest_reuse = "0.7"
|
||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
tokio = { version = "1", features = [
|
tokio = { version = "1.48", features = [
|
||||||
"net",
|
"net",
|
||||||
"tracing",
|
"tracing",
|
||||||
"macros",
|
"macros",
|
||||||
@@ -74,15 +73,15 @@ tokio = { version = "1", features = [
|
|||||||
url = "2.5"
|
url = "2.5"
|
||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
thiserror = "2.0"
|
thiserror = "2.0"
|
||||||
quick-xml = { version = "0.38" }
|
quick-xml = { version = "0.39" }
|
||||||
rust-embed = "8.5"
|
rust-embed = "8.9"
|
||||||
tower-sessions = "0.14"
|
tower-sessions = "0.14"
|
||||||
futures-core = "0.3.31"
|
futures-core = "0.3"
|
||||||
hex = { version = "0.4.3", features = ["serde"] }
|
hex = { version = "0.4", features = ["serde"] }
|
||||||
mime_guess = "2.0"
|
mime_guess = "2.0"
|
||||||
itertools = "0.14"
|
itertools = "0.14"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
derive_more = { version = "2.0", features = [
|
derive_more = { version = "2.1", features = [
|
||||||
"from",
|
"from",
|
||||||
"try_into",
|
"try_into",
|
||||||
"into",
|
"into",
|
||||||
@@ -90,8 +89,8 @@ derive_more = { version = "2.0", features = [
|
|||||||
"constructor",
|
"constructor",
|
||||||
"display",
|
"display",
|
||||||
] }
|
] }
|
||||||
askama = { version = "0.14", features = ["serde_json"] }
|
askama = { version = "0.15", features = ["serde_json"] }
|
||||||
askama_web = { version = "0.14.0", features = ["axum-0.8"] }
|
askama_web = { version = "0.15", features = ["axum-0.8"] }
|
||||||
sqlx = { version = "0.8", default-features = false, features = [
|
sqlx = { version = "0.8", default-features = false, features = [
|
||||||
"sqlx-sqlite",
|
"sqlx-sqlite",
|
||||||
"uuid",
|
"uuid",
|
||||||
@@ -102,15 +101,13 @@ sqlx = { version = "0.8", default-features = false, features = [
|
|||||||
"migrate",
|
"migrate",
|
||||||
"json",
|
"json",
|
||||||
] }
|
] }
|
||||||
http = "1.3"
|
http = "1.4"
|
||||||
headers = "0.4"
|
headers = "0.4"
|
||||||
strum = "0.27"
|
strum = "0.27"
|
||||||
strum_macros = "0.27"
|
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 = { git = "https://github.com/lennart-k/ical-rs", features = [
|
ical = { git = "https://github.com/lennart-k/ical-rs", rev = "f1ad6456fd6cbd1e6da095297febddd2cfe61422", features = [
|
||||||
"generator",
|
|
||||||
"serde",
|
|
||||||
"chrono-tz",
|
"chrono-tz",
|
||||||
] }
|
] }
|
||||||
toml = "0.9"
|
toml = "0.9"
|
||||||
@@ -127,7 +124,7 @@ rand = "0.9"
|
|||||||
axum-extra = { version = "0.12", features = ["typed-header"] }
|
axum-extra = { version = "0.12", features = ["typed-header"] }
|
||||||
rrule = "0.14"
|
rrule = "0.14"
|
||||||
argon2 = "0.5"
|
argon2 = "0.5"
|
||||||
rpassword = "7.3"
|
rpassword = "7.4"
|
||||||
password-hash = { version = "0.5" }
|
password-hash = { version = "0.5" }
|
||||||
syn = { version = "2.0", features = ["full"] }
|
syn = { version = "2.0", features = ["full"] }
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
@@ -149,12 +146,14 @@ ece = { version = "2.3", default-features = false, features = [
|
|||||||
openssl = { version = "0.10", features = ["vendored"] }
|
openssl = { version = "0.10", features = ["vendored"] }
|
||||||
async-std = { version = "1.13", features = ["attributes"] }
|
async-std = { version = "1.13", features = ["attributes"] }
|
||||||
similar-asserts = "1.7"
|
similar-asserts = "1.7"
|
||||||
insta = "1.44"
|
insta = { version = "1.44", features = ["filters"] }
|
||||||
|
criterion = { version = "0.8", features = ["async_tokio"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rstest.workspace = true
|
rstest.workspace = true
|
||||||
rustical_store_sqlite = { workspace = true, features = ["test"] }
|
rustical_store_sqlite = { workspace = true, features = ["test"] }
|
||||||
insta.workspace = true
|
insta.workspace = true
|
||||||
|
similar-asserts.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustical_store.workspace = true
|
rustical_store.workspace = true
|
||||||
@@ -162,6 +161,7 @@ rustical_store_sqlite.workspace = true
|
|||||||
rustical_caldav.workspace = true
|
rustical_caldav.workspace = true
|
||||||
rustical_carddav.workspace = true
|
rustical_carddav.workspace = true
|
||||||
rustical_frontend.workspace = true
|
rustical_frontend.workspace = true
|
||||||
|
ical.workspace = true
|
||||||
toml.workspace = true
|
toml.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM --platform=$BUILDPLATFORM rust:1.91-alpine AS chef
|
FROM --platform=$BUILDPLATFORM rust:1.92-alpine AS chef
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
@@ -36,7 +36,7 @@ COPY --from=planner /rustical/recipe.json recipe.json
|
|||||||
RUN cargo chef cook --release --target "$(cat /tmp/rust_target)"
|
RUN cargo chef cook --release --target "$(cat /tmp/rust_target)"
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN cargo install --target "$(cat /tmp/rust_target)" --path .
|
RUN cargo install --locked --target "$(cat /tmp/rust_target)" --path .
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=builder /usr/local/cargo/bin/rustical /usr/local/bin/rustical
|
COPY --from=builder /usr/local/cargo/bin/rustical /usr/local/bin/rustical
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
[](https://raw.githubusercontent.com/lennart-k/rustical/main/LICENSE)
|
||||||
|
[](https://coveralls.io/github/lennart-k/rustical?branch=main)
|
||||||
|
|
||||||
# RustiCal
|
# RustiCal
|
||||||
|
|
||||||
a CalDAV/CardDAV server
|
a CalDAV/CardDAV server
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ base64.workspace = true
|
|||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
url.workspace = true
|
url.workspace = true
|
||||||
rustical_dav.workspace = true
|
rustical_dav = { workspace = true, features = ["ical"] }
|
||||||
rustical_store.workspace = true
|
rustical_store.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
chrono-tz.workspace = true
|
chrono-tz.workspace = true
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ 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, Method, StatusCode, header};
|
use http::{HeaderValue, Method, StatusCode, header};
|
||||||
use ical::generator::{Emitter, IcalCalendarBuilder};
|
use ical::component::IcalCalendar;
|
||||||
use ical::property::Property;
|
use ical::generator::Emitter;
|
||||||
|
use ical::property::ContentLine;
|
||||||
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
||||||
use rustical_ical::{CalendarObjectComponent, EventObject};
|
|
||||||
use rustical_store::{CalendarStore, SubscriptionStore, auth::Principal};
|
use rustical_store::{CalendarStore, SubscriptionStore, auth::Principal};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
@@ -32,70 +31,49 @@ pub async fn route_get<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
return Err(crate::Error::Unauthorized);
|
return Err(crate::Error::Unauthorized);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut vtimezones = HashMap::new();
|
let objects = cal_store
|
||||||
let objects = cal_store.get_objects(&principal, &calendar_id).await?;
|
.get_objects(&principal, &calendar_id)
|
||||||
|
.await?
|
||||||
|
.into_iter()
|
||||||
|
.map(|(_, object)| object.into())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let mut props = vec![];
|
||||||
|
|
||||||
let mut ical_calendar_builder = IcalCalendarBuilder::version("4.0")
|
|
||||||
.gregorian()
|
|
||||||
.prodid("RustiCal");
|
|
||||||
if let Some(displayname) = calendar.meta.displayname {
|
if let Some(displayname) = calendar.meta.displayname {
|
||||||
ical_calendar_builder = ical_calendar_builder.set(Property {
|
props.push(ContentLine {
|
||||||
name: "X-WR-CALNAME".to_owned(),
|
name: "X-WR-CALNAME".to_owned(),
|
||||||
value: Some(displayname),
|
value: Some(displayname),
|
||||||
params: None,
|
params: vec![].into(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if let Some(description) = calendar.meta.description {
|
if let Some(description) = calendar.meta.description {
|
||||||
ical_calendar_builder = ical_calendar_builder.set(Property {
|
props.push(ContentLine {
|
||||||
name: "X-WR-CALDESC".to_owned(),
|
name: "X-WR-CALDESC".to_owned(),
|
||||||
value: Some(description),
|
value: Some(description),
|
||||||
params: None,
|
params: vec![].into(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if let Some(color) = calendar.meta.color {
|
||||||
|
props.push(ContentLine {
|
||||||
|
name: "X-WR-CALCOLOR".to_owned(),
|
||||||
|
value: Some(color),
|
||||||
|
params: vec![].into(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if let Some(timezone_id) = calendar.timezone_id {
|
if let Some(timezone_id) = calendar.timezone_id {
|
||||||
ical_calendar_builder = ical_calendar_builder.set(Property {
|
props.push(ContentLine {
|
||||||
name: "X-WR-TIMEZONE".to_owned(),
|
name: "X-WR-TIMEZONE".to_owned(),
|
||||||
value: Some(timezone_id),
|
value: Some(timezone_id),
|
||||||
params: None,
|
params: vec![].into(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for object in &objects {
|
let export_calendar = IcalCalendar::from_objects("RustiCal Export".to_owned(), objects, props);
|
||||||
vtimezones.extend(object.get_vtimezones());
|
|
||||||
match object.get_data() {
|
|
||||||
CalendarObjectComponent::Event(EventObject { event, .. }, overrides) => {
|
|
||||||
ical_calendar_builder = ical_calendar_builder.add_event(event.clone());
|
|
||||||
for ev_override in overrides {
|
|
||||||
ical_calendar_builder =
|
|
||||||
ical_calendar_builder.add_event(ev_override.event.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CalendarObjectComponent::Todo(todo, overrides) => {
|
|
||||||
ical_calendar_builder = ical_calendar_builder.add_todo(todo.clone());
|
|
||||||
for ev_override in overrides {
|
|
||||||
ical_calendar_builder = ical_calendar_builder.add_todo(ev_override.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CalendarObjectComponent::Journal(journal, overrides) => {
|
|
||||||
ical_calendar_builder = ical_calendar_builder.add_journal(journal.clone());
|
|
||||||
for ev_override in overrides {
|
|
||||||
ical_calendar_builder = ical_calendar_builder.add_journal(ev_override.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for vtimezone in vtimezones.into_values() {
|
|
||||||
ical_calendar_builder = ical_calendar_builder.add_tz(vtimezone.to_owned());
|
|
||||||
}
|
|
||||||
|
|
||||||
let ical_calendar = ical_calendar_builder
|
|
||||||
.build()
|
|
||||||
.map_err(|parser_error| Error::IcalError(parser_error.into()))?;
|
|
||||||
|
|
||||||
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/calendar").unwrap());
|
hdrs.typed_insert(ContentType::from_str("text/calendar; charset=utf-8").unwrap());
|
||||||
|
|
||||||
let filename = format!("{}_{}.ics", calendar.principal, calendar.id);
|
let filename = format!("{}_{}.ics", calendar.principal, calendar.id);
|
||||||
let filename = utf8_percent_encode(&filename, CONTROLS);
|
let filename = utf8_percent_encode(&filename, CONTROLS);
|
||||||
@@ -109,6 +87,6 @@ pub async fn route_get<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
if matches!(method, Method::HEAD) {
|
if matches!(method, Method::HEAD) {
|
||||||
Ok(resp.body(Body::empty()).unwrap())
|
Ok(resp.body(Body::empty()).unwrap())
|
||||||
} else {
|
} else {
|
||||||
Ok(resp.body(Body::new(ical_calendar.generate())).unwrap())
|
Ok(resp.body(Body::new(export_calendar.generate())).unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,12 @@ use axum::{
|
|||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
};
|
};
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use ical::{
|
use ical::parser::{Component, ComponentMut};
|
||||||
generator::Emitter,
|
|
||||||
parser::{Component, ComponentMut},
|
|
||||||
};
|
|
||||||
use rustical_dav::header::Overwrite;
|
use rustical_dav::header::Overwrite;
|
||||||
use rustical_ical::{CalendarObject, CalendarObjectType};
|
use rustical_ical::CalendarObjectType;
|
||||||
use rustical_store::{
|
use rustical_store::{
|
||||||
Calendar, CalendarMetadata, CalendarStore, SubscriptionStore, auth::Principal,
|
Calendar, CalendarMetadata, CalendarStore, SubscriptionStore, auth::Principal,
|
||||||
};
|
};
|
||||||
use std::io::BufReader;
|
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
#[instrument(skip(resource_service))]
|
#[instrument(skip(resource_service))]
|
||||||
@@ -29,18 +25,11 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
return Err(Error::Unauthorized);
|
return Err(Error::Unauthorized);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut parser = ical::IcalParser::new(BufReader::new(body.as_bytes()));
|
let parser = ical::IcalParser::from_slice(body.as_bytes());
|
||||||
let mut cal = parser
|
let mut cal = match parser.expect_one() {
|
||||||
.next()
|
Ok(cal) => cal.mutable(),
|
||||||
.expect("input must contain calendar")
|
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
|
||||||
.unwrap()
|
};
|
||||||
.mutable();
|
|
||||||
if parser.next().is_some() {
|
|
||||||
return Err(rustical_ical::Error::InvalidData(
|
|
||||||
"multiple calendars, only one allowed".to_owned(),
|
|
||||||
)
|
|
||||||
.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract calendar metadata
|
// Extract calendar metadata
|
||||||
let displayname = cal
|
let displayname = cal
|
||||||
@@ -49,14 +38,19 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
let description = cal
|
let description = cal
|
||||||
.get_property("X-WR-CALDESC")
|
.get_property("X-WR-CALDESC")
|
||||||
.and_then(|prop| prop.value.clone());
|
.and_then(|prop| prop.value.clone());
|
||||||
|
let color = cal
|
||||||
|
.get_property("X-WR-CALCOLOR")
|
||||||
|
.and_then(|prop| prop.value.clone());
|
||||||
let timezone_id = cal
|
let timezone_id = cal
|
||||||
.get_property("X-WR-TIMEZONE")
|
.get_property("X-WR-TIMEZONE")
|
||||||
.and_then(|prop| prop.value.clone());
|
.and_then(|prop| prop.value.clone());
|
||||||
// These properties should not appear in the expanded calendar objects
|
// These properties should not appear in the expanded calendar objects
|
||||||
cal.remove_property("X-WR-CALNAME");
|
cal.remove_property("X-WR-CALNAME");
|
||||||
cal.remove_property("X-WR-CALDESC");
|
cal.remove_property("X-WR-CALDESC");
|
||||||
|
cal.remove_property("X-WR-CALCOLOR");
|
||||||
cal.remove_property("X-WR-TIMEZONE");
|
cal.remove_property("X-WR-TIMEZONE");
|
||||||
let cal = cal.verify().unwrap();
|
let cal = cal.build(None).unwrap();
|
||||||
|
|
||||||
// Make sure timezone is valid
|
// Make sure timezone is valid
|
||||||
if let Some(timezone_id) = timezone_id.as_ref() {
|
if let Some(timezone_id) = timezone_id.as_ref() {
|
||||||
assert!(
|
assert!(
|
||||||
@@ -64,8 +58,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
"Invalid calendar timezone id"
|
"Invalid calendar timezone id"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// // Extract necessary component types
|
||||||
// Extract necessary component types
|
|
||||||
let mut cal_components = vec![];
|
let mut cal_components = vec![];
|
||||||
if !cal.events.is_empty() {
|
if !cal.events.is_empty() {
|
||||||
cal_components.push(CalendarObjectType::Event);
|
cal_components.push(CalendarObjectType::Event);
|
||||||
@@ -77,13 +70,10 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
cal_components.push(CalendarObjectType::Todo);
|
cal_components.push(CalendarObjectType::Todo);
|
||||||
}
|
}
|
||||||
|
|
||||||
let expanded_cals = cal.expand_calendar();
|
let objects = match cal.into_objects() {
|
||||||
// Janky way to convert between IcalCalendar and CalendarObject
|
Ok(objects) => objects.into_iter().map(Into::into).collect(),
|
||||||
let objects = expanded_cals
|
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
|
||||||
.into_iter()
|
};
|
||||||
.map(|cal| cal.generate())
|
|
||||||
.map(|ics| CalendarObject::from_ics(ics, None))
|
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
|
||||||
let new_cal = Calendar {
|
let new_cal = Calendar {
|
||||||
principal,
|
principal,
|
||||||
id: cal_id,
|
id: cal_id,
|
||||||
@@ -91,7 +81,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
displayname,
|
displayname,
|
||||||
order: 0,
|
order: 0,
|
||||||
description,
|
description,
|
||||||
color: None,
|
color,
|
||||||
},
|
},
|
||||||
timezone_id,
|
timezone_id,
|
||||||
deleted_at: None,
|
deleted_at: None,
|
||||||
|
|||||||
@@ -87,17 +87,18 @@ pub async fn route_mkcalendar<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
Some(tzid)
|
Some(tzid)
|
||||||
} else if let Some(tz) = request.calendar_timezone {
|
} else if let Some(tz) = request.calendar_timezone {
|
||||||
// TODO: Proper error (calendar-timezone precondition)
|
// TODO: Proper error (calendar-timezone precondition)
|
||||||
let calendar = IcalParser::new(tz.as_bytes())
|
let calendar = IcalParser::from_slice(tz.as_bytes())
|
||||||
.next()
|
.next()
|
||||||
.ok_or_else(|| rustical_dav::Error::BadRequest("No timezone data provided".to_owned()))?
|
.ok_or_else(|| rustical_dav::Error::BadRequest("No timezone data provided".to_owned()))?
|
||||||
.map_err(|_| rustical_dav::Error::BadRequest("No timezone data provided".to_owned()))?;
|
.map_err(|_| rustical_dav::Error::BadRequest("Error parsing timezone".to_owned()))?;
|
||||||
|
|
||||||
let timezone = calendar.timezones.first().ok_or_else(|| {
|
let timezone = calendar.vtimezones.values().next().ok_or_else(|| {
|
||||||
rustical_dav::Error::BadRequest("No timezone data provided".to_owned())
|
rustical_dav::Error::BadRequest("No timezone data provided".to_owned())
|
||||||
})?;
|
})?;
|
||||||
let timezone: chrono_tz::Tz = timezone
|
let timezone: Option<chrono_tz::Tz> = timezone.into();
|
||||||
.try_into()
|
let timezone = timezone.ok_or_else(|| {
|
||||||
.map_err(|_| rustical_dav::Error::BadRequest("No timezone data provided".to_owned()))?;
|
rustical_dav::Error::BadRequest("Cannot translate VTIMEZONE into IANA TZID".to_owned())
|
||||||
|
})?;
|
||||||
|
|
||||||
Some(timezone.name().to_owned())
|
Some(timezone.name().to_owned())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub async fn get_objects_calendar_multiget<C: CalendarStore>(
|
|||||||
principal: &str,
|
principal: &str,
|
||||||
cal_id: &str,
|
cal_id: &str,
|
||||||
store: &C,
|
store: &C,
|
||||||
) -> Result<(Vec<CalendarObject>, Vec<String>), Error> {
|
) -> Result<(Vec<(String, CalendarObject)>, Vec<String>), Error> {
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
let mut not_found = vec![];
|
let mut not_found = vec![];
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ pub async fn get_objects_calendar_multiget<C: CalendarStore>(
|
|||||||
let filename = filename.trim_start_matches('/');
|
let filename = filename.trim_start_matches('/');
|
||||||
if let Some(object_id) = filename.strip_suffix(".ics") {
|
if let Some(object_id) = filename.strip_suffix(".ics") {
|
||||||
match store.get_object(principal, cal_id, object_id, false).await {
|
match store.get_object(principal, cal_id, object_id, false).await {
|
||||||
Ok(object) => result.push(object),
|
Ok(object) => result.push((object_id.to_owned(), object)),
|
||||||
Err(rustical_store::Error::NotFound) => not_found.push(href.to_string()),
|
Err(rustical_store::Error::NotFound) => not_found.push(href.to_string()),
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => return Err(err.into()),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ use crate::calendar::methods::report::calendar_query::{
|
|||||||
TimeRangeElement,
|
TimeRangeElement,
|
||||||
prop_filter::{PropFilterElement, PropFilterable},
|
prop_filter::{PropFilterElement, PropFilterable},
|
||||||
};
|
};
|
||||||
use ical::parser::ical::component::IcalTimeZone;
|
use ical::{
|
||||||
use rustical_ical::{CalendarObject, CalendarObjectComponent, CalendarObjectType};
|
component::{CalendarInnerData, IcalAlarm, IcalCalendarObject, IcalEvent, IcalTodo},
|
||||||
|
parser::{Component, ical::component::IcalTimeZone},
|
||||||
|
};
|
||||||
use rustical_xml::XmlDeserialize;
|
use rustical_xml::XmlDeserialize;
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
||||||
@@ -68,9 +70,98 @@ pub trait CompFilterable: PropFilterable + Sized {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompFilterable for CalendarObject {
|
impl CompFilterable for CalendarInnerData {
|
||||||
fn get_comp_name(&self) -> &'static str {
|
fn get_comp_name(&self) -> &'static str {
|
||||||
"VCALENDAR"
|
match self {
|
||||||
|
Self::Event(main, _) => main.get_comp_name(),
|
||||||
|
Self::Journal(main, _) => main.get_comp_name(),
|
||||||
|
Self::Todo(main, _) => main.get_comp_name(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_time_range(&self, time_range: &TimeRangeElement) -> bool {
|
||||||
|
if let Some(start) = &time_range.start
|
||||||
|
&& let Some(last_end) = self.get_last_occurence()
|
||||||
|
&& start.to_utc() > last_end.utc()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if let Some(end) = &time_range.end
|
||||||
|
&& let Some(first_start) = self.get_first_occurence()
|
||||||
|
&& end.to_utc() < first_start.utc()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_subcomponents(&self, comp_filter: &CompFilterElement) -> bool {
|
||||||
|
match self {
|
||||||
|
Self::Event(main, overrides) => std::iter::once(main)
|
||||||
|
.chain(overrides.iter())
|
||||||
|
.flat_map(IcalEvent::get_alarms)
|
||||||
|
.any(|alarm| alarm.matches(comp_filter)),
|
||||||
|
Self::Todo(main, overrides) => std::iter::once(main)
|
||||||
|
.chain(overrides.iter())
|
||||||
|
.flat_map(IcalTodo::get_alarms)
|
||||||
|
.any(|alarm| alarm.matches(comp_filter)),
|
||||||
|
// VJOURNAL has no subcomponents
|
||||||
|
Self::Journal(_, _) => comp_filter.is_not_defined.is_some(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for IcalAlarm {
|
||||||
|
fn get_named_properties<'a>(
|
||||||
|
&'a self,
|
||||||
|
name: &'a str,
|
||||||
|
) -> impl Iterator<Item = &'a ical::property::ContentLine> {
|
||||||
|
Component::get_named_properties(self, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CompFilterable for IcalAlarm {
|
||||||
|
fn get_comp_name(&self) -> &'static str {
|
||||||
|
Component::get_comp_name(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_time_range(&self, _time_range: &TimeRangeElement) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_subcomponents(&self, comp_filter: &CompFilterElement) -> bool {
|
||||||
|
comp_filter.is_not_defined.is_some()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for CalendarInnerData {
|
||||||
|
#[allow(refining_impl_trait)]
|
||||||
|
fn get_named_properties<'a>(
|
||||||
|
&'a self,
|
||||||
|
name: &'a str,
|
||||||
|
) -> Box<dyn Iterator<Item = &'a ical::property::ContentLine> + 'a> {
|
||||||
|
// TODO: If we were pedantic, we would have to do recurrence expansion first
|
||||||
|
// and take into account the overrides :(
|
||||||
|
match self {
|
||||||
|
Self::Event(main, _) => Box::new(main.get_named_properties(name)),
|
||||||
|
Self::Todo(main, _) => Box::new(main.get_named_properties(name)),
|
||||||
|
Self::Journal(main, _) => Box::new(main.get_named_properties(name)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for IcalCalendarObject {
|
||||||
|
fn get_named_properties<'a>(
|
||||||
|
&'a self,
|
||||||
|
name: &'a str,
|
||||||
|
) -> impl Iterator<Item = &'a ical::property::ContentLine> {
|
||||||
|
Component::get_named_properties(self, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CompFilterable for IcalCalendarObject {
|
||||||
|
fn get_comp_name(&self) -> &'static str {
|
||||||
|
Component::get_comp_name(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_time_range(&self, _time_range: &TimeRangeElement) -> bool {
|
fn match_time_range(&self, _time_range: &TimeRangeElement) -> bool {
|
||||||
@@ -83,72 +174,53 @@ impl CompFilterable for CalendarObject {
|
|||||||
.get_vtimezones()
|
.get_vtimezones()
|
||||||
.values()
|
.values()
|
||||||
.map(|tz| tz.matches(comp_filter))
|
.map(|tz| tz.matches(comp_filter))
|
||||||
.chain([self.get_data().matches(comp_filter)]);
|
.chain([self.get_inner().matches(comp_filter)]);
|
||||||
|
|
||||||
if comp_filter.is_not_defined.is_some() {
|
if comp_filter.is_not_defined.is_some() {
|
||||||
matches.all(|x| x)
|
matches.all(|x| !x)
|
||||||
} else {
|
} else {
|
||||||
matches.any(|x| x)
|
matches.any(|x| x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompFilterable for IcalTimeZone {
|
impl PropFilterable for IcalTimeZone {
|
||||||
fn get_comp_name(&self) -> &'static str {
|
fn get_named_properties<'a>(
|
||||||
"VTIMEZONE"
|
&'a self,
|
||||||
|
name: &'a str,
|
||||||
|
) -> impl Iterator<Item = &'a ical::property::ContentLine> {
|
||||||
|
Component::get_named_properties(self, name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CompFilterable for IcalTimeZone {
|
||||||
|
fn get_comp_name(&self) -> &'static str {
|
||||||
|
Component::get_comp_name(self)
|
||||||
|
}
|
||||||
fn match_time_range(&self, _time_range: &TimeRangeElement) -> bool {
|
fn match_time_range(&self, _time_range: &TimeRangeElement) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_subcomponents(&self, _comp_filter: &CompFilterElement) -> bool {
|
fn match_subcomponents(&self, comp_filter: &CompFilterElement) -> bool {
|
||||||
true
|
// VTIMEZONE has no subcomponents
|
||||||
}
|
comp_filter.is_not_defined.is_some()
|
||||||
}
|
|
||||||
|
|
||||||
impl CompFilterable for CalendarObjectComponent {
|
|
||||||
fn get_comp_name(&self) -> &'static str {
|
|
||||||
CalendarObjectType::from(self).as_str()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn match_time_range(&self, time_range: &TimeRangeElement) -> bool {
|
|
||||||
if let Some(start) = &time_range.start
|
|
||||||
&& let Some(last_occurence) = self.get_last_occurence().unwrap_or(None)
|
|
||||||
&& **start > last_occurence.utc()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if let Some(end) = &time_range.end
|
|
||||||
&& let Some(first_occurence) = self.get_first_occurence().unwrap_or(None)
|
|
||||||
&& **end < first_occurence.utc()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn match_subcomponents(&self, _comp_filter: &CompFilterElement) -> bool {
|
|
||||||
// TODO: Properly check subcomponents
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
|
use rustical_dav::xml::{MatchType, NegateCondition, TextCollation, TextMatchElement};
|
||||||
use rustical_ical::{CalendarObject, UtcDateTime};
|
use rustical_ical::{CalendarObject, UtcDateTime};
|
||||||
|
|
||||||
use crate::calendar::methods::report::calendar_query::{
|
use crate::calendar::methods::report::calendar_query::{
|
||||||
CompFilterable, TextMatchElement, TimeRangeElement,
|
CompFilterElement, CompFilterable, PropFilterElement, TimeRangeElement,
|
||||||
comp_filter::CompFilterElement,
|
|
||||||
prop_filter::PropFilterElement,
|
|
||||||
text_match::{NegateCondition, TextCollation},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ICS: &str = r"BEGIN:VCALENDAR
|
const ICS: &str = r"BEGIN:VCALENDAR
|
||||||
CALSCALE:GREGORIAN
|
CALSCALE:GREGORIAN
|
||||||
VERSION:2.0
|
VERSION:2.0
|
||||||
|
PRODID:me
|
||||||
BEGIN:VTIMEZONE
|
BEGIN:VTIMEZONE
|
||||||
TZID:Europe/Berlin
|
TZID:Europe/Berlin
|
||||||
X-LIC-LOCATION:Europe/Berlin
|
X-LIC-LOCATION:Europe/Berlin
|
||||||
@@ -168,7 +240,7 @@ END:VCALENDAR";
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_comp_filter_matching() {
|
fn test_comp_filter_matching() {
|
||||||
let object = CalendarObject::from_ics(ICS.to_string(), None).unwrap();
|
let object = CalendarObject::from_ics(ICS.to_string()).unwrap();
|
||||||
|
|
||||||
let comp_filter = CompFilterElement {
|
let comp_filter = CompFilterElement {
|
||||||
is_not_defined: Some(()),
|
is_not_defined: Some(()),
|
||||||
@@ -177,7 +249,10 @@ END:VCALENDAR";
|
|||||||
prop_filter: vec![],
|
prop_filter: vec![],
|
||||||
comp_filter: vec![],
|
comp_filter: vec![],
|
||||||
};
|
};
|
||||||
assert!(!object.matches(&comp_filter), "filter: wants no VCALENDAR");
|
assert!(
|
||||||
|
!object.get_inner().matches(&comp_filter),
|
||||||
|
"filter: wants no VCALENDAR"
|
||||||
|
);
|
||||||
|
|
||||||
let comp_filter = CompFilterElement {
|
let comp_filter = CompFilterElement {
|
||||||
is_not_defined: None,
|
is_not_defined: None,
|
||||||
@@ -192,7 +267,10 @@ END:VCALENDAR";
|
|||||||
comp_filter: vec![],
|
comp_filter: vec![],
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
assert!(!object.matches(&comp_filter), "filter matches VTODO");
|
assert!(
|
||||||
|
!object.get_inner().matches(&comp_filter),
|
||||||
|
"filter matches VTODO"
|
||||||
|
);
|
||||||
|
|
||||||
let comp_filter = CompFilterElement {
|
let comp_filter = CompFilterElement {
|
||||||
is_not_defined: None,
|
is_not_defined: None,
|
||||||
@@ -207,7 +285,10 @@ END:VCALENDAR";
|
|||||||
comp_filter: vec![],
|
comp_filter: vec![],
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
assert!(object.matches(&comp_filter), "filter matches VEVENT");
|
assert!(
|
||||||
|
object.get_inner().matches(&comp_filter),
|
||||||
|
"filter matches VEVENT"
|
||||||
|
);
|
||||||
|
|
||||||
let comp_filter = CompFilterElement {
|
let comp_filter = CompFilterElement {
|
||||||
is_not_defined: None,
|
is_not_defined: None,
|
||||||
@@ -219,6 +300,7 @@ END:VCALENDAR";
|
|||||||
name: "VERSION".to_string(),
|
name: "VERSION".to_string(),
|
||||||
time_range: None,
|
time_range: None,
|
||||||
text_match: Some(TextMatchElement {
|
text_match: Some(TextMatchElement {
|
||||||
|
match_type: MatchType::Contains,
|
||||||
needle: "2.0".to_string(),
|
needle: "2.0".to_string(),
|
||||||
collation: TextCollation::default(),
|
collation: TextCollation::default(),
|
||||||
negate_condition: NegateCondition::default(),
|
negate_condition: NegateCondition::default(),
|
||||||
@@ -242,6 +324,7 @@ END:VCALENDAR";
|
|||||||
name: "SUMMARY".to_string(),
|
name: "SUMMARY".to_string(),
|
||||||
time_range: None,
|
time_range: None,
|
||||||
text_match: Some(TextMatchElement {
|
text_match: Some(TextMatchElement {
|
||||||
|
match_type: MatchType::Contains,
|
||||||
collation: TextCollation::default(),
|
collation: TextCollation::default(),
|
||||||
negate_condition: NegateCondition(false),
|
negate_condition: NegateCondition(false),
|
||||||
needle: "weekly".to_string(),
|
needle: "weekly".to_string(),
|
||||||
@@ -252,13 +335,13 @@ END:VCALENDAR";
|
|||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
assert!(
|
assert!(
|
||||||
object.matches(&comp_filter),
|
object.get_inner().matches(&comp_filter),
|
||||||
"Some prop filters on VCALENDAR and VEVENT"
|
"Some prop filters on VCALENDAR and VEVENT"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_comp_filter_time_range() {
|
fn test_comp_filter_time_range() {
|
||||||
let object = CalendarObject::from_ics(ICS.to_string(), None).unwrap();
|
let object = CalendarObject::from_ics(ICS.to_string()).unwrap();
|
||||||
|
|
||||||
let comp_filter = CompFilterElement {
|
let comp_filter = CompFilterElement {
|
||||||
is_not_defined: None,
|
is_not_defined: None,
|
||||||
@@ -281,7 +364,7 @@ END:VCALENDAR";
|
|||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
assert!(
|
assert!(
|
||||||
object.matches(&comp_filter),
|
object.get_inner().matches(&comp_filter),
|
||||||
"event should lie in time range"
|
"event should lie in time range"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -306,14 +389,14 @@ END:VCALENDAR";
|
|||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
assert!(
|
assert!(
|
||||||
!object.matches(&comp_filter),
|
!object.get_inner().matches(&comp_filter),
|
||||||
"event should not lie in time range"
|
"event should not lie in time range"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_match_timezone() {
|
fn test_match_timezone() {
|
||||||
let object = CalendarObject::from_ics(ICS.to_string(), None).unwrap();
|
let object = CalendarObject::from_ics(ICS.to_string()).unwrap();
|
||||||
|
|
||||||
let comp_filter = CompFilterElement {
|
let comp_filter = CompFilterElement {
|
||||||
is_not_defined: None,
|
is_not_defined: None,
|
||||||
@@ -329,6 +412,7 @@ END:VCALENDAR";
|
|||||||
name: "TZID".to_string(),
|
name: "TZID".to_string(),
|
||||||
time_range: None,
|
time_range: None,
|
||||||
text_match: Some(TextMatchElement {
|
text_match: Some(TextMatchElement {
|
||||||
|
match_type: MatchType::Contains,
|
||||||
collation: TextCollation::AsciiCasemap,
|
collation: TextCollation::AsciiCasemap,
|
||||||
negate_condition: NegateCondition::default(),
|
negate_condition: NegateCondition::default(),
|
||||||
needle: "Europe/Berlin".to_string(),
|
needle: "Europe/Berlin".to_string(),
|
||||||
@@ -339,7 +423,7 @@ END:VCALENDAR";
|
|||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
assert!(
|
assert!(
|
||||||
object.matches(&comp_filter),
|
object.get_inner().matches(&comp_filter),
|
||||||
"Timezone should be Europe/Berlin"
|
"Timezone should be Europe/Berlin"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
use crate::{
|
use super::comp_filter::{CompFilterElement, CompFilterable};
|
||||||
calendar::methods::report::calendar_query::{
|
use crate::calendar_object::CalendarObjectPropWrapperName;
|
||||||
TextMatchElement,
|
use ical::{component::IcalCalendarObject, property::ContentLine};
|
||||||
comp_filter::{CompFilterElement, CompFilterable},
|
use rustical_dav::xml::{PropfindType, TextMatchElement};
|
||||||
},
|
use rustical_ical::UtcDateTime;
|
||||||
calendar_object::CalendarObjectPropWrapperName,
|
|
||||||
};
|
|
||||||
use rustical_dav::xml::PropfindType;
|
|
||||||
use rustical_ical::{CalendarObject, UtcDateTime};
|
|
||||||
use rustical_store::calendar_store::CalendarQuery;
|
use rustical_store::calendar_store::CalendarQuery;
|
||||||
use rustical_xml::XmlDeserialize;
|
use rustical_xml::{XmlDeserialize, XmlRootTag};
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@@ -32,7 +28,25 @@ pub struct ParamFilterElement {
|
|||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
impl ParamFilterElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_property(&self, prop: &ContentLine) -> bool {
|
||||||
|
let Some(param) = prop.params.get_param(&self.name) else {
|
||||||
|
return self.is_not_defined.is_some();
|
||||||
|
};
|
||||||
|
if self.is_not_defined.is_some() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let Some(text_match) = self.text_match.as_ref() else {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
text_match.match_text(param)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, XmlRootTag, Clone, Debug, PartialEq)]
|
||||||
|
#[xml(root = "filter", ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
// https://datatracker.ietf.org/doc/html/rfc4791#section-9.7
|
// https://datatracker.ietf.org/doc/html/rfc4791#section-9.7
|
||||||
pub struct FilterElement {
|
pub struct FilterElement {
|
||||||
@@ -43,7 +57,7 @@ pub struct FilterElement {
|
|||||||
|
|
||||||
impl FilterElement {
|
impl FilterElement {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn matches(&self, cal_object: &CalendarObject) -> bool {
|
pub fn matches(&self, cal_object: &IcalCalendarObject) -> bool {
|
||||||
cal_object.matches(&self.comp_filter)
|
cal_object.matches(&self.comp_filter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,47 +5,43 @@ use rustical_store::CalendarStore;
|
|||||||
mod comp_filter;
|
mod comp_filter;
|
||||||
mod elements;
|
mod elements;
|
||||||
mod prop_filter;
|
mod prop_filter;
|
||||||
pub mod text_match;
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub use comp_filter::{CompFilterElement, CompFilterable};
|
pub use comp_filter::{CompFilterElement, CompFilterable};
|
||||||
pub use elements::*;
|
pub use elements::*;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub use prop_filter::{PropFilterElement, PropFilterable};
|
pub use prop_filter::PropFilterElement;
|
||||||
#[allow(unused_imports)]
|
|
||||||
pub use text_match::TextMatchElement;
|
|
||||||
|
|
||||||
pub async fn get_objects_calendar_query<C: CalendarStore>(
|
pub async fn get_objects_calendar_query<C: CalendarStore>(
|
||||||
cal_query: &CalendarQueryRequest,
|
cal_query: &CalendarQueryRequest,
|
||||||
principal: &str,
|
principal: &str,
|
||||||
cal_id: &str,
|
cal_id: &str,
|
||||||
store: &C,
|
store: &C,
|
||||||
) -> Result<Vec<CalendarObject>, Error> {
|
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
||||||
let mut objects = store
|
let mut objects = store
|
||||||
.calendar_query(principal, cal_id, cal_query.into())
|
.calendar_query(principal, cal_id, cal_query.into())
|
||||||
.await?;
|
.await?;
|
||||||
if let Some(filter) = &cal_query.filter {
|
if let Some(filter) = &cal_query.filter {
|
||||||
objects.retain(|object| filter.matches(object));
|
objects.retain(|(_id, object)| filter.matches(object.get_inner()));
|
||||||
}
|
}
|
||||||
Ok(objects)
|
Ok(objects)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod xml_tests {
|
||||||
use rustical_dav::xml::PropElement;
|
use super::{
|
||||||
use rustical_xml::XmlDocument;
|
CalendarQueryRequest, FilterElement, ParamFilterElement, comp_filter::CompFilterElement,
|
||||||
|
|
||||||
use crate::{
|
|
||||||
calendar::methods::report::{
|
|
||||||
ReportRequest,
|
|
||||||
calendar_query::{
|
|
||||||
CalendarQueryRequest, FilterElement, ParamFilterElement, TextMatchElement,
|
|
||||||
comp_filter::CompFilterElement,
|
|
||||||
prop_filter::PropFilterElement,
|
prop_filter::PropFilterElement,
|
||||||
text_match::{NegateCondition, TextCollation},
|
};
|
||||||
},
|
use crate::{
|
||||||
},
|
calendar::methods::report::ReportRequest,
|
||||||
calendar_object::{CalendarData, CalendarObjectPropName, CalendarObjectPropWrapperName},
|
calendar_object::{CalendarData, CalendarObjectPropName, CalendarObjectPropWrapperName},
|
||||||
};
|
};
|
||||||
|
use rustical_dav::xml::{
|
||||||
|
MatchType, NegateCondition, PropElement, TextCollation, TextMatchElement,
|
||||||
|
};
|
||||||
|
use rustical_xml::XmlDocument;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn calendar_query_7_8_7() {
|
fn calendar_query_7_8_7() {
|
||||||
@@ -101,6 +97,7 @@ mod tests {
|
|||||||
prop_filter: vec![PropFilterElement {
|
prop_filter: vec![PropFilterElement {
|
||||||
name: "ATTENDEE".to_owned(),
|
name: "ATTENDEE".to_owned(),
|
||||||
text_match: Some(TextMatchElement {
|
text_match: Some(TextMatchElement {
|
||||||
|
match_type: MatchType::Contains,
|
||||||
collation: TextCollation::AsciiCasemap,
|
collation: TextCollation::AsciiCasemap,
|
||||||
negate_condition: NegateCondition(false),
|
negate_condition: NegateCondition(false),
|
||||||
needle: "mailto:lisa@example.com".to_string()
|
needle: "mailto:lisa@example.com".to_string()
|
||||||
@@ -110,6 +107,7 @@ mod tests {
|
|||||||
is_not_defined: None,
|
is_not_defined: None,
|
||||||
name: "PARTSTAT".to_owned(),
|
name: "PARTSTAT".to_owned(),
|
||||||
text_match: Some(TextMatchElement {
|
text_match: Some(TextMatchElement {
|
||||||
|
match_type: MatchType::Contains,
|
||||||
collation: TextCollation::AsciiCasemap,
|
collation: TextCollation::AsciiCasemap,
|
||||||
negate_condition: NegateCondition(false),
|
negate_condition: NegateCondition(false),
|
||||||
needle: "NEEDS-ACTION".to_string()
|
needle: "NEEDS-ACTION".to_string()
|
||||||
|
|||||||
@@ -1,20 +1,9 @@
|
|||||||
use std::collections::HashMap;
|
use super::{ParamFilterElement, TimeRangeElement};
|
||||||
|
use ical::{property::ContentLine, types::CalDateTime};
|
||||||
use ical::{
|
use rustical_dav::xml::TextMatchElement;
|
||||||
generator::{IcalCalendar, IcalEvent},
|
use rustical_ical::UtcDateTime;
|
||||||
parser::{
|
|
||||||
Component,
|
|
||||||
ical::component::{IcalJournal, IcalTimeZone, IcalTodo},
|
|
||||||
},
|
|
||||||
property::Property,
|
|
||||||
};
|
|
||||||
use rustical_ical::{CalDateTime, CalendarObject, CalendarObjectComponent, UtcDateTime};
|
|
||||||
use rustical_xml::XmlDeserialize;
|
use rustical_xml::XmlDeserialize;
|
||||||
|
|
||||||
use crate::calendar::methods::report::calendar_query::{
|
|
||||||
ParamFilterElement, TextMatchElement, TimeRangeElement,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
// https://www.rfc-editor.org/rfc/rfc4791#section-9.7.2
|
// https://www.rfc-editor.org/rfc/rfc4791#section-9.7.2
|
||||||
@@ -32,22 +21,16 @@ pub struct PropFilterElement {
|
|||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PropFilterElement {
|
pub trait PropFilterable {
|
||||||
pub fn match_component(&self, comp: &impl PropFilterable) -> bool {
|
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine>;
|
||||||
let property = comp.get_property(&self.name);
|
}
|
||||||
let property = match (self.is_not_defined.is_some(), property) {
|
|
||||||
// We are the component that's not supposed to be defined
|
|
||||||
(true, Some(_))
|
|
||||||
// We don't match
|
|
||||||
| (false, None) => return false,
|
|
||||||
// We shall not be and indeed we aren't
|
|
||||||
(true, None) => return true,
|
|
||||||
(false, Some(property)) => property
|
|
||||||
};
|
|
||||||
|
|
||||||
|
impl PropFilterElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_property(&self, property: &ContentLine) -> bool {
|
||||||
if let Some(TimeRangeElement { start, end }) = &self.time_range {
|
if let Some(TimeRangeElement { start, end }) = &self.time_range {
|
||||||
// TODO: Respect timezones
|
// TODO: Respect timezones
|
||||||
let Ok(timestamp) = CalDateTime::parse_prop(property, &HashMap::default()) else {
|
let Ok(timestamp) = CalDateTime::parse_prop(property, None) else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let timestamp = timestamp.utc();
|
let timestamp = timestamp.utc();
|
||||||
@@ -70,58 +53,25 @@ impl PropFilterElement {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: param-filter
|
if !self
|
||||||
|
.param_filter
|
||||||
|
.iter()
|
||||||
|
.all(|param_filter| param_filter.match_property(property))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn match_component(&self, comp: &impl PropFilterable) -> bool {
|
||||||
|
let mut properties = comp.get_named_properties(&self.name);
|
||||||
|
if self.is_not_defined.is_some() {
|
||||||
|
return properties.next().is_none();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PropFilterable {
|
// The filter matches when one property instance matches
|
||||||
fn get_property(&self, name: &str) -> Option<&Property>;
|
// Example where this matters: We have multiple attendees and want to match one
|
||||||
}
|
properties.any(|prop| self.match_property(prop))
|
||||||
|
|
||||||
impl PropFilterable for CalendarObject {
|
|
||||||
fn get_property(&self, name: &str) -> Option<&Property> {
|
|
||||||
Self::get_property(self, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PropFilterable for IcalEvent {
|
|
||||||
fn get_property(&self, name: &str) -> Option<&Property> {
|
|
||||||
Component::get_property(self, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PropFilterable for IcalTodo {
|
|
||||||
fn get_property(&self, name: &str) -> Option<&Property> {
|
|
||||||
Component::get_property(self, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PropFilterable for IcalJournal {
|
|
||||||
fn get_property(&self, name: &str) -> Option<&Property> {
|
|
||||||
Component::get_property(self, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PropFilterable for IcalCalendar {
|
|
||||||
fn get_property(&self, name: &str) -> Option<&Property> {
|
|
||||||
Component::get_property(self, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PropFilterable for IcalTimeZone {
|
|
||||||
fn get_property(&self, name: &str) -> Option<&Property> {
|
|
||||||
Component::get_property(self, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PropFilterable for CalendarObjectComponent {
|
|
||||||
fn get_property(&self, name: &str) -> Option<&Property> {
|
|
||||||
match self {
|
|
||||||
Self::Event(event, _) => PropFilterable::get_property(&event.event, name),
|
|
||||||
Self::Todo(todo, _) => PropFilterable::get_property(todo, name),
|
|
||||||
Self::Journal(journal, _) => PropFilterable::get_property(journal, name),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
use super::FilterElement;
|
||||||
|
use rstest::rstest;
|
||||||
|
use rustical_ical::CalendarObject;
|
||||||
|
use rustical_xml::XmlDocument;
|
||||||
|
|
||||||
|
const ICS_1: &str = r"BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
LAST-MODIFIED:20040110T032845Z
|
||||||
|
TZID:US/Eastern
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
DTSTART:20000404T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
|
||||||
|
TZNAME:EDT
|
||||||
|
TZOFFSETFROM:-0500
|
||||||
|
TZOFFSETTO:-0400
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
DTSTART:20001026T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
|
||||||
|
TZNAME:EST
|
||||||
|
TZOFFSETFROM:-0400
|
||||||
|
TZOFFSETTO:-0500
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
BEGIN:VEVENT
|
||||||
|
ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:cyrus@example.com
|
||||||
|
ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
|
||||||
|
DTSTAMP:20060206T001220Z
|
||||||
|
DTSTART;TZID=US/Eastern:20060104T100000
|
||||||
|
DURATION:PT1H
|
||||||
|
LAST-MODIFIED:20060206T001330Z
|
||||||
|
ORGANIZER:mailto:cyrus@example.com
|
||||||
|
SEQUENCE:1
|
||||||
|
STATUS:TENTATIVE
|
||||||
|
SUMMARY:Event #3
|
||||||
|
UID:DC6C50A017428C5216A2F1CD@example.com
|
||||||
|
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
||||||
|
";
|
||||||
|
|
||||||
|
const FILTER_1: &str = r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:filter xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<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>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const FILTER_2: &str = r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:filter xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<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">ACCEPTED</C:text-match>
|
||||||
|
</C:param-filter>
|
||||||
|
</C:prop-filter>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:filter>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
#[case(ICS_1, FILTER_1, true)]
|
||||||
|
#[case(ICS_1, FILTER_2, false)]
|
||||||
|
fn yeet(#[case] ics: &str, #[case] filter: &str, #[case] matches: bool) {
|
||||||
|
let obj = CalendarObject::from_ics(ics.to_owned()).unwrap();
|
||||||
|
let filter = FilterElement::parse_str(filter).unwrap();
|
||||||
|
assert_eq!(matches, filter.matches(obj.get_inner()));
|
||||||
|
}
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
use ical::property::Property;
|
|
||||||
use rustical_xml::{ValueDeserialize, XmlDeserialize};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
|
||||||
pub enum TextCollation {
|
|
||||||
#[default]
|
|
||||||
AsciiCasemap,
|
|
||||||
Octet,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TextCollation {
|
|
||||||
// Check whether a haystack contains a needle respecting the collation
|
|
||||||
#[must_use]
|
|
||||||
pub fn match_text(&self, needle: &str, haystack: &str) -> bool {
|
|
||||||
match self {
|
|
||||||
// https://datatracker.ietf.org/doc/html/rfc4790#section-9.2
|
|
||||||
Self::AsciiCasemap => haystack
|
|
||||||
.to_ascii_uppercase()
|
|
||||||
.contains(&needle.to_ascii_uppercase()),
|
|
||||||
Self::Octet => haystack.contains(needle),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AsRef<str> for TextCollation {
|
|
||||||
fn as_ref(&self) -> &str {
|
|
||||||
match self {
|
|
||||||
Self::AsciiCasemap => "i;ascii-casemap",
|
|
||||||
Self::Octet => "i;octet",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ValueDeserialize for TextCollation {
|
|
||||||
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
|
||||||
match val {
|
|
||||||
"i;ascii-casemap" => Ok(Self::AsciiCasemap),
|
|
||||||
"i;octet" => Ok(Self::Octet),
|
|
||||||
_ => Err(rustical_xml::XmlError::InvalidVariant(format!(
|
|
||||||
"Invalid collation: {val}"
|
|
||||||
))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
|
||||||
pub struct NegateCondition(pub bool);
|
|
||||||
|
|
||||||
impl ValueDeserialize for NegateCondition {
|
|
||||||
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
|
||||||
match val {
|
|
||||||
"yes" => Ok(Self(true)),
|
|
||||||
"no" => Ok(Self(false)),
|
|
||||||
_ => Err(rustical_xml::XmlError::InvalidVariant(format!(
|
|
||||||
"Invalid negate-condition parameter: {val}"
|
|
||||||
))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct TextMatchElement {
|
|
||||||
#[xml(ty = "attr", default = "Default::default")]
|
|
||||||
pub collation: TextCollation,
|
|
||||||
#[xml(ty = "attr", default = "Default::default")]
|
|
||||||
pub(crate) negate_condition: NegateCondition,
|
|
||||||
#[xml(ty = "text")]
|
|
||||||
pub(crate) needle: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TextMatchElement {
|
|
||||||
#[must_use]
|
|
||||||
pub fn match_property(&self, property: &Property) -> bool {
|
|
||||||
let Self {
|
|
||||||
collation,
|
|
||||||
negate_condition,
|
|
||||||
needle,
|
|
||||||
} = self;
|
|
||||||
|
|
||||||
let matches = property
|
|
||||||
.value
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|haystack| collation.match_text(needle, haystack));
|
|
||||||
|
|
||||||
// XOR
|
|
||||||
negate_condition.0 ^ matches
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::calendar::methods::report::calendar_query::text_match::TextCollation;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_collation() {
|
|
||||||
assert!(TextCollation::AsciiCasemap.match_text("GrüN", "grün"));
|
|
||||||
assert!(!TextCollation::AsciiCasemap.match_text("GrÜN", "grün"));
|
|
||||||
assert!(!TextCollation::Octet.match_text("GrÜN", "grün"));
|
|
||||||
assert!(TextCollation::Octet.match_text("hallo", "hallo"));
|
|
||||||
assert!(TextCollation::AsciiCasemap.match_text("HaLlo", "hAllo"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -51,7 +51,7 @@ impl ReportRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn objects_response(
|
fn objects_response(
|
||||||
objects: Vec<CalendarObject>,
|
objects: Vec<(String, CalendarObject)>,
|
||||||
not_found: Vec<String>,
|
not_found: Vec<String>,
|
||||||
path: &str,
|
path: &str,
|
||||||
principal: &str,
|
principal: &str,
|
||||||
@@ -60,11 +60,12 @@ fn objects_response(
|
|||||||
prop: &PropfindType<CalendarObjectPropWrapperName>,
|
prop: &PropfindType<CalendarObjectPropWrapperName>,
|
||||||
) -> Result<MultistatusElement<CalendarObjectPropWrapper, String>, Error> {
|
) -> Result<MultistatusElement<CalendarObjectPropWrapper, String>, Error> {
|
||||||
let mut responses = Vec::new();
|
let mut responses = Vec::new();
|
||||||
for object in objects {
|
for (object_id, object) in objects {
|
||||||
let path = format!("{}/{}.ics", path, object.get_id());
|
let path = format!("{path}/{object_id}.ics");
|
||||||
responses.push(
|
responses.push(
|
||||||
CalendarObjectResource {
|
CalendarObjectResource {
|
||||||
object,
|
object,
|
||||||
|
object_id,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, prop, None, puri, user)?,
|
.propfind(&path, prop, None, puri, user)?,
|
||||||
@@ -174,7 +175,7 @@ mod tests {
|
|||||||
prop: rustical_dav::xml::PropfindType::Prop(PropElement(vec![
|
prop: rustical_dav::xml::PropfindType::Prop(PropElement(vec![
|
||||||
CalendarObjectPropWrapperName::CalendarObject(CalendarObjectPropName::Getetag),
|
CalendarObjectPropWrapperName::CalendarObject(CalendarObjectPropName::Getetag),
|
||||||
CalendarObjectPropWrapperName::CalendarObject(CalendarObjectPropName::CalendarData(
|
CalendarObjectPropWrapperName::CalendarObject(CalendarObjectPropName::CalendarData(
|
||||||
CalendarData { comp: None, expand: Some(ExpandElement {
|
CalendarData { comp: None, prop: None, expand: Some(ExpandElement {
|
||||||
start: <UtcDateTime as ValueDeserialize>::deserialize("20250426T220000Z").unwrap(),
|
start: <UtcDateTime as ValueDeserialize>::deserialize("20250426T220000Z").unwrap(),
|
||||||
end: <UtcDateTime as ValueDeserialize>::deserialize("20250503T220000Z").unwrap(),
|
end: <UtcDateTime as ValueDeserialize>::deserialize("20250503T220000Z").unwrap(),
|
||||||
}), limit_recurrence_set: None, limit_freebusy_set: None }
|
}), limit_recurrence_set: None, limit_freebusy_set: None }
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ pub async fn handle_sync_collection<C: CalendarStore>(
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let mut responses = Vec::new();
|
let mut responses = Vec::new();
|
||||||
for object in new_objects {
|
for (object_id, object) in new_objects {
|
||||||
let path = format!("{}/{}.ics", path, object.get_id());
|
let path = format!("{}/{}.ics", path, &object_id);
|
||||||
responses.push(
|
responses.push(
|
||||||
CalendarObjectResource {
|
CalendarObjectResource {
|
||||||
object,
|
object,
|
||||||
|
object_id,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, &sync_collection.prop, None, puri, user)?,
|
.propfind(&path, &sync_collection.prop, None, puri, user)?,
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{From, Into};
|
||||||
|
use rustical_dav::xml::TextCollation;
|
||||||
use rustical_ical::CalendarObjectType;
|
use rustical_ical::CalendarObjectType;
|
||||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||||
use strum_macros::VariantArray;
|
use strum_macros::VariantArray;
|
||||||
|
|
||||||
use crate::calendar::methods::report::calendar_query::text_match::TextCollation;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
|
||||||
pub struct SupportedCalendarComponent {
|
pub struct SupportedCalendarComponent {
|
||||||
#[xml(ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
@@ -55,6 +54,7 @@ impl Default for SupportedCollationSet {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self(vec![
|
Self(vec![
|
||||||
SupportedCollation(TextCollation::AsciiCasemap),
|
SupportedCollation(TextCollation::AsciiCasemap),
|
||||||
|
SupportedCollation(TextCollation::UnicodeCasemap),
|
||||||
SupportedCollation(TextCollation::Octet),
|
SupportedCollation(TextCollation::Octet),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use crate::calendar::prop::{ReportMethod, SupportedCollationSet};
|
|||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{From, Into};
|
||||||
use ical::IcalParser;
|
use ical::IcalParser;
|
||||||
|
use ical::types::CalDateTime;
|
||||||
use rustical_dav::extensions::{
|
use rustical_dav::extensions::{
|
||||||
CommonPropertiesExtension, CommonPropertiesProp, SyncTokenExtension, SyncTokenExtensionProp,
|
CommonPropertiesExtension, CommonPropertiesProp, SyncTokenExtension, SyncTokenExtensionProp,
|
||||||
};
|
};
|
||||||
@@ -11,12 +12,12 @@ use rustical_dav::privileges::UserPrivilegeSet;
|
|||||||
use rustical_dav::resource::{PrincipalUri, Resource, ResourceName};
|
use rustical_dav::resource::{PrincipalUri, Resource, ResourceName};
|
||||||
use rustical_dav::xml::{HrefElement, Resourcetype, ResourcetypeInner, SupportedReportSet};
|
use rustical_dav::xml::{HrefElement, Resourcetype, ResourcetypeInner, SupportedReportSet};
|
||||||
use rustical_dav_push::{DavPushExtension, DavPushExtensionProp};
|
use rustical_dav_push::{DavPushExtension, DavPushExtensionProp};
|
||||||
use rustical_ical::CalDateTime;
|
|
||||||
use rustical_store::Calendar;
|
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 serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
||||||
#[xml(unit_variants_ident = "CalendarPropName")]
|
#[xml(unit_variants_ident = "CalendarPropName")]
|
||||||
@@ -41,7 +42,7 @@ pub enum CalendarProp {
|
|||||||
SupportedCalendarData(SupportedCalendarData),
|
SupportedCalendarData(SupportedCalendarData),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
||||||
SupportedCollationSet(SupportedCollationSet),
|
SupportedCollationSet(SupportedCollationSet),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
MaxResourceSize(i64),
|
MaxResourceSize(i64),
|
||||||
#[xml(skip_deserializing)]
|
#[xml(skip_deserializing)]
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
@@ -72,8 +73,8 @@ pub struct CalendarResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for CalendarResource {
|
impl ResourceName for CalendarResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
self.cal.id.clone()
|
Cow::from(&self.cal.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +202,7 @@ impl Resource for CalendarResource {
|
|||||||
CalendarProp::CalendarTimezone(timezone) => {
|
CalendarProp::CalendarTimezone(timezone) => {
|
||||||
if let Some(tz) = timezone {
|
if let Some(tz) = timezone {
|
||||||
// TODO: Proper error (calendar-timezone precondition)
|
// TODO: Proper error (calendar-timezone precondition)
|
||||||
let calendar = IcalParser::new(tz.as_bytes())
|
let calendar = IcalParser::from_slice(tz.as_bytes())
|
||||||
.next()
|
.next()
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
rustical_dav::Error::BadRequest(
|
rustical_dav::Error::BadRequest(
|
||||||
@@ -214,13 +215,13 @@ impl Resource for CalendarResource {
|
|||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let timezone = calendar.timezones.first().ok_or_else(|| {
|
let timezone = calendar.vtimezones.values().next().ok_or_else(|| {
|
||||||
rustical_dav::Error::BadRequest("No timezone data provided".to_owned())
|
rustical_dav::Error::BadRequest("No timezone data provided".to_owned())
|
||||||
})?;
|
})?;
|
||||||
let timezone: chrono_tz::Tz = timezone.try_into().map_err(|_| {
|
let timezone: Option<chrono_tz::Tz> = timezone.into();
|
||||||
|
let timezone = timezone.ok_or_else(|| {
|
||||||
rustical_dav::Error::BadRequest("No timezone data provided".to_owned())
|
rustical_dav::Error::BadRequest("No timezone data provided".to_owned())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.cal.timezone_id = Some(timezone.name().to_owned());
|
self.cal.timezone_id = Some(timezone.name().to_owned());
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -78,8 +78,9 @@ impl<C: CalendarStore, S: SubscriptionStore> ResourceService for CalendarResourc
|
|||||||
.get_objects(principal, cal_id)
|
.get_objects(principal, cal_id)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|object| CalendarObjectResource {
|
.map(|(object_id, object)| CalendarObjectResource {
|
||||||
object,
|
object,
|
||||||
|
object_id,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
})
|
})
|
||||||
.collect())
|
.collect())
|
||||||
@@ -91,7 +92,7 @@ impl<C: CalendarStore, S: SubscriptionStore> ResourceService for CalendarResourc
|
|||||||
file: Self::Resource,
|
file: Self::Resource,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
self.cal_store
|
self.cal_store
|
||||||
.update_calendar(principal.to_owned(), cal_id.to_owned(), file.into())
|
.update_calendar(principal, cal_id, file.into())
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,200 @@
|
|||||||
|
---
|
||||||
|
source: crates/caldav/src/calendar/tests.rs
|
||||||
|
expression: output
|
||||||
|
---
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<response xmlns="DAV:">
|
||||||
|
<href>/caldav/principal/user/calendar/</href>
|
||||||
|
<propstat>
|
||||||
|
<prop xmlns="DAV:">
|
||||||
|
<calendar-timezone xmlns="urn:ietf:params:xml:ns:caldav">BEGIN:VCALENDAR
|
||||||
|
PRODID:-//github.com/lennart-k/vzic-rs//RustiCal Calendar server//EN
|
||||||
|
VERSION:2.0
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Europe/Berlin
|
||||||
|
LAST-MODIFIED:20250723T190331Z
|
||||||
|
X-LIC-LOCATION:Europe/Berlin
|
||||||
|
X-PROLEPTIC-TZNAME:LMT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+005328
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:18930401T000000
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19160430T230000
|
||||||
|
RDATE:19400401T020000
|
||||||
|
RDATE:19430329T020000
|
||||||
|
RDATE:19460414T020000
|
||||||
|
RDATE:19470406T030000
|
||||||
|
RDATE:19480418T020000
|
||||||
|
RDATE:19490410T020000
|
||||||
|
RDATE:19800406T020000
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19161001T010000
|
||||||
|
RDATE:19421102T030000
|
||||||
|
RDATE:19431004T030000
|
||||||
|
RDATE:19441002T030000
|
||||||
|
RDATE:19451118T030000
|
||||||
|
RDATE:19461007T030000
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19170416T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=3MO;UNTIL=19180415T010000Z
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19170917T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=3MO;UNTIL=19180916T010000Z
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19440403T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1MO;UNTIL=19450402T010000Z
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEMT
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0300
|
||||||
|
DTSTART:19450524T020000
|
||||||
|
RDATE:19470511T030000
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0300
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19450924T030000
|
||||||
|
RDATE:19470629T030000
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19460101T000000
|
||||||
|
RDATE:19800101T000000
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19471005T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=1SU;UNTIL=19491002T010000Z
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19800928T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=-1SU;UNTIL=19950924T010000Z
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19810329T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19961027T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
END:VCALENDAR
|
||||||
|
</calendar-timezone>
|
||||||
|
<timezone-service-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<href xmlns="DAV:">https://www.iana.org/time-zones</href>
|
||||||
|
</timezone-service-set>
|
||||||
|
<calendar-timezone-id xmlns="urn:ietf:params:xml:ns:caldav">Europe/Berlin</calendar-timezone-id>
|
||||||
|
<calendar-order xmlns="http://apple.com/ns/ical/">0</calendar-order>
|
||||||
|
<supported-calendar-component-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<comp xmlns="urn:ietf:params:xml:ns:caldav" name="VEVENT"/>
|
||||||
|
<comp xmlns="urn:ietf:params:xml:ns:caldav" name="VTODO"/>
|
||||||
|
</supported-calendar-component-set>
|
||||||
|
<supported-calendar-data xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<calendar-data xmlns="urn:ietf:params:xml:ns:caldav" content-type="text/calendar" version="2.0"/>
|
||||||
|
</supported-calendar-data>
|
||||||
|
<supported-collation-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<supported-collation xmlns="urn:ietf:params:xml:ns:caldav">i;ascii-casemap</supported-collation>
|
||||||
|
<supported-collation xmlns="urn:ietf:params:xml:ns:caldav">i;unicode-casemap</supported-collation>
|
||||||
|
<supported-collation xmlns="urn:ietf:params:xml:ns:caldav">i;octet</supported-collation>
|
||||||
|
</supported-collation-set>
|
||||||
|
<max-resource-size xmlns="urn:ietf:params:xml:ns:caldav">10000000</max-resource-size>
|
||||||
|
<supported-report-set xmlns="DAV:">
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<calendar-query xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
</report>
|
||||||
|
</supported-report>
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<calendar-multiget xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
</report>
|
||||||
|
</supported-report>
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<sync-collection xmlns="DAV:"/>
|
||||||
|
</report>
|
||||||
|
</supported-report>
|
||||||
|
</supported-report-set>
|
||||||
|
<min-date-time xmlns="urn:ietf:params:xml:ns:caldav">-2621430101T000000Z</min-date-time>
|
||||||
|
<max-date-time xmlns="urn:ietf:params:xml:ns:caldav">+2621421231T235959Z</max-date-time>
|
||||||
|
<sync-token xmlns="DAV:">github.com/lennart-k/rustical/ns/12</sync-token>
|
||||||
|
<getctag xmlns="http://calendarserver.org/ns/">github.com/lennart-k/rustical/ns/12</getctag>
|
||||||
|
<transports xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<web-push xmlns="https://bitfire.at/webdav-push"/>
|
||||||
|
</transports>
|
||||||
|
<topic xmlns="https://bitfire.at/webdav-push">b28b41e9-8801-4fc5-ae29-8efb5fadeb36</topic>
|
||||||
|
<supported-triggers xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<content-update xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<depth xmlns="DAV:">1</depth>
|
||||||
|
</content-update>
|
||||||
|
<property-update xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<depth xmlns="DAV:">1</depth>
|
||||||
|
</property-update>
|
||||||
|
</supported-triggers>
|
||||||
|
<resourcetype xmlns="DAV:">
|
||||||
|
<collection xmlns="DAV:"/>
|
||||||
|
<calendar xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
</resourcetype>
|
||||||
|
<displayname xmlns="DAV:">Calendar</displayname>
|
||||||
|
<current-user-principal xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
|
</current-user-principal>
|
||||||
|
<current-user-privilege-set xmlns="DAV:">
|
||||||
|
<privilege>
|
||||||
|
<read/>
|
||||||
|
</privilege>
|
||||||
|
<privilege>
|
||||||
|
<write-properties/>
|
||||||
|
</privilege>
|
||||||
|
<privilege>
|
||||||
|
<read-acl/>
|
||||||
|
</privilege>
|
||||||
|
<privilege>
|
||||||
|
<read-current-user-privilege-set/>
|
||||||
|
</privilege>
|
||||||
|
</current-user-privilege-set>
|
||||||
|
<owner xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
|
</owner>
|
||||||
|
</prop>
|
||||||
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
|
</propstat>
|
||||||
|
</response>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
source: crates/caldav/src/calendar/tests.rs
|
||||||
|
expression: output
|
||||||
|
---
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<response xmlns="DAV:">
|
||||||
|
<href>/caldav/principal/user/calendar/</href>
|
||||||
|
<propstat>
|
||||||
|
<prop xmlns="DAV:">
|
||||||
|
<calendar-color xmlns="http://apple.com/ns/ical/"/>
|
||||||
|
<calendar-description xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<calendar-timezone xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<timezone-service-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<calendar-timezone-id xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<calendar-order xmlns="http://apple.com/ns/ical/"/>
|
||||||
|
<supported-calendar-component-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<supported-calendar-data xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<supported-collation-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<max-resource-size xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<supported-report-set xmlns="DAV:"/>
|
||||||
|
<source xmlns="http://calendarserver.org/ns/"/>
|
||||||
|
<min-date-time xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<max-date-time xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<sync-token xmlns="DAV:"/>
|
||||||
|
<getctag xmlns="http://calendarserver.org/ns/"/>
|
||||||
|
<transports xmlns="https://bitfire.at/webdav-push"/>
|
||||||
|
<topic xmlns="https://bitfire.at/webdav-push"/>
|
||||||
|
<supported-triggers xmlns="https://bitfire.at/webdav-push"/>
|
||||||
|
<resourcetype xmlns="DAV:"/>
|
||||||
|
<displayname xmlns="DAV:"/>
|
||||||
|
<current-user-principal xmlns="DAV:"/>
|
||||||
|
<current-user-privilege-set xmlns="DAV:"/>
|
||||||
|
<owner xmlns="DAV:"/>
|
||||||
|
</prop>
|
||||||
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
|
</propstat>
|
||||||
|
</response>
|
||||||
@@ -1,230 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<response xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CARD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/" xmlns:PUSH="https://bitfire.at/webdav-push">
|
|
||||||
<href>/caldav/principal/user/calendar/</href>
|
|
||||||
<propstat>
|
|
||||||
<prop>
|
|
||||||
<calendar-color xmlns="http://apple.com/ns/ical/"/>
|
|
||||||
<calendar-description xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<calendar-timezone xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<timezone-service-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<calendar-timezone-id xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<calendar-order xmlns="http://apple.com/ns/ical/"/>
|
|
||||||
<supported-calendar-component-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<supported-calendar-data xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<supported-collation-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<max-resource-size xmlns="DAV:"/>
|
|
||||||
<supported-report-set xmlns="DAV:"/>
|
|
||||||
<source xmlns="http://calendarserver.org/ns/"/>
|
|
||||||
<min-date-time xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<max-date-time xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<sync-token xmlns="DAV:"/>
|
|
||||||
<getctag xmlns="http://calendarserver.org/ns/"/>
|
|
||||||
<transports xmlns="https://bitfire.at/webdav-push"/>
|
|
||||||
<topic xmlns="https://bitfire.at/webdav-push"/>
|
|
||||||
<supported-triggers xmlns="https://bitfire.at/webdav-push"/>
|
|
||||||
<resourcetype xmlns="DAV:"/>
|
|
||||||
<displayname xmlns="DAV:"/>
|
|
||||||
<current-user-principal xmlns="DAV:"/>
|
|
||||||
<current-user-privilege-set xmlns="DAV:"/>
|
|
||||||
<owner xmlns="DAV:"/>
|
|
||||||
</prop>
|
|
||||||
<status>HTTP/1.1 200 OK</status>
|
|
||||||
</propstat>
|
|
||||||
</response>
|
|
||||||
|
|
||||||
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<response xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CARD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/" xmlns:PUSH="https://bitfire.at/webdav-push">
|
|
||||||
<href>/caldav/principal/user/calendar/</href>
|
|
||||||
<propstat>
|
|
||||||
<prop>
|
|
||||||
<CAL:calendar-timezone>BEGIN:VCALENDAR
|
|
||||||
PRODID:-//github.com/lennart-k/vzic-rs//RustiCal Calendar server//EN
|
|
||||||
VERSION:2.0
|
|
||||||
BEGIN:VTIMEZONE
|
|
||||||
TZID:Europe/Berlin
|
|
||||||
LAST-MODIFIED:20250723T190331Z
|
|
||||||
X-LIC-LOCATION:Europe/Berlin
|
|
||||||
X-PROLEPTIC-TZNAME:LMT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+005328
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:18930401T000000
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19160430T230000
|
|
||||||
RDATE:19400401T020000
|
|
||||||
RDATE:19430329T020000
|
|
||||||
RDATE:19460414T020000
|
|
||||||
RDATE:19470406T030000
|
|
||||||
RDATE:19480418T020000
|
|
||||||
RDATE:19490410T020000
|
|
||||||
RDATE:19800406T020000
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19161001T010000
|
|
||||||
RDATE:19421102T030000
|
|
||||||
RDATE:19431004T030000
|
|
||||||
RDATE:19441002T030000
|
|
||||||
RDATE:19451118T030000
|
|
||||||
RDATE:19461007T030000
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19170416T020000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=3MO;UNTIL=19180415T010000Z
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19170917T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=3MO;UNTIL=19180916T010000Z
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19440403T020000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1MO;UNTIL=19450402T010000Z
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEMT
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0300
|
|
||||||
DTSTART:19450524T020000
|
|
||||||
RDATE:19470511T030000
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0300
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19450924T030000
|
|
||||||
RDATE:19470629T030000
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19460101T000000
|
|
||||||
RDATE:19800101T000000
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19471005T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=1SU;UNTIL=19491002T010000Z
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19800928T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=-1SU;UNTIL=19950924T010000Z
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19810329T020000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19961027T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
|
||||||
END:STANDARD
|
|
||||||
END:VTIMEZONE
|
|
||||||
END:VCALENDAR
|
|
||||||
</CAL:calendar-timezone>
|
|
||||||
<CAL:timezone-service-set>
|
|
||||||
<href>https://www.iana.org/time-zones</href>
|
|
||||||
</CAL:timezone-service-set>
|
|
||||||
<CAL:calendar-timezone-id>Europe/Berlin</CAL:calendar-timezone-id>
|
|
||||||
<calendar-order xmlns="http://apple.com/ns/ical/">0</calendar-order>
|
|
||||||
<CAL:supported-calendar-component-set>
|
|
||||||
<CAL:comp name="VEVENT"/>
|
|
||||||
<CAL:comp name="VTODO"/>
|
|
||||||
</CAL:supported-calendar-component-set>
|
|
||||||
<CAL:supported-calendar-data>
|
|
||||||
<CAL:calendar-data content-type="text/calendar" version="2.0"/>
|
|
||||||
</CAL:supported-calendar-data>
|
|
||||||
<CAL:supported-collation-set>
|
|
||||||
<CAL:supported-collation>i;ascii-casemap</CAL:supported-collation>
|
|
||||||
<CAL:supported-collation>i;octet</CAL:supported-collation>
|
|
||||||
</CAL:supported-collation-set>
|
|
||||||
<max-resource-size>10000000</max-resource-size>
|
|
||||||
<supported-report-set>
|
|
||||||
<supported-report>
|
|
||||||
<report>
|
|
||||||
<CAL:calendar-query/>
|
|
||||||
</report>
|
|
||||||
</supported-report>
|
|
||||||
<supported-report>
|
|
||||||
<report>
|
|
||||||
<CAL:calendar-multiget/>
|
|
||||||
</report>
|
|
||||||
</supported-report>
|
|
||||||
<supported-report>
|
|
||||||
<report>
|
|
||||||
<sync-collection/>
|
|
||||||
</report>
|
|
||||||
</supported-report>
|
|
||||||
</supported-report-set>
|
|
||||||
<CAL:min-date-time>-2621430101T000000Z</CAL:min-date-time>
|
|
||||||
<CAL:max-date-time>+2621421231T235959Z</CAL:max-date-time>
|
|
||||||
<sync-token>github.com/lennart-k/rustical/ns/12</sync-token>
|
|
||||||
<CS:getctag>github.com/lennart-k/rustical/ns/12</CS:getctag>
|
|
||||||
<PUSH:transports>
|
|
||||||
<PUSH:web-push/>
|
|
||||||
</PUSH:transports>
|
|
||||||
<PUSH:topic>b28b41e9-8801-4fc5-ae29-8efb5fadeb36</PUSH:topic>
|
|
||||||
<PUSH:supported-triggers>
|
|
||||||
<PUSH:content-update>
|
|
||||||
<depth>1</depth>
|
|
||||||
</PUSH:content-update>
|
|
||||||
<PUSH:property-update>
|
|
||||||
<depth>1</depth>
|
|
||||||
</PUSH:property-update>
|
|
||||||
</PUSH:supported-triggers>
|
|
||||||
<resourcetype>
|
|
||||||
<collection/>
|
|
||||||
<CAL:calendar/>
|
|
||||||
</resourcetype>
|
|
||||||
<displayname>Calendar</displayname>
|
|
||||||
<current-user-principal>
|
|
||||||
<href>/caldav/principal/user/</href>
|
|
||||||
</current-user-principal>
|
|
||||||
<current-user-privilege-set>
|
|
||||||
<privilege>
|
|
||||||
<read/>
|
|
||||||
</privilege>
|
|
||||||
<privilege>
|
|
||||||
<write-properties/>
|
|
||||||
</privilege>
|
|
||||||
<privilege>
|
|
||||||
<read-acl/>
|
|
||||||
</privilege>
|
|
||||||
<privilege>
|
|
||||||
<read-current-user-privilege-set/>
|
|
||||||
</privilege>
|
|
||||||
</current-user-privilege-set>
|
|
||||||
<owner>
|
|
||||||
<href>/caldav/principal/user/</href>
|
|
||||||
</owner>
|
|
||||||
</prop>
|
|
||||||
<status>HTTP/1.1 200 OK</status>
|
|
||||||
</propstat>
|
|
||||||
</response>
|
|
||||||
@@ -14,14 +14,9 @@ async fn test_propfind() {
|
|||||||
from_str(include_str!("./test_files/propfind.principals.json")).unwrap();
|
from_str(include_str!("./test_files/propfind.principals.json")).unwrap();
|
||||||
let resources: Vec<CalendarResource> =
|
let resources: Vec<CalendarResource> =
|
||||||
from_str(include_str!("./test_files/propfind.resources.json")).unwrap();
|
from_str(include_str!("./test_files/propfind.resources.json")).unwrap();
|
||||||
let outputs: Vec<_> = include_str!("./test_files/propfind.outputs")
|
|
||||||
.trim()
|
|
||||||
.split("\n\n")
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
for principal in principals {
|
for principal in principals {
|
||||||
for ((request, resource), &expected_output) in requests.iter().zip(&resources).zip(&outputs)
|
for (request, resource) in requests.iter().zip(&resources) {
|
||||||
{
|
|
||||||
let propfind = CalendarResource::parse_propfind(request).unwrap();
|
let propfind = CalendarResource::parse_propfind(request).unwrap();
|
||||||
|
|
||||||
let response = resource
|
let response = resource
|
||||||
@@ -33,13 +28,12 @@ async fn test_propfind() {
|
|||||||
&principal,
|
&principal,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let expected_output = expected_output.trim();
|
|
||||||
let output = response
|
let output = response
|
||||||
.serialize_to_string()
|
.serialize_to_string()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.trim()
|
.trim()
|
||||||
.replace("\r\n", "\n");
|
.replace("\r\n", "\n");
|
||||||
similar_asserts::assert_eq!(expected_output, output);
|
insta::assert_snapshot!(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ 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, Method, StatusCode};
|
use http::{HeaderMap, HeaderValue, 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;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use tracing::{debug, instrument};
|
use tracing::{instrument, warn};
|
||||||
|
|
||||||
#[instrument(skip(cal_store))]
|
#[instrument(skip(cal_store))]
|
||||||
pub async fn get_event<C: CalendarStore>(
|
pub async fn get_event<C: CalendarStore>(
|
||||||
@@ -42,7 +42,7 @@ pub async fn get_event<C: CalendarStore>(
|
|||||||
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(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; charset=utf-8").unwrap());
|
||||||
if matches!(method, Method::HEAD) {
|
if matches!(method, Method::HEAD) {
|
||||||
Ok(resp.body(Body::empty()).unwrap())
|
Ok(resp.body(Body::empty()).unwrap())
|
||||||
} else {
|
} else {
|
||||||
@@ -73,18 +73,44 @@ pub async fn put_event<C: CalendarStore>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let overwrite = if let Some(TypedHeader(if_none_match)) = if_none_match {
|
let overwrite = if let Some(TypedHeader(if_none_match)) = if_none_match {
|
||||||
if_none_match == IfNoneMatch::any()
|
// TODO: Put into transaction?
|
||||||
|
let existing = match cal_store
|
||||||
|
.get_object(&principal, &calendar_id, &object_id, false)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(existing) => Some(existing),
|
||||||
|
Err(rustical_store::Error::NotFound) => None,
|
||||||
|
Err(err) => Err(err)?,
|
||||||
|
};
|
||||||
|
existing.is_none_or(|existing| {
|
||||||
|
if_none_match.precondition_passes(
|
||||||
|
&existing
|
||||||
|
.get_etag()
|
||||||
|
.parse()
|
||||||
|
.expect("We only generate valid ETags"),
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|
||||||
let Ok(object) = CalendarObject::from_ics(body.clone(), Some(object_id)) else {
|
let object = match CalendarObject::from_ics(body.clone()) {
|
||||||
debug!("invalid calendar data:\n{body}");
|
Ok(object) => object,
|
||||||
|
Err(err) => {
|
||||||
|
warn!("invalid calendar data:\n{body}");
|
||||||
|
warn!("{err}");
|
||||||
return Err(Error::PreconditionFailed(Precondition::ValidCalendarData));
|
return Err(Error::PreconditionFailed(Precondition::ValidCalendarData));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
let etag = object.get_etag();
|
||||||
cal_store
|
cal_store
|
||||||
.put_object(principal, calendar_id, object, overwrite)
|
.put_object(&principal, &calendar_id, &object_id, object, overwrite)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(StatusCode::CREATED.into_response())
|
let mut headers = HeaderMap::new();
|
||||||
|
headers.insert(
|
||||||
|
"ETag",
|
||||||
|
HeaderValue::from_str(&etag).expect("Contains no invalid characters"),
|
||||||
|
);
|
||||||
|
Ok((StatusCode::CREATED, headers).into_response())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use rustical_dav::extensions::CommonPropertiesProp;
|
use rustical_dav::extensions::CommonPropertiesProp;
|
||||||
use rustical_ical::UtcDateTime;
|
use rustical_ical::UtcDateTime;
|
||||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
use rustical_xml::{EnumVariants, PropName, Unparsed, XmlDeserialize, XmlSerialize};
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
||||||
#[xml(unit_variants_ident = "CalendarObjectPropName")]
|
#[xml(unit_variants_ident = "CalendarObjectPropName")]
|
||||||
@@ -35,7 +35,9 @@ pub struct ExpandElement {
|
|||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Default, Eq, Hash)]
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Default, Eq, Hash)]
|
||||||
pub struct CalendarData {
|
pub struct CalendarData {
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
pub(crate) comp: Option<()>,
|
pub(crate) comp: Option<Unparsed>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
|
pub(crate) prop: Option<Unparsed>,
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
pub(crate) expand: Option<ExpandElement>,
|
pub(crate) expand: Option<ExpandElement>,
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use super::prop::{
|
|||||||
};
|
};
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{From, Into};
|
||||||
|
use ical::generator::Emitter;
|
||||||
use rustical_dav::{
|
use rustical_dav::{
|
||||||
extensions::CommonPropertiesExtension,
|
extensions::CommonPropertiesExtension,
|
||||||
privileges::UserPrivilegeSet,
|
privileges::UserPrivilegeSet,
|
||||||
@@ -12,16 +13,18 @@ use rustical_dav::{
|
|||||||
};
|
};
|
||||||
use rustical_ical::CalendarObject;
|
use rustical_ical::CalendarObject;
|
||||||
use rustical_store::auth::Principal;
|
use rustical_store::auth::Principal;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
#[derive(Clone, From, Into)]
|
#[derive(Clone, From, Into)]
|
||||||
pub struct CalendarObjectResource {
|
pub struct CalendarObjectResource {
|
||||||
pub object: CalendarObject,
|
pub object: CalendarObject,
|
||||||
|
pub object_id: String,
|
||||||
pub principal: String,
|
pub principal: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for CalendarObjectResource {
|
impl ResourceName for CalendarObjectResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
format!("{}.ics", self.object.get_id())
|
Cow::from(format!("{}.ics", self.object_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,14 +54,18 @@ impl Resource for CalendarObjectResource {
|
|||||||
CalendarObjectProp::Getetag(self.object.get_etag())
|
CalendarObjectProp::Getetag(self.object.get_etag())
|
||||||
}
|
}
|
||||||
CalendarObjectPropName::CalendarData(CalendarData { expand, .. }) => {
|
CalendarObjectPropName::CalendarData(CalendarData { expand, .. }) => {
|
||||||
CalendarObjectProp::CalendarData(if let Some(expand) = expand.as_ref() {
|
CalendarObjectProp::CalendarData(expand.as_ref().map_or_else(
|
||||||
self.object.expand_recurrence(
|
|| self.object.get_ics().to_owned(),
|
||||||
|
|expand| {
|
||||||
|
self.object
|
||||||
|
.get_inner()
|
||||||
|
.expand_recurrence(
|
||||||
Some(expand.start.to_utc()),
|
Some(expand.start.to_utc()),
|
||||||
Some(expand.end.to_utc()),
|
Some(expand.end.to_utc()),
|
||||||
)?
|
)
|
||||||
} else {
|
.generate()
|
||||||
self.object.get_ics().to_owned()
|
},
|
||||||
})
|
))
|
||||||
}
|
}
|
||||||
CalendarObjectPropName::Getcontenttype => {
|
CalendarObjectPropName::Getcontenttype => {
|
||||||
CalendarObjectProp::Getcontenttype("text/calendar;charset=utf-8")
|
CalendarObjectProp::Getcontenttype("text/calendar;charset=utf-8")
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ impl<C: CalendarStore> ResourceService for CalendarObjectResourceService<C> {
|
|||||||
.await?;
|
.await?;
|
||||||
Ok(CalendarObjectResource {
|
Ok(CalendarObjectResource {
|
||||||
object,
|
object,
|
||||||
|
object_id: object_id.to_owned(),
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ impl IntoResponse for Precondition {
|
|||||||
if let Err(err) = error.serialize_root(&mut writer) {
|
if let Err(err) = error.serialize_root(&mut writer) {
|
||||||
return rustical_dav::Error::from(err).into_response();
|
return rustical_dav::Error::from(err).into_response();
|
||||||
}
|
}
|
||||||
let mut res = Response::builder().status(StatusCode::PRECONDITION_FAILED);
|
let mut res = Response::builder().status(StatusCode::FORBIDDEN);
|
||||||
res.headers_mut().unwrap().typed_insert(ContentType::xml());
|
res.headers_mut().unwrap().typed_insert(ContentType::xml());
|
||||||
res.body(Body::from(output)).unwrap()
|
res.body(Body::from(output)).unwrap()
|
||||||
}
|
}
|
||||||
@@ -52,9 +52,6 @@ pub enum Error {
|
|||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
XmlDecodeError(#[from] rustical_xml::XmlError),
|
XmlDecodeError(#[from] rustical_xml::XmlError),
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
IcalError(#[from] rustical_ical::Error),
|
|
||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
PreconditionFailed(Precondition),
|
PreconditionFailed(Precondition),
|
||||||
}
|
}
|
||||||
@@ -75,18 +72,20 @@ impl Error {
|
|||||||
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
|
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
|
||||||
Self::ChronoParseError(_) | Self::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
|
Self::ChronoParseError(_) | Self::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
Self::NotFound => StatusCode::NOT_FOUND,
|
Self::NotFound => StatusCode::NOT_FOUND,
|
||||||
Self::IcalError(err) => err.status_code(),
|
// The correct status code for a failed precondition is not PreconditionFailed but
|
||||||
Self::PreconditionFailed(_err) => StatusCode::PRECONDITION_FAILED,
|
// Forbidden (or Conflict):
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc4791#section-1.3
|
||||||
|
Self::PreconditionFailed(_err) => StatusCode::FORBIDDEN,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoResponse for Error {
|
impl IntoResponse for Error {
|
||||||
fn into_response(self) -> axum::response::Response {
|
fn into_response(self) -> axum::response::Response {
|
||||||
if matches!(
|
if let Self::PreconditionFailed(precondition) = self {
|
||||||
self.status_code(),
|
return precondition.into_response();
|
||||||
StatusCode::INTERNAL_SERVER_ERROR | StatusCode::PRECONDITION_FAILED
|
}
|
||||||
) {
|
if matches!(self.status_code(), StatusCode::INTERNAL_SERVER_ERROR) {
|
||||||
error!("{self}");
|
error!("{self}");
|
||||||
}
|
}
|
||||||
(self.status_code(), self.to_string()).into_response()
|
(self.status_code(), self.to_string()).into_response()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use rustical_dav::xml::{
|
|||||||
GroupMemberSet, GroupMembership, Resourcetype, ResourcetypeInner, SupportedReportSet,
|
GroupMemberSet, GroupMembership, Resourcetype, ResourcetypeInner, SupportedReportSet,
|
||||||
};
|
};
|
||||||
use rustical_store::auth::Principal;
|
use rustical_store::auth::Principal;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
mod service;
|
mod service;
|
||||||
pub use service::*;
|
pub use service::*;
|
||||||
@@ -23,8 +24,8 @@ pub struct PrincipalResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for PrincipalResource {
|
impl ResourceName for PrincipalResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
self.principal.id.clone()
|
Cow::from(&self.principal.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,51 +3,51 @@ source: crates/caldav/src/principal/tests.rs
|
|||||||
expression: response.serialize_to_string().unwrap()
|
expression: response.serialize_to_string().unwrap()
|
||||||
---
|
---
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<response xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CARD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/" xmlns:PUSH="https://bitfire.at/webdav-push">
|
<response xmlns="DAV:">
|
||||||
<href>/caldav/principal/user/</href>
|
<href>/caldav/principal/user/</href>
|
||||||
<propstat>
|
<propstat>
|
||||||
<prop>
|
<prop xmlns="DAV:">
|
||||||
<CAL:calendar-user-type>INDIVIDUAL</CAL:calendar-user-type>
|
<calendar-user-type xmlns="urn:ietf:params:xml:ns:caldav">INDIVIDUAL</calendar-user-type>
|
||||||
<CAL:calendar-user-address-set>
|
<calendar-user-address-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
<href>/caldav/principal/user/</href>
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
</CAL:calendar-user-address-set>
|
</calendar-user-address-set>
|
||||||
<principal-URL>
|
<principal-URL xmlns="DAV:">
|
||||||
<href>/caldav/principal/user/</href>
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
</principal-URL>
|
</principal-URL>
|
||||||
<group-membership>
|
<group-membership xmlns="DAV:">
|
||||||
<href>/caldav/principal/group/</href>
|
<href xmlns="DAV:">/caldav/principal/group/</href>
|
||||||
</group-membership>
|
</group-membership>
|
||||||
<group-member-set>
|
<group-member-set xmlns="DAV:">
|
||||||
</group-member-set>
|
</group-member-set>
|
||||||
<alternate-URI-set/>
|
<alternate-URI-set xmlns="DAV:"/>
|
||||||
<supported-report-set>
|
<supported-report-set xmlns="DAV:">
|
||||||
<supported-report>
|
<supported-report xmlns="DAV:">
|
||||||
<report>
|
<report xmlns="DAV:">
|
||||||
<principal-match/>
|
<principal-match xmlns="DAV:"/>
|
||||||
</report>
|
</report>
|
||||||
</supported-report>
|
</supported-report>
|
||||||
</supported-report-set>
|
</supported-report-set>
|
||||||
<CAL:calendar-home-set>
|
<calendar-home-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
<href>/caldav/principal/group/</href>
|
<href xmlns="DAV:">/caldav/principal/group/</href>
|
||||||
<href>/caldav/principal/user/</href>
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
</CAL:calendar-home-set>
|
</calendar-home-set>
|
||||||
<resourcetype>
|
<resourcetype xmlns="DAV:">
|
||||||
<collection/>
|
<collection xmlns="DAV:"/>
|
||||||
<principal/>
|
<principal xmlns="DAV:"/>
|
||||||
</resourcetype>
|
</resourcetype>
|
||||||
<displayname>user</displayname>
|
<displayname xmlns="DAV:">user</displayname>
|
||||||
<current-user-principal>
|
<current-user-principal xmlns="DAV:">
|
||||||
<href>/caldav/principal/user/</href>
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
</current-user-principal>
|
</current-user-principal>
|
||||||
<current-user-privilege-set>
|
<current-user-privilege-set xmlns="DAV:">
|
||||||
<privilege>
|
<privilege>
|
||||||
<all/>
|
<all/>
|
||||||
</privilege>
|
</privilege>
|
||||||
</current-user-privilege-set>
|
</current-user-privilege-set>
|
||||||
<owner>
|
<owner xmlns="DAV:">
|
||||||
<href>/caldav/principal/user/</href>
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
</owner>
|
</owner>
|
||||||
</prop>
|
</prop>
|
||||||
<status>HTTP/1.1 200 OK</status>
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
</propstat>
|
</propstat>
|
||||||
</response>
|
</response>
|
||||||
|
|||||||
@@ -5,32 +5,27 @@ use crate::{
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use rustical_dav::resource::{Resource, ResourceService};
|
use rustical_dav::resource::{Resource, ResourceService};
|
||||||
use rustical_store::auth::{Principal, PrincipalType::Individual};
|
use rustical_store::auth::{Principal, PrincipalType::Individual};
|
||||||
use rustical_store_sqlite::{
|
use rustical_store_sqlite::tests::{TestStoreContext, test_store_context};
|
||||||
SqliteStore,
|
|
||||||
calendar_store::SqliteCalendarStore,
|
|
||||||
principal_store::SqlitePrincipalStore,
|
|
||||||
tests::{get_test_calendar_store, get_test_principal_store, get_test_subscription_store},
|
|
||||||
};
|
|
||||||
use rustical_xml::XmlSerializeRoot;
|
use rustical_xml::XmlSerializeRoot;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_principal_resource(
|
async fn test_principal_resource(
|
||||||
#[from(get_test_calendar_store)]
|
|
||||||
#[future]
|
#[future]
|
||||||
cal_store: SqliteCalendarStore,
|
#[from(test_store_context)]
|
||||||
#[from(get_test_principal_store)]
|
context: TestStoreContext,
|
||||||
#[future]
|
|
||||||
auth_provider: SqlitePrincipalStore,
|
|
||||||
#[from(get_test_subscription_store)]
|
|
||||||
#[future]
|
|
||||||
sub_store: SqliteStore,
|
|
||||||
) {
|
) {
|
||||||
|
let TestStoreContext {
|
||||||
|
cal_store,
|
||||||
|
sub_store,
|
||||||
|
principal_store: auth_provider,
|
||||||
|
..
|
||||||
|
} = context.await;
|
||||||
let service = PrincipalResourceService {
|
let service = PrincipalResourceService {
|
||||||
cal_store: Arc::new(cal_store.await),
|
cal_store: Arc::new(cal_store),
|
||||||
sub_store: Arc::new(sub_store.await),
|
sub_store: Arc::new(sub_store),
|
||||||
auth_provider: Arc::new(auth_provider.await),
|
auth_provider: Arc::new(auth_provider),
|
||||||
simplified_home_set: false,
|
simplified_home_set: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ base64.workspace = true
|
|||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
url.workspace = true
|
url.workspace = true
|
||||||
rustical_dav.workspace = true
|
rustical_dav = { workspace = true, features = ["ical"] }
|
||||||
rustical_store.workspace = true
|
rustical_store.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
rustical_xml.workspace = true
|
rustical_xml.workspace = true
|
||||||
@@ -35,6 +35,7 @@ percent-encoding.workspace = true
|
|||||||
ical.workspace = true
|
ical.workspace = true
|
||||||
strum.workspace = true
|
strum.workspace = true
|
||||||
strum_macros.workspace = true
|
strum_macros.workspace = true
|
||||||
|
rstest.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
insta.workspace = true
|
insta.workspace = true
|
||||||
|
|||||||
@@ -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::HeaderValue;
|
||||||
use http::Method;
|
use http::Method;
|
||||||
use http::{HeaderMap, StatusCode};
|
use http::{HeaderMap, StatusCode};
|
||||||
use rustical_dav::privileges::UserPrivilege;
|
use rustical_dav::privileges::UserPrivilege;
|
||||||
@@ -50,7 +51,7 @@ pub async fn get_object<AS: AddressbookStore>(
|
|||||||
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(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; charset=utf-8").unwrap());
|
||||||
if matches!(method, Method::HEAD) {
|
if matches!(method, Method::HEAD) {
|
||||||
Ok(resp.body(Body::empty()).unwrap())
|
Ok(resp.body(Body::empty()).unwrap())
|
||||||
} else {
|
} else {
|
||||||
@@ -81,15 +82,40 @@ pub async fn put_object<AS: AddressbookStore>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let overwrite = if let Some(TypedHeader(if_none_match)) = if_none_match {
|
let overwrite = if let Some(TypedHeader(if_none_match)) = if_none_match {
|
||||||
if_none_match == IfNoneMatch::any()
|
// TODO: Put into transaction?
|
||||||
|
let existing = match addr_store
|
||||||
|
.get_object(&principal, &addressbook_id, &object_id, false)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(existing) => Some(existing),
|
||||||
|
Err(rustical_store::Error::NotFound) => None,
|
||||||
|
Err(err) => Err(err)?,
|
||||||
|
};
|
||||||
|
existing.is_none_or(|existing| {
|
||||||
|
if_none_match.precondition_passes(
|
||||||
|
&existing
|
||||||
|
.get_etag()
|
||||||
|
.parse()
|
||||||
|
.expect("We only generate valid ETags"),
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|
||||||
let object = AddressObject::from_vcf(object_id, body)?;
|
let object = match AddressObject::from_vcf(body) {
|
||||||
|
Ok(object) => object,
|
||||||
|
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
|
||||||
|
};
|
||||||
|
let etag = object.get_etag();
|
||||||
addr_store
|
addr_store
|
||||||
.put_object(principal, addressbook_id, object, overwrite)
|
.put_object(&principal, &addressbook_id, &object_id, object, overwrite)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(StatusCode::CREATED.into_response())
|
let mut headers = HeaderMap::new();
|
||||||
|
headers.insert(
|
||||||
|
"ETag",
|
||||||
|
HeaderValue::from_str(&etag).expect("Contains no invalid characters"),
|
||||||
|
);
|
||||||
|
Ok((StatusCode::CREATED, headers).into_response())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Error,
|
Error,
|
||||||
address_object::{
|
address_object::{
|
||||||
@@ -6,6 +8,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{From, Into};
|
||||||
|
use ical::parser::VcardFNProperty;
|
||||||
use rustical_dav::{
|
use rustical_dav::{
|
||||||
extensions::CommonPropertiesExtension,
|
extensions::CommonPropertiesExtension,
|
||||||
privileges::UserPrivilegeSet,
|
privileges::UserPrivilegeSet,
|
||||||
@@ -19,11 +22,12 @@ use rustical_store::auth::Principal;
|
|||||||
pub struct AddressObjectResource {
|
pub struct AddressObjectResource {
|
||||||
pub object: AddressObject,
|
pub object: AddressObject,
|
||||||
pub principal: String,
|
pub principal: String,
|
||||||
|
pub object_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for AddressObjectResource {
|
impl ResourceName for AddressObjectResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
format!("{}.vcf", self.object.get_id())
|
Cow::from(format!("{}.vcf", self.object_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +71,11 @@ impl Resource for AddressObjectResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_displayname(&self) -> Option<&str> {
|
fn get_displayname(&self) -> Option<&str> {
|
||||||
self.object.get_full_name()
|
self.object
|
||||||
|
.get_vcard()
|
||||||
|
.full_name
|
||||||
|
.first()
|
||||||
|
.map(|VcardFNProperty(name, _)| name.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_owner(&self) -> Option<&str> {
|
fn get_owner(&self) -> Option<&str> {
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ impl<AS: AddressbookStore> ResourceService for AddressObjectResourceService<AS>
|
|||||||
.await?;
|
.await?;
|
||||||
Ok(AddressObjectResource {
|
Ok(AddressObjectResource {
|
||||||
object,
|
object,
|
||||||
|
object_id: object_id.to_owned(),
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ 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;
|
||||||
use rustical_ical::AddressObject;
|
|
||||||
use rustical_store::auth::Principal;
|
use rustical_store::auth::Principal;
|
||||||
use rustical_store::{AddressbookStore, SubscriptionStore};
|
use rustical_store::{AddressbookStore, SubscriptionStore};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@@ -40,13 +39,13 @@ pub async fn route_get<AS: AddressbookStore, S: SubscriptionStore>(
|
|||||||
let objects = addr_store.get_objects(&principal, &addressbook_id).await?;
|
let objects = addr_store.get_objects(&principal, &addressbook_id).await?;
|
||||||
let vcf = objects
|
let vcf = objects
|
||||||
.iter()
|
.iter()
|
||||||
.map(AddressObject::get_vcf)
|
.map(|(_id, obj)| obj.get_vcf())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\r\n");
|
.join("\r\n");
|
||||||
|
|
||||||
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; charset=utf-8").unwrap());
|
||||||
let filename = format!("{principal}_{addressbook_id}.vcf");
|
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(
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::io::BufReader;
|
|
||||||
|
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use crate::addressbook::AddressbookResourceService;
|
use crate::addressbook::AddressbookResourceService;
|
||||||
use axum::{
|
use axum::{
|
||||||
@@ -9,7 +7,7 @@ use axum::{
|
|||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use ical::{
|
use ical::{
|
||||||
parser::{Component, ComponentMut, vcard},
|
parser::{Component, ComponentMut, vcard},
|
||||||
property::Property,
|
property::ContentLine,
|
||||||
};
|
};
|
||||||
use rustical_store::{Addressbook, AddressbookStore, SubscriptionStore, auth::Principal};
|
use rustical_store::{Addressbook, AddressbookStore, SubscriptionStore, auth::Principal};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
@@ -25,7 +23,7 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
|
|||||||
return Err(Error::Unauthorized);
|
return Err(Error::Unauthorized);
|
||||||
}
|
}
|
||||||
|
|
||||||
let parser = vcard::VcardParser::new(BufReader::new(body.as_bytes()));
|
let parser = vcard::VcardParser::from_slice(body.as_bytes());
|
||||||
|
|
||||||
let mut objects = vec![];
|
let mut objects = vec![];
|
||||||
for res in parser {
|
for res in parser {
|
||||||
@@ -33,15 +31,16 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
|
|||||||
let uid = card.get_uid();
|
let uid = card.get_uid();
|
||||||
if uid.is_none() {
|
if uid.is_none() {
|
||||||
let mut card_mut = card.mutable();
|
let mut card_mut = card.mutable();
|
||||||
card_mut.set_property(Property {
|
card_mut.add_content_line(ContentLine {
|
||||||
name: "UID".to_owned(),
|
name: "UID".to_owned(),
|
||||||
value: Some(uuid::Uuid::new_v4().to_string()),
|
value: Some(uuid::Uuid::new_v4().to_string()),
|
||||||
params: None,
|
params: vec![].into(),
|
||||||
});
|
});
|
||||||
card = card_mut.verify().unwrap();
|
card = card_mut.build(None).unwrap();
|
||||||
}
|
}
|
||||||
|
// TODO: Make nicer
|
||||||
objects.push(card.try_into().unwrap());
|
let uid = card.get_uid().unwrap();
|
||||||
|
objects.push((uid.to_owned(), card.into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if objects.is_empty() {
|
if objects.is_empty() {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub async fn get_objects_addressbook_multiget<AS: AddressbookStore>(
|
|||||||
principal: &str,
|
principal: &str,
|
||||||
addressbook_id: &str,
|
addressbook_id: &str,
|
||||||
store: &AS,
|
store: &AS,
|
||||||
) -> Result<(Vec<AddressObject>, Vec<String>), Error> {
|
) -> Result<(Vec<(String, AddressObject)>, Vec<String>), Error> {
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
let mut not_found = vec![];
|
let mut not_found = vec![];
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ pub async fn get_objects_addressbook_multiget<AS: AddressbookStore>(
|
|||||||
.get_object(principal, addressbook_id, object_id, false)
|
.get_object(principal, addressbook_id, object_id, false)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(object) => result.push(object),
|
Ok(object) => result.push((object_id.to_owned(), object)),
|
||||||
Err(rustical_store::Error::NotFound) => not_found.push(href.to_string()),
|
Err(rustical_store::Error::NotFound) => not_found.push(href.to_string()),
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => return Err(err.into()),
|
||||||
}
|
}
|
||||||
@@ -74,11 +74,12 @@ pub async fn handle_addressbook_multiget<AS: AddressbookStore>(
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let mut responses = Vec::new();
|
let mut responses = Vec::new();
|
||||||
for object in objects {
|
for (object_id, object) in objects {
|
||||||
let path = format!("{}/{}.vcf", path, object.get_id());
|
let path = format!("{path}/{object_id}.vcf");
|
||||||
responses.push(
|
responses.push(
|
||||||
AddressObjectResource {
|
AddressObjectResource {
|
||||||
object,
|
object,
|
||||||
|
object_id,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, prop, None, puri, user)?,
|
.propfind(&path, prop, None, puri, user)?,
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
use crate::{
|
||||||
|
address_object::AddressObjectPropWrapperName,
|
||||||
|
addressbook::methods::report::addressbook_query::PropFilterElement,
|
||||||
|
};
|
||||||
|
use derive_more::{From, Into};
|
||||||
|
use ical::property::ContentLine;
|
||||||
|
use rustical_dav::xml::{PropfindType, TextMatchElement};
|
||||||
|
use rustical_ical::{AddressObject, UtcDateTime};
|
||||||
|
use rustical_xml::{ValueDeserialize, XmlDeserialize, XmlRootTag};
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct TimeRangeElement {
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) start: Option<UtcDateTime>,
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) end: Option<UtcDateTime>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
// https://www.rfc-editor.org/rfc/rfc4791#section-9.7.3
|
||||||
|
pub struct ParamFilterElement {
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) is_not_defined: Option<()>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) text_match: Option<TextMatchElement>,
|
||||||
|
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ParamFilterElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_property(&self, prop: &ContentLine) -> bool {
|
||||||
|
let Some(param) = prop.params.get_param(&self.name) else {
|
||||||
|
return self.is_not_defined.is_some();
|
||||||
|
};
|
||||||
|
if self.is_not_defined.is_some() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let Some(text_match) = self.text_match.as_ref() else {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
text_match.match_text(param)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Default, From, Into)]
|
||||||
|
pub struct Allof(pub bool);
|
||||||
|
|
||||||
|
impl ValueDeserialize for Allof {
|
||||||
|
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
||||||
|
Ok(Self(match val {
|
||||||
|
"allof" => true,
|
||||||
|
"anyof" => false,
|
||||||
|
_ => {
|
||||||
|
return Err(rustical_xml::XmlError::InvalidVariant(format!(
|
||||||
|
"Invalid test parameter: {val}"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <!ELEMENT filter (prop-filter*)>
|
||||||
|
// <!ATTLIST filter test (anyof | allof) "anyof">
|
||||||
|
// <!-- test value:
|
||||||
|
// anyof logical OR for prop-filter matches
|
||||||
|
// allof logical AND for prop-filter matches -->
|
||||||
|
#[derive(XmlDeserialize, XmlRootTag, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[xml(root = "filter", ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct FilterElement {
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub test: Allof,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", flatten)]
|
||||||
|
pub(crate) prop_filter: Vec<PropFilterElement>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FilterElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn matches(&self, addr_object: &AddressObject) -> bool {
|
||||||
|
if self.prop_filter.is_empty() {
|
||||||
|
// Filter empty
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let Allof(allof) = self.test;
|
||||||
|
let mut results = self
|
||||||
|
.prop_filter
|
||||||
|
.iter()
|
||||||
|
.map(|prop_filter| prop_filter.match_component(addr_object));
|
||||||
|
if allof {
|
||||||
|
results.all(|x| x)
|
||||||
|
} else {
|
||||||
|
results.any(|x| x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
// <!ELEMENT addressbook-query ((DAV:allprop |
|
||||||
|
// DAV:propname |
|
||||||
|
// DAV:prop)?, filter, limit?)>
|
||||||
|
pub struct AddressbookQueryRequest {
|
||||||
|
#[xml(ty = "untagged")]
|
||||||
|
pub prop: PropfindType<AddressObjectPropWrapperName>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) filter: FilterElement,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) limit: Option<LimitElement>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc5323#section-5.17
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub struct LimitElement {
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub nresults: NresultsElement,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<u64> for LimitElement {
|
||||||
|
fn from(value: u64) -> Self {
|
||||||
|
Self {
|
||||||
|
nresults: NresultsElement(value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<LimitElement> for u64 {
|
||||||
|
fn from(value: LimitElement) -> Self {
|
||||||
|
value.nresults.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub struct NresultsElement(#[xml(ty = "text")] pub u64);
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
use crate::Error;
|
||||||
|
mod elements;
|
||||||
|
mod prop_filter;
|
||||||
|
pub use elements::*;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use prop_filter::{PropFilterElement, PropFilterable};
|
||||||
|
use rustical_ical::AddressObject;
|
||||||
|
use rustical_store::AddressbookStore;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
|
|
||||||
|
pub async fn get_objects_addressbook_query<AS: AddressbookStore>(
|
||||||
|
addr_query: &AddressbookQueryRequest,
|
||||||
|
principal: &str,
|
||||||
|
addressbook_id: &str,
|
||||||
|
store: &AS,
|
||||||
|
) -> Result<Vec<(String, AddressObject)>, Error> {
|
||||||
|
let mut objects = store.get_objects(principal, addressbook_id).await?;
|
||||||
|
objects.retain(|(_id, object)| addr_query.filter.matches(object));
|
||||||
|
Ok(objects)
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
use super::{Allof, ParamFilterElement};
|
||||||
|
use ical::{parser::Component, property::ContentLine};
|
||||||
|
use rustical_dav::xml::TextMatchElement;
|
||||||
|
use rustical_ical::AddressObject;
|
||||||
|
use rustical_xml::XmlDeserialize;
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
// <!ELEMENT prop-filter (is-not-defined |
|
||||||
|
// (text-match*, param-filter*))>
|
||||||
|
//
|
||||||
|
// <!ATTLIST prop-filter name CDATA #REQUIRED
|
||||||
|
// test (anyof | allof) "anyof">
|
||||||
|
// <!-- name value: a vCard property name (e.g., "NICKNAME")
|
||||||
|
// test value:
|
||||||
|
// anyof logical OR for text-match/param-filter matches
|
||||||
|
// allof logical AND for text-match/param-filter matches -->
|
||||||
|
pub struct PropFilterElement {
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) is_not_defined: Option<()>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", flatten)]
|
||||||
|
pub(crate) text_match: Vec<TextMatchElement>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", flatten)]
|
||||||
|
pub(crate) param_filter: Vec<ParamFilterElement>,
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub test: Allof,
|
||||||
|
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_property(&self, property: &ContentLine) -> bool {
|
||||||
|
if self.param_filter.is_empty() && self.text_match.is_empty() {
|
||||||
|
// Filter empty
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let Allof(allof) = self.test;
|
||||||
|
let text_matches = self
|
||||||
|
.text_match
|
||||||
|
.iter()
|
||||||
|
.map(|text_match| text_match.match_property(property));
|
||||||
|
|
||||||
|
let param_matches = self
|
||||||
|
.param_filter
|
||||||
|
.iter()
|
||||||
|
.map(|param_filter| param_filter.match_property(property));
|
||||||
|
let mut matches = text_matches.chain(param_matches);
|
||||||
|
|
||||||
|
if allof {
|
||||||
|
matches.all(|a| a)
|
||||||
|
} else {
|
||||||
|
matches.any(|a| a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn match_component(&self, comp: &impl PropFilterable) -> bool {
|
||||||
|
let mut properties = comp.get_named_properties(&self.name);
|
||||||
|
if self.is_not_defined.is_some() {
|
||||||
|
return properties.next().is_none();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The filter matches when one property instance matches
|
||||||
|
properties.any(|prop| self.match_property(prop))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait PropFilterable {
|
||||||
|
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for AddressObject {
|
||||||
|
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine> {
|
||||||
|
self.get_vcard().get_named_properties(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
use super::FilterElement;
|
||||||
|
use rstest::rstest;
|
||||||
|
use rustical_ical::AddressObject;
|
||||||
|
use rustical_xml::XmlDocument;
|
||||||
|
|
||||||
|
const VCF_1: &str = r"BEGIN:VCARD
|
||||||
|
VERSION:4.0
|
||||||
|
FN:Simon Perreault
|
||||||
|
N:Perreault;Simon;;;ing. jr,M.Sc.
|
||||||
|
BDAY:--0203
|
||||||
|
GENDER:M
|
||||||
|
EMAIL;TYPE=work:simon.perreault@viagenie.ca
|
||||||
|
END:VCARD";
|
||||||
|
|
||||||
|
const VCF_2: &str = r"BEGIN:VCARD
|
||||||
|
VERSION:4.0
|
||||||
|
N:Gump;Forrest;;Mr.;
|
||||||
|
FN:Forrest Gump
|
||||||
|
ORG:Bubba Gump Shrimp Co.
|
||||||
|
TITLE:Shrimp Man
|
||||||
|
PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif
|
||||||
|
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212
|
||||||
|
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212
|
||||||
|
ADR;TYPE=WORK;PREF=1;LABEL=100 Waters Edge\\nBaytown\\, LA 30314\\nUnited S
|
||||||
|
tates of America:;;100 Waters Edge;Baytown;LA;30314;United States of Ameri
|
||||||
|
ca
|
||||||
|
ADR;TYPE=HOME;LABEL=42 Plantation St.\\nBaytown\\, LA 30314\\nUnited States
|
||||||
|
of America:;;42 Plantation St.;Baytown;LA;30314;United States of America
|
||||||
|
EMAIL:forrestgump@example.com
|
||||||
|
REV:20080424T195243Z
|
||||||
|
x-qq:21588891
|
||||||
|
UID:890a9da4-bb6d-4afb-9f32-b5eff6494a53
|
||||||
|
END:VCARD
|
||||||
|
";
|
||||||
|
|
||||||
|
const FILTER_1: &str = r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:filter xmlns:C="urn:ietf:params:xml:ns:carddav">
|
||||||
|
<C:prop-filter name="EMAIL" test="allof">
|
||||||
|
<C:text-match collation="i;ascii-casemap">simon.perreault@viagenie.ca</C:text-match>
|
||||||
|
<C:param-filter name="TYPE">
|
||||||
|
<C:text-match match-type="equals" collation="i;unicode-casemap">WORK</C:text-match>
|
||||||
|
</C:param-filter>
|
||||||
|
</C:prop-filter>
|
||||||
|
</C:filter>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const FILTER_2: &str = r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:filter xmlns:C="urn:ietf:params:xml:ns:carddav">
|
||||||
|
<C:prop-filter name="EMAIL" test="anyof">
|
||||||
|
<C:text-match collation="i;ascii-casemap">forrestgump@example.com</C:text-match>
|
||||||
|
<C:param-filter name="TYPE">
|
||||||
|
<C:text-match match-type="equals" collation="i;ascii-casemap">WORK</C:text-match>
|
||||||
|
</C:param-filter>
|
||||||
|
</C:prop-filter>
|
||||||
|
</C:filter>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
#[case(VCF_1, FILTER_1, true)]
|
||||||
|
#[case(VCF_2, FILTER_1, false)]
|
||||||
|
#[case(VCF_1, FILTER_2, true)]
|
||||||
|
#[case(VCF_2, FILTER_2, true)]
|
||||||
|
fn test_filter(#[case] vcf: &str, #[case] filter: &str, #[case] matches: bool) {
|
||||||
|
dbg!(vcf);
|
||||||
|
let obj = AddressObject::from_vcf(vcf.to_owned()).unwrap();
|
||||||
|
let filter = FilterElement::parse_str(filter).unwrap();
|
||||||
|
assert_eq!(matches, filter.matches(&obj));
|
||||||
|
}
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
CardDavPrincipalUri, Error, address_object::AddressObjectPropWrapperName,
|
CardDavPrincipalUri, Error,
|
||||||
addressbook::AddressbookResourceService,
|
address_object::{
|
||||||
|
AddressObjectPropWrapper, AddressObjectPropWrapperName, resource::AddressObjectResource,
|
||||||
|
},
|
||||||
|
addressbook::{
|
||||||
|
AddressbookResourceService,
|
||||||
|
methods::report::addressbook_query::{
|
||||||
|
AddressbookQueryRequest, get_objects_addressbook_query,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use addressbook_multiget::{AddressbookMultigetRequest, handle_addressbook_multiget};
|
use addressbook_multiget::{AddressbookMultigetRequest, handle_addressbook_multiget};
|
||||||
use axum::{
|
use axum::{
|
||||||
@@ -8,19 +16,30 @@ use axum::{
|
|||||||
extract::{OriginalUri, Path, State},
|
extract::{OriginalUri, Path, State},
|
||||||
response::IntoResponse,
|
response::IntoResponse,
|
||||||
};
|
};
|
||||||
use rustical_dav::xml::{PropfindType, sync_collection::SyncCollectionRequest};
|
use http::StatusCode;
|
||||||
|
use rustical_dav::{
|
||||||
|
resource::{PrincipalUri, Resource},
|
||||||
|
xml::{
|
||||||
|
MultistatusElement, PropfindType, multistatus::ResponseElement,
|
||||||
|
sync_collection::SyncCollectionRequest,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use rustical_ical::AddressObject;
|
||||||
use rustical_store::{AddressbookStore, SubscriptionStore, auth::Principal};
|
use rustical_store::{AddressbookStore, SubscriptionStore, auth::Principal};
|
||||||
use rustical_xml::{XmlDeserialize, XmlDocument};
|
use rustical_xml::{XmlDeserialize, XmlDocument};
|
||||||
use sync_collection::handle_sync_collection;
|
use sync_collection::handle_sync_collection;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
mod addressbook_multiget;
|
mod addressbook_multiget;
|
||||||
|
mod addressbook_query;
|
||||||
mod sync_collection;
|
mod sync_collection;
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlDocument, Clone, Debug, PartialEq)]
|
#[derive(XmlDeserialize, XmlDocument, Clone, Debug, PartialEq)]
|
||||||
pub(crate) enum ReportRequest {
|
pub(crate) enum ReportRequest {
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
AddressbookMultiget(AddressbookMultigetRequest),
|
AddressbookMultiget(AddressbookMultigetRequest),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
AddressbookQuery(AddressbookQueryRequest),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
SyncCollection(SyncCollectionRequest<AddressObjectPropWrapperName>),
|
SyncCollection(SyncCollectionRequest<AddressObjectPropWrapperName>),
|
||||||
}
|
}
|
||||||
@@ -29,11 +48,50 @@ impl ReportRequest {
|
|||||||
const fn props(&self) -> &PropfindType<AddressObjectPropWrapperName> {
|
const fn props(&self) -> &PropfindType<AddressObjectPropWrapperName> {
|
||||||
match self {
|
match self {
|
||||||
Self::AddressbookMultiget(AddressbookMultigetRequest { prop, .. })
|
Self::AddressbookMultiget(AddressbookMultigetRequest { prop, .. })
|
||||||
| Self::SyncCollection(SyncCollectionRequest { prop, .. }) => prop,
|
| Self::SyncCollection(SyncCollectionRequest { prop, .. })
|
||||||
|
| Self::AddressbookQuery(AddressbookQueryRequest { prop, .. }) => prop,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn objects_response(
|
||||||
|
objects: Vec<(String, AddressObject)>,
|
||||||
|
not_found: Vec<String>,
|
||||||
|
path: &str,
|
||||||
|
principal: &str,
|
||||||
|
puri: &impl PrincipalUri,
|
||||||
|
user: &Principal,
|
||||||
|
prop: &PropfindType<AddressObjectPropWrapperName>,
|
||||||
|
) -> Result<MultistatusElement<AddressObjectPropWrapper, String>, Error> {
|
||||||
|
let mut responses = Vec::new();
|
||||||
|
for (object_id, object) in objects {
|
||||||
|
let path = format!("{}/{}.vcf", path, &object_id);
|
||||||
|
responses.push(
|
||||||
|
AddressObjectResource {
|
||||||
|
object,
|
||||||
|
object_id,
|
||||||
|
principal: principal.to_owned(),
|
||||||
|
}
|
||||||
|
.propfind(&path, prop, None, puri, user)?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let not_found_responses = not_found
|
||||||
|
.into_iter()
|
||||||
|
.map(|path| ResponseElement {
|
||||||
|
href: path,
|
||||||
|
status: Some(StatusCode::NOT_FOUND),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
Ok(MultistatusElement {
|
||||||
|
responses,
|
||||||
|
member_responses: not_found_responses,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[instrument(skip(addr_store))]
|
#[instrument(skip(addr_store))]
|
||||||
pub async fn route_report_addressbook<AS: AddressbookStore, S: SubscriptionStore>(
|
pub async fn route_report_addressbook<AS: AddressbookStore, S: SubscriptionStore>(
|
||||||
Path((principal, addressbook_id)): Path<(String, String)>,
|
Path((principal, addressbook_id)): Path<(String, String)>,
|
||||||
@@ -75,13 +133,36 @@ pub async fn route_report_addressbook<AS: AddressbookStore, S: SubscriptionStore
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
|
ReportRequest::AddressbookQuery(addr_query) => {
|
||||||
|
let objects = get_objects_addressbook_query(
|
||||||
|
addr_query,
|
||||||
|
&principal,
|
||||||
|
&addressbook_id,
|
||||||
|
addr_store.as_ref(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
objects_response(
|
||||||
|
objects,
|
||||||
|
vec![],
|
||||||
|
uri.path(),
|
||||||
|
&principal,
|
||||||
|
&puri,
|
||||||
|
&user,
|
||||||
|
&addr_query.prop,
|
||||||
|
)?
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::address_object::AddressObjectPropName;
|
use crate::{
|
||||||
|
address_object::AddressObjectPropName,
|
||||||
|
addressbook::methods::report::addressbook_query::{
|
||||||
|
Allof, FilterElement, LimitElement, NresultsElement, PropFilterElement,
|
||||||
|
},
|
||||||
|
};
|
||||||
use rustical_dav::xml::{PropElement, sync_collection::SyncLevel};
|
use rustical_dav::xml::{PropElement, sync_collection::SyncLevel};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -144,4 +225,50 @@ mod tests {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_xml_addressbook_query() {
|
||||||
|
let report_request = ReportRequest::parse_str(
|
||||||
|
r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<card:addressbook-query xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">
|
||||||
|
<d:prop>
|
||||||
|
<d:getetag/>
|
||||||
|
</d:prop>
|
||||||
|
<card:filter>
|
||||||
|
<card:prop-filter name="FN"/>
|
||||||
|
</card:filter>
|
||||||
|
<card:limit>
|
||||||
|
<card:nresults>100</card:nresults>
|
||||||
|
</card:limit>
|
||||||
|
</card:addressbook-query>
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
report_request,
|
||||||
|
ReportRequest::AddressbookQuery(AddressbookQueryRequest {
|
||||||
|
prop: rustical_dav::xml::PropfindType::Prop(PropElement(
|
||||||
|
vec![AddressObjectPropWrapperName::AddressObject(
|
||||||
|
AddressObjectPropName::Getetag
|
||||||
|
),],
|
||||||
|
vec![]
|
||||||
|
)),
|
||||||
|
filter: FilterElement {
|
||||||
|
test: Allof::default(),
|
||||||
|
prop_filter: vec![PropFilterElement {
|
||||||
|
name: "FN".to_owned(),
|
||||||
|
is_not_defined: None,
|
||||||
|
text_match: vec![],
|
||||||
|
param_filter: vec![],
|
||||||
|
test: Allof::default()
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
limit: Some(LimitElement {
|
||||||
|
nresults: NresultsElement(100)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ pub async fn handle_sync_collection<AS: AddressbookStore>(
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let mut responses = Vec::new();
|
let mut responses = Vec::new();
|
||||||
for object in new_objects {
|
for (object_id, object) in new_objects {
|
||||||
let path = format!("{}/{}.vcf", path.trim_end_matches('/'), object.get_id());
|
let path = format!("{}/{}.vcf", path.trim_end_matches('/'), object_id);
|
||||||
responses.push(
|
responses.push(
|
||||||
AddressObjectResource {
|
AddressObjectResource {
|
||||||
object,
|
object,
|
||||||
|
object_id,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
}
|
}
|
||||||
.propfind(&path, &sync_collection.prop, None, puri, user)?,
|
.propfind(&path, &sync_collection.prop, None, puri, user)?,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
use derive_more::{From, Into};
|
||||||
use rustical_dav::{
|
use rustical_dav::{
|
||||||
extensions::{CommonPropertiesProp, SyncTokenExtensionProp},
|
extensions::{CommonPropertiesProp, SyncTokenExtensionProp},
|
||||||
xml::SupportedReportSet,
|
xml::{SupportedReportSet, TextCollation},
|
||||||
};
|
};
|
||||||
use rustical_dav_push::DavPushExtensionProp;
|
use rustical_dav_push::DavPushExtensionProp;
|
||||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
||||||
@@ -14,9 +15,11 @@ pub enum AddressbookProp {
|
|||||||
AddressbookDescription(Option<String>),
|
AddressbookDescription(Option<String>),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", skip_deserializing)]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", skip_deserializing)]
|
||||||
SupportedAddressData(SupportedAddressData),
|
SupportedAddressData(SupportedAddressData),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", skip_deserializing)]
|
||||||
|
SupportedCollationSet(SupportedCollationSet),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV", skip_deserializing)]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV", skip_deserializing)]
|
||||||
SupportedReportSet(SupportedReportSet<ReportMethod>),
|
SupportedReportSet(SupportedReportSet<ReportMethod>),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
MaxResourceSize(i64),
|
MaxResourceSize(i64),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +63,29 @@ impl Default for SupportedAddressData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
|
||||||
|
pub struct SupportedCollation(#[xml(ty = "text")] pub TextCollation);
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq)]
|
||||||
|
pub struct SupportedCollationSet(
|
||||||
|
#[xml(
|
||||||
|
ns = "rustical_dav::namespace::NS_CARDDAV",
|
||||||
|
flatten,
|
||||||
|
rename = "supported-collation"
|
||||||
|
)]
|
||||||
|
pub Vec<SupportedCollation>,
|
||||||
|
);
|
||||||
|
|
||||||
|
impl Default for SupportedCollationSet {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self(vec![
|
||||||
|
SupportedCollation(TextCollation::AsciiCasemap),
|
||||||
|
SupportedCollation(TextCollation::UnicodeCasemap),
|
||||||
|
SupportedCollation(TextCollation::Octet),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq, VariantArray)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq, VariantArray)]
|
||||||
pub enum ReportMethod {
|
pub enum ReportMethod {
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use super::prop::SupportedAddressData;
|
|||||||
use crate::Error;
|
use crate::Error;
|
||||||
use crate::addressbook::prop::{
|
use crate::addressbook::prop::{
|
||||||
AddressbookProp, AddressbookPropName, AddressbookPropWrapper, AddressbookPropWrapperName,
|
AddressbookProp, AddressbookPropName, AddressbookPropWrapper, AddressbookPropWrapperName,
|
||||||
|
SupportedCollationSet,
|
||||||
};
|
};
|
||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{From, Into};
|
||||||
use rustical_dav::extensions::{CommonPropertiesExtension, SyncTokenExtension};
|
use rustical_dav::extensions::{CommonPropertiesExtension, SyncTokenExtension};
|
||||||
@@ -11,13 +12,14 @@ use rustical_dav::xml::{Resourcetype, ResourcetypeInner, SupportedReportSet};
|
|||||||
use rustical_dav_push::DavPushExtension;
|
use rustical_dav_push::DavPushExtension;
|
||||||
use rustical_store::Addressbook;
|
use rustical_store::Addressbook;
|
||||||
use rustical_store::auth::Principal;
|
use rustical_store::auth::Principal;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
#[derive(Clone, Debug, From, Into)]
|
#[derive(Clone, Debug, From, Into)]
|
||||||
pub struct AddressbookResource(pub(crate) Addressbook);
|
pub struct AddressbookResource(pub(crate) Addressbook);
|
||||||
|
|
||||||
impl ResourceName for AddressbookResource {
|
impl ResourceName for AddressbookResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
self.0.id.clone()
|
Cow::from(&self.0.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +63,9 @@ impl Resource for AddressbookResource {
|
|||||||
AddressbookPropName::MaxResourceSize => {
|
AddressbookPropName::MaxResourceSize => {
|
||||||
AddressbookProp::MaxResourceSize(10_000_000)
|
AddressbookProp::MaxResourceSize(10_000_000)
|
||||||
}
|
}
|
||||||
|
AddressbookPropName::SupportedCollationSet => {
|
||||||
|
AddressbookProp::SupportedCollationSet(SupportedCollationSet::default())
|
||||||
|
}
|
||||||
AddressbookPropName::SupportedReportSet => {
|
AddressbookPropName::SupportedReportSet => {
|
||||||
AddressbookProp::SupportedReportSet(SupportedReportSet::all())
|
AddressbookProp::SupportedReportSet(SupportedReportSet::all())
|
||||||
}
|
}
|
||||||
@@ -93,6 +98,7 @@ impl Resource for AddressbookResource {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
AddressbookProp::MaxResourceSize(_)
|
AddressbookProp::MaxResourceSize(_)
|
||||||
|
| AddressbookProp::SupportedCollationSet(_)
|
||||||
| AddressbookProp::SupportedReportSet(_)
|
| AddressbookProp::SupportedReportSet(_)
|
||||||
| AddressbookProp::SupportedAddressData(_) => {
|
| AddressbookProp::SupportedAddressData(_) => {
|
||||||
Err(rustical_dav::Error::PropReadOnly)
|
Err(rustical_dav::Error::PropReadOnly)
|
||||||
@@ -115,6 +121,7 @@ impl Resource for AddressbookResource {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
AddressbookPropName::MaxResourceSize
|
AddressbookPropName::MaxResourceSize
|
||||||
|
| AddressbookPropName::SupportedCollationSet
|
||||||
| AddressbookPropName::SupportedReportSet
|
| AddressbookPropName::SupportedReportSet
|
||||||
| AddressbookPropName::SupportedAddressData => {
|
| AddressbookPropName::SupportedAddressData => {
|
||||||
Err(rustical_dav::Error::PropReadOnly)
|
Err(rustical_dav::Error::PropReadOnly)
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ impl<AS: AddressbookStore, S: SubscriptionStore> ResourceService
|
|||||||
.get_objects(principal, addressbook_id)
|
.get_objects(principal, addressbook_id)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|object| AddressObjectResource {
|
.map(|(object_id, object)| AddressObjectResource {
|
||||||
|
object_id,
|
||||||
object,
|
object,
|
||||||
principal: principal.to_owned(),
|
principal: principal.to_owned(),
|
||||||
})
|
})
|
||||||
@@ -91,7 +92,7 @@ impl<AS: AddressbookStore, S: SubscriptionStore> ResourceService
|
|||||||
file: Self::Resource,
|
file: Self::Resource,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
self.addr_store
|
self.addr_store
|
||||||
.update_addressbook(principal.to_owned(), addressbook_id.to_owned(), file.into())
|
.update_addressbook(principal, addressbook_id, file.into())
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,23 @@ ResponseElement {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Addressbook(
|
||||||
|
SupportedCollationSet(
|
||||||
|
SupportedCollationSet(
|
||||||
|
[
|
||||||
|
SupportedCollation(
|
||||||
|
AsciiCasemap,
|
||||||
|
),
|
||||||
|
SupportedCollation(
|
||||||
|
UnicodeCasemap,
|
||||||
|
),
|
||||||
|
SupportedCollation(
|
||||||
|
Octet,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
Addressbook(
|
Addressbook(
|
||||||
SupportedReportSet(
|
SupportedReportSet(
|
||||||
SupportedReportSet {
|
SupportedReportSet {
|
||||||
|
|||||||
@@ -3,57 +3,62 @@ source: crates/carddav/src/addressbook/tests.rs
|
|||||||
expression: response.serialize_to_string().unwrap()
|
expression: response.serialize_to_string().unwrap()
|
||||||
---
|
---
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<response xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CARD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/" xmlns:PUSH="https://bitfire.at/webdav-push">
|
<response xmlns="DAV:">
|
||||||
<href>/carddav/principal/user/yeet/</href>
|
<href>/carddav/principal/user/yeet/</href>
|
||||||
<propstat>
|
<propstat>
|
||||||
<prop>
|
<prop xmlns="DAV:">
|
||||||
<CARD:supported-address-data>
|
<supported-address-data xmlns="urn:ietf:params:xml:ns:carddav">
|
||||||
<CARD:address-data-type content-type="text/vcard" version="3.0"/>
|
<address-data-type xmlns="urn:ietf:params:xml:ns:carddav" content-type="text/vcard" version="3.0"/>
|
||||||
<CARD:address-data-type content-type="text/vcard" version="4.0"/>
|
<address-data-type xmlns="urn:ietf:params:xml:ns:carddav" content-type="text/vcard" version="4.0"/>
|
||||||
</CARD:supported-address-data>
|
</supported-address-data>
|
||||||
<supported-report-set>
|
<supported-collation-set xmlns="urn:ietf:params:xml:ns:carddav">
|
||||||
<supported-report>
|
<supported-collation xmlns="urn:ietf:params:xml:ns:carddav">i;ascii-casemap</supported-collation>
|
||||||
<report>
|
<supported-collation xmlns="urn:ietf:params:xml:ns:carddav">i;unicode-casemap</supported-collation>
|
||||||
<CARD:addressbook-multiget/>
|
<supported-collation xmlns="urn:ietf:params:xml:ns:carddav">i;octet</supported-collation>
|
||||||
|
</supported-collation-set>
|
||||||
|
<supported-report-set xmlns="DAV:">
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<addressbook-multiget xmlns="urn:ietf:params:xml:ns:carddav"/>
|
||||||
</report>
|
</report>
|
||||||
</supported-report>
|
</supported-report>
|
||||||
<supported-report>
|
<supported-report xmlns="DAV:">
|
||||||
<report>
|
<report xmlns="DAV:">
|
||||||
<sync-collection/>
|
<sync-collection xmlns="DAV:"/>
|
||||||
</report>
|
</report>
|
||||||
</supported-report>
|
</supported-report>
|
||||||
</supported-report-set>
|
</supported-report-set>
|
||||||
<max-resource-size>10000000</max-resource-size>
|
<max-resource-size xmlns="urn:ietf:params:xml:ns:carddav">10000000</max-resource-size>
|
||||||
<sync-token>github.com/lennart-k/rustical/ns/0</sync-token>
|
<sync-token xmlns="DAV:">github.com/lennart-k/rustical/ns/0</sync-token>
|
||||||
<CS:getctag>github.com/lennart-k/rustical/ns/0</CS:getctag>
|
<getctag xmlns="http://calendarserver.org/ns/">github.com/lennart-k/rustical/ns/0</getctag>
|
||||||
<PUSH:transports>
|
<transports xmlns="https://bitfire.at/webdav-push">
|
||||||
<PUSH:web-push/>
|
<web-push xmlns="https://bitfire.at/webdav-push"/>
|
||||||
</PUSH:transports>
|
</transports>
|
||||||
<PUSH:topic>asdasd</PUSH:topic>
|
<topic xmlns="https://bitfire.at/webdav-push">asdasd</topic>
|
||||||
<PUSH:supported-triggers>
|
<supported-triggers xmlns="https://bitfire.at/webdav-push">
|
||||||
<PUSH:content-update>
|
<content-update xmlns="https://bitfire.at/webdav-push">
|
||||||
<depth>1</depth>
|
<depth xmlns="DAV:">1</depth>
|
||||||
</PUSH:content-update>
|
</content-update>
|
||||||
<PUSH:property-update>
|
<property-update xmlns="https://bitfire.at/webdav-push">
|
||||||
<depth>1</depth>
|
<depth xmlns="DAV:">1</depth>
|
||||||
</PUSH:property-update>
|
</property-update>
|
||||||
</PUSH:supported-triggers>
|
</supported-triggers>
|
||||||
<resourcetype>
|
<resourcetype xmlns="DAV:">
|
||||||
<collection/>
|
<collection xmlns="DAV:"/>
|
||||||
<CARD:addressbook/>
|
<addressbook xmlns="urn:ietf:params:xml:ns:carddav"/>
|
||||||
</resourcetype>
|
</resourcetype>
|
||||||
<current-user-principal>
|
<current-user-principal xmlns="DAV:">
|
||||||
<href>/carddav/principal/user/</href>
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
</current-user-principal>
|
</current-user-principal>
|
||||||
<current-user-privilege-set>
|
<current-user-privilege-set xmlns="DAV:">
|
||||||
<privilege>
|
<privilege>
|
||||||
<all/>
|
<all/>
|
||||||
</privilege>
|
</privilege>
|
||||||
</current-user-privilege-set>
|
</current-user-privilege-set>
|
||||||
<owner>
|
<owner xmlns="DAV:">
|
||||||
<href>/carddav/principal/user/</href>
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
</owner>
|
</owner>
|
||||||
</prop>
|
</prop>
|
||||||
<status>HTTP/1.1 200 OK</status>
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
</propstat>
|
</propstat>
|
||||||
</response>
|
</response>
|
||||||
|
|||||||
@@ -23,9 +23,6 @@ pub enum Error {
|
|||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
XmlDecodeError(#[from] rustical_xml::XmlError),
|
XmlDecodeError(#[from] rustical_xml::XmlError),
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
IcalError(#[from] rustical_ical::Error),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
@@ -43,7 +40,6 @@ impl Error {
|
|||||||
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
|
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
|
||||||
Self::ChronoParseError(_) | Self::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
|
Self::ChronoParseError(_) | Self::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
Self::NotFound => StatusCode::NOT_FOUND,
|
Self::NotFound => StatusCode::NOT_FOUND,
|
||||||
Self::IcalError(err) => err.status_code(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use rustical_dav::extensions::CommonPropertiesExtension;
|
use rustical_dav::extensions::CommonPropertiesExtension;
|
||||||
use rustical_dav::privileges::UserPrivilegeSet;
|
use rustical_dav::privileges::UserPrivilegeSet;
|
||||||
@@ -21,8 +23,8 @@ pub struct PrincipalResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for PrincipalResource {
|
impl ResourceName for PrincipalResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
self.principal.id.clone()
|
Cow::from(&self.principal.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,43 +3,43 @@ source: crates/carddav/src/principal/tests.rs
|
|||||||
expression: response.serialize_to_string().unwrap()
|
expression: response.serialize_to_string().unwrap()
|
||||||
---
|
---
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<response xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CARD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/" xmlns:PUSH="https://bitfire.at/webdav-push">
|
<response xmlns="DAV:">
|
||||||
<href>/carddav/principal/user/</href>
|
<href>/carddav/principal/user/</href>
|
||||||
<propstat>
|
<propstat>
|
||||||
<prop>
|
<prop xmlns="DAV:">
|
||||||
<principal-URL>
|
<principal-URL xmlns="DAV:">
|
||||||
<href>/carddav/principal/user/</href>
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
</principal-URL>
|
</principal-URL>
|
||||||
<group-membership>
|
<group-membership xmlns="DAV:">
|
||||||
<href>/carddav/principal/group/</href>
|
<href xmlns="DAV:">/carddav/principal/group/</href>
|
||||||
</group-membership>
|
</group-membership>
|
||||||
<group-member-set>
|
<group-member-set xmlns="DAV:">
|
||||||
</group-member-set>
|
</group-member-set>
|
||||||
<alternate-URI-set/>
|
<alternate-URI-set xmlns="DAV:"/>
|
||||||
<principal-collection-set>
|
<principal-collection-set xmlns="DAV:">
|
||||||
<href>/carddav/principal/</href>
|
<href xmlns="DAV:">/carddav/principal/</href>
|
||||||
</principal-collection-set>
|
</principal-collection-set>
|
||||||
<CARD:addressbook-home-set>
|
<addressbook-home-set xmlns="urn:ietf:params:xml:ns:carddav">
|
||||||
<href>/carddav/principal/group/</href>
|
<href xmlns="DAV:">/carddav/principal/group/</href>
|
||||||
<href>/carddav/principal/user/</href>
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
</CARD:addressbook-home-set>
|
</addressbook-home-set>
|
||||||
<resourcetype>
|
<resourcetype xmlns="DAV:">
|
||||||
<collection/>
|
<collection xmlns="DAV:"/>
|
||||||
<principal/>
|
<principal xmlns="DAV:"/>
|
||||||
</resourcetype>
|
</resourcetype>
|
||||||
<displayname>user</displayname>
|
<displayname xmlns="DAV:">user</displayname>
|
||||||
<current-user-principal>
|
<current-user-principal xmlns="DAV:">
|
||||||
<href>/carddav/principal/user/</href>
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
</current-user-principal>
|
</current-user-principal>
|
||||||
<current-user-privilege-set>
|
<current-user-privilege-set xmlns="DAV:">
|
||||||
<privilege>
|
<privilege>
|
||||||
<all/>
|
<all/>
|
||||||
</privilege>
|
</privilege>
|
||||||
</current-user-privilege-set>
|
</current-user-privilege-set>
|
||||||
<owner>
|
<owner xmlns="DAV:">
|
||||||
<href>/carddav/principal/user/</href>
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
</owner>
|
</owner>
|
||||||
</prop>
|
</prop>
|
||||||
<status>HTTP/1.1 200 OK</status>
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
</propstat>
|
</propstat>
|
||||||
</response>
|
</response>
|
||||||
|
|||||||
@@ -28,3 +28,7 @@ headers.workspace = true
|
|||||||
strum.workspace = true
|
strum.workspace = true
|
||||||
matchit.workspace = true
|
matchit.workspace = true
|
||||||
matchit-serde.workspace = true
|
matchit-serde.workspace = true
|
||||||
|
ical = { workspace = true, optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
ical = ["dep:ical"]
|
||||||
|
|||||||
@@ -51,19 +51,18 @@ impl Error {
|
|||||||
_ => StatusCode::BAD_REQUEST,
|
_ => StatusCode::BAD_REQUEST,
|
||||||
},
|
},
|
||||||
Self::PropReadOnly => StatusCode::CONFLICT,
|
Self::PropReadOnly => StatusCode::CONFLICT,
|
||||||
Self::PreconditionFailed => StatusCode::PRECONDITION_FAILED,
|
|
||||||
Self::InternalError | Self::IOError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
Self::InternalError | Self::IOError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
Self::Forbidden => StatusCode::FORBIDDEN,
|
// The correct status code for a failed precondition is not PreconditionFailed but
|
||||||
|
// Forbidden (or Conflict):
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc4791#section-1.3
|
||||||
|
Self::PreconditionFailed | Self::Forbidden => StatusCode::FORBIDDEN,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl axum::response::IntoResponse for Error {
|
impl axum::response::IntoResponse for Error {
|
||||||
fn into_response(self) -> axum::response::Response {
|
fn into_response(self) -> axum::response::Response {
|
||||||
if matches!(
|
if matches!(self.status_code(), StatusCode::INTERNAL_SERVER_ERROR) {
|
||||||
self.status_code(),
|
|
||||||
StatusCode::INTERNAL_SERVER_ERROR | StatusCode::PRECONDITION_FAILED
|
|
||||||
) {
|
|
||||||
error!("{self}");
|
error!("{self}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,15 @@ use axum::{
|
|||||||
extract::{MatchedPath, Path, State},
|
extract::{MatchedPath, Path, State},
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
};
|
};
|
||||||
|
use axum_extra::TypedHeader;
|
||||||
|
use headers::Host;
|
||||||
use http::{HeaderMap, StatusCode, Uri};
|
use http::{HeaderMap, StatusCode, Uri};
|
||||||
use matchit_serde::ParamsDeserializer;
|
use matchit_serde::ParamsDeserializer;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
#[instrument(skip(path, resource_service,))]
|
#[instrument(skip(path, resource_service,))]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub async fn axum_route_copy<R: ResourceService>(
|
pub async fn axum_route_copy<R: ResourceService>(
|
||||||
Path(path): Path<R::PathComponents>,
|
Path(path): Path<R::PathComponents>,
|
||||||
State(resource_service): State<R>,
|
State(resource_service): State<R>,
|
||||||
@@ -20,6 +23,7 @@ pub async fn axum_route_copy<R: ResourceService>(
|
|||||||
Overwrite(overwrite): Overwrite,
|
Overwrite(overwrite): Overwrite,
|
||||||
matched_path: MatchedPath,
|
matched_path: MatchedPath,
|
||||||
header_map: HeaderMap,
|
header_map: HeaderMap,
|
||||||
|
TypedHeader(host): TypedHeader<Host>,
|
||||||
) -> Result<Response, R::Error> {
|
) -> Result<Response, R::Error> {
|
||||||
let destination = header_map
|
let destination = header_map
|
||||||
.get("Destination")
|
.get("Destination")
|
||||||
@@ -27,7 +31,11 @@ pub async fn axum_route_copy<R: ResourceService>(
|
|||||||
.to_str()
|
.to_str()
|
||||||
.map_err(|_| crate::Error::Forbidden)?;
|
.map_err(|_| crate::Error::Forbidden)?;
|
||||||
let destination_uri: Uri = destination.parse().map_err(|_| crate::Error::Forbidden)?;
|
let destination_uri: Uri = destination.parse().map_err(|_| crate::Error::Forbidden)?;
|
||||||
// TODO: Check that host also matches
|
if let Some(authority) = destination_uri.authority()
|
||||||
|
&& host != authority.clone().into()
|
||||||
|
{
|
||||||
|
return Err(crate::Error::Forbidden.into());
|
||||||
|
}
|
||||||
let destination = destination_uri.path();
|
let destination = destination_uri.path();
|
||||||
|
|
||||||
let mut router = matchit::Router::new();
|
let mut router = matchit::Router::new();
|
||||||
|
|||||||
@@ -52,13 +52,12 @@ pub async fn route_delete<R: ResourceService>(
|
|||||||
return Err(Error::Unauthorized.into());
|
return Err(Error::Unauthorized.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(if_match) = if_match {
|
if let Some(if_match) = if_match
|
||||||
dbg!(&if_match);
|
&& !resource.satisfies_if_match(&if_match)
|
||||||
if !resource.satisfies_if_match(&if_match) {
|
{
|
||||||
// Precondition failed
|
// Precondition failed
|
||||||
return Err(crate::Error::PreconditionFailed.into());
|
return Err(crate::Error::PreconditionFailed.into());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if let Some(if_none_match) = if_none_match
|
if let Some(if_none_match) = if_none_match
|
||||||
&& resource.satisfies_if_none_match(&if_none_match)
|
&& resource.satisfies_if_none_match(&if_none_match)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,12 +6,15 @@ use axum::{
|
|||||||
extract::{MatchedPath, Path, State},
|
extract::{MatchedPath, Path, State},
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
};
|
};
|
||||||
|
use axum_extra::TypedHeader;
|
||||||
|
use headers::Host;
|
||||||
use http::{HeaderMap, StatusCode, Uri};
|
use http::{HeaderMap, StatusCode, Uri};
|
||||||
use matchit_serde::ParamsDeserializer;
|
use matchit_serde::ParamsDeserializer;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
#[instrument(skip(path, resource_service,))]
|
#[instrument(skip(path, resource_service,))]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub async fn axum_route_move<R: ResourceService>(
|
pub async fn axum_route_move<R: ResourceService>(
|
||||||
Path(path): Path<R::PathComponents>,
|
Path(path): Path<R::PathComponents>,
|
||||||
State(resource_service): State<R>,
|
State(resource_service): State<R>,
|
||||||
@@ -20,6 +23,7 @@ pub async fn axum_route_move<R: ResourceService>(
|
|||||||
Overwrite(overwrite): Overwrite,
|
Overwrite(overwrite): Overwrite,
|
||||||
matched_path: MatchedPath,
|
matched_path: MatchedPath,
|
||||||
header_map: HeaderMap,
|
header_map: HeaderMap,
|
||||||
|
TypedHeader(host): TypedHeader<Host>,
|
||||||
) -> Result<Response, R::Error> {
|
) -> Result<Response, R::Error> {
|
||||||
let destination = header_map
|
let destination = header_map
|
||||||
.get("Destination")
|
.get("Destination")
|
||||||
@@ -27,7 +31,11 @@ pub async fn axum_route_move<R: ResourceService>(
|
|||||||
.to_str()
|
.to_str()
|
||||||
.map_err(|_| crate::Error::Forbidden)?;
|
.map_err(|_| crate::Error::Forbidden)?;
|
||||||
let destination_uri: Uri = destination.parse().map_err(|_| crate::Error::Forbidden)?;
|
let destination_uri: Uri = destination.parse().map_err(|_| crate::Error::Forbidden)?;
|
||||||
// TODO: Check that host also matches
|
if let Some(authority) = destination_uri.authority()
|
||||||
|
&& host != authority.clone().into()
|
||||||
|
{
|
||||||
|
return Err(crate::Error::Forbidden.into());
|
||||||
|
}
|
||||||
let destination = destination_uri.path();
|
let destination = destination_uri.path();
|
||||||
|
|
||||||
let mut router = matchit::Router::new();
|
let mut router = matchit::Router::new();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ pub use resource_service::ResourceService;
|
|||||||
use rustical_xml::{
|
use rustical_xml::{
|
||||||
EnumVariants, NamespaceOwned, PropName, XmlDeserialize, XmlDocument, XmlSerialize,
|
EnumVariants, NamespaceOwned, PropName, XmlDeserialize, XmlDocument, XmlSerialize,
|
||||||
};
|
};
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
mod axum_methods;
|
mod axum_methods;
|
||||||
@@ -30,7 +31,7 @@ pub trait ResourcePropName: FromStr {}
|
|||||||
impl<T: FromStr> ResourcePropName for T {}
|
impl<T: FromStr> ResourcePropName for T {}
|
||||||
|
|
||||||
pub trait ResourceName {
|
pub trait ResourceName {
|
||||||
fn get_name(&self) -> String;
|
fn get_name(&self) -> Cow<'_, str>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Resource: Clone + Send + 'static {
|
pub trait Resource: Clone + Send + 'static {
|
||||||
|
|||||||
@@ -15,3 +15,7 @@ mod report_set;
|
|||||||
pub use report_set::SupportedReportSet;
|
pub use report_set::SupportedReportSet;
|
||||||
mod group;
|
mod group;
|
||||||
pub use group::*;
|
pub use group::*;
|
||||||
|
#[cfg(feature = "ical")]
|
||||||
|
mod text_match;
|
||||||
|
#[cfg(feature = "ical")]
|
||||||
|
pub use text_match::*;
|
||||||
|
|||||||
@@ -42,13 +42,6 @@ pub enum PropstatWrapper<T: XmlSerialize> {
|
|||||||
// responsedescription?) >
|
// responsedescription?) >
|
||||||
#[derive(XmlSerialize, XmlRootTag, Debug)]
|
#[derive(XmlSerialize, XmlRootTag, Debug)]
|
||||||
#[xml(ns = "crate::namespace::NS_DAV", root = "response")]
|
#[xml(ns = "crate::namespace::NS_DAV", root = "response")]
|
||||||
#[xml(ns_prefix(
|
|
||||||
crate::namespace::NS_DAV = "",
|
|
||||||
crate::namespace::NS_CARDDAV = "CARD",
|
|
||||||
crate::namespace::NS_CALDAV = "CAL",
|
|
||||||
crate::namespace::NS_CALENDARSERVER = "CS",
|
|
||||||
crate::namespace::NS_DAVPUSH = "PUSH"
|
|
||||||
))]
|
|
||||||
pub struct ResponseElement<PropstatType: XmlSerialize> {
|
pub struct ResponseElement<PropstatType: XmlSerialize> {
|
||||||
pub href: String,
|
pub href: String,
|
||||||
#[xml(serialize_with = "xml_serialize_optional_status")]
|
#[xml(serialize_with = "xml_serialize_optional_status")]
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ impl<PN: XmlDeserialize> XmlDeserialize for PropElement<PN> {
|
|||||||
// start of a child element
|
// start of a child element
|
||||||
Event::Start(start) | Event::Empty(start) => {
|
Event::Start(start) | Event::Empty(start) => {
|
||||||
let empty = matches!(event, Event::Empty(_));
|
let empty = matches!(event, Event::Empty(_));
|
||||||
let (ns, name) = reader.resolve_element(start.name());
|
let (ns, name) = reader.resolver().resolve_element(start.name());
|
||||||
let ns = match ns {
|
let ns = match ns {
|
||||||
ResolveResult::Bound(ns) => Some(NamespaceOwned::from(ns)),
|
ResolveResult::Bound(ns) => Some(NamespaceOwned::from(ns)),
|
||||||
ResolveResult::Unknown(_ns) => todo!("handle error"),
|
ResolveResult::Unknown(_ns) => todo!("handle error"),
|
||||||
|
|||||||
154
crates/dav/src/xml/text_match.rs
Normal file
154
crates/dav/src/xml/text_match.rs
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
use ical::property::ContentLine;
|
||||||
|
use rustical_xml::{ValueDeserialize, XmlDeserialize};
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
||||||
|
pub enum TextCollation {
|
||||||
|
#[default]
|
||||||
|
AsciiCasemap,
|
||||||
|
UnicodeCasemap,
|
||||||
|
Octet,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TextCollation {
|
||||||
|
#[must_use]
|
||||||
|
pub fn normalise<'a>(&self, value: &'a str) -> Cow<'a, str> {
|
||||||
|
match self {
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc4790#section-9.2
|
||||||
|
Self::AsciiCasemap => Cow::from(value.to_ascii_uppercase()),
|
||||||
|
Self::UnicodeCasemap => Cow::from(value.to_uppercase()),
|
||||||
|
Self::Octet => Cow::from(value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsRef<str> for TextCollation {
|
||||||
|
fn as_ref(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
Self::AsciiCasemap => "i;ascii-casemap",
|
||||||
|
Self::UnicodeCasemap => "i;unicode-casemap",
|
||||||
|
Self::Octet => "i;octet",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ValueDeserialize for TextCollation {
|
||||||
|
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
||||||
|
match val {
|
||||||
|
"i;ascii-casemap" => Ok(Self::AsciiCasemap),
|
||||||
|
"i;unicode-casemap" => Ok(Self::UnicodeCasemap),
|
||||||
|
"i;octet" => Ok(Self::Octet),
|
||||||
|
_ => Err(rustical_xml::XmlError::InvalidVariant(format!(
|
||||||
|
"Invalid collation: {val}"
|
||||||
|
))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
||||||
|
pub struct NegateCondition(pub bool);
|
||||||
|
|
||||||
|
impl ValueDeserialize for NegateCondition {
|
||||||
|
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
||||||
|
match val {
|
||||||
|
"yes" => Ok(Self(true)),
|
||||||
|
"no" => Ok(Self(false)),
|
||||||
|
_ => Err(rustical_xml::XmlError::InvalidVariant(format!(
|
||||||
|
"Invalid negate-condition parameter: {val}"
|
||||||
|
))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
||||||
|
pub enum MatchType {
|
||||||
|
Equals,
|
||||||
|
#[default]
|
||||||
|
Contains,
|
||||||
|
StartsWith,
|
||||||
|
EndsWith,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MatchType {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_text(&self, collation: &TextCollation, needle: &str, haystack: &str) -> bool {
|
||||||
|
let haystack = collation.normalise(haystack);
|
||||||
|
let needle = collation.normalise(needle);
|
||||||
|
|
||||||
|
match &self {
|
||||||
|
Self::Equals => haystack == needle,
|
||||||
|
Self::Contains => haystack.contains(needle.as_ref()),
|
||||||
|
Self::StartsWith => haystack.starts_with(needle.as_ref()),
|
||||||
|
Self::EndsWith => haystack.ends_with(needle.as_ref()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ValueDeserialize for MatchType {
|
||||||
|
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
||||||
|
Ok(match val {
|
||||||
|
"equals" => Self::Equals,
|
||||||
|
"contains" => Self::Contains,
|
||||||
|
"starts-with" => Self::StartsWith,
|
||||||
|
"ends-with" => Self::EndsWith,
|
||||||
|
_ => {
|
||||||
|
return Err(rustical_xml::XmlError::InvalidVariant(format!(
|
||||||
|
"Invalid match-type parameter: {val}"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct TextMatchElement {
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub collation: TextCollation,
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub negate_condition: NegateCondition,
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub match_type: MatchType,
|
||||||
|
#[xml(ty = "text")]
|
||||||
|
pub needle: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TextMatchElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_text(&self, haystack: &str) -> bool {
|
||||||
|
let Self {
|
||||||
|
collation,
|
||||||
|
negate_condition,
|
||||||
|
needle,
|
||||||
|
match_type,
|
||||||
|
} = self;
|
||||||
|
|
||||||
|
let matches = match_type.match_text(collation, needle, haystack);
|
||||||
|
// XOR
|
||||||
|
negate_condition.0 ^ matches
|
||||||
|
}
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_property(&self, property: &ContentLine) -> bool {
|
||||||
|
let text = property.value.as_deref().unwrap_or("");
|
||||||
|
self.match_text(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::TextCollation;
|
||||||
|
use crate::xml::MatchType;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_collation() {
|
||||||
|
assert!(!MatchType::Contains.match_text(&TextCollation::AsciiCasemap, "GrÜN", "grünsd"));
|
||||||
|
assert!(MatchType::Contains.match_text(&TextCollation::AsciiCasemap, "GrüN", "grün"));
|
||||||
|
assert!(!MatchType::Contains.match_text(&TextCollation::Octet, "GrüN", "grün"));
|
||||||
|
assert!(MatchType::Contains.match_text(&TextCollation::UnicodeCasemap, "GrÜN", "grün"));
|
||||||
|
assert!(MatchType::Contains.match_text(&TextCollation::AsciiCasemap, "GrüN", "grün"));
|
||||||
|
assert!(MatchType::Contains.match_text(&TextCollation::AsciiCasemap, "GrüN", "grün"));
|
||||||
|
assert!(MatchType::StartsWith.match_text(&TextCollation::Octet, "hello", "hello you"));
|
||||||
|
assert!(MatchType::EndsWith.match_text(&TextCollation::Octet, "mama", "joe mama"));
|
||||||
|
assert!(MatchType::Equals.match_text(&TextCollation::UnicodeCasemap, "GrÜN", "grün"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,8 +11,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"@deno/vite-plugin": "npm:@deno/vite-plugin@^1.0.5",
|
"@deno/vite-plugin": "npm:@deno/vite-plugin@^1.0.6",
|
||||||
"lit": "npm:lit@^3.3.1",
|
"lit": "npm:lit@^3.3.1",
|
||||||
"vite": "npm:vite@^7.1.12"
|
"vite": "npm:vite@^7.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
126
crates/frontend/js-components/deno.lock
generated
126
crates/frontend/js-components/deno.lock
generated
@@ -1,145 +1,145 @@
|
|||||||
{
|
{
|
||||||
"version": "5",
|
"version": "5",
|
||||||
"specifiers": {
|
"specifiers": {
|
||||||
"npm:@deno/vite-plugin@^1.0.5": "1.0.5_vite@7.1.12__picomatch@4.0.3",
|
"npm:@deno/vite-plugin@^1.0.6": "1.0.6_vite@7.3.0__picomatch@4.0.3",
|
||||||
"npm:lit@^3.3.1": "3.3.1",
|
"npm:lit@^3.3.1": "3.3.1",
|
||||||
"npm:vite@*": "7.1.12_picomatch@4.0.3",
|
"npm:vite@*": "7.3.0_picomatch@4.0.3",
|
||||||
"npm:vite@^7.1.12": "7.1.12_picomatch@4.0.3"
|
"npm:vite@^7.3.0": "7.3.0_picomatch@4.0.3"
|
||||||
},
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
"@deno/vite-plugin@1.0.5_vite@7.1.12__picomatch@4.0.3": {
|
"@deno/vite-plugin@1.0.6_vite@7.3.0__picomatch@4.0.3": {
|
||||||
"integrity": "sha512-tLja5n4dyMhcze1NzvSs2iiriBymfBlDCZIrjMTxb9O2ru0gvmV6mn5oBD2teNw5Sd92cj3YJzKwsAs8tMJXlg==",
|
"integrity": "sha512-Sh5XqvFuKAwjARTesi0n6xRpEXm1V0UeqKh+SxIrexCofxOaieNDMqXZD02RiZCg0mrJ43V8eCMuVrDfq6mLmg==",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"vite"
|
"vite"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"@esbuild/aix-ppc64@0.25.12": {
|
"@esbuild/aix-ppc64@0.27.1": {
|
||||||
"integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==",
|
"integrity": "sha512-HHB50pdsBX6k47S4u5g/CaLjqS3qwaOVE5ILsq64jyzgMhLuCuZ8rGzM9yhsAjfjkbgUPMzZEPa7DAp7yz6vuA==",
|
||||||
"os": ["aix"],
|
"os": ["aix"],
|
||||||
"cpu": ["ppc64"]
|
"cpu": ["ppc64"]
|
||||||
},
|
},
|
||||||
"@esbuild/android-arm64@0.25.12": {
|
"@esbuild/android-arm64@0.27.1": {
|
||||||
"integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==",
|
"integrity": "sha512-45fuKmAJpxnQWixOGCrS+ro4Uvb4Re9+UTieUY2f8AEc+t7d4AaZ6eUJ3Hva7dtrxAAWHtlEFsXFMAgNnGU9uQ==",
|
||||||
"os": ["android"],
|
"os": ["android"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/android-arm@0.25.12": {
|
"@esbuild/android-arm@0.27.1": {
|
||||||
"integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==",
|
"integrity": "sha512-kFqa6/UcaTbGm/NncN9kzVOODjhZW8e+FRdSeypWe6j33gzclHtwlANs26JrupOntlcWmB0u8+8HZo8s7thHvg==",
|
||||||
"os": ["android"],
|
"os": ["android"],
|
||||||
"cpu": ["arm"]
|
"cpu": ["arm"]
|
||||||
},
|
},
|
||||||
"@esbuild/android-x64@0.25.12": {
|
"@esbuild/android-x64@0.27.1": {
|
||||||
"integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==",
|
"integrity": "sha512-LBEpOz0BsgMEeHgenf5aqmn/lLNTFXVfoWMUox8CtWWYK9X4jmQzWjoGoNb8lmAYml/tQ/Ysvm8q7szu7BoxRQ==",
|
||||||
"os": ["android"],
|
"os": ["android"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/darwin-arm64@0.25.12": {
|
"@esbuild/darwin-arm64@0.27.1": {
|
||||||
"integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==",
|
"integrity": "sha512-veg7fL8eMSCVKL7IW4pxb54QERtedFDfY/ASrumK/SbFsXnRazxY4YykN/THYqFnFwJ0aVjiUrVG2PwcdAEqQQ==",
|
||||||
"os": ["darwin"],
|
"os": ["darwin"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/darwin-x64@0.25.12": {
|
"@esbuild/darwin-x64@0.27.1": {
|
||||||
"integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==",
|
"integrity": "sha512-+3ELd+nTzhfWb07Vol7EZ+5PTbJ/u74nC6iv4/lwIU99Ip5uuY6QoIf0Hn4m2HoV0qcnRivN3KSqc+FyCHjoVQ==",
|
||||||
"os": ["darwin"],
|
"os": ["darwin"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/freebsd-arm64@0.25.12": {
|
"@esbuild/freebsd-arm64@0.27.1": {
|
||||||
"integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==",
|
"integrity": "sha512-/8Rfgns4XD9XOSXlzUDepG8PX+AVWHliYlUkFI3K3GB6tqbdjYqdhcb4BKRd7C0BhZSoaCxhv8kTcBrcZWP+xg==",
|
||||||
"os": ["freebsd"],
|
"os": ["freebsd"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/freebsd-x64@0.25.12": {
|
"@esbuild/freebsd-x64@0.27.1": {
|
||||||
"integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==",
|
"integrity": "sha512-GITpD8dK9C+r+5yRT/UKVT36h/DQLOHdwGVwwoHidlnA168oD3uxA878XloXebK4Ul3gDBBIvEdL7go9gCUFzQ==",
|
||||||
"os": ["freebsd"],
|
"os": ["freebsd"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-arm64@0.25.12": {
|
"@esbuild/linux-arm64@0.27.1": {
|
||||||
"integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==",
|
"integrity": "sha512-W9//kCrh/6in9rWIBdKaMtuTTzNj6jSeG/haWBADqLLa9P8O5YSRDzgD5y9QBok4AYlzS6ARHifAb75V6G670Q==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-arm@0.25.12": {
|
"@esbuild/linux-arm@0.27.1": {
|
||||||
"integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==",
|
"integrity": "sha512-ieMID0JRZY/ZeCrsFQ3Y3NlHNCqIhTprJfDgSB3/lv5jJZ8FX3hqPyXWhe+gvS5ARMBJ242PM+VNz/ctNj//eA==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm"]
|
"cpu": ["arm"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-ia32@0.25.12": {
|
"@esbuild/linux-ia32@0.27.1": {
|
||||||
"integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==",
|
"integrity": "sha512-VIUV4z8GD8rtSVMfAj1aXFahsi/+tcoXXNYmXgzISL+KB381vbSTNdeZHHHIYqFyXcoEhu9n5cT+05tRv13rlw==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["ia32"]
|
"cpu": ["ia32"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-loong64@0.25.12": {
|
"@esbuild/linux-loong64@0.27.1": {
|
||||||
"integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==",
|
"integrity": "sha512-l4rfiiJRN7sTNI//ff65zJ9z8U+k6zcCg0LALU5iEWzY+a1mVZ8iWC1k5EsNKThZ7XCQ6YWtsZ8EWYm7r1UEsg==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["loong64"]
|
"cpu": ["loong64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-mips64el@0.25.12": {
|
"@esbuild/linux-mips64el@0.27.1": {
|
||||||
"integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==",
|
"integrity": "sha512-U0bEuAOLvO/DWFdygTHWY8C067FXz+UbzKgxYhXC0fDieFa0kDIra1FAhsAARRJbvEyso8aAqvPdNxzWuStBnA==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["mips64el"]
|
"cpu": ["mips64el"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-ppc64@0.25.12": {
|
"@esbuild/linux-ppc64@0.27.1": {
|
||||||
"integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==",
|
"integrity": "sha512-NzdQ/Xwu6vPSf/GkdmRNsOfIeSGnh7muundsWItmBsVpMoNPVpM61qNzAVY3pZ1glzzAxLR40UyYM23eaDDbYQ==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["ppc64"]
|
"cpu": ["ppc64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-riscv64@0.25.12": {
|
"@esbuild/linux-riscv64@0.27.1": {
|
||||||
"integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==",
|
"integrity": "sha512-7zlw8p3IApcsN7mFw0O1Z1PyEk6PlKMu18roImfl3iQHTnr/yAfYv6s4hXPidbDoI2Q0pW+5xeoM4eTCC0UdrQ==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["riscv64"]
|
"cpu": ["riscv64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-s390x@0.25.12": {
|
"@esbuild/linux-s390x@0.27.1": {
|
||||||
"integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==",
|
"integrity": "sha512-cGj5wli+G+nkVQdZo3+7FDKC25Uh4ZVwOAK6A06Hsvgr8WqBBuOy/1s+PUEd/6Je+vjfm6stX0kmib5b/O2Ykw==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["s390x"]
|
"cpu": ["s390x"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-x64@0.25.12": {
|
"@esbuild/linux-x64@0.27.1": {
|
||||||
"integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==",
|
"integrity": "sha512-z3H/HYI9MM0HTv3hQZ81f+AKb+yEoCRlUby1F80vbQ5XdzEMyY/9iNlAmhqiBKw4MJXwfgsh7ERGEOhrM1niMA==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/netbsd-arm64@0.25.12": {
|
"@esbuild/netbsd-arm64@0.27.1": {
|
||||||
"integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==",
|
"integrity": "sha512-wzC24DxAvk8Em01YmVXyjl96Mr+ecTPyOuADAvjGg+fyBpGmxmcr2E5ttf7Im8D0sXZihpxzO1isus8MdjMCXQ==",
|
||||||
"os": ["netbsd"],
|
"os": ["netbsd"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/netbsd-x64@0.25.12": {
|
"@esbuild/netbsd-x64@0.27.1": {
|
||||||
"integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==",
|
"integrity": "sha512-1YQ8ybGi2yIXswu6eNzJsrYIGFpnlzEWRl6iR5gMgmsrR0FcNoV1m9k9sc3PuP5rUBLshOZylc9nqSgymI+TYg==",
|
||||||
"os": ["netbsd"],
|
"os": ["netbsd"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/openbsd-arm64@0.25.12": {
|
"@esbuild/openbsd-arm64@0.27.1": {
|
||||||
"integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==",
|
"integrity": "sha512-5Z+DzLCrq5wmU7RDaMDe2DVXMRm2tTDvX2KU14JJVBN2CT/qov7XVix85QoJqHltpvAOZUAc3ndU56HSMWrv8g==",
|
||||||
"os": ["openbsd"],
|
"os": ["openbsd"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/openbsd-x64@0.25.12": {
|
"@esbuild/openbsd-x64@0.27.1": {
|
||||||
"integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==",
|
"integrity": "sha512-Q73ENzIdPF5jap4wqLtsfh8YbYSZ8Q0wnxplOlZUOyZy7B4ZKW8DXGWgTCZmF8VWD7Tciwv5F4NsRf6vYlZtqg==",
|
||||||
"os": ["openbsd"],
|
"os": ["openbsd"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/openharmony-arm64@0.25.12": {
|
"@esbuild/openharmony-arm64@0.27.1": {
|
||||||
"integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==",
|
"integrity": "sha512-ajbHrGM/XiK+sXM0JzEbJAen+0E+JMQZ2l4RR4VFwvV9JEERx+oxtgkpoKv1SevhjavK2z2ReHk32pjzktWbGg==",
|
||||||
"os": ["openharmony"],
|
"os": ["openharmony"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/sunos-x64@0.25.12": {
|
"@esbuild/sunos-x64@0.27.1": {
|
||||||
"integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==",
|
"integrity": "sha512-IPUW+y4VIjuDVn+OMzHc5FV4GubIwPnsz6ubkvN8cuhEqH81NovB53IUlrlBkPMEPxvNnf79MGBoz8rZ2iW8HA==",
|
||||||
"os": ["sunos"],
|
"os": ["sunos"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/win32-arm64@0.25.12": {
|
"@esbuild/win32-arm64@0.27.1": {
|
||||||
"integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==",
|
"integrity": "sha512-RIVRWiljWA6CdVu8zkWcRmGP7iRRIIwvhDKem8UMBjPql2TXM5PkDVvvrzMtj1V+WFPB4K7zkIGM7VzRtFkjdg==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/win32-ia32@0.25.12": {
|
"@esbuild/win32-ia32@0.27.1": {
|
||||||
"integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==",
|
"integrity": "sha512-2BR5M8CPbptC1AK5JbJT1fWrHLvejwZidKx3UMSF0ecHMa+smhi16drIrCEggkgviBwLYd5nwrFLSl5Kho96RQ==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["ia32"]
|
"cpu": ["ia32"]
|
||||||
},
|
},
|
||||||
"@esbuild/win32-x64@0.25.12": {
|
"@esbuild/win32-x64@0.27.1": {
|
||||||
"integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==",
|
"integrity": "sha512-d5X6RMYv6taIymSk8JBP+nxv8DQAMY6A51GPgusqLdK9wBz5wWIXy1KjTck6HnjE9hqJzJRdk+1p/t5soSbCtw==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
@@ -268,8 +268,8 @@
|
|||||||
"@types/trusted-types@2.0.7": {
|
"@types/trusted-types@2.0.7": {
|
||||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw=="
|
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw=="
|
||||||
},
|
},
|
||||||
"esbuild@0.25.12": {
|
"esbuild@0.27.1": {
|
||||||
"integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==",
|
"integrity": "sha512-yY35KZckJJuVVPXpvjgxiCuVEJT67F6zDeVTv4rizyPrfGBUpZQsvmxnN+C371c2esD/hNMjj4tpBhuueLN7aA==",
|
||||||
"optionalDependencies": [
|
"optionalDependencies": [
|
||||||
"@esbuild/aix-ppc64",
|
"@esbuild/aix-ppc64",
|
||||||
"@esbuild/android-arm",
|
"@esbuild/android-arm",
|
||||||
@@ -397,8 +397,8 @@
|
|||||||
"picomatch"
|
"picomatch"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"vite@7.1.12_picomatch@4.0.3": {
|
"vite@7.3.0_picomatch@4.0.3": {
|
||||||
"integrity": "sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug==",
|
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"esbuild",
|
"esbuild",
|
||||||
"fdir",
|
"fdir",
|
||||||
@@ -415,9 +415,9 @@
|
|||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"npm:@deno/vite-plugin@^1.0.5",
|
"npm:@deno/vite-plugin@^1.0.6",
|
||||||
"npm:lit@^3.3.1",
|
"npm:lit@^3.3.1",
|
||||||
"npm:vite@^7.1.12"
|
"npm:vite@^7.3.0"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Vite + Lit</title>
|
|
||||||
<link rel="stylesheet" href="./src/index.css" />
|
|
||||||
<script type="module" src="/src/my-element.ts"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<my-element>
|
|
||||||
<h1>Vite + Lit</h1>
|
|
||||||
</my-element>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
8
crates/frontend/js-components/lib/bundle.ts
Normal file
8
crates/frontend/js-components/lib/bundle.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export { CreateAddressbookForm } from './create-addressbook-form.ts'
|
||||||
|
export { CreateBirthdayCalendarForm } from './create-birthday-calendar-form.ts'
|
||||||
|
export { CreateCalendarForm } from './create-calendar-form.ts'
|
||||||
|
export { DeleteButton } from './delete-button.ts'
|
||||||
|
export { EditAddressbookForm } from './edit-addressbook-form.ts'
|
||||||
|
export { EditCalendarForm } from './edit-calendar-form.ts'
|
||||||
|
export { ImportAddressbookForm } from './import-addressbook-form.ts'
|
||||||
|
export { ImportCalendarForm } from './import-calendar-form.ts'
|
||||||
@@ -5,7 +5,7 @@ import { escapeXml } from ".";
|
|||||||
import { getTimezones } from "./timezones.ts";
|
import { getTimezones } from "./timezones.ts";
|
||||||
|
|
||||||
@customElement("create-birthday-calendar-form")
|
@customElement("create-birthday-calendar-form")
|
||||||
export class CreateCalendarForm extends LitElement {
|
export class CreateBirthdayCalendarForm extends LitElement {
|
||||||
protected override createRenderRoot() {
|
protected override createRenderRoot() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,21 +14,14 @@ export default defineConfig({
|
|||||||
|
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: [
|
input: [
|
||||||
"lib/create-birthday-calendar-form.ts",
|
"lib/bundle.ts",
|
||||||
"lib/create-calendar-form.ts",
|
|
||||||
"lib/edit-calendar-form.ts",
|
|
||||||
"lib/import-calendar-form.ts",
|
|
||||||
"lib/create-addressbook-form.ts",
|
|
||||||
"lib/edit-addressbook-form.ts",
|
|
||||||
"lib/import-addressbook-form.ts",
|
|
||||||
"lib/delete-button.ts",
|
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
dir: "../public/assets/js/",
|
dir: "../public/assets/js/",
|
||||||
format: "es",
|
format: "es",
|
||||||
manualChunks: {
|
// manualChunks: {
|
||||||
lit: ["lit"],
|
// lit: ["lit"],
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
1625
crates/frontend/public/assets/js/bundle.mjs
Normal file
1625
crates/frontend/public/assets/js/bundle.mjs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,125 +0,0 @@
|
|||||||
import { i, x } from "./lit-DKg0et_P.mjs";
|
|
||||||
import { n as n$1, t } from "./property-C8WJQOrH.mjs";
|
|
||||||
import { e, n } from "./ref-BivNNNRN.mjs";
|
|
||||||
import { e as escapeXml } from "./index-fgowJCc1.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 CreateAddressbookForm = class extends i {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.user = "";
|
|
||||||
this.principal = "";
|
|
||||||
this.addr_id = self.crypto.randomUUID();
|
|
||||||
this.displayname = "";
|
|
||||||
this.description = "";
|
|
||||||
this.dialog = e();
|
|
||||||
this.form = e();
|
|
||||||
}
|
|
||||||
createRenderRoot() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
return x`
|
|
||||||
<button @click=${() => this.dialog.value.showModal()}>Create addressbook</button>
|
|
||||||
<dialog ${n(this.dialog)}>
|
|
||||||
<h3>Create addressbook</h3>
|
|
||||||
<form @submit=${this.submit} ${n(this.form)}>
|
|
||||||
<label>
|
|
||||||
principal (for group addressbooks)
|
|
||||||
<select .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>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
id
|
|
||||||
<input type="text" .value=${this.addr_id} @change=${(e2) => this.addr_id = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Displayname
|
|
||||||
<input type="text" .value=${this.displayname} @change=${(e2) => this.displayname = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Description
|
|
||||||
<input type="text" .value=${this.description} @change=${(e2) => this.description = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<button type="submit">Create</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) {
|
|
||||||
console.log(this.displayname);
|
|
||||||
e2.preventDefault();
|
|
||||||
if (!this.addr_id) {
|
|
||||||
alert("Empty id");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.displayname) {
|
|
||||||
alert("Empty displayname");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let response = await fetch(`/carddav/principal/${this.principal || this.user}/${this.addr_id}`, {
|
|
||||||
method: "MKCOL",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/xml"
|
|
||||||
},
|
|
||||||
body: `
|
|
||||||
<mkcol 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>
|
|
||||||
</mkcol>
|
|
||||||
`
|
|
||||||
});
|
|
||||||
if (response.status >= 400) {
|
|
||||||
alert(`Error ${response.status}: ${await response.text()}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
window.location.reload();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateAddressbookForm.prototype, "user", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateAddressbookForm.prototype, "principal", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateAddressbookForm.prototype, "addr_id", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateAddressbookForm.prototype, "displayname", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateAddressbookForm.prototype, "description", 2);
|
|
||||||
CreateAddressbookForm = __decorateClass([
|
|
||||||
t("create-addressbook-form")
|
|
||||||
], CreateAddressbookForm);
|
|
||||||
export {
|
|
||||||
CreateAddressbookForm
|
|
||||||
};
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
import { i, x } from "./lit-DKg0et_P.mjs";
|
|
||||||
import { n as n$1, t } from "./property-C8WJQOrH.mjs";
|
|
||||||
import { e, n } from "./ref-BivNNNRN.mjs";
|
|
||||||
import { e as escapeXml } from "./index-fgowJCc1.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 CreateCalendarForm = class extends i {
|
|
||||||
constructor() {
|
|
||||||
super(...arguments);
|
|
||||||
this.principal = "";
|
|
||||||
this.addr_id = "";
|
|
||||||
this.displayname = "";
|
|
||||||
this.description = "";
|
|
||||||
this.color = "";
|
|
||||||
this.dialog = e();
|
|
||||||
this.form = e();
|
|
||||||
this.timezones = [];
|
|
||||||
}
|
|
||||||
createRenderRoot() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
return x`
|
|
||||||
<button @click=${() => this.dialog.value.showModal()}>Create birthday calendar</button>
|
|
||||||
<dialog ${n(this.dialog)}>
|
|
||||||
<h3>Create calendar</h3>
|
|
||||||
<form @submit=${this.submit} ${n(this.form)}>
|
|
||||||
<label>
|
|
||||||
Displayname
|
|
||||||
<input type="text" .value=${this.displayname} required @change=${(e2) => this.displayname = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Description
|
|
||||||
<input type="text" .value=${this.description} @change=${(e2) => this.description = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Color
|
|
||||||
<input type="color" .value=${this.color} @change=${(e2) => this.color = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<button type="submit">Create</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.addr_id) {
|
|
||||||
alert("Empty id");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.displayname) {
|
|
||||||
alert("Empty displayname");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let response = await fetch(`/caldav/principal/${this.principal}/_birthdays_${this.addr_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/">
|
|
||||||
<set>
|
|
||||||
<prop>
|
|
||||||
<displayname>${escapeXml(this.displayname)}</displayname>
|
|
||||||
${this.description ? `<CAL:calendar-description>${escapeXml(this.description)}</CAL:calendar-description>` : ""}
|
|
||||||
${this.color ? `<ICAL:calendar-color>${escapeXml(this.color)}</ICAL:calendar-color>` : ""}
|
|
||||||
<CAL:supported-calendar-component-set>
|
|
||||||
<CAL:comp name="VEVENT" />
|
|
||||||
</CAL:supported-calendar-component-set>
|
|
||||||
</prop>
|
|
||||||
</set>
|
|
||||||
</mkcol>
|
|
||||||
`
|
|
||||||
});
|
|
||||||
if (response.status >= 400) {
|
|
||||||
alert(`Error ${response.status}: ${await response.text()}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
window.location.reload();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "principal", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "addr_id", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "displayname", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "description", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "color", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "timezones", 2);
|
|
||||||
CreateCalendarForm = __decorateClass([
|
|
||||||
t("create-birthday-calendar-form")
|
|
||||||
], CreateCalendarForm);
|
|
||||||
export {
|
|
||||||
CreateCalendarForm
|
|
||||||
};
|
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
import { i, x } from "./lit-DKg0et_P.mjs";
|
|
||||||
import { n as n$1, t } from "./property-C8WJQOrH.mjs";
|
|
||||||
import { e, n } from "./ref-BivNNNRN.mjs";
|
|
||||||
import { S as SVG_ICON_CALENDAR, a as SVG_ICON_INTERNET, e as escapeXml } from "./index-fgowJCc1.mjs";
|
|
||||||
import { g as getTimezones } from "./timezones-B0vBBzCP.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 CreateCalendarForm = class extends i {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.user = "";
|
|
||||||
this.dialog = e();
|
|
||||||
this.form = e();
|
|
||||||
this.timezones = [];
|
|
||||||
this.resetForm();
|
|
||||||
this.fetchTimezones();
|
|
||||||
}
|
|
||||||
resetForm() {
|
|
||||||
this.form.value?.reset();
|
|
||||||
this.principal = this.user;
|
|
||||||
this.cal_id = self.crypto.randomUUID();
|
|
||||||
this.displayname = "";
|
|
||||||
this.description = "";
|
|
||||||
this.timezone_id = "";
|
|
||||||
this.color = "";
|
|
||||||
this.isSubscription = false;
|
|
||||||
this.subscriptionUrl = null;
|
|
||||||
this.components = /* @__PURE__ */ new Set(["VEVENT", "VTODO"]);
|
|
||||||
}
|
|
||||||
async fetchTimezones() {
|
|
||||||
this.timezones = await getTimezones();
|
|
||||||
}
|
|
||||||
createRenderRoot() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
return x`
|
|
||||||
<button @click=${(e2) => this.dialog.value.showModal()}>Create calendar</button>
|
|
||||||
<dialog ${n(this.dialog)} @close=${(e2) => this.resetForm()}>
|
|
||||||
<h3>Create calendar</h3>
|
|
||||||
<form @submit=${this.submit} ${n(this.form)}>
|
|
||||||
<label>
|
|
||||||
principal (for group calendars)
|
|
||||||
<select required 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>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
id
|
|
||||||
<input type="text" required .value=${this.cal_id} @change=${(e2) => this.cal_id = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Displayname
|
|
||||||
<input type="text" required .value=${this.displayname} @change=${(e2) => this.displayname = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Timezone (optional)
|
|
||||||
<select .value=${this.timezone_id} @change=${(e2) => this.timezone_id = e2.target.value}>
|
|
||||||
<option value="">No timezone</option>
|
|
||||||
${this.timezones.map((timezone) => x`
|
|
||||||
<option value=${timezone} ?selected=${timezone === this.timezone_id}>${timezone}</option>
|
|
||||||
`)}
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Description
|
|
||||||
<input type="text" .value=${this.description} @change=${(e2) => this.description = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Color
|
|
||||||
<input type="color" .value=${this.color} @change=${(e2) => this.color = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<label>Type</label>
|
|
||||||
<div class="tab-radio">
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="type" .checked=${!this.isSubscription} @change=${(e2) => this.isSubscription = false}></input>
|
|
||||||
${SVG_ICON_CALENDAR}
|
|
||||||
Calendar
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="type" .checked=${this.isSubscription} @change=${(e2) => this.isSubscription = true}></input>
|
|
||||||
${SVG_ICON_INTERNET}
|
|
||||||
webCal Subscription
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
${this.isSubscription ? x`
|
|
||||||
<label>
|
|
||||||
Subscription URL
|
|
||||||
<input type="text" pattern="https://.*" .required=${this.isSubscription} .value=${this.subscriptionUrl} @change=${(e2) => this.subscriptionUrl = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
` : x``}
|
|
||||||
|
|
||||||
<label>Components</label>
|
|
||||||
<div>
|
|
||||||
${["VEVENT", "VTODO", "VJOURNAL"].map((comp) => x`
|
|
||||||
<label>
|
|
||||||
Support ${comp}
|
|
||||||
<input type="checkbox" .value=${comp} @change=${(e2) => e2.target.checked ? this.components.add(e2.target.value) : this.components.delete(e2.target.value)} .checked=${this.components.has(comp)} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
`)}
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<button type="submit">Create</button>
|
|
||||||
<button type="submit" @click=${(event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
this.dialog.value.close();
|
|
||||||
}} class="cancel">Cancel</button>
|
|
||||||
</form>
|
|
||||||
</dialog>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
async submit(e2) {
|
|
||||||
e2.preventDefault();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (this.isSubscription && !this.subscriptionUrl) {
|
|
||||||
alert("Invalid subscription url");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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/">
|
|
||||||
<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>` : ""}
|
|
||||||
${this.isSubscription && this.subscriptionUrl ? `<CS:source><href>${escapeXml(this.subscriptionUrl)}</href></CS:source>` : ""}
|
|
||||||
<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>
|
|
||||||
</mkcol>
|
|
||||||
`
|
|
||||||
});
|
|
||||||
if (response.status >= 400) {
|
|
||||||
alert(`Error ${response.status}: ${await response.text()}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
window.location.reload();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "user", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "principal", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "cal_id", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "displayname", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "description", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "timezone_id", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "color", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "isSubscription", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "subscriptionUrl", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "components", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], CreateCalendarForm.prototype, "timezones", 2);
|
|
||||||
CreateCalendarForm = __decorateClass([
|
|
||||||
t("create-calendar-form")
|
|
||||||
], CreateCalendarForm);
|
|
||||||
export {
|
|
||||||
CreateCalendarForm
|
|
||||||
};
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
import { i, x } from "./lit-DKg0et_P.mjs";
|
|
||||||
import { n, t } from "./property-C8WJQOrH.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 DeleteButton = class extends i {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.trash = false;
|
|
||||||
}
|
|
||||||
createRenderRoot() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
let text = this.trash ? "Trash" : "Delete";
|
|
||||||
return x`<button class="delete" @click=${(e) => this._onClick(e)}>${text}</button>`;
|
|
||||||
}
|
|
||||||
async _onClick(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
if (!this.trash && !confirm("Do you want to delete this collection permanently?")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let response = await fetch(this.href, {
|
|
||||||
method: "DELETE",
|
|
||||||
headers: {
|
|
||||||
"X-No-Trashbin": this.trash ? "0" : "1"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (response.status < 200 || response.status >= 300) {
|
|
||||||
alert("An error occured, look into the console");
|
|
||||||
console.error(response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
__decorateClass([
|
|
||||||
n({ type: Boolean })
|
|
||||||
], DeleteButton.prototype, "trash", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n()
|
|
||||||
], DeleteButton.prototype, "href", 2);
|
|
||||||
DeleteButton = __decorateClass([
|
|
||||||
t("delete-button")
|
|
||||||
], DeleteButton);
|
|
||||||
export {
|
|
||||||
DeleteButton
|
|
||||||
};
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
import { i, x } from "./lit-DKg0et_P.mjs";
|
|
||||||
import { n as n$1, t } from "./property-C8WJQOrH.mjs";
|
|
||||||
import { e, n } from "./ref-BivNNNRN.mjs";
|
|
||||||
import { e as escapeXml } from "./index-fgowJCc1.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</button>
|
|
||||||
<dialog ${n(this.dialog)}>
|
|
||||||
<h3>Edit addressbook</h3>
|
|
||||||
<form @submit=${this.submit} ${n(this.form)}>
|
|
||||||
<label>
|
|
||||||
Displayname
|
|
||||||
<input type="text" .value=${this.displayname} @change=${(e2) => this.displayname = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Description
|
|
||||||
<input type="text" .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
|
|
||||||
};
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
import { i, x } from "./lit-DKg0et_P.mjs";
|
|
||||||
import { n as n$1, t } from "./property-C8WJQOrH.mjs";
|
|
||||||
import { e, n } from "./ref-BivNNNRN.mjs";
|
|
||||||
import { e as escapeXml } from "./index-fgowJCc1.mjs";
|
|
||||||
import { g as getTimezones } from "./timezones-B0vBBzCP.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();
|
|
||||||
this.timezones = [];
|
|
||||||
this.fetchTimezones();
|
|
||||||
}
|
|
||||||
async fetchTimezones() {
|
|
||||||
this.timezones = await getTimezones();
|
|
||||||
}
|
|
||||||
createRenderRoot() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
return x`
|
|
||||||
<button @click=${() => this.dialog.value.showModal()}>Edit</button>
|
|
||||||
<dialog ${n(this.dialog)}>
|
|
||||||
<h3>Edit calendar</h3>
|
|
||||||
<form @submit=${this.submit} ${n(this.form)}>
|
|
||||||
<label>
|
|
||||||
Displayname
|
|
||||||
<input type="text" required .value=${this.displayname} @change=${(e2) => this.displayname = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Timezone (optional)
|
|
||||||
<select .value=${this.timezone_id} @change=${(e2) => this.timezone_id = e2.target.value}>
|
|
||||||
<option value="">No timezone</option>
|
|
||||||
${this.timezones.map((timezone) => x`
|
|
||||||
<option value=${timezone} ?selected=${timezone === this.timezone_id}>${timezone}</option>
|
|
||||||
`)}
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Description
|
|
||||||
<input type="text" .value=${this.description} @change=${(e2) => this.description = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
Color
|
|
||||||
<input type="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.timezone_id ? `<CAL:calendar-timezone-id />` : ""}
|
|
||||||
${!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);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], EditCalendarForm.prototype, "timezones", 2);
|
|
||||||
EditCalendarForm = __decorateClass([
|
|
||||||
t("edit-calendar-form")
|
|
||||||
], EditCalendarForm);
|
|
||||||
export {
|
|
||||||
EditCalendarForm
|
|
||||||
};
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
import { i, x } from "./lit-DKg0et_P.mjs";
|
|
||||||
import { n as n$1, t } from "./property-C8WJQOrH.mjs";
|
|
||||||
import { e, n } from "./ref-BivNNNRN.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 ImportAddressbookForm = class extends i {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.user = "";
|
|
||||||
this.addressbook_id = self.crypto.randomUUID();
|
|
||||||
this.dialog = e();
|
|
||||||
this.form = e();
|
|
||||||
}
|
|
||||||
createRenderRoot() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
return x`
|
|
||||||
<button @click=${() => this.dialog.value.showModal()}>Import addressbook</button>
|
|
||||||
<dialog ${n(this.dialog)}>
|
|
||||||
<h3>Import addressbook</h3>
|
|
||||||
<form @submit=${this.submit} ${n(this.form)}>
|
|
||||||
<label>
|
|
||||||
principal (for group addressbook)
|
|
||||||
<select name="principal" required .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>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
id
|
|
||||||
<input type="text" required .value=${this.addressbook_id} @change=${(e2) => this.addressbook_id = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
file
|
|
||||||
<input type="file" accept="text/vcard" required @change=${(e2) => this.file = e2.target.files[0]} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<button type="submit">Import</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();
|
|
||||||
this.principal ||= this.user;
|
|
||||||
if (!this.principal) {
|
|
||||||
alert("Empty principal");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.addressbook_id) {
|
|
||||||
alert("Empty id");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let response = await fetch(`/carddav/principal/${this.principal}/${this.addressbook_id}`, {
|
|
||||||
method: "IMPORT",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "text/vcard"
|
|
||||||
},
|
|
||||||
body: this.file
|
|
||||||
});
|
|
||||||
if (response.status >= 400) {
|
|
||||||
alert(`Error ${response.status}: ${await response.text()}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
window.location.reload();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], ImportAddressbookForm.prototype, "user", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], ImportAddressbookForm.prototype, "principal", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], ImportAddressbookForm.prototype, "addressbook_id", 2);
|
|
||||||
ImportAddressbookForm = __decorateClass([
|
|
||||||
t("import-addressbook-form")
|
|
||||||
], ImportAddressbookForm);
|
|
||||||
export {
|
|
||||||
ImportAddressbookForm
|
|
||||||
};
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
import { i, x } from "./lit-DKg0et_P.mjs";
|
|
||||||
import { n as n$1, t } from "./property-C8WJQOrH.mjs";
|
|
||||||
import { e, n } from "./ref-BivNNNRN.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 ImportCalendarForm = class extends i {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.user = "";
|
|
||||||
this.cal_id = self.crypto.randomUUID();
|
|
||||||
this.dialog = e();
|
|
||||||
this.form = e();
|
|
||||||
}
|
|
||||||
createRenderRoot() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
return x`
|
|
||||||
<button @click=${() => this.dialog.value.showModal()}>Import calendar</button>
|
|
||||||
<dialog ${n(this.dialog)}>
|
|
||||||
<h3>Import calendar</h3>
|
|
||||||
<form @submit=${this.submit} ${n(this.form)}>
|
|
||||||
<label>
|
|
||||||
principal (for group calendars)
|
|
||||||
<select name="principal" required .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>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
id
|
|
||||||
<input type="text" required .value=${this.cal_id} @change=${(e2) => this.cal_id = e2.target.value} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<label>
|
|
||||||
file
|
|
||||||
<input type="file" required accept="text/calendar" @change=${(e2) => this.file = e2.target.files[0]} />
|
|
||||||
</label>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<button type="submit">Import</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();
|
|
||||||
this.principal ||= this.user;
|
|
||||||
if (!this.principal) {
|
|
||||||
alert("Empty principal");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.cal_id) {
|
|
||||||
alert("Empty id");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let response = await fetch(`/caldav/principal/${this.principal}/${this.cal_id}`, {
|
|
||||||
method: "IMPORT",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "text/calendar"
|
|
||||||
},
|
|
||||||
body: this.file
|
|
||||||
});
|
|
||||||
if (response.status >= 400) {
|
|
||||||
alert(`Error ${response.status}: ${await response.text()}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
window.location.reload();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], ImportCalendarForm.prototype, "user", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], ImportCalendarForm.prototype, "principal", 2);
|
|
||||||
__decorateClass([
|
|
||||||
n$1()
|
|
||||||
], ImportCalendarForm.prototype, "cal_id", 2);
|
|
||||||
ImportCalendarForm = __decorateClass([
|
|
||||||
t("import-calendar-form")
|
|
||||||
], ImportCalendarForm);
|
|
||||||
export {
|
|
||||||
ImportCalendarForm
|
|
||||||
};
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import { b } from "./lit-DKg0et_P.mjs";
|
|
||||||
function escapeXml(unsafe) {
|
|
||||||
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
||||||
}
|
|
||||||
const SVG_ICON_CALENDAR = b`<!-- Adapted from https://iconoir.com/ -->
|
|
||||||
<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="M3 10V6C3 4.89543 3.89543 4 5 4H7" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
||||||
<path d="M7 2V6" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
||||||
<path d="M21 10V6C21 4.89543 20.1046 4 19 4H18.5" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
||||||
</svg>
|
|
||||||
`;
|
|
||||||
const SVG_ICON_INTERNET = b`<!-- Adapted from https://iconoir.com/ -->
|
|
||||||
<svg class="icon" width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
||||||
<path d="M13 2.04932C13 2.04932 16 5.99994 16 11.9999" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
||||||
<path d="M11 21.9506C11 21.9506 8 17.9999 8 11.9999C8 5.99994 11 2.04932 11 2.04932" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
||||||
<path d="M2.62964 15.5H12" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
||||||
<path d="M2.62964 8.5H21.3704" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.8789 17.9174C22.3727 18.2211 22.3423 18.9604 21.8337 19.0181L19.2671 19.309L18.1159 21.6213C17.8878 22.0795 17.1827 21.8552 17.0661 21.2873L15.8108 15.1713C15.7123 14.6913 16.1437 14.3892 16.561 14.646L21.8789 17.9174Z"></path>
|
|
||||||
</svg>
|
|
||||||
`;
|
|
||||||
export {
|
|
||||||
SVG_ICON_CALENDAR as S,
|
|
||||||
SVG_ICON_INTERNET as a,
|
|
||||||
escapeXml as e
|
|
||||||
};
|
|
||||||
@@ -1,521 +0,0 @@
|
|||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2019 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const t$1 = globalThis, e$2 = t$1.ShadowRoot && (void 0 === t$1.ShadyCSS || t$1.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$2 = Symbol(), o$3 = /* @__PURE__ */ new WeakMap();
|
|
||||||
let n$2 = class n {
|
|
||||||
constructor(t2, e2, o2) {
|
|
||||||
if (this._$cssResult$ = true, o2 !== s$2) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
||||||
this.cssText = t2, this.t = e2;
|
|
||||||
}
|
|
||||||
get styleSheet() {
|
|
||||||
let t2 = this.o;
|
|
||||||
const s2 = this.t;
|
|
||||||
if (e$2 && void 0 === t2) {
|
|
||||||
const e2 = void 0 !== s2 && 1 === s2.length;
|
|
||||||
e2 && (t2 = o$3.get(s2)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && o$3.set(s2, t2));
|
|
||||||
}
|
|
||||||
return t2;
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
return this.cssText;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const r$2 = (t2) => new n$2("string" == typeof t2 ? t2 : t2 + "", void 0, s$2), S$1 = (s2, o2) => {
|
|
||||||
if (e$2) s2.adoptedStyleSheets = o2.map(((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet));
|
|
||||||
else for (const e2 of o2) {
|
|
||||||
const o3 = document.createElement("style"), n3 = t$1.litNonce;
|
|
||||||
void 0 !== n3 && o3.setAttribute("nonce", n3), o3.textContent = e2.cssText, s2.appendChild(o3);
|
|
||||||
}
|
|
||||||
}, c$2 = e$2 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => {
|
|
||||||
let e2 = "";
|
|
||||||
for (const s2 of t3.cssRules) e2 += s2.cssText;
|
|
||||||
return r$2(e2);
|
|
||||||
})(t2) : t2;
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2017 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const { is: i$2, defineProperty: e$1, getOwnPropertyDescriptor: h$1, getOwnPropertyNames: r$1, getOwnPropertySymbols: o$2, getPrototypeOf: n$1 } = Object, a$1 = globalThis, c$1 = a$1.trustedTypes, l$1 = c$1 ? c$1.emptyScript : "", p$1 = a$1.reactiveElementPolyfillSupport, d$1 = (t2, s2) => t2, u$1 = { toAttribute(t2, s2) {
|
|
||||||
switch (s2) {
|
|
||||||
case Boolean:
|
|
||||||
t2 = t2 ? l$1 : null;
|
|
||||||
break;
|
|
||||||
case Object:
|
|
||||||
case Array:
|
|
||||||
t2 = null == t2 ? t2 : JSON.stringify(t2);
|
|
||||||
}
|
|
||||||
return t2;
|
|
||||||
}, fromAttribute(t2, s2) {
|
|
||||||
let i2 = t2;
|
|
||||||
switch (s2) {
|
|
||||||
case Boolean:
|
|
||||||
i2 = null !== t2;
|
|
||||||
break;
|
|
||||||
case Number:
|
|
||||||
i2 = null === t2 ? null : Number(t2);
|
|
||||||
break;
|
|
||||||
case Object:
|
|
||||||
case Array:
|
|
||||||
try {
|
|
||||||
i2 = JSON.parse(t2);
|
|
||||||
} catch (t3) {
|
|
||||||
i2 = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i2;
|
|
||||||
} }, f$1 = (t2, s2) => !i$2(t2, s2), b$1 = { attribute: true, type: String, converter: u$1, reflect: false, useDefault: false, hasChanged: f$1 };
|
|
||||||
Symbol.metadata ??= Symbol("metadata"), a$1.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
|
|
||||||
let y$1 = class y extends HTMLElement {
|
|
||||||
static addInitializer(t2) {
|
|
||||||
this._$Ei(), (this.l ??= []).push(t2);
|
|
||||||
}
|
|
||||||
static get observedAttributes() {
|
|
||||||
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
||||||
}
|
|
||||||
static createProperty(t2, s2 = b$1) {
|
|
||||||
if (s2.state && (s2.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t2) && ((s2 = Object.create(s2)).wrapped = true), this.elementProperties.set(t2, s2), !s2.noAccessor) {
|
|
||||||
const i2 = Symbol(), h2 = this.getPropertyDescriptor(t2, i2, s2);
|
|
||||||
void 0 !== h2 && e$1(this.prototype, t2, h2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static getPropertyDescriptor(t2, s2, i2) {
|
|
||||||
const { get: e2, set: r2 } = h$1(this.prototype, t2) ?? { get() {
|
|
||||||
return this[s2];
|
|
||||||
}, set(t3) {
|
|
||||||
this[s2] = t3;
|
|
||||||
} };
|
|
||||||
return { get: e2, set(s3) {
|
|
||||||
const h2 = e2?.call(this);
|
|
||||||
r2?.call(this, s3), this.requestUpdate(t2, h2, i2);
|
|
||||||
}, configurable: true, enumerable: true };
|
|
||||||
}
|
|
||||||
static getPropertyOptions(t2) {
|
|
||||||
return this.elementProperties.get(t2) ?? b$1;
|
|
||||||
}
|
|
||||||
static _$Ei() {
|
|
||||||
if (this.hasOwnProperty(d$1("elementProperties"))) return;
|
|
||||||
const t2 = n$1(this);
|
|
||||||
t2.finalize(), void 0 !== t2.l && (this.l = [...t2.l]), this.elementProperties = new Map(t2.elementProperties);
|
|
||||||
}
|
|
||||||
static finalize() {
|
|
||||||
if (this.hasOwnProperty(d$1("finalized"))) return;
|
|
||||||
if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d$1("properties"))) {
|
|
||||||
const t3 = this.properties, s2 = [...r$1(t3), ...o$2(t3)];
|
|
||||||
for (const i2 of s2) this.createProperty(i2, t3[i2]);
|
|
||||||
}
|
|
||||||
const t2 = this[Symbol.metadata];
|
|
||||||
if (null !== t2) {
|
|
||||||
const s2 = litPropertyMetadata.get(t2);
|
|
||||||
if (void 0 !== s2) for (const [t3, i2] of s2) this.elementProperties.set(t3, i2);
|
|
||||||
}
|
|
||||||
this._$Eh = /* @__PURE__ */ new Map();
|
|
||||||
for (const [t3, s2] of this.elementProperties) {
|
|
||||||
const i2 = this._$Eu(t3, s2);
|
|
||||||
void 0 !== i2 && this._$Eh.set(i2, t3);
|
|
||||||
}
|
|
||||||
this.elementStyles = this.finalizeStyles(this.styles);
|
|
||||||
}
|
|
||||||
static finalizeStyles(s2) {
|
|
||||||
const i2 = [];
|
|
||||||
if (Array.isArray(s2)) {
|
|
||||||
const e2 = new Set(s2.flat(1 / 0).reverse());
|
|
||||||
for (const s3 of e2) i2.unshift(c$2(s3));
|
|
||||||
} else void 0 !== s2 && i2.push(c$2(s2));
|
|
||||||
return i2;
|
|
||||||
}
|
|
||||||
static _$Eu(t2, s2) {
|
|
||||||
const i2 = s2.attribute;
|
|
||||||
return false === i2 ? void 0 : "string" == typeof i2 ? i2 : "string" == typeof t2 ? t2.toLowerCase() : void 0;
|
|
||||||
}
|
|
||||||
constructor() {
|
|
||||||
super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
|
|
||||||
}
|
|
||||||
_$Ev() {
|
|
||||||
this._$ES = new Promise(((t2) => this.enableUpdating = t2)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((t2) => t2(this)));
|
|
||||||
}
|
|
||||||
addController(t2) {
|
|
||||||
(this._$EO ??= /* @__PURE__ */ new Set()).add(t2), void 0 !== this.renderRoot && this.isConnected && t2.hostConnected?.();
|
|
||||||
}
|
|
||||||
removeController(t2) {
|
|
||||||
this._$EO?.delete(t2);
|
|
||||||
}
|
|
||||||
_$E_() {
|
|
||||||
const t2 = /* @__PURE__ */ new Map(), s2 = this.constructor.elementProperties;
|
|
||||||
for (const i2 of s2.keys()) this.hasOwnProperty(i2) && (t2.set(i2, this[i2]), delete this[i2]);
|
|
||||||
t2.size > 0 && (this._$Ep = t2);
|
|
||||||
}
|
|
||||||
createRenderRoot() {
|
|
||||||
const t2 = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
||||||
return S$1(t2, this.constructor.elementStyles), t2;
|
|
||||||
}
|
|
||||||
connectedCallback() {
|
|
||||||
this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach(((t2) => t2.hostConnected?.()));
|
|
||||||
}
|
|
||||||
enableUpdating(t2) {
|
|
||||||
}
|
|
||||||
disconnectedCallback() {
|
|
||||||
this._$EO?.forEach(((t2) => t2.hostDisconnected?.()));
|
|
||||||
}
|
|
||||||
attributeChangedCallback(t2, s2, i2) {
|
|
||||||
this._$AK(t2, i2);
|
|
||||||
}
|
|
||||||
_$ET(t2, s2) {
|
|
||||||
const i2 = this.constructor.elementProperties.get(t2), e2 = this.constructor._$Eu(t2, i2);
|
|
||||||
if (void 0 !== e2 && true === i2.reflect) {
|
|
||||||
const h2 = (void 0 !== i2.converter?.toAttribute ? i2.converter : u$1).toAttribute(s2, i2.type);
|
|
||||||
this._$Em = t2, null == h2 ? this.removeAttribute(e2) : this.setAttribute(e2, h2), this._$Em = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_$AK(t2, s2) {
|
|
||||||
const i2 = this.constructor, e2 = i2._$Eh.get(t2);
|
|
||||||
if (void 0 !== e2 && this._$Em !== e2) {
|
|
||||||
const t3 = i2.getPropertyOptions(e2), h2 = "function" == typeof t3.converter ? { fromAttribute: t3.converter } : void 0 !== t3.converter?.fromAttribute ? t3.converter : u$1;
|
|
||||||
this._$Em = e2;
|
|
||||||
const r2 = h2.fromAttribute(s2, t3.type);
|
|
||||||
this[e2] = r2 ?? this._$Ej?.get(e2) ?? r2, this._$Em = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
requestUpdate(t2, s2, i2) {
|
|
||||||
if (void 0 !== t2) {
|
|
||||||
const e2 = this.constructor, h2 = this[t2];
|
|
||||||
if (i2 ??= e2.getPropertyOptions(t2), !((i2.hasChanged ?? f$1)(h2, s2) || i2.useDefault && i2.reflect && h2 === this._$Ej?.get(t2) && !this.hasAttribute(e2._$Eu(t2, i2)))) return;
|
|
||||||
this.C(t2, s2, i2);
|
|
||||||
}
|
|
||||||
false === this.isUpdatePending && (this._$ES = this._$EP());
|
|
||||||
}
|
|
||||||
C(t2, s2, { useDefault: i2, reflect: e2, wrapped: h2 }, r2) {
|
|
||||||
i2 && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t2) && (this._$Ej.set(t2, r2 ?? s2 ?? this[t2]), true !== h2 || void 0 !== r2) || (this._$AL.has(t2) || (this.hasUpdated || i2 || (s2 = void 0), this._$AL.set(t2, s2)), true === e2 && this._$Em !== t2 && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t2));
|
|
||||||
}
|
|
||||||
async _$EP() {
|
|
||||||
this.isUpdatePending = true;
|
|
||||||
try {
|
|
||||||
await this._$ES;
|
|
||||||
} catch (t3) {
|
|
||||||
Promise.reject(t3);
|
|
||||||
}
|
|
||||||
const t2 = this.scheduleUpdate();
|
|
||||||
return null != t2 && await t2, !this.isUpdatePending;
|
|
||||||
}
|
|
||||||
scheduleUpdate() {
|
|
||||||
return this.performUpdate();
|
|
||||||
}
|
|
||||||
performUpdate() {
|
|
||||||
if (!this.isUpdatePending) return;
|
|
||||||
if (!this.hasUpdated) {
|
|
||||||
if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
|
|
||||||
for (const [t4, s3] of this._$Ep) this[t4] = s3;
|
|
||||||
this._$Ep = void 0;
|
|
||||||
}
|
|
||||||
const t3 = this.constructor.elementProperties;
|
|
||||||
if (t3.size > 0) for (const [s3, i2] of t3) {
|
|
||||||
const { wrapped: t4 } = i2, e2 = this[s3];
|
|
||||||
true !== t4 || this._$AL.has(s3) || void 0 === e2 || this.C(s3, void 0, i2, e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let t2 = false;
|
|
||||||
const s2 = this._$AL;
|
|
||||||
try {
|
|
||||||
t2 = this.shouldUpdate(s2), t2 ? (this.willUpdate(s2), this._$EO?.forEach(((t3) => t3.hostUpdate?.())), this.update(s2)) : this._$EM();
|
|
||||||
} catch (s3) {
|
|
||||||
throw t2 = false, this._$EM(), s3;
|
|
||||||
}
|
|
||||||
t2 && this._$AE(s2);
|
|
||||||
}
|
|
||||||
willUpdate(t2) {
|
|
||||||
}
|
|
||||||
_$AE(t2) {
|
|
||||||
this._$EO?.forEach(((t3) => t3.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t2)), this.updated(t2);
|
|
||||||
}
|
|
||||||
_$EM() {
|
|
||||||
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
|
|
||||||
}
|
|
||||||
get updateComplete() {
|
|
||||||
return this.getUpdateComplete();
|
|
||||||
}
|
|
||||||
getUpdateComplete() {
|
|
||||||
return this._$ES;
|
|
||||||
}
|
|
||||||
shouldUpdate(t2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
update(t2) {
|
|
||||||
this._$Eq &&= this._$Eq.forEach(((t3) => this._$ET(t3, this[t3]))), this._$EM();
|
|
||||||
}
|
|
||||||
updated(t2) {
|
|
||||||
}
|
|
||||||
firstUpdated(t2) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
y$1.elementStyles = [], y$1.shadowRootOptions = { mode: "open" }, y$1[d$1("elementProperties")] = /* @__PURE__ */ new Map(), y$1[d$1("finalized")] = /* @__PURE__ */ new Map(), p$1?.({ ReactiveElement: y$1 }), (a$1.reactiveElementVersions ??= []).push("2.1.1");
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2017 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const t = globalThis, i$1 = t.trustedTypes, s$1 = i$1 ? i$1.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, e = "$lit$", h = `lit$${Math.random().toFixed(9).slice(2)}$`, o$1 = "?" + h, n2 = `<${o$1}>`, r = document, l = () => r.createComment(""), c = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, a = Array.isArray, u = (t2) => a(t2) || "function" == typeof t2?.[Symbol.iterator], d = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, v = /-->/g, _ = />/g, m = RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^
|
|
||||||
\f\r"'\`<>=]|("|')|))|$)`, "g"), p = /'/g, g = /"/g, $ = /^(?:script|style|textarea|title)$/i, y2 = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = y2(1), b = y2(2), T = Symbol.for("lit-noChange"), E = Symbol.for("lit-nothing"), A = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129);
|
|
||||||
function P(t2, i2) {
|
|
||||||
if (!a(t2) || !t2.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
||||||
return void 0 !== s$1 ? s$1.createHTML(i2) : i2;
|
|
||||||
}
|
|
||||||
const V = (t2, i2) => {
|
|
||||||
const s2 = t2.length - 1, o2 = [];
|
|
||||||
let r2, l2 = 2 === i2 ? "<svg>" : 3 === i2 ? "<math>" : "", c2 = f;
|
|
||||||
for (let i3 = 0; i3 < s2; i3++) {
|
|
||||||
const s3 = t2[i3];
|
|
||||||
let a2, u2, d2 = -1, y3 = 0;
|
|
||||||
for (; y3 < s3.length && (c2.lastIndex = y3, u2 = c2.exec(s3), null !== u2); ) y3 = c2.lastIndex, c2 === f ? "!--" === u2[1] ? c2 = v : void 0 !== u2[1] ? c2 = _ : void 0 !== u2[2] ? ($.test(u2[2]) && (r2 = RegExp("</" + u2[2], "g")), c2 = m) : void 0 !== u2[3] && (c2 = m) : c2 === m ? ">" === u2[0] ? (c2 = r2 ?? f, d2 = -1) : void 0 === u2[1] ? d2 = -2 : (d2 = c2.lastIndex - u2[2].length, a2 = u2[1], c2 = void 0 === u2[3] ? m : '"' === u2[3] ? g : p) : c2 === g || c2 === p ? c2 = m : c2 === v || c2 === _ ? c2 = f : (c2 = m, r2 = void 0);
|
|
||||||
const x2 = c2 === m && t2[i3 + 1].startsWith("/>") ? " " : "";
|
|
||||||
l2 += c2 === f ? s3 + n2 : d2 >= 0 ? (o2.push(a2), s3.slice(0, d2) + e + s3.slice(d2) + h + x2) : s3 + h + (-2 === d2 ? i3 : x2);
|
|
||||||
}
|
|
||||||
return [P(t2, l2 + (t2[s2] || "<?>") + (2 === i2 ? "</svg>" : 3 === i2 ? "</math>" : "")), o2];
|
|
||||||
};
|
|
||||||
class N {
|
|
||||||
constructor({ strings: t2, _$litType$: s2 }, n3) {
|
|
||||||
let r2;
|
|
||||||
this.parts = [];
|
|
||||||
let c2 = 0, a2 = 0;
|
|
||||||
const u2 = t2.length - 1, d2 = this.parts, [f2, v2] = V(t2, s2);
|
|
||||||
if (this.el = N.createElement(f2, n3), C.currentNode = this.el.content, 2 === s2 || 3 === s2) {
|
|
||||||
const t3 = this.el.content.firstChild;
|
|
||||||
t3.replaceWith(...t3.childNodes);
|
|
||||||
}
|
|
||||||
for (; null !== (r2 = C.nextNode()) && d2.length < u2; ) {
|
|
||||||
if (1 === r2.nodeType) {
|
|
||||||
if (r2.hasAttributes()) for (const t3 of r2.getAttributeNames()) if (t3.endsWith(e)) {
|
|
||||||
const i2 = v2[a2++], s3 = r2.getAttribute(t3).split(h), e2 = /([.?@])?(.*)/.exec(i2);
|
|
||||||
d2.push({ type: 1, index: c2, name: e2[2], strings: s3, ctor: "." === e2[1] ? H : "?" === e2[1] ? I : "@" === e2[1] ? L : k }), r2.removeAttribute(t3);
|
|
||||||
} else t3.startsWith(h) && (d2.push({ type: 6, index: c2 }), r2.removeAttribute(t3));
|
|
||||||
if ($.test(r2.tagName)) {
|
|
||||||
const t3 = r2.textContent.split(h), s3 = t3.length - 1;
|
|
||||||
if (s3 > 0) {
|
|
||||||
r2.textContent = i$1 ? i$1.emptyScript : "";
|
|
||||||
for (let i2 = 0; i2 < s3; i2++) r2.append(t3[i2], l()), C.nextNode(), d2.push({ type: 2, index: ++c2 });
|
|
||||||
r2.append(t3[s3], l());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (8 === r2.nodeType) if (r2.data === o$1) d2.push({ type: 2, index: c2 });
|
|
||||||
else {
|
|
||||||
let t3 = -1;
|
|
||||||
for (; -1 !== (t3 = r2.data.indexOf(h, t3 + 1)); ) d2.push({ type: 7, index: c2 }), t3 += h.length - 1;
|
|
||||||
}
|
|
||||||
c2++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static createElement(t2, i2) {
|
|
||||||
const s2 = r.createElement("template");
|
|
||||||
return s2.innerHTML = t2, s2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function S(t2, i2, s2 = t2, e2) {
|
|
||||||
if (i2 === T) return i2;
|
|
||||||
let h2 = void 0 !== e2 ? s2._$Co?.[e2] : s2._$Cl;
|
|
||||||
const o2 = c(i2) ? void 0 : i2._$litDirective$;
|
|
||||||
return h2?.constructor !== o2 && (h2?._$AO?.(false), void 0 === o2 ? h2 = void 0 : (h2 = new o2(t2), h2._$AT(t2, s2, e2)), void 0 !== e2 ? (s2._$Co ??= [])[e2] = h2 : s2._$Cl = h2), void 0 !== h2 && (i2 = S(t2, h2._$AS(t2, i2.values), h2, e2)), i2;
|
|
||||||
}
|
|
||||||
class M {
|
|
||||||
constructor(t2, i2) {
|
|
||||||
this._$AV = [], this._$AN = void 0, this._$AD = t2, this._$AM = i2;
|
|
||||||
}
|
|
||||||
get parentNode() {
|
|
||||||
return this._$AM.parentNode;
|
|
||||||
}
|
|
||||||
get _$AU() {
|
|
||||||
return this._$AM._$AU;
|
|
||||||
}
|
|
||||||
u(t2) {
|
|
||||||
const { el: { content: i2 }, parts: s2 } = this._$AD, e2 = (t2?.creationScope ?? r).importNode(i2, true);
|
|
||||||
C.currentNode = e2;
|
|
||||||
let h2 = C.nextNode(), o2 = 0, n3 = 0, l2 = s2[0];
|
|
||||||
for (; void 0 !== l2; ) {
|
|
||||||
if (o2 === l2.index) {
|
|
||||||
let i3;
|
|
||||||
2 === l2.type ? i3 = new R(h2, h2.nextSibling, this, t2) : 1 === l2.type ? i3 = new l2.ctor(h2, l2.name, l2.strings, this, t2) : 6 === l2.type && (i3 = new z(h2, this, t2)), this._$AV.push(i3), l2 = s2[++n3];
|
|
||||||
}
|
|
||||||
o2 !== l2?.index && (h2 = C.nextNode(), o2++);
|
|
||||||
}
|
|
||||||
return C.currentNode = r, e2;
|
|
||||||
}
|
|
||||||
p(t2) {
|
|
||||||
let i2 = 0;
|
|
||||||
for (const s2 of this._$AV) void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class R {
|
|
||||||
get _$AU() {
|
|
||||||
return this._$AM?._$AU ?? this._$Cv;
|
|
||||||
}
|
|
||||||
constructor(t2, i2, s2, e2) {
|
|
||||||
this.type = 2, this._$AH = E, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cv = e2?.isConnected ?? true;
|
|
||||||
}
|
|
||||||
get parentNode() {
|
|
||||||
let t2 = this._$AA.parentNode;
|
|
||||||
const i2 = this._$AM;
|
|
||||||
return void 0 !== i2 && 11 === t2?.nodeType && (t2 = i2.parentNode), t2;
|
|
||||||
}
|
|
||||||
get startNode() {
|
|
||||||
return this._$AA;
|
|
||||||
}
|
|
||||||
get endNode() {
|
|
||||||
return this._$AB;
|
|
||||||
}
|
|
||||||
_$AI(t2, i2 = this) {
|
|
||||||
t2 = S(this, t2, i2), c(t2) ? t2 === E || null == t2 || "" === t2 ? (this._$AH !== E && this._$AR(), this._$AH = E) : t2 !== this._$AH && t2 !== T && this._(t2) : void 0 !== t2._$litType$ ? this.$(t2) : void 0 !== t2.nodeType ? this.T(t2) : u(t2) ? this.k(t2) : this._(t2);
|
|
||||||
}
|
|
||||||
O(t2) {
|
|
||||||
return this._$AA.parentNode.insertBefore(t2, this._$AB);
|
|
||||||
}
|
|
||||||
T(t2) {
|
|
||||||
this._$AH !== t2 && (this._$AR(), this._$AH = this.O(t2));
|
|
||||||
}
|
|
||||||
_(t2) {
|
|
||||||
this._$AH !== E && c(this._$AH) ? this._$AA.nextSibling.data = t2 : this.T(r.createTextNode(t2)), this._$AH = t2;
|
|
||||||
}
|
|
||||||
$(t2) {
|
|
||||||
const { values: i2, _$litType$: s2 } = t2, e2 = "number" == typeof s2 ? this._$AC(t2) : (void 0 === s2.el && (s2.el = N.createElement(P(s2.h, s2.h[0]), this.options)), s2);
|
|
||||||
if (this._$AH?._$AD === e2) this._$AH.p(i2);
|
|
||||||
else {
|
|
||||||
const t3 = new M(e2, this), s3 = t3.u(this.options);
|
|
||||||
t3.p(i2), this.T(s3), this._$AH = t3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_$AC(t2) {
|
|
||||||
let i2 = A.get(t2.strings);
|
|
||||||
return void 0 === i2 && A.set(t2.strings, i2 = new N(t2)), i2;
|
|
||||||
}
|
|
||||||
k(t2) {
|
|
||||||
a(this._$AH) || (this._$AH = [], this._$AR());
|
|
||||||
const i2 = this._$AH;
|
|
||||||
let s2, e2 = 0;
|
|
||||||
for (const h2 of t2) e2 === i2.length ? i2.push(s2 = new R(this.O(l()), this.O(l()), this, this.options)) : s2 = i2[e2], s2._$AI(h2), e2++;
|
|
||||||
e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2);
|
|
||||||
}
|
|
||||||
_$AR(t2 = this._$AA.nextSibling, i2) {
|
|
||||||
for (this._$AP?.(false, true, i2); t2 !== this._$AB; ) {
|
|
||||||
const i3 = t2.nextSibling;
|
|
||||||
t2.remove(), t2 = i3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setConnected(t2) {
|
|
||||||
void 0 === this._$AM && (this._$Cv = t2, this._$AP?.(t2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class k {
|
|
||||||
get tagName() {
|
|
||||||
return this.element.tagName;
|
|
||||||
}
|
|
||||||
get _$AU() {
|
|
||||||
return this._$AM._$AU;
|
|
||||||
}
|
|
||||||
constructor(t2, i2, s2, e2, h2) {
|
|
||||||
this.type = 1, this._$AH = E, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = h2, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = E;
|
|
||||||
}
|
|
||||||
_$AI(t2, i2 = this, s2, e2) {
|
|
||||||
const h2 = this.strings;
|
|
||||||
let o2 = false;
|
|
||||||
if (void 0 === h2) t2 = S(this, t2, i2, 0), o2 = !c(t2) || t2 !== this._$AH && t2 !== T, o2 && (this._$AH = t2);
|
|
||||||
else {
|
|
||||||
const e3 = t2;
|
|
||||||
let n3, r2;
|
|
||||||
for (t2 = h2[0], n3 = 0; n3 < h2.length - 1; n3++) r2 = S(this, e3[s2 + n3], i2, n3), r2 === T && (r2 = this._$AH[n3]), o2 ||= !c(r2) || r2 !== this._$AH[n3], r2 === E ? t2 = E : t2 !== E && (t2 += (r2 ?? "") + h2[n3 + 1]), this._$AH[n3] = r2;
|
|
||||||
}
|
|
||||||
o2 && !e2 && this.j(t2);
|
|
||||||
}
|
|
||||||
j(t2) {
|
|
||||||
t2 === E ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t2 ?? "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class H extends k {
|
|
||||||
constructor() {
|
|
||||||
super(...arguments), this.type = 3;
|
|
||||||
}
|
|
||||||
j(t2) {
|
|
||||||
this.element[this.name] = t2 === E ? void 0 : t2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class I extends k {
|
|
||||||
constructor() {
|
|
||||||
super(...arguments), this.type = 4;
|
|
||||||
}
|
|
||||||
j(t2) {
|
|
||||||
this.element.toggleAttribute(this.name, !!t2 && t2 !== E);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class L extends k {
|
|
||||||
constructor(t2, i2, s2, e2, h2) {
|
|
||||||
super(t2, i2, s2, e2, h2), this.type = 5;
|
|
||||||
}
|
|
||||||
_$AI(t2, i2 = this) {
|
|
||||||
if ((t2 = S(this, t2, i2, 0) ?? E) === T) return;
|
|
||||||
const s2 = this._$AH, e2 = t2 === E && s2 !== E || t2.capture !== s2.capture || t2.once !== s2.once || t2.passive !== s2.passive, h2 = t2 !== E && (s2 === E || e2);
|
|
||||||
e2 && this.element.removeEventListener(this.name, this, s2), h2 && this.element.addEventListener(this.name, this, t2), this._$AH = t2;
|
|
||||||
}
|
|
||||||
handleEvent(t2) {
|
|
||||||
"function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t2) : this._$AH.handleEvent(t2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class z {
|
|
||||||
constructor(t2, i2, s2) {
|
|
||||||
this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s2;
|
|
||||||
}
|
|
||||||
get _$AU() {
|
|
||||||
return this._$AM._$AU;
|
|
||||||
}
|
|
||||||
_$AI(t2) {
|
|
||||||
S(this, t2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const j = t.litHtmlPolyfillSupport;
|
|
||||||
j?.(N, R), (t.litHtmlVersions ??= []).push("3.3.1");
|
|
||||||
const B = (t2, i2, s2) => {
|
|
||||||
const e2 = s2?.renderBefore ?? i2;
|
|
||||||
let h2 = e2._$litPart$;
|
|
||||||
if (void 0 === h2) {
|
|
||||||
const t3 = s2?.renderBefore ?? null;
|
|
||||||
e2._$litPart$ = h2 = new R(i2.insertBefore(l(), t3), t3, void 0, s2 ?? {});
|
|
||||||
}
|
|
||||||
return h2._$AI(t2), h2;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2017 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const s = globalThis;
|
|
||||||
class i extends y$1 {
|
|
||||||
constructor() {
|
|
||||||
super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
|
|
||||||
}
|
|
||||||
createRenderRoot() {
|
|
||||||
const t2 = super.createRenderRoot();
|
|
||||||
return this.renderOptions.renderBefore ??= t2.firstChild, t2;
|
|
||||||
}
|
|
||||||
update(t2) {
|
|
||||||
const r2 = this.render();
|
|
||||||
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t2), this._$Do = B(r2, this.renderRoot, this.renderOptions);
|
|
||||||
}
|
|
||||||
connectedCallback() {
|
|
||||||
super.connectedCallback(), this._$Do?.setConnected(true);
|
|
||||||
}
|
|
||||||
disconnectedCallback() {
|
|
||||||
super.disconnectedCallback(), this._$Do?.setConnected(false);
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
return T;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i._$litElement$ = true, i["finalized"] = true, s.litElementHydrateSupport?.({ LitElement: i });
|
|
||||||
const o = s.litElementPolyfillSupport;
|
|
||||||
o?.({ LitElement: i });
|
|
||||||
(s.litElementVersions ??= []).push("4.2.1");
|
|
||||||
export {
|
|
||||||
E,
|
|
||||||
b,
|
|
||||||
f$1 as f,
|
|
||||||
i,
|
|
||||||
u$1 as u,
|
|
||||||
x
|
|
||||||
};
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
import { f, u } from "./lit-DKg0et_P.mjs";
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2017 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const t = (t2) => (e, o2) => {
|
|
||||||
void 0 !== o2 ? o2.addInitializer((() => {
|
|
||||||
customElements.define(t2, e);
|
|
||||||
})) : customElements.define(t2, e);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2017 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const o = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f }, r = (t2 = o, e, r2) => {
|
|
||||||
const { kind: n2, metadata: i } = r2;
|
|
||||||
let s = globalThis.litPropertyMetadata.get(i);
|
|
||||||
if (void 0 === s && globalThis.litPropertyMetadata.set(i, s = /* @__PURE__ */ new Map()), "setter" === n2 && ((t2 = Object.create(t2)).wrapped = true), s.set(r2.name, t2), "accessor" === n2) {
|
|
||||||
const { name: o2 } = r2;
|
|
||||||
return { set(r3) {
|
|
||||||
const n3 = e.get.call(this);
|
|
||||||
e.set.call(this, r3), this.requestUpdate(o2, n3, t2);
|
|
||||||
}, init(e2) {
|
|
||||||
return void 0 !== e2 && this.C(o2, void 0, t2, e2), e2;
|
|
||||||
} };
|
|
||||||
}
|
|
||||||
if ("setter" === n2) {
|
|
||||||
const { name: o2 } = r2;
|
|
||||||
return function(r3) {
|
|
||||||
const n3 = this[o2];
|
|
||||||
e.call(this, r3), this.requestUpdate(o2, n3, t2);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
throw Error("Unsupported decorator location: " + n2);
|
|
||||||
};
|
|
||||||
function n(t2) {
|
|
||||||
return (e, o2) => "object" == typeof o2 ? r(t2, e, o2) : ((t3, e2, o3) => {
|
|
||||||
const r2 = e2.hasOwnProperty(o3);
|
|
||||||
return e2.constructor.createProperty(o3, t3), r2 ? Object.getOwnPropertyDescriptor(e2, o3) : void 0;
|
|
||||||
})(t2, e, o2);
|
|
||||||
}
|
|
||||||
export {
|
|
||||||
n,
|
|
||||||
t
|
|
||||||
};
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
import { E } from "./lit-DKg0et_P.mjs";
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2020 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const f$1 = (o2) => void 0 === o2.strings;
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2017 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const t = { CHILD: 2 }, e$1 = (t2) => (...e2) => ({ _$litDirective$: t2, values: e2 });
|
|
||||||
class i {
|
|
||||||
constructor(t2) {
|
|
||||||
}
|
|
||||||
get _$AU() {
|
|
||||||
return this._$AM._$AU;
|
|
||||||
}
|
|
||||||
_$AT(t2, e2, i2) {
|
|
||||||
this._$Ct = t2, this._$AM = e2, this._$Ci = i2;
|
|
||||||
}
|
|
||||||
_$AS(t2, e2) {
|
|
||||||
return this.update(t2, e2);
|
|
||||||
}
|
|
||||||
update(t2, e2) {
|
|
||||||
return this.render(...e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2017 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const s = (i2, t2) => {
|
|
||||||
const e2 = i2._$AN;
|
|
||||||
if (void 0 === e2) return false;
|
|
||||||
for (const i3 of e2) i3._$AO?.(t2, false), s(i3, t2);
|
|
||||||
return true;
|
|
||||||
}, o$1 = (i2) => {
|
|
||||||
let t2, e2;
|
|
||||||
do {
|
|
||||||
if (void 0 === (t2 = i2._$AM)) break;
|
|
||||||
e2 = t2._$AN, e2.delete(i2), i2 = t2;
|
|
||||||
} while (0 === e2?.size);
|
|
||||||
}, r = (i2) => {
|
|
||||||
for (let t2; t2 = i2._$AM; i2 = t2) {
|
|
||||||
let e2 = t2._$AN;
|
|
||||||
if (void 0 === e2) t2._$AN = e2 = /* @__PURE__ */ new Set();
|
|
||||||
else if (e2.has(i2)) break;
|
|
||||||
e2.add(i2), c(t2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
function h$1(i2) {
|
|
||||||
void 0 !== this._$AN ? (o$1(this), this._$AM = i2, r(this)) : this._$AM = i2;
|
|
||||||
}
|
|
||||||
function n$1(i2, t2 = false, e2 = 0) {
|
|
||||||
const r2 = this._$AH, h2 = this._$AN;
|
|
||||||
if (void 0 !== h2 && 0 !== h2.size) if (t2) if (Array.isArray(r2)) for (let i3 = e2; i3 < r2.length; i3++) s(r2[i3], false), o$1(r2[i3]);
|
|
||||||
else null != r2 && (s(r2, false), o$1(r2));
|
|
||||||
else s(this, i2);
|
|
||||||
}
|
|
||||||
const c = (i2) => {
|
|
||||||
i2.type == t.CHILD && (i2._$AP ??= n$1, i2._$AQ ??= h$1);
|
|
||||||
};
|
|
||||||
class f extends i {
|
|
||||||
constructor() {
|
|
||||||
super(...arguments), this._$AN = void 0;
|
|
||||||
}
|
|
||||||
_$AT(i2, t2, e2) {
|
|
||||||
super._$AT(i2, t2, e2), r(this), this.isConnected = i2._$AU;
|
|
||||||
}
|
|
||||||
_$AO(i2, t2 = true) {
|
|
||||||
i2 !== this.isConnected && (this.isConnected = i2, i2 ? this.reconnected?.() : this.disconnected?.()), t2 && (s(this, i2), o$1(this));
|
|
||||||
}
|
|
||||||
setValue(t2) {
|
|
||||||
if (f$1(this._$Ct)) this._$Ct._$AI(t2, this);
|
|
||||||
else {
|
|
||||||
const i2 = [...this._$Ct._$AH];
|
|
||||||
i2[this._$Ci] = t2, this._$Ct._$AI(i2, this, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
disconnected() {
|
|
||||||
}
|
|
||||||
reconnected() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright 2020 Google LLC
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
const e = () => new h();
|
|
||||||
class h {
|
|
||||||
}
|
|
||||||
const o = /* @__PURE__ */ new WeakMap(), n = e$1(class extends f {
|
|
||||||
render(i2) {
|
|
||||||
return E;
|
|
||||||
}
|
|
||||||
update(i2, [s2]) {
|
|
||||||
const e2 = s2 !== this.G;
|
|
||||||
return e2 && void 0 !== this.G && this.rt(void 0), (e2 || this.lt !== this.ct) && (this.G = s2, this.ht = i2.options?.host, this.rt(this.ct = i2.element)), E;
|
|
||||||
}
|
|
||||||
rt(t2) {
|
|
||||||
if (this.isConnected || (t2 = void 0), "function" == typeof this.G) {
|
|
||||||
const i2 = this.ht ?? globalThis;
|
|
||||||
let s2 = o.get(i2);
|
|
||||||
void 0 === s2 && (s2 = /* @__PURE__ */ new WeakMap(), o.set(i2, s2)), void 0 !== s2.get(this.G) && this.G.call(this.ht, void 0), s2.set(this.G, t2), void 0 !== t2 && this.G.call(this.ht, t2);
|
|
||||||
} else this.G.value = t2;
|
|
||||||
}
|
|
||||||
get lt() {
|
|
||||||
return "function" == typeof this.G ? o.get(this.ht ?? globalThis)?.get(this.G) : this.G?.value;
|
|
||||||
}
|
|
||||||
disconnected() {
|
|
||||||
this.lt === this.ct && this.rt(void 0);
|
|
||||||
}
|
|
||||||
reconnected() {
|
|
||||||
this.rt(this.ct);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
export {
|
|
||||||
e,
|
|
||||||
n
|
|
||||||
};
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
let timezonesPromise = null;
|
|
||||||
async function getTimezones() {
|
|
||||||
timezonesPromise ||= new Promise(async (resolve, reject) => {
|
|
||||||
try {
|
|
||||||
let response = await fetch("/frontend/_timezones.json");
|
|
||||||
resolve(await response.json());
|
|
||||||
} catch (e) {
|
|
||||||
reject(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return await timezonesPromise;
|
|
||||||
}
|
|
||||||
export {
|
|
||||||
getTimezones as g
|
|
||||||
};
|
|
||||||
@@ -5,14 +5,7 @@
|
|||||||
<script>
|
<script>
|
||||||
window.rusticalUser = JSON.parse(document.querySelector('#data-rustical-user').innerHTML)
|
window.rusticalUser = JSON.parse(document.querySelector('#data-rustical-user').innerHTML)
|
||||||
</script>
|
</script>
|
||||||
<script type="module" src="/frontend/assets/js/create-birthday-calendar-form.mjs" async></script>
|
<script type="module" src="/frontend/assets/js/bundle.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/import-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/edit-addressbook-form.mjs" async></script>
|
|
||||||
<script type="module" src="/frontend/assets/js/import-addressbook-form.mjs" async></script>
|
|
||||||
<script type="module" src="/frontend/assets/js/delete-button.mjs" async></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block header_center %}
|
{% block header_center %}
|
||||||
<nav class="header-center">
|
<nav class="header-center">
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ use axum::{
|
|||||||
extract::Path,
|
extract::Path,
|
||||||
response::{Html, IntoResponse, Response},
|
response::{Html, IntoResponse, Response},
|
||||||
};
|
};
|
||||||
use axum_extra::{TypedHeader, extract::Host};
|
use axum_extra::TypedHeader;
|
||||||
use chrono::{Duration, Utc};
|
use chrono::{Duration, Utc};
|
||||||
use headers::UserAgent;
|
use headers::{Host, UserAgent};
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use rustical_store::auth::{AuthenticationProvider, Principal};
|
use rustical_store::auth::{AuthenticationProvider, Principal};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -21,7 +21,7 @@ use tracing::instrument;
|
|||||||
pub async fn post_nextcloud_login(
|
pub async fn post_nextcloud_login(
|
||||||
Extension(state): Extension<Arc<NextcloudFlows>>,
|
Extension(state): Extension<Arc<NextcloudFlows>>,
|
||||||
TypedHeader(user_agent): TypedHeader<UserAgent>,
|
TypedHeader(user_agent): TypedHeader<UserAgent>,
|
||||||
Host(host): Host,
|
TypedHeader(host): TypedHeader<Host>,
|
||||||
) -> Json<NextcloudLoginResponse> {
|
) -> Json<NextcloudLoginResponse> {
|
||||||
let flow_id = uuid::Uuid::new_v4().to_string();
|
let flow_id = uuid::Uuid::new_v4().to_string();
|
||||||
let token = uuid::Uuid::new_v4().to_string();
|
let token = uuid::Uuid::new_v4().to_string();
|
||||||
@@ -150,7 +150,7 @@ pub async fn post_nextcloud_flow(
|
|||||||
user: Principal,
|
user: Principal,
|
||||||
Extension(state): Extension<Arc<NextcloudFlows>>,
|
Extension(state): Extension<Arc<NextcloudFlows>>,
|
||||||
Path(flow_id): Path<String>,
|
Path(flow_id): Path<String>,
|
||||||
Host(host): Host,
|
TypedHeader(host): TypedHeader<Host>,
|
||||||
Form(form): Form<NextcloudAuthorizeForm>,
|
Form(form): Form<NextcloudAuthorizeForm>,
|
||||||
) -> Result<Response, rustical_store::Error> {
|
) -> Result<Response, rustical_store::Error> {
|
||||||
if let Some(flow) = state.flows.write().await.get_mut(&flow_id) {
|
if let Some(flow) = state.flows.write().await.get_mut(&flow_id) {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use axum::{
|
|||||||
extract::Path,
|
extract::Path,
|
||||||
response::{IntoResponse, Redirect, Response},
|
response::{IntoResponse, Redirect, Response},
|
||||||
};
|
};
|
||||||
use axum_extra::extract::Host;
|
use axum_extra::TypedHeader;
|
||||||
use headers::{ContentType, HeaderMapExt};
|
use headers::{ContentType, HeaderMapExt, Host};
|
||||||
use http::{HeaderValue, StatusCode, header};
|
use http::{HeaderValue, StatusCode, header};
|
||||||
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
||||||
use rand::{Rng, distr::Alphanumeric};
|
use rand::{Rng, distr::Alphanumeric};
|
||||||
@@ -50,7 +50,7 @@ pub async fn route_post_app_token<AP: AuthenticationProvider>(
|
|||||||
user: Principal,
|
user: Principal,
|
||||||
Extension(auth_provider): Extension<Arc<AP>>,
|
Extension(auth_provider): Extension<Arc<AP>>,
|
||||||
Path(user_id): Path<String>,
|
Path(user_id): Path<String>,
|
||||||
Host(hostname): Host,
|
TypedHeader(host): TypedHeader<Host>,
|
||||||
Form(PostAppTokenForm { apple, name }): Form<PostAppTokenForm>,
|
Form(PostAppTokenForm { apple, name }): Form<PostAppTokenForm>,
|
||||||
) -> Result<Response, rustical_store::Error> {
|
) -> Result<Response, rustical_store::Error> {
|
||||||
assert!(!name.is_empty());
|
assert!(!name.is_empty());
|
||||||
@@ -66,10 +66,10 @@ pub async fn route_post_app_token<AP: AuthenticationProvider>(
|
|||||||
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, &host),
|
||||||
hostname: hostname.clone(),
|
hostname: host.to_string(),
|
||||||
caldav_principal_url: format!("https://{hostname}/caldav-compat/principal/{user_id}"),
|
caldav_principal_url: format!("https://{host}/caldav-compat/principal/{user_id}"),
|
||||||
carddav_principal_url: format!("https://{hostname}/carddav/principal/{user_id}"),
|
carddav_principal_url: format!("https://{host}/carddav/principal/{user_id}"),
|
||||||
user: user.id.clone(),
|
user: user.id.clone(),
|
||||||
token,
|
token,
|
||||||
caldav_profile_uuid: Uuid::new_v4(),
|
caldav_profile_uuid: Uuid::new_v4(),
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use crate::{FrontendConfig, OidcConfig, pages::DefaultLayoutData};
|
use crate::{FrontendConfig, OidcConfig, pages::DefaultLayoutData};
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
use askama_web::WebTemplate;
|
use askama_web::WebTemplate;
|
||||||
@@ -8,10 +6,12 @@ use axum::{
|
|||||||
extract::Query,
|
extract::Query,
|
||||||
response::{IntoResponse, Redirect, Response},
|
response::{IntoResponse, Redirect, Response},
|
||||||
};
|
};
|
||||||
use axum_extra::extract::Host;
|
use axum_extra::TypedHeader;
|
||||||
|
use headers::Host;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use rustical_store::auth::AuthenticationProvider;
|
use rustical_store::auth::AuthenticationProvider;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use std::sync::Arc;
|
||||||
use tower_sessions::Session;
|
use tower_sessions::Session;
|
||||||
use tracing::{instrument, warn};
|
use tracing::{instrument, warn};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@@ -73,7 +73,7 @@ pub async fn route_post_login<AP: AuthenticationProvider>(
|
|||||||
Extension(auth_provider): Extension<Arc<AP>>,
|
Extension(auth_provider): Extension<Arc<AP>>,
|
||||||
Extension(config): Extension<FrontendConfig>,
|
Extension(config): Extension<FrontendConfig>,
|
||||||
session: Session,
|
session: Session,
|
||||||
Host(host): Host,
|
TypedHeader(host): TypedHeader<Host>,
|
||||||
Form(PostLoginForm {
|
Form(PostLoginForm {
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use crate::pages::user::{Section, UserPage};
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
use askama_web::WebTemplate;
|
use askama_web::WebTemplate;
|
||||||
use axum::{
|
use axum::{
|
||||||
@@ -7,13 +8,11 @@ use axum::{
|
|||||||
extract::Path,
|
extract::Path,
|
||||||
response::{IntoResponse, Redirect},
|
response::{IntoResponse, Redirect},
|
||||||
};
|
};
|
||||||
use axum_extra::{TypedHeader, extract::Host};
|
use axum_extra::TypedHeader;
|
||||||
use headers::UserAgent;
|
use headers::{Host, UserAgent};
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use rustical_store::auth::{AppToken, AuthenticationProvider, Principal};
|
use rustical_store::auth::{AppToken, AuthenticationProvider, Principal};
|
||||||
|
|
||||||
use crate::pages::user::{Section, UserPage};
|
|
||||||
|
|
||||||
impl Section for ProfileSection {
|
impl Section for ProfileSection {
|
||||||
fn name() -> &'static str {
|
fn name() -> &'static str {
|
||||||
"profile"
|
"profile"
|
||||||
@@ -33,7 +32,7 @@ pub async fn route_user_named<AP: AuthenticationProvider>(
|
|||||||
Path(user_id): Path<String>,
|
Path(user_id): Path<String>,
|
||||||
Extension(auth_provider): Extension<Arc<AP>>,
|
Extension(auth_provider): Extension<Arc<AP>>,
|
||||||
TypedHeader(user_agent): TypedHeader<UserAgent>,
|
TypedHeader(user_agent): TypedHeader<UserAgent>,
|
||||||
Host(host): Host,
|
TypedHeader(host): TypedHeader<Host>,
|
||||||
user: Principal,
|
user: Principal,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
if user_id != user.id {
|
if user_id != user.id {
|
||||||
@@ -41,7 +40,10 @@ pub async fn route_user_named<AP: AuthenticationProvider>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let is_apple = user_agent.as_str().contains("Apple") || user_agent.as_str().contains("Mac OS");
|
let is_apple = user_agent.as_str().contains("Apple") || user_agent.as_str().contains("Mac OS");
|
||||||
let davx5_hostname = user_agent.as_str().contains("Android").then_some(host);
|
let davx5_hostname = user_agent
|
||||||
|
.as_str()
|
||||||
|
.contains("Android")
|
||||||
|
.then_some(host.to_string());
|
||||||
|
|
||||||
UserPage {
|
UserPage {
|
||||||
section: ProfileSection {
|
section: ProfileSection {
|
||||||
|
|||||||
@@ -21,3 +21,5 @@ rrule.workspace = true
|
|||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
sha2.workspace = true
|
sha2.workspace = true
|
||||||
axum.workspace = true
|
axum.workspace = true
|
||||||
|
rstest.workspace = true
|
||||||
|
similar-asserts.workspace = true
|
||||||
|
|||||||
@@ -1,59 +1,45 @@
|
|||||||
use crate::{CalDateTime, LOCAL_DATE};
|
|
||||||
use crate::{CalendarObject, Error};
|
use crate::{CalendarObject, Error};
|
||||||
use chrono::Datelike;
|
use chrono::{NaiveDate, Utc};
|
||||||
use ical::generator::Emitter;
|
use ical::component::{
|
||||||
use ical::parser::{
|
CalendarInnerDataBuilder, IcalAlarmBuilder, IcalCalendarObjectBuilder, IcalEventBuilder,
|
||||||
Component,
|
|
||||||
vcard::{self, component::VcardContact},
|
|
||||||
};
|
};
|
||||||
|
use ical::generator::Emitter;
|
||||||
|
use ical::parser::vcard::{self, component::VcardContact};
|
||||||
|
use ical::parser::{
|
||||||
|
Calscale, ComponentMut, IcalCALSCALEProperty, IcalDTENDProperty, IcalDTSTAMPProperty,
|
||||||
|
IcalDTSTARTProperty, IcalPRODIDProperty, IcalRRULEProperty, IcalSUMMARYProperty,
|
||||||
|
IcalUIDProperty, IcalVERSIONProperty, IcalVersion, VcardANNIVERSARYProperty, VcardBDAYProperty,
|
||||||
|
VcardFNProperty,
|
||||||
|
};
|
||||||
|
use ical::property::ContentLine;
|
||||||
|
use ical::types::{CalDate, PartialDate};
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use std::{collections::HashMap, io::BufReader};
|
use std::collections::HashMap;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AddressObject {
|
pub struct AddressObject {
|
||||||
id: String,
|
|
||||||
vcf: String,
|
vcf: String,
|
||||||
vcard: VcardContact,
|
vcard: VcardContact,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<VcardContact> for AddressObject {
|
impl From<VcardContact> for AddressObject {
|
||||||
type Error = Error;
|
fn from(vcard: VcardContact) -> Self {
|
||||||
|
|
||||||
fn try_from(vcard: VcardContact) -> Result<Self, Self::Error> {
|
|
||||||
let uid = vcard
|
|
||||||
.get_uid()
|
|
||||||
.ok_or_else(|| Error::InvalidData("missing UID".to_owned()))?
|
|
||||||
.to_owned();
|
|
||||||
let vcf = vcard.generate();
|
let vcf = vcard.generate();
|
||||||
Ok(Self {
|
Self { vcf, vcard }
|
||||||
vcf,
|
|
||||||
vcard,
|
|
||||||
id: uid,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddressObject {
|
impl AddressObject {
|
||||||
pub fn from_vcf(id: String, vcf: String) -> Result<Self, Error> {
|
pub fn from_vcf(vcf: String) -> Result<Self, Error> {
|
||||||
let mut parser = vcard::VcardParser::new(BufReader::new(vcf.as_bytes()));
|
let parser = vcard::VcardParser::from_slice(vcf.as_bytes());
|
||||||
let vcard = parser.next().ok_or(Error::MissingContact)??;
|
let vcard = parser.expect_one()?;
|
||||||
if parser.next().is_some() {
|
Ok(Self { vcf, vcard })
|
||||||
return Err(Error::InvalidData(
|
|
||||||
"multiple vcards, only one allowed".to_owned(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
Ok(Self { id, vcf, vcard })
|
|
||||||
}
|
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
pub fn get_id(&self) -> &str {
|
|
||||||
&self.id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_etag(&self) -> String {
|
pub fn get_etag(&self) -> String {
|
||||||
let mut hasher = Sha256::new();
|
let mut hasher = Sha256::new();
|
||||||
hasher.update(self.get_id());
|
|
||||||
hasher.update(self.get_vcf());
|
hasher.update(self.get_vcf());
|
||||||
format!("\"{:x}\"", hasher.finalize())
|
format!("\"{:x}\"", hasher.finalize())
|
||||||
}
|
}
|
||||||
@@ -63,120 +49,119 @@ impl AddressObject {
|
|||||||
&self.vcf
|
&self.vcf
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
fn get_significant_date_object(
|
||||||
pub fn get_anniversary(&self) -> Option<(CalDateTime, bool)> {
|
&self,
|
||||||
let prop = self.vcard.get_property("ANNIVERSARY")?.value.as_deref()?;
|
date: &PartialDate,
|
||||||
CalDateTime::parse_vcard(prop).ok()
|
summary_prefix: &str,
|
||||||
}
|
suffix: &str,
|
||||||
|
) -> Result<Option<CalendarObject>, Error> {
|
||||||
|
let Some(uid) = self.vcard.get_uid() else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
let uid = format!("{uid}{suffix}");
|
||||||
|
let year = date.get_year();
|
||||||
|
let year_suffix = year.map(|year| format!(" {year}")).unwrap_or_default();
|
||||||
|
let Some(month) = date.get_month() else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
let Some(day) = date.get_day() else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
let Some(dtstart) = NaiveDate::from_ymd_opt(year.unwrap_or(1900), month, day) else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
let start_date = CalDate(dtstart, ical::types::Timezone::Local);
|
||||||
|
let Some(end_date) = start_date.succ_opt() else {
|
||||||
|
// start_date is MAX_DATE, this should never happen but FAPP also not raise an error
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
let Some(VcardFNProperty(fullname, _)) = self.vcard.full_name.first() else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
|
let summary = format!("{summary_prefix} {fullname}{year_suffix}");
|
||||||
|
|
||||||
#[must_use]
|
let event = IcalEventBuilder {
|
||||||
pub fn get_birthday(&self) -> Option<(CalDateTime, bool)> {
|
properties: vec![
|
||||||
let prop = self.vcard.get_property("BDAY")?.value.as_deref()?;
|
IcalDTSTAMPProperty(Utc::now().into(), vec![].into()).into(),
|
||||||
CalDateTime::parse_vcard(prop).ok()
|
IcalDTSTARTProperty(start_date.into(), vec![].into()).into(),
|
||||||
}
|
IcalDTENDProperty(end_date.into(), vec![].into()).into(),
|
||||||
|
IcalUIDProperty(uid, vec![].into()).into(),
|
||||||
|
IcalRRULEProperty(
|
||||||
|
rrule::RRule::from_str("FREQ=YEARLY").unwrap(),
|
||||||
|
vec![].into(),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
IcalSUMMARYProperty(summary.clone(), vec![].into()).into(),
|
||||||
|
ContentLine {
|
||||||
|
name: "TRANSP".to_owned(),
|
||||||
|
value: Some("TRANSPARENT".to_owned()),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
],
|
||||||
|
alarms: vec![IcalAlarmBuilder {
|
||||||
|
properties: vec![
|
||||||
|
ContentLine {
|
||||||
|
name: "TRIGGER".to_owned(),
|
||||||
|
value: Some("-PT0M".to_owned()),
|
||||||
|
params: vec![("VALUE".to_owned(), vec!["DURATION".to_owned()])].into(),
|
||||||
|
},
|
||||||
|
ContentLine {
|
||||||
|
name: "ACTION".to_owned(),
|
||||||
|
value: Some("DISPLAY".to_owned()),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
ContentLine {
|
||||||
|
name: "DESCRIPTION".to_owned(),
|
||||||
|
value: Some(summary),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
|
||||||
#[must_use]
|
Ok(Some(
|
||||||
pub fn get_full_name(&self) -> Option<&str> {
|
IcalCalendarObjectBuilder {
|
||||||
let prop = self.vcard.get_property("FN")?;
|
properties: vec![
|
||||||
prop.value.as_deref()
|
IcalVERSIONProperty(IcalVersion::Version2_0, vec![].into()).into(),
|
||||||
|
IcalCALSCALEProperty(Calscale::Gregorian, vec![].into()).into(),
|
||||||
|
IcalPRODIDProperty(
|
||||||
|
"-//github.com/lennart-k/rustical birthday calendar//EN".to_owned(),
|
||||||
|
vec![].into(),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
],
|
||||||
|
inner: Some(CalendarInnerDataBuilder::Event(vec![event])),
|
||||||
|
vtimezones: HashMap::default(),
|
||||||
|
}
|
||||||
|
.build(None)?
|
||||||
|
.into(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_anniversary_object(&self) -> Result<Option<CalendarObject>, Error> {
|
pub fn get_anniversary_object(&self) -> Result<Option<CalendarObject>, Error> {
|
||||||
Ok(
|
let Some(VcardANNIVERSARYProperty(anniversary, _)) = &self.vcard.anniversary else {
|
||||||
if let Some((anniversary, contains_year)) = self.get_anniversary() {
|
return Ok(None);
|
||||||
let Some(fullname) = self.get_full_name() else {
|
};
|
||||||
|
let Some(date) = &anniversary.date else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
let anniversary = anniversary.date();
|
|
||||||
let year = contains_year.then_some(anniversary.year());
|
|
||||||
let anniversary_start = anniversary.format(LOCAL_DATE);
|
|
||||||
let anniversary_end = anniversary
|
|
||||||
.succ_opt()
|
|
||||||
.unwrap_or(anniversary)
|
|
||||||
.format(LOCAL_DATE);
|
|
||||||
let uid = format!("{}-anniversary", self.get_id());
|
|
||||||
|
|
||||||
let year_suffix = year.map(|year| format!(" ({year})")).unwrap_or_default();
|
self.get_significant_date_object(date, "💍", "-anniversary")
|
||||||
Some(CalendarObject::from_ics(
|
|
||||||
format!(
|
|
||||||
r"BEGIN:VCALENDAR
|
|
||||||
VERSION:2.0
|
|
||||||
CALSCALE:GREGORIAN
|
|
||||||
PRODID:-//github.com/lennart-k/rustical birthday calendar//EN
|
|
||||||
BEGIN:VEVENT
|
|
||||||
DTSTART;VALUE=DATE:{anniversary_start}
|
|
||||||
DTEND;VALUE=DATE:{anniversary_end}
|
|
||||||
UID:{uid}
|
|
||||||
RRULE:FREQ=YEARLY
|
|
||||||
SUMMARY:💍 {fullname}{year_suffix}
|
|
||||||
TRANSP:TRANSPARENT
|
|
||||||
BEGIN:VALARM
|
|
||||||
TRIGGER;VALUE=DURATION:-PT0M
|
|
||||||
ACTION:DISPLAY
|
|
||||||
DESCRIPTION:💍 {fullname}{year_suffix}
|
|
||||||
END:VALARM
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR",
|
|
||||||
),
|
|
||||||
None,
|
|
||||||
)?)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_birthday_object(&self) -> Result<Option<CalendarObject>, Error> {
|
pub fn get_birthday_object(&self) -> Result<Option<CalendarObject>, Error> {
|
||||||
Ok(
|
let Some(VcardBDAYProperty(bday, _)) = &self.vcard.birthday else {
|
||||||
if let Some((birthday, contains_year)) = self.get_birthday() {
|
return Ok(None);
|
||||||
let Some(fullname) = self.get_full_name() else {
|
};
|
||||||
|
let Some(date) = &bday.date else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
let birthday = birthday.date();
|
|
||||||
let year = contains_year.then_some(birthday.year());
|
|
||||||
let birthday_start = birthday.format(LOCAL_DATE);
|
|
||||||
let birthday_end = birthday.succ_opt().unwrap_or(birthday).format(LOCAL_DATE);
|
|
||||||
let uid = format!("{}-birthday", self.get_id());
|
|
||||||
|
|
||||||
let year_suffix = year.map(|year| format!(" ({year})")).unwrap_or_default();
|
self.get_significant_date_object(date, "🎂", "-birthday")
|
||||||
Some(CalendarObject::from_ics(
|
|
||||||
format!(
|
|
||||||
r"BEGIN:VCALENDAR
|
|
||||||
VERSION:2.0
|
|
||||||
CALSCALE:GREGORIAN
|
|
||||||
PRODID:-//github.com/lennart-k/rustical birthday calendar//EN
|
|
||||||
BEGIN:VEVENT
|
|
||||||
DTSTART;VALUE=DATE:{birthday_start}
|
|
||||||
DTEND;VALUE=DATE:{birthday_end}
|
|
||||||
UID:{uid}
|
|
||||||
RRULE:FREQ=YEARLY
|
|
||||||
SUMMARY:🎂 {fullname}{year_suffix}
|
|
||||||
TRANSP:TRANSPARENT
|
|
||||||
BEGIN:VALARM
|
|
||||||
TRIGGER;VALUE=DURATION:-PT0M
|
|
||||||
ACTION:DISPLAY
|
|
||||||
DESCRIPTION:🎂 {fullname}{year_suffix}
|
|
||||||
END:VALARM
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR",
|
|
||||||
),
|
|
||||||
None,
|
|
||||||
)?)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get significant dates associated with this address object
|
#[must_use]
|
||||||
pub fn get_significant_dates(&self) -> Result<HashMap<&'static str, CalendarObject>, Error> {
|
pub const fn get_vcard(&self) -> &VcardContact {
|
||||||
let mut out = HashMap::new();
|
&self.vcard
|
||||||
if let Some(birthday) = self.get_birthday_object()? {
|
|
||||||
out.insert("birthday", birthday);
|
|
||||||
}
|
|
||||||
if let Some(anniversary) = self.get_anniversary_object()? {
|
|
||||||
out.insert("anniversary", anniversary);
|
|
||||||
}
|
|
||||||
Ok(out)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
120
crates/ical/src/calendar_object.rs
Normal file
120
crates/ical/src/calendar_object.rs
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
use crate::Error;
|
||||||
|
use derive_more::Display;
|
||||||
|
use ical::IcalObjectParser;
|
||||||
|
use ical::component::CalendarInnerData;
|
||||||
|
use ical::component::IcalCalendarObject;
|
||||||
|
use ical::generator::Emitter;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Display)]
|
||||||
|
// specified in https://datatracker.ietf.org/doc/html/rfc5545#section-3.6
|
||||||
|
pub enum CalendarObjectType {
|
||||||
|
#[serde(rename = "VEVENT")]
|
||||||
|
Event = 0,
|
||||||
|
#[serde(rename = "VTODO")]
|
||||||
|
Todo = 1,
|
||||||
|
#[serde(rename = "VJOURNAL")]
|
||||||
|
Journal = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&IcalCalendarObject> for CalendarObjectType {
|
||||||
|
fn from(value: &IcalCalendarObject) -> Self {
|
||||||
|
match value.get_inner() {
|
||||||
|
CalendarInnerData::Event(_, _) => Self::Event,
|
||||||
|
CalendarInnerData::Todo(_, _) => Self::Todo,
|
||||||
|
CalendarInnerData::Journal(_, _) => Self::Journal,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CalendarObjectType {
|
||||||
|
#[must_use]
|
||||||
|
pub const fn as_str(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Self::Event => "VEVENT",
|
||||||
|
Self::Todo => "VTODO",
|
||||||
|
Self::Journal => "VJOURNAL",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl rustical_xml::ValueSerialize for CalendarObjectType {
|
||||||
|
fn serialize(&self) -> String {
|
||||||
|
self.as_str().to_owned()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl rustical_xml::ValueDeserialize for CalendarObjectType {
|
||||||
|
fn deserialize(val: &str) -> std::result::Result<Self, rustical_xml::XmlError> {
|
||||||
|
match <String as rustical_xml::ValueDeserialize>::deserialize(val)?.as_str() {
|
||||||
|
"VEVENT" => Ok(Self::Event),
|
||||||
|
"VTODO" => Ok(Self::Todo),
|
||||||
|
"VJOURNAL" => Ok(Self::Journal),
|
||||||
|
_ => Err(rustical_xml::XmlError::InvalidValue(
|
||||||
|
rustical_xml::ParseValueError::Other(format!(
|
||||||
|
"Invalid value '{val}', must be VEVENT, VTODO, or VJOURNAL"
|
||||||
|
)),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct CalendarObject {
|
||||||
|
inner: IcalCalendarObject,
|
||||||
|
ics: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CalendarObject {
|
||||||
|
pub fn from_ics(ics: String) -> Result<Self, Error> {
|
||||||
|
let parser = IcalObjectParser::from_slice(ics.as_bytes());
|
||||||
|
let inner = parser.expect_one()?;
|
||||||
|
|
||||||
|
Ok(Self { inner, ics })
|
||||||
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub const fn get_inner(&self) -> &IcalCalendarObject {
|
||||||
|
&self.inner
|
||||||
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn get_uid(&self) -> &str {
|
||||||
|
self.inner.get_uid()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn get_etag(&self) -> String {
|
||||||
|
let mut hasher = Sha256::new();
|
||||||
|
hasher.update(self.get_uid());
|
||||||
|
hasher.update(self.get_ics());
|
||||||
|
format!("\"{:x}\"", hasher.finalize())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn get_ics(&self) -> &str {
|
||||||
|
&self.ics
|
||||||
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn get_object_type(&self) -> CalendarObjectType {
|
||||||
|
(&self.inner).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<CalendarObject> for IcalCalendarObject {
|
||||||
|
fn from(value: CalendarObject) -> Self {
|
||||||
|
value.inner
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<IcalCalendarObject> for CalendarObject {
|
||||||
|
fn from(value: IcalCalendarObject) -> Self {
|
||||||
|
Self {
|
||||||
|
ics: value.generate(),
|
||||||
|
inner: value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
use axum::{http::StatusCode, response::IntoResponse};
|
|
||||||
|
|
||||||
use crate::CalDateTimeError;
|
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
|
|
||||||
pub enum Error {
|
|
||||||
#[error("Invalid ics/vcf input: {0}")]
|
|
||||||
InvalidData(String),
|
|
||||||
|
|
||||||
#[error("Missing calendar")]
|
|
||||||
MissingCalendar,
|
|
||||||
|
|
||||||
#[error("Missing contact")]
|
|
||||||
MissingContact,
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
ParserError(#[from] ical::parser::ParserError),
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
CalDateTimeError(#[from] CalDateTimeError),
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
RRuleError(#[from] rrule::RRuleError),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Error {
|
|
||||||
#[must_use]
|
|
||||||
pub const fn status_code(&self) -> StatusCode {
|
|
||||||
match self {
|
|
||||||
Self::InvalidData(_) | Self::MissingCalendar | Self::MissingContact => {
|
|
||||||
StatusCode::BAD_REQUEST
|
|
||||||
}
|
|
||||||
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IntoResponse for Error {
|
|
||||||
fn into_response(self) -> axum::response::Response {
|
|
||||||
(self.status_code(), self.to_string()).into_response()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,268 +0,0 @@
|
|||||||
use crate::CalDateTime;
|
|
||||||
use crate::Error;
|
|
||||||
use chrono::{DateTime, Duration, Utc};
|
|
||||||
use ical::parser::ComponentMut;
|
|
||||||
use ical::{generator::IcalEvent, parser::Component, property::Property};
|
|
||||||
use rrule::{RRule, RRuleSet};
|
|
||||||
use std::{collections::HashMap, str::FromStr};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
|
||||||
pub struct EventObject {
|
|
||||||
pub event: IcalEvent,
|
|
||||||
// If a timezone is None that means that in the VCALENDAR object there's a timezone defined
|
|
||||||
// with that name but its not from the Olson DB
|
|
||||||
pub timezones: HashMap<String, Option<chrono_tz::Tz>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EventObject {
|
|
||||||
#[must_use]
|
|
||||||
pub fn get_uid(&self) -> &str {
|
|
||||||
self.event.get_uid()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_dtstart(&self) -> Result<Option<CalDateTime>, Error> {
|
|
||||||
if let Some(dtstart) = self.event.get_dtstart() {
|
|
||||||
Ok(Some(CalDateTime::parse_prop(dtstart, &self.timezones)?))
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_dtend(&self) -> Result<Option<CalDateTime>, Error> {
|
|
||||||
if let Some(dtend) = self.event.get_dtend() {
|
|
||||||
Ok(Some(CalDateTime::parse_prop(dtend, &self.timezones)?))
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_last_occurence(&self) -> Result<Option<CalDateTime>, Error> {
|
|
||||||
if self.event.get_rrule().is_some() {
|
|
||||||
// TODO: understand recurrence rules
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(dtend) = self.get_dtend()? {
|
|
||||||
return Ok(Some(dtend));
|
|
||||||
}
|
|
||||||
|
|
||||||
let duration = self.event.get_duration().unwrap_or(Duration::days(1));
|
|
||||||
|
|
||||||
let first_occurence = self.get_dtstart()?;
|
|
||||||
Ok(first_occurence.map(|first_occurence| first_occurence + duration))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn recurrence_ruleset(&self) -> Result<Option<rrule::RRuleSet>, Error> {
|
|
||||||
let dtstart: DateTime<rrule::Tz> = if let Some(dtstart) = self.get_dtstart()? {
|
|
||||||
if let Some(dtend) = self.get_dtend()? {
|
|
||||||
// DTSTART and DTEND MUST have the same timezone
|
|
||||||
assert_eq!(dtstart.timezone(), dtend.timezone());
|
|
||||||
}
|
|
||||||
|
|
||||||
dtstart
|
|
||||||
.as_datetime()
|
|
||||||
.with_timezone(&dtstart.timezone().into())
|
|
||||||
} else {
|
|
||||||
return Ok(None);
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut rrule_set = RRuleSet::new(dtstart);
|
|
||||||
|
|
||||||
for prop in &self.event.properties {
|
|
||||||
rrule_set = match prop.name.as_str() {
|
|
||||||
"RRULE" => {
|
|
||||||
let rrule = RRule::from_str(prop.value.as_ref().ok_or_else(|| {
|
|
||||||
Error::RRuleError(rrule::ParseError::MissingDateGenerationRules.into())
|
|
||||||
})?)?
|
|
||||||
.validate(dtstart)
|
|
||||||
.unwrap();
|
|
||||||
rrule_set.rrule(rrule)
|
|
||||||
}
|
|
||||||
"RDATE" => {
|
|
||||||
let rdate = CalDateTime::parse_prop(prop, &self.timezones)?.into();
|
|
||||||
rrule_set.rdate(rdate)
|
|
||||||
}
|
|
||||||
"EXDATE" => {
|
|
||||||
let exdate = CalDateTime::parse_prop(prop, &self.timezones)?.into();
|
|
||||||
rrule_set.exdate(exdate)
|
|
||||||
}
|
|
||||||
_ => rrule_set,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Some(rrule_set))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn expand_recurrence(
|
|
||||||
&self,
|
|
||||||
start: Option<DateTime<Utc>>,
|
|
||||||
end: Option<DateTime<Utc>>,
|
|
||||||
overrides: &[Self],
|
|
||||||
) -> Result<Vec<IcalEvent>, Error> {
|
|
||||||
if let Some(mut rrule_set) = self.recurrence_ruleset()? {
|
|
||||||
if let Some(start) = start {
|
|
||||||
rrule_set = rrule_set.after(start.with_timezone(&rrule::Tz::UTC));
|
|
||||||
}
|
|
||||||
if let Some(end) = end {
|
|
||||||
rrule_set = rrule_set.before(end.with_timezone(&rrule::Tz::UTC));
|
|
||||||
}
|
|
||||||
let mut events = vec![];
|
|
||||||
let dates = rrule_set.all(2048).dates;
|
|
||||||
let dtstart = self.get_dtstart()?.expect("We must have a DTSTART here");
|
|
||||||
let computed_duration = self
|
|
||||||
.get_dtend()?
|
|
||||||
.map(|dtend| dtend.as_datetime().into_owned() - dtstart.as_datetime().into_owned());
|
|
||||||
|
|
||||||
'recurrence: for date in dates {
|
|
||||||
let date = CalDateTime::from(date);
|
|
||||||
let dateformat = if dtstart.is_date() {
|
|
||||||
date.format_date()
|
|
||||||
} else {
|
|
||||||
date.format()
|
|
||||||
};
|
|
||||||
|
|
||||||
for ev_override in overrides {
|
|
||||||
if let Some(override_id) = &ev_override
|
|
||||||
.event
|
|
||||||
.get_recurrence_id()
|
|
||||||
.as_ref()
|
|
||||||
.expect("overrides have a recurrence id")
|
|
||||||
.value
|
|
||||||
&& override_id == &dateformat
|
|
||||||
{
|
|
||||||
// We have an override for this occurence
|
|
||||||
//
|
|
||||||
events.push(ev_override.event.clone());
|
|
||||||
continue 'recurrence;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut ev = self.event.clone().mutable();
|
|
||||||
ev.remove_property("RRULE");
|
|
||||||
ev.remove_property("RDATE");
|
|
||||||
ev.remove_property("EXDATE");
|
|
||||||
ev.remove_property("EXRULE");
|
|
||||||
let dtstart_prop = ev
|
|
||||||
.get_property("DTSTART")
|
|
||||||
.expect("We must have a DTSTART here")
|
|
||||||
.clone();
|
|
||||||
ev.remove_property("DTSTART");
|
|
||||||
ev.remove_property("DTEND");
|
|
||||||
|
|
||||||
ev.set_property(Property {
|
|
||||||
name: "RECURRENCE-ID".to_string(),
|
|
||||||
value: Some(dateformat.clone()),
|
|
||||||
params: None,
|
|
||||||
});
|
|
||||||
ev.set_property(Property {
|
|
||||||
name: "DTSTART".to_string(),
|
|
||||||
value: Some(dateformat),
|
|
||||||
params: dtstart_prop.params.clone(),
|
|
||||||
});
|
|
||||||
if let Some(duration) = computed_duration {
|
|
||||||
let dtend = date + duration;
|
|
||||||
let dtendformat = if dtstart.is_date() {
|
|
||||||
dtend.format_date()
|
|
||||||
} else {
|
|
||||||
dtend.format()
|
|
||||||
};
|
|
||||||
ev.set_property(Property {
|
|
||||||
name: "DTEND".to_string(),
|
|
||||||
value: Some(dtendformat),
|
|
||||||
params: dtstart_prop.params,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
events.push(ev.verify()?);
|
|
||||||
}
|
|
||||||
Ok(events)
|
|
||||||
} else {
|
|
||||||
Ok(vec![self.event.clone()])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::CalendarObject;
|
|
||||||
use ical::generator::Emitter;
|
|
||||||
|
|
||||||
const ICS: &str = r"BEGIN:VCALENDAR
|
|
||||||
CALSCALE:GREGORIAN
|
|
||||||
VERSION:2.0
|
|
||||||
BEGIN:VTIMEZONE
|
|
||||||
TZID:Europe/Berlin
|
|
||||||
X-LIC-LOCATION:Europe/Berlin
|
|
||||||
END:VTIMEZONE
|
|
||||||
|
|
||||||
BEGIN:VEVENT
|
|
||||||
UID:318ec6503573d9576818daf93dac07317058d95c
|
|
||||||
DTSTAMP:20250502T132758Z
|
|
||||||
DTSTART;TZID=Europe/Berlin:20250506T090000
|
|
||||||
DTEND;TZID=Europe/Berlin:20250506T092500
|
|
||||||
SEQUENCE:2
|
|
||||||
SUMMARY:weekly stuff
|
|
||||||
TRANSP:OPAQUE
|
|
||||||
RRULE:FREQ=WEEKLY;COUNT=4;INTERVAL=2;BYDAY=TU,TH,SU
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR";
|
|
||||||
|
|
||||||
const EXPANDED: [&str; 4] = [
|
|
||||||
"BEGIN:VEVENT\r
|
|
||||||
UID:318ec6503573d9576818daf93dac07317058d95c\r
|
|
||||||
DTSTAMP:20250502T132758Z\r
|
|
||||||
SEQUENCE:2\r
|
|
||||||
SUMMARY:weekly stuff\r
|
|
||||||
TRANSP:OPAQUE\r
|
|
||||||
RECURRENCE-ID:20250506T090000\r
|
|
||||||
DTSTART;TZID=Europe/Berlin:20250506T090000\r
|
|
||||||
DTEND;TZID=Europe/Berlin:20250506T092500\r
|
|
||||||
END:VEVENT\r\n",
|
|
||||||
"BEGIN:VEVENT\r
|
|
||||||
UID:318ec6503573d9576818daf93dac07317058d95c\r
|
|
||||||
DTSTAMP:20250502T132758Z\r
|
|
||||||
SEQUENCE:2\r
|
|
||||||
SUMMARY:weekly stuff\r
|
|
||||||
TRANSP:OPAQUE\r
|
|
||||||
RECURRENCE-ID:20250508T090000\r
|
|
||||||
DTSTART;TZID=Europe/Berlin:20250508T090000\r
|
|
||||||
DTEND;TZID=Europe/Berlin:20250508T092500\r
|
|
||||||
END:VEVENT\r\n",
|
|
||||||
"BEGIN:VEVENT\r
|
|
||||||
UID:318ec6503573d9576818daf93dac07317058d95c\r
|
|
||||||
DTSTAMP:20250502T132758Z\r
|
|
||||||
SEQUENCE:2\r
|
|
||||||
SUMMARY:weekly stuff\r
|
|
||||||
TRANSP:OPAQUE\r
|
|
||||||
RECURRENCE-ID:20250511T090000\r
|
|
||||||
DTSTART;TZID=Europe/Berlin:20250511T090000\r
|
|
||||||
DTEND;TZID=Europe/Berlin:20250511T092500\r
|
|
||||||
END:VEVENT\r\n",
|
|
||||||
"BEGIN:VEVENT\r
|
|
||||||
UID:318ec6503573d9576818daf93dac07317058d95c\r
|
|
||||||
DTSTAMP:20250502T132758Z\r
|
|
||||||
SEQUENCE:2\r
|
|
||||||
SUMMARY:weekly stuff\r
|
|
||||||
TRANSP:OPAQUE\r
|
|
||||||
RECURRENCE-ID:20250520T090000\r
|
|
||||||
DTSTART;TZID=Europe/Berlin:20250520T090000\r
|
|
||||||
DTEND;TZID=Europe/Berlin:20250520T092500\r
|
|
||||||
END:VEVENT\r\n",
|
|
||||||
];
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_expand_recurrence() {
|
|
||||||
let event = CalendarObject::from_ics(ICS.to_string(), None).unwrap();
|
|
||||||
let crate::CalendarObjectComponent::Event(event, overrides) = event.get_data() else {
|
|
||||||
panic!()
|
|
||||||
};
|
|
||||||
|
|
||||||
let events: Vec<String> = event
|
|
||||||
.expand_recurrence(None, None, overrides)
|
|
||||||
.unwrap()
|
|
||||||
.into_iter()
|
|
||||||
.map(|event| Emitter::generate(&event))
|
|
||||||
.collect();
|
|
||||||
assert_eq!(events.as_slice()[0], EXPANDED[0]);
|
|
||||||
assert_eq!(events.as_slice(), &EXPANDED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
mod event;
|
|
||||||
mod object;
|
|
||||||
|
|
||||||
pub use event::*;
|
|
||||||
pub use object::*;
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user