mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-31 10:18:16 +00:00
Compare commits
19 Commits
v0.12.0
...
b9c2a4cc27
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9c2a4cc27 | ||
|
|
c91205558e | ||
|
|
cd9e3ed8d6 | ||
|
|
200d5e7170 | ||
|
|
5cb538d3fb | ||
|
|
d9da123ff4 | ||
|
|
eba2f0da9f | ||
|
|
291bd967da | ||
|
|
002814a564 | ||
|
|
ba13aaa703 | ||
|
|
7a02bfeffc | ||
|
|
1b69148d6f | ||
|
|
f4de80c6b9 | ||
|
|
7a1ec3e351 | ||
|
|
eb7bdd0018 | ||
|
|
8e583e24cb | ||
|
|
5e5017a185 | ||
|
|
3c87191f69 | ||
|
|
d1947a159b |
8
.github/workflows/docker-publish.yml
vendored
8
.github/workflows/docker-publish.yml
vendored
@@ -2,10 +2,7 @@ name: Docker
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: ["main"]
|
||||||
- main
|
|
||||||
- dev
|
|
||||||
- feat/*
|
|
||||||
release:
|
release:
|
||||||
types: ["published"]
|
types: ["published"]
|
||||||
|
|
||||||
@@ -48,8 +45,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
${{ github.ref_name == 'main' && 'type=ref,event=branch' || '' }}
|
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}}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"db_name": "SQLite",
|
|
||||||
"query": "DELETE FROM calendarobjectchangelog WHERE (principal, cal_id, object_id) = (?, ?, ?);",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 3
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "146e23ae4e0eaae4d65ac7563c67d4f295ccc2534dcc4b3bd710de773ed137f9"
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"db_name": "SQLite",
|
|
||||||
"query": "UPDATE calendarobjects SET ics = ? WHERE (principal, cal_id, id) = (?, ?, ?);",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 4
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "354decac84758c88280f60fbf0f93dddc6c7ff92ac7b8ba44049d31df3c680e3"
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
109
Cargo.lock
generated
109
Cargo.lock
generated
@@ -573,9 +573,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.53"
|
version = "1.2.52"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "755d2fce177175ffca841e9a06afdb2c4ab0f593d53b4dee48147dfaade85932"
|
checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
"find-msvc-tools",
|
||||||
"shlex",
|
"shlex",
|
||||||
@@ -1241,9 +1241,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "find-msvc-tools"
|
name = "find-msvc-tools"
|
||||||
version = "0.1.8"
|
version = "0.1.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db"
|
checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flume"
|
name = "flume"
|
||||||
@@ -1771,7 +1771,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ical"
|
name = "ical"
|
||||||
version = "0.12.0-dev"
|
version = "0.12.0-dev"
|
||||||
source = "git+https://github.com/lennart-k/ical-rs?rev=f1ad6456fd6cbd1e6da095297febddd2cfe61422#f1ad6456fd6cbd1e6da095297febddd2cfe61422"
|
source = "git+https://github.com/lennart-k/ical-rs?branch=dev#5e61c25646c3785448d349e7d18b2833fc483c53"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"chrono-tz",
|
"chrono-tz",
|
||||||
@@ -1781,7 +1781,7 @@ dependencies = [
|
|||||||
"phf 0.13.1",
|
"phf 0.13.1",
|
||||||
"regex",
|
"regex",
|
||||||
"rrule",
|
"rrule",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2118,7 +2118,7 @@ dependencies = [
|
|||||||
"matchit 0.9.1",
|
"matchit 0.9.1",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2370,7 +2370,7 @@ dependencies = [
|
|||||||
"futures-sink",
|
"futures-sink",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2400,7 +2400,7 @@ dependencies = [
|
|||||||
"opentelemetry_sdk",
|
"opentelemetry_sdk",
|
||||||
"prost",
|
"prost",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tonic",
|
"tonic",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -2437,7 +2437,7 @@ dependencies = [
|
|||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"rand 0.9.2",
|
"rand 0.9.2",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
]
|
]
|
||||||
@@ -2870,9 +2870,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-xml"
|
name = "quick-xml"
|
||||||
version = "0.39.0"
|
version = "0.38.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f2e3bf4aa9d243beeb01a7b3bc30b77cfe2c44e24ec02d751a7104a53c2c49a1"
|
checksum = "b66c2058c55a409d601666cffe35f04333cf1013010882cec174a7467cd4e21c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
@@ -2891,7 +2891,7 @@ dependencies = [
|
|||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"rustls",
|
"rustls",
|
||||||
"socket2",
|
"socket2",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"web-time",
|
"web-time",
|
||||||
@@ -2912,7 +2912,7 @@ dependencies = [
|
|||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"slab",
|
"slab",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tinyvec",
|
"tinyvec",
|
||||||
"tracing",
|
"tracing",
|
||||||
"web-time",
|
"web-time",
|
||||||
@@ -3187,7 +3187,7 @@ dependencies = [
|
|||||||
"chrono-tz",
|
"chrono-tz",
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3317,7 +3317,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical"
|
name = "rustical"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argon2",
|
"argon2",
|
||||||
@@ -3328,7 +3328,6 @@ dependencies = [
|
|||||||
"figment",
|
"figment",
|
||||||
"headers",
|
"headers",
|
||||||
"http",
|
"http",
|
||||||
"ical",
|
|
||||||
"insta",
|
"insta",
|
||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
"opentelemetry-otlp",
|
"opentelemetry-otlp",
|
||||||
@@ -3349,7 +3348,6 @@ dependencies = [
|
|||||||
"rustical_store",
|
"rustical_store",
|
||||||
"rustical_store_sqlite",
|
"rustical_store_sqlite",
|
||||||
"serde",
|
"serde",
|
||||||
"similar-asserts",
|
|
||||||
"sqlx",
|
"sqlx",
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml 0.9.11+spec-1.1.0",
|
"toml 0.9.11+spec-1.1.0",
|
||||||
@@ -3364,7 +3362,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_caldav"
|
name = "rustical_caldav"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -3394,7 +3392,7 @@ dependencies = [
|
|||||||
"similar-asserts",
|
"similar-asserts",
|
||||||
"strum",
|
"strum",
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower",
|
"tower",
|
||||||
"tower-http",
|
"tower-http",
|
||||||
@@ -3406,7 +3404,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_carddav"
|
name = "rustical_carddav"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3429,7 +3427,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"strum",
|
"strum",
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower",
|
"tower",
|
||||||
"tower-http",
|
"tower-http",
|
||||||
@@ -3440,7 +3438,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_dav"
|
name = "rustical_dav"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3458,7 +3456,7 @@ dependencies = [
|
|||||||
"rustical_xml",
|
"rustical_xml",
|
||||||
"serde",
|
"serde",
|
||||||
"strum",
|
"strum",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower",
|
"tower",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -3466,7 +3464,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_dav_push"
|
name = "rustical_dav_push"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3484,14 +3482,14 @@ dependencies = [
|
|||||||
"rustical_store",
|
"rustical_store",
|
||||||
"rustical_xml",
|
"rustical_xml",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_frontend"
|
name = "rustical_frontend"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"askama_web",
|
"askama_web",
|
||||||
@@ -3514,7 +3512,7 @@ dependencies = [
|
|||||||
"rustical_store",
|
"rustical_store",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower",
|
"tower",
|
||||||
"tower-http",
|
"tower-http",
|
||||||
@@ -3527,7 +3525,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_ical"
|
name = "rustical_ical"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -3541,12 +3539,12 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"sha2",
|
"sha2",
|
||||||
"similar-asserts",
|
"similar-asserts",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_oidc"
|
name = "rustical_oidc"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3555,14 +3553,14 @@ dependencies = [
|
|||||||
"openidconnect",
|
"openidconnect",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tower-sessions",
|
"tower-sessions",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_store"
|
name = "rustical_store"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -3585,7 +3583,7 @@ dependencies = [
|
|||||||
"rustical_xml",
|
"rustical_xml",
|
||||||
"serde",
|
"serde",
|
||||||
"sha2",
|
"sha2",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower",
|
"tower",
|
||||||
"tower-sessions",
|
"tower-sessions",
|
||||||
@@ -3595,7 +3593,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_store_sqlite"
|
name = "rustical_store_sqlite"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -3605,14 +3603,13 @@ dependencies = [
|
|||||||
"password-auth",
|
"password-auth",
|
||||||
"password-hash",
|
"password-hash",
|
||||||
"pbkdf2",
|
"pbkdf2",
|
||||||
"regex",
|
|
||||||
"rstest",
|
"rstest",
|
||||||
"rustical_ical",
|
"rustical_ical",
|
||||||
"rustical_store",
|
"rustical_store",
|
||||||
"serde",
|
"serde",
|
||||||
"sha2",
|
"sha2",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"uuid",
|
"uuid",
|
||||||
@@ -3620,10 +3617,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustical_xml"
|
name = "rustical_xml"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"xml_derive",
|
"xml_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3656,9 +3653,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-pki-types"
|
name = "rustls-pki-types"
|
||||||
version = "1.14.0"
|
version = "1.13.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd"
|
checksum = "4910321ebe4151be888e35fe062169554e74aad01beafed60410131420ceffbc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"web-time",
|
"web-time",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
@@ -3666,9 +3663,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-webpki"
|
name = "rustls-webpki"
|
||||||
version = "0.103.9"
|
version = "0.103.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53"
|
checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ring",
|
"ring",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
@@ -4048,7 +4045,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -4132,7 +4129,7 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"stringprep",
|
"stringprep",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tracing",
|
"tracing",
|
||||||
"uuid",
|
"uuid",
|
||||||
"whoami",
|
"whoami",
|
||||||
@@ -4171,7 +4168,7 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"stringprep",
|
"stringprep",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tracing",
|
"tracing",
|
||||||
"uuid",
|
"uuid",
|
||||||
"whoami",
|
"whoami",
|
||||||
@@ -4197,7 +4194,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
@@ -4316,11 +4313,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.18"
|
version = "2.0.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
|
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl 2.0.18",
|
"thiserror-impl 2.0.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4336,9 +4333,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "2.0.18"
|
version = "2.0.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
|
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -4720,7 +4717,7 @@ dependencies = [
|
|||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.17",
|
||||||
"time",
|
"time",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -5442,7 +5439,7 @@ checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xml_derive"
|
name = "xml_derive"
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling 0.23.0",
|
"darling 0.23.0",
|
||||||
"heck",
|
"heck",
|
||||||
@@ -5563,6 +5560,6 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zmij"
|
name = "zmij"
|
||||||
version = "1.0.15"
|
version = "1.0.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94f63c051f4fe3c1509da62131a678643c5b6fbdc9273b2b79d4378ebda003d2"
|
checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.12.0"
|
version = "0.11.10"
|
||||||
rust-version = "1.92"
|
rust-version = "1.92"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
description = "A CalDAV server"
|
description = "A CalDAV server"
|
||||||
@@ -73,7 +73,7 @@ tokio = { version = "1.48", features = [
|
|||||||
url = "2.5"
|
url = "2.5"
|
||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
thiserror = "2.0"
|
thiserror = "2.0"
|
||||||
quick-xml = { version = "0.39" }
|
quick-xml = { version = "0.38" }
|
||||||
rust-embed = "8.9"
|
rust-embed = "8.9"
|
||||||
tower-sessions = "0.14"
|
tower-sessions = "0.14"
|
||||||
futures-core = "0.3"
|
futures-core = "0.3"
|
||||||
@@ -107,7 +107,7 @@ 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", rev = "f1ad6456fd6cbd1e6da095297febddd2cfe61422", features = [
|
ical = { git = "https://github.com/lennart-k/ical-rs", branch = "dev", features = [
|
||||||
"chrono-tz",
|
"chrono-tz",
|
||||||
] }
|
] }
|
||||||
toml = "0.9"
|
toml = "0.9"
|
||||||
@@ -153,7 +153,6 @@ criterion = { version = "0.8", features = ["async_tokio"] }
|
|||||||
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
|
||||||
@@ -161,7 +160,6 @@ 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
|
||||||
|
|||||||
@@ -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 --locked --target "$(cat /tmp/rust_target)" --path .
|
RUN cargo install --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
|
||||||
|
|||||||
@@ -26,10 +26,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let parser = ical::IcalParser::from_slice(body.as_bytes());
|
let parser = ical::IcalParser::from_slice(body.as_bytes());
|
||||||
let mut cal = match parser.expect_one() {
|
let mut cal = parser.expect_one()?.mutable();
|
||||||
Ok(cal) => cal.mutable(),
|
|
||||||
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Extract calendar metadata
|
// Extract calendar metadata
|
||||||
let displayname = cal
|
let displayname = cal
|
||||||
@@ -70,10 +67,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
cal_components.push(CalendarObjectType::Todo);
|
cal_components.push(CalendarObjectType::Todo);
|
||||||
}
|
}
|
||||||
|
|
||||||
let objects = match cal.into_objects() {
|
let objects = cal.into_objects()?.into_iter().map(Into::into).collect();
|
||||||
Ok(objects) => objects.into_iter().map(Into::into).collect(),
|
|
||||||
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
|
|
||||||
};
|
|
||||||
let new_cal = Calendar {
|
let new_cal = Calendar {
|
||||||
principal,
|
principal,
|
||||||
id: cal_id,
|
id: cal_id,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ 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::{instrument, warn};
|
use tracing::{debug, instrument};
|
||||||
|
|
||||||
#[instrument(skip(cal_store))]
|
#[instrument(skip(cal_store))]
|
||||||
pub async fn get_event<C: CalendarStore>(
|
pub async fn get_event<C: CalendarStore>(
|
||||||
@@ -94,13 +94,9 @@ pub async fn put_event<C: CalendarStore>(
|
|||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|
||||||
let object = match CalendarObject::from_ics(body.clone()) {
|
let Ok(object) = CalendarObject::from_ics(body.clone()) else {
|
||||||
Ok(object) => object,
|
debug!("invalid calendar data:\n{body}");
|
||||||
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();
|
let etag = object.get_etag();
|
||||||
cal_store
|
cal_store
|
||||||
|
|||||||
@@ -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::FORBIDDEN);
|
let mut res = Response::builder().status(StatusCode::PRECONDITION_FAILED);
|
||||||
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,6 +52,9 @@ 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),
|
||||||
}
|
}
|
||||||
@@ -72,20 +75,19 @@ 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,
|
||||||
// The correct status code for a failed precondition is not PreconditionFailed but
|
// TODO: Can also be Bad Request, if it's used input
|
||||||
// Forbidden (or Conflict):
|
Self::IcalError(_err) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
// https://datatracker.ietf.org/doc/html/rfc4791#section-1.3
|
Self::PreconditionFailed(_err) => StatusCode::PRECONDITION_FAILED,
|
||||||
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 let Self::PreconditionFailed(precondition) = self {
|
if matches!(
|
||||||
return precondition.into_response();
|
self.status_code(),
|
||||||
}
|
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()
|
||||||
|
|||||||
@@ -103,10 +103,7 @@ pub async fn put_object<AS: AddressbookStore>(
|
|||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|
||||||
let object = match AddressObject::from_vcf(body) {
|
let object = AddressObject::from_vcf(body)?;
|
||||||
Ok(object) => object,
|
|
||||||
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
|
|
||||||
};
|
|
||||||
let etag = object.get_etag();
|
let etag = object.get_etag();
|
||||||
addr_store
|
addr_store
|
||||||
.put_object(&principal, &addressbook_id, &object_id, object, overwrite)
|
.put_object(&principal, &addressbook_id, &object_id, object, overwrite)
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ 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 {
|
||||||
@@ -40,6 +43,8 @@ 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,
|
||||||
|
// TODO: Can also be Bad Request, if it's used input
|
||||||
|
Self::IcalError(_err) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,18 +51,19 @@ 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,
|
||||||
// The correct status code for a failed precondition is not PreconditionFailed but
|
Self::Forbidden => StatusCode::FORBIDDEN,
|
||||||
// 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!(self.status_code(), StatusCode::INTERNAL_SERVER_ERROR) {
|
if matches!(
|
||||||
|
self.status_code(),
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR | StatusCode::PRECONDITION_FAILED
|
||||||
|
) {
|
||||||
error!("{self}");
|
error!("{self}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,15 +6,12 @@ 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>,
|
||||||
@@ -23,7 +20,6 @@ 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")
|
||||||
@@ -31,11 +27,7 @@ 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)?;
|
||||||
if let Some(authority) = destination_uri.authority()
|
// TODO: Check that host also matches
|
||||||
&& 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();
|
||||||
|
|||||||
@@ -6,15 +6,12 @@ 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>,
|
||||||
@@ -23,7 +20,6 @@ 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")
|
||||||
@@ -31,11 +27,7 @@ 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)?;
|
||||||
if let Some(authority) = destination_uri.authority()
|
// TODO: Check that host also matches
|
||||||
&& 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();
|
||||||
|
|||||||
@@ -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.resolver().resolve_element(start.name());
|
let (ns, name) = reader.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"),
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ impl IntoResponse for Error {
|
|||||||
fn into_response(self) -> axum::response::Response {
|
fn into_response(self) -> axum::response::Response {
|
||||||
if matches!(
|
if matches!(
|
||||||
self.status_code(),
|
self.status_code(),
|
||||||
StatusCode::INTERNAL_SERVER_ERROR | StatusCode::CONFLICT
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
| StatusCode::PRECONDITION_FAILED
|
||||||
|
| StatusCode::CONFLICT
|
||||||
) {
|
) {
|
||||||
error!("{self}");
|
error!("{self}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,3 @@ pbkdf2.workspace = true
|
|||||||
rustical_ical.workspace = true
|
rustical_ical.workspace = true
|
||||||
rstest = { workspace = true, optional = true }
|
rstest = { workspace = true, optional = true }
|
||||||
sha2.workspace = true
|
sha2.workspace = true
|
||||||
regex.workspace = true
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use super::ChangeOperation;
|
|||||||
use crate::BEGIN_IMMEDIATE;
|
use crate::BEGIN_IMMEDIATE;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use derive_more::derive::Constructor;
|
use derive_more::derive::Constructor;
|
||||||
use ical::parser::ParserError;
|
|
||||||
use rustical_ical::AddressObject;
|
use rustical_ical::AddressObject;
|
||||||
use rustical_store::{
|
use rustical_store::{
|
||||||
Addressbook, AddressbookStore, CollectionMetadata, CollectionOperation,
|
Addressbook, AddressbookStore, CollectionMetadata, CollectionOperation,
|
||||||
@@ -10,7 +9,7 @@ use rustical_store::{
|
|||||||
};
|
};
|
||||||
use sqlx::{Acquire, Executor, Sqlite, SqlitePool, Transaction};
|
use sqlx::{Acquire, Executor, Sqlite, SqlitePool, Transaction};
|
||||||
use tokio::sync::mpsc::Sender;
|
use tokio::sync::mpsc::Sender;
|
||||||
use tracing::{error, error_span, instrument, warn};
|
use tracing::{error_span, instrument, warn};
|
||||||
|
|
||||||
pub mod birthday_calendar;
|
pub mod birthday_calendar;
|
||||||
|
|
||||||
@@ -19,12 +18,6 @@ struct AddressObjectRow {
|
|||||||
id: String,
|
id: String,
|
||||||
vcf: String,
|
vcf: String,
|
||||||
}
|
}
|
||||||
impl From<AddressObjectRow> for (String, Result<AddressObject, ParserError>) {
|
|
||||||
fn from(row: AddressObjectRow) -> Self {
|
|
||||||
let result = AddressObject::from_vcf(row.vcf);
|
|
||||||
(row.id, result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<AddressObjectRow> for (String, AddressObject) {
|
impl TryFrom<AddressObjectRow> for (String, AddressObject) {
|
||||||
type Error = rustical_store::Error;
|
type Error = rustical_store::Error;
|
||||||
@@ -38,7 +31,6 @@ impl TryFrom<AddressObjectRow> for (String, AddressObject) {
|
|||||||
pub struct SqliteAddressbookStore {
|
pub struct SqliteAddressbookStore {
|
||||||
db: SqlitePool,
|
db: SqlitePool,
|
||||||
sender: Sender<CollectionOperation>,
|
sender: Sender<CollectionOperation>,
|
||||||
skip_broken: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SqliteAddressbookStore {
|
impl SqliteAddressbookStore {
|
||||||
@@ -96,36 +88,6 @@ impl SqliteAddressbookStore {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::missing_panics_doc)]
|
|
||||||
pub async fn validate_objects(&self, principal: &str) -> Result<(), Error> {
|
|
||||||
let mut success = true;
|
|
||||||
for addressbook in self.get_addressbooks(principal).await? {
|
|
||||||
for (object_id, res) in Self::_get_objects(&self.db, principal, &addressbook.id).await?
|
|
||||||
{
|
|
||||||
if let Err(err) = res {
|
|
||||||
warn!(
|
|
||||||
"Invalid address object found at {principal}/{addr_id}/{object_id}.vcf. Error: {err}",
|
|
||||||
addr_id = addressbook.id
|
|
||||||
);
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !success {
|
|
||||||
if self.skip_broken {
|
|
||||||
error!(
|
|
||||||
"Not all address objects are valid. Since data_store.sqlite.skip_broken=true they will be hidden. You are still advised to manually remove or repair the object. If you need help feel free to open up an issue on GitHub."
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
error!(
|
|
||||||
"Not all address objects are valid. Since data_store.sqlite.skip_broken=false this causes a panic. Remove or repair the broken objects manually or set data_store.sqlite.skip_broken=false as a temporary solution to ignore the error. If you need help feel free to open up an issue on GitHub."
|
|
||||||
);
|
|
||||||
panic!();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Logs an operation to an address object
|
// Logs an operation to an address object
|
||||||
async fn log_object_operation(
|
async fn log_object_operation(
|
||||||
tx: &mut Transaction<'_, Sqlite>,
|
tx: &mut Transaction<'_, Sqlite>,
|
||||||
@@ -172,7 +134,7 @@ impl SqliteAddressbookStore {
|
|||||||
if let Err(err) = self.sender.try_send(CollectionOperation { topic, data }) {
|
if let Err(err) = self.sender.try_send(CollectionOperation { topic, data }) {
|
||||||
error_span!(
|
error_span!(
|
||||||
"Error trying to send addressbook update notification:",
|
"Error trying to send addressbook update notification:",
|
||||||
err = format!("{err}"),
|
err = format!("{err:?}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -391,8 +353,8 @@ impl SqliteAddressbookStore {
|
|||||||
executor: E,
|
executor: E,
|
||||||
principal: &str,
|
principal: &str,
|
||||||
addressbook_id: &str,
|
addressbook_id: &str,
|
||||||
) -> Result<impl Iterator<Item = (String, Result<AddressObject, ParserError>)>, Error> {
|
) -> Result<Vec<(String, AddressObject)>, rustical_store::Error> {
|
||||||
Ok(sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
AddressObjectRow,
|
AddressObjectRow,
|
||||||
"SELECT id, vcf FROM addressobjects WHERE principal = ? AND addressbook_id = ? AND deleted_at IS NULL",
|
"SELECT id, vcf FROM addressobjects WHERE principal = ? AND addressbook_id = ? AND deleted_at IS NULL",
|
||||||
principal,
|
principal,
|
||||||
@@ -401,8 +363,8 @@ impl SqliteAddressbookStore {
|
|||||||
.fetch_all(executor)
|
.fetch_all(executor)
|
||||||
.await.map_err(crate::Error::from)?
|
.await.map_err(crate::Error::from)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(Into::into)
|
.map(std::convert::TryInto::try_into)
|
||||||
)
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn _get_object<'e, E: Executor<'e, Database = Sqlite>>(
|
async fn _get_object<'e, E: Executor<'e, Database = Sqlite>>(
|
||||||
@@ -645,16 +607,7 @@ impl AddressbookStore for SqliteAddressbookStore {
|
|||||||
principal: &str,
|
principal: &str,
|
||||||
addressbook_id: &str,
|
addressbook_id: &str,
|
||||||
) -> Result<Vec<(String, AddressObject)>, rustical_store::Error> {
|
) -> Result<Vec<(String, AddressObject)>, rustical_store::Error> {
|
||||||
let objects = Self::_get_objects(&self.db, principal, addressbook_id).await?;
|
Self::_get_objects(&self.db, principal, addressbook_id).await
|
||||||
if self.skip_broken {
|
|
||||||
Ok(objects
|
|
||||||
.filter_map(|(id, res)| Some((id, res.ok()?)))
|
|
||||||
.collect())
|
|
||||||
} else {
|
|
||||||
Ok(objects
|
|
||||||
.map(|(id, res)| res.map(|obj| (id, obj)))
|
|
||||||
.collect::<Result<Vec<_>, _>>()?)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument]
|
#[instrument]
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ use crate::BEGIN_IMMEDIATE;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use chrono::TimeDelta;
|
use chrono::TimeDelta;
|
||||||
use derive_more::derive::Constructor;
|
use derive_more::derive::Constructor;
|
||||||
use ical::parser::ParserError;
|
|
||||||
use ical::types::CalDateTime;
|
use ical::types::CalDateTime;
|
||||||
use regex::Regex;
|
|
||||||
use rustical_ical::{CalendarObject, CalendarObjectType};
|
use rustical_ical::{CalendarObject, CalendarObjectType};
|
||||||
use rustical_store::calendar_store::CalendarQuery;
|
use rustical_store::calendar_store::CalendarQuery;
|
||||||
use rustical_store::synctoken::format_synctoken;
|
use rustical_store::synctoken::format_synctoken;
|
||||||
@@ -14,7 +12,7 @@ use rustical_store::{CollectionOperation, CollectionOperationInfo};
|
|||||||
use sqlx::types::chrono::NaiveDateTime;
|
use sqlx::types::chrono::NaiveDateTime;
|
||||||
use sqlx::{Acquire, Executor, Sqlite, SqlitePool, Transaction};
|
use sqlx::{Acquire, Executor, Sqlite, SqlitePool, Transaction};
|
||||||
use tokio::sync::mpsc::Sender;
|
use tokio::sync::mpsc::Sender;
|
||||||
use tracing::{error, error_span, instrument, warn};
|
use tracing::{error_span, instrument, warn};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct CalendarObjectRow {
|
struct CalendarObjectRow {
|
||||||
@@ -23,23 +21,6 @@ struct CalendarObjectRow {
|
|||||||
uid: String,
|
uid: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CalendarObjectRow> for (String, Result<CalendarObject, ParserError>) {
|
|
||||||
fn from(row: CalendarObjectRow) -> Self {
|
|
||||||
let result = CalendarObject::from_ics(row.ics).inspect(|object| {
|
|
||||||
if object.get_uid() != row.uid {
|
|
||||||
warn!(
|
|
||||||
"Calendar object {}.ics: UID={} and row uid={} do not match",
|
|
||||||
row.id,
|
|
||||||
object.get_uid(),
|
|
||||||
row.uid
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
(row.id, result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<CalendarObjectRow> for (String, CalendarObject) {
|
impl TryFrom<CalendarObjectRow> for (String, CalendarObject) {
|
||||||
type Error = rustical_store::Error;
|
type Error = rustical_store::Error;
|
||||||
|
|
||||||
@@ -110,7 +91,6 @@ impl From<CalendarRow> for Calendar {
|
|||||||
pub struct SqliteCalendarStore {
|
pub struct SqliteCalendarStore {
|
||||||
db: SqlitePool,
|
db: SqlitePool,
|
||||||
sender: Sender<CollectionOperation>,
|
sender: Sender<CollectionOperation>,
|
||||||
skip_broken: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SqliteCalendarStore {
|
impl SqliteCalendarStore {
|
||||||
@@ -160,117 +140,11 @@ impl SqliteCalendarStore {
|
|||||||
if let Err(err) = self.sender.try_send(CollectionOperation { topic, data }) {
|
if let Err(err) = self.sender.try_send(CollectionOperation { topic, data }) {
|
||||||
error_span!(
|
error_span!(
|
||||||
"Error trying to send calendar update notification:",
|
"Error trying to send calendar update notification:",
|
||||||
err = format!("{err}"),
|
err = format!("{err:?}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::missing_panics_doc)]
|
|
||||||
pub async fn validate_objects(&self, principal: &str) -> Result<(), Error> {
|
|
||||||
let mut success = true;
|
|
||||||
for calendar in self.get_calendars(principal).await? {
|
|
||||||
for (object_id, res) in Self::_get_objects(&self.db, principal, &calendar.id).await? {
|
|
||||||
if let Err(err) = res {
|
|
||||||
warn!(
|
|
||||||
"Invalid calendar object found at {principal}/{cal_id}/{object_id}.ics. Error: {err}",
|
|
||||||
cal_id = calendar.id
|
|
||||||
);
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !success {
|
|
||||||
if self.skip_broken {
|
|
||||||
error!(
|
|
||||||
"Not all calendar objects are valid. Since data_store.sqlite.skip_broken=true they will be hidden. You are still advised to manually remove or repair the object. If you need help feel free to open up an issue on GitHub."
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
error!(
|
|
||||||
"Not all calendar objects are valid. Since data_store.sqlite.skip_broken=false this causes a panic. Remove or repair the broken objects manually or set data_store.sqlite.skip_broken=false as a temporary solution to ignore the error. If you need help feel free to open up an issue on GitHub."
|
|
||||||
);
|
|
||||||
panic!();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// In the past exports generated objects with invalid VERSION:4.0
|
|
||||||
/// This repair sets them to VERSION:2.0
|
|
||||||
#[allow(clippy::missing_panics_doc)]
|
|
||||||
pub async fn repair_invalid_version_4_0(&self) -> Result<(), Error> {
|
|
||||||
struct Row {
|
|
||||||
principal: String,
|
|
||||||
cal_id: String,
|
|
||||||
id: String,
|
|
||||||
ics: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut tx = self
|
|
||||||
.db
|
|
||||||
.begin_with(BEGIN_IMMEDIATE)
|
|
||||||
.await
|
|
||||||
.map_err(crate::Error::from)?;
|
|
||||||
|
|
||||||
#[allow(clippy::missing_panics_doc)]
|
|
||||||
let version_pattern = Regex::new(r"(?mi)^VERSION:4.0").unwrap();
|
|
||||||
|
|
||||||
let repairs: Vec<Row> = sqlx::query_as!(
|
|
||||||
Row,
|
|
||||||
r#"SELECT principal, cal_id, id, ics FROM calendarobjects WHERE ics LIKE '%VERSION:4.0%';"#
|
|
||||||
)
|
|
||||||
.fetch_all(&mut *tx)
|
|
||||||
.await
|
|
||||||
.map_err(crate::Error::from)?
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|mut row| {
|
|
||||||
version_pattern.find(&row.ics)?;
|
|
||||||
let new_ics = version_pattern.replace(&row.ics, "VERSION:2.0");
|
|
||||||
// Safeguard that we really only changed the version
|
|
||||||
assert_eq!(row.ics.len(), new_ics.len());
|
|
||||||
row.ics = new_ics.to_string();
|
|
||||||
Some(row)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
if repairs.is_empty() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
warn!(
|
|
||||||
"Found {} calendar objects with invalid VERSION:4.0. Repairing by setting to VERSION:2.0",
|
|
||||||
repairs.len()
|
|
||||||
);
|
|
||||||
|
|
||||||
for repair in &repairs {
|
|
||||||
// calendarobjectchangelog is used by sync-collection to fetch changes
|
|
||||||
// By deleting entries we will later regenerate new entries such that clients will notice
|
|
||||||
// the objects have changed
|
|
||||||
warn!(
|
|
||||||
"Repairing VERSION for {}/{}/{}.ics",
|
|
||||||
repair.principal, repair.cal_id, repair.id
|
|
||||||
);
|
|
||||||
sqlx::query!(
|
|
||||||
"DELETE FROM calendarobjectchangelog WHERE (principal, cal_id, object_id) = (?, ?, ?);",
|
|
||||||
repair.principal, repair.cal_id, repair.id
|
|
||||||
).execute(&mut *tx).await
|
|
||||||
.map_err(crate::Error::from)?;
|
|
||||||
|
|
||||||
sqlx::query!(
|
|
||||||
"UPDATE calendarobjects SET ics = ? WHERE (principal, cal_id, id) = (?, ?, ?);",
|
|
||||||
repair.ics,
|
|
||||||
repair.principal,
|
|
||||||
repair.cal_id,
|
|
||||||
repair.id
|
|
||||||
)
|
|
||||||
.execute(&mut *tx)
|
|
||||||
.await
|
|
||||||
.map_err(crate::Error::from)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
tx.commit().await.map_err(crate::Error::from)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit "orphaned" objects to the changelog table
|
// Commit "orphaned" objects to the changelog table
|
||||||
pub async fn repair_orphans(&self) -> Result<(), Error> {
|
pub async fn repair_orphans(&self) -> Result<(), Error> {
|
||||||
struct Row {
|
struct Row {
|
||||||
@@ -504,8 +378,8 @@ impl SqliteCalendarStore {
|
|||||||
executor: E,
|
executor: E,
|
||||||
principal: &str,
|
principal: &str,
|
||||||
cal_id: &str,
|
cal_id: &str,
|
||||||
) -> Result<impl Iterator<Item = (String, Result<CalendarObject, ParserError>)>, Error> {
|
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
||||||
Ok(sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
CalendarObjectRow,
|
CalendarObjectRow,
|
||||||
"SELECT id, uid, ics FROM calendarobjects WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL",
|
"SELECT id, uid, ics FROM calendarobjects WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL",
|
||||||
principal,
|
principal,
|
||||||
@@ -514,8 +388,8 @@ impl SqliteCalendarStore {
|
|||||||
.fetch_all(executor)
|
.fetch_all(executor)
|
||||||
.await.map_err(crate::Error::from)?
|
.await.map_err(crate::Error::from)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(Into::into)
|
.map(std::convert::TryInto::try_into)
|
||||||
)
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn _calendar_query<'e, E: Executor<'e, Database = Sqlite>>(
|
async fn _calendar_query<'e, E: Executor<'e, Database = Sqlite>>(
|
||||||
@@ -523,14 +397,14 @@ impl SqliteCalendarStore {
|
|||||||
principal: &str,
|
principal: &str,
|
||||||
cal_id: &str,
|
cal_id: &str,
|
||||||
query: CalendarQuery,
|
query: CalendarQuery,
|
||||||
) -> Result<impl Iterator<Item = (String, Result<CalendarObject, ParserError>)>, Error> {
|
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
||||||
// We extend our query interval by one day in each direction since we really don't want to
|
// We extend our query interval by one day in each direction since we really don't want to
|
||||||
// miss any objects because of timezone differences
|
// miss any objects because of timezone differences
|
||||||
// I've previously tried NaiveDate::MIN,MAX, but it seems like sqlite cannot handle these
|
// I've previously tried NaiveDate::MIN,MAX, but it seems like sqlite cannot handle these
|
||||||
let start = query.time_start.map(|start| start - TimeDelta::days(1));
|
let start = query.time_start.map(|start| start - TimeDelta::days(1));
|
||||||
let end = query.time_end.map(|end| end + TimeDelta::days(1));
|
let end = query.time_end.map(|end| end + TimeDelta::days(1));
|
||||||
|
|
||||||
Ok(sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
CalendarObjectRow,
|
CalendarObjectRow,
|
||||||
r"SELECT id, uid, ics FROM calendarobjects
|
r"SELECT id, uid, ics FROM calendarobjects
|
||||||
WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL
|
WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL
|
||||||
@@ -548,7 +422,8 @@ impl SqliteCalendarStore {
|
|||||||
.await
|
.await
|
||||||
.map_err(crate::Error::from)?
|
.map_err(crate::Error::from)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(Into::into))
|
.map(std::convert::TryInto::try_into)
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn _get_object<'e, E: Executor<'e, Database = Sqlite>>(
|
async fn _get_object<'e, E: Executor<'e, Database = Sqlite>>(
|
||||||
@@ -688,7 +563,6 @@ impl SqliteCalendarStore {
|
|||||||
principal: &str,
|
principal: &str,
|
||||||
cal_id: &str,
|
cal_id: &str,
|
||||||
synctoken: i64,
|
synctoken: i64,
|
||||||
skip_broken: bool,
|
|
||||||
) -> Result<(Vec<(String, CalendarObject)>, Vec<String>, i64), Error> {
|
) -> Result<(Vec<(String, CalendarObject)>, Vec<String>, i64), Error> {
|
||||||
struct Row {
|
struct Row {
|
||||||
object_id: String,
|
object_id: String,
|
||||||
@@ -718,8 +592,6 @@ impl SqliteCalendarStore {
|
|||||||
match Self::_get_object(&mut *conn, principal, cal_id, &object_id, false).await {
|
match Self::_get_object(&mut *conn, principal, cal_id, &object_id, false).await {
|
||||||
Ok(object) => objects.push((object_id, object)),
|
Ok(object) => objects.push((object_id, object)),
|
||||||
Err(rustical_store::Error::NotFound) => deleted_objects.push(object_id),
|
Err(rustical_store::Error::NotFound) => deleted_objects.push(object_id),
|
||||||
// Skip broken object
|
|
||||||
Err(rustical_store::Error::IcalError(_)) if skip_broken => (),
|
|
||||||
Err(err) => return Err(err),
|
Err(err) => return Err(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -870,16 +742,7 @@ impl CalendarStore for SqliteCalendarStore {
|
|||||||
cal_id: &str,
|
cal_id: &str,
|
||||||
query: CalendarQuery,
|
query: CalendarQuery,
|
||||||
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
||||||
let objects = Self::_calendar_query(&self.db, principal, cal_id, query).await?;
|
Self::_calendar_query(&self.db, principal, cal_id, query).await
|
||||||
if self.skip_broken {
|
|
||||||
Ok(objects
|
|
||||||
.filter_map(|(id, res)| Some((id, res.ok()?)))
|
|
||||||
.collect())
|
|
||||||
} else {
|
|
||||||
Ok(objects
|
|
||||||
.map(|(id, res)| res.map(|obj| (id, obj)))
|
|
||||||
.collect::<Result<Vec<_>, _>>()?)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn calendar_metadata(
|
async fn calendar_metadata(
|
||||||
@@ -910,16 +773,7 @@ impl CalendarStore for SqliteCalendarStore {
|
|||||||
principal: &str,
|
principal: &str,
|
||||||
cal_id: &str,
|
cal_id: &str,
|
||||||
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
||||||
let objects = Self::_get_objects(&self.db, principal, cal_id).await?;
|
Self::_get_objects(&self.db, principal, cal_id).await
|
||||||
if self.skip_broken {
|
|
||||||
Ok(objects
|
|
||||||
.filter_map(|(id, res)| Some((id, res.ok()?)))
|
|
||||||
.collect())
|
|
||||||
} else {
|
|
||||||
Ok(objects
|
|
||||||
.map(|(id, res)| res.map(|obj| (id, obj)))
|
|
||||||
.collect::<Result<Vec<_>, _>>()?)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument]
|
#[instrument]
|
||||||
@@ -1042,7 +896,7 @@ impl CalendarStore for SqliteCalendarStore {
|
|||||||
cal_id: &str,
|
cal_id: &str,
|
||||||
synctoken: i64,
|
synctoken: i64,
|
||||||
) -> Result<(Vec<(String, CalendarObject)>, Vec<String>, i64), Error> {
|
) -> Result<(Vec<(String, CalendarObject)>, Vec<String>, i64), Error> {
|
||||||
Self::_sync_changes(&self.db, principal, cal_id, synctoken, self.skip_broken).await
|
Self::_sync_changes(&self.db, principal, cal_id, synctoken).await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_read_only(&self, _cal_id: &str) -> bool {
|
fn is_read_only(&self, _cal_id: &str) -> bool {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ impl From<sqlx::Error> for Error {
|
|||||||
sqlx::Error::RowNotFound => Self::StoreError(rustical_store::Error::NotFound),
|
sqlx::Error::RowNotFound => Self::StoreError(rustical_store::Error::NotFound),
|
||||||
sqlx::Error::Database(err) => {
|
sqlx::Error::Database(err) => {
|
||||||
if err.is_unique_violation() {
|
if err.is_unique_violation() {
|
||||||
warn!("{err}");
|
warn!("{err:?}");
|
||||||
Self::StoreError(rustical_store::Error::AlreadyExists)
|
Self::StoreError(rustical_store::Error::AlreadyExists)
|
||||||
} else {
|
} else {
|
||||||
Self::SqlxError(sqlx::Error::Database(err))
|
Self::SqlxError(sqlx::Error::Database(err))
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ pub async fn test_store_context() -> TestStoreContext {
|
|||||||
let db = get_test_db().await;
|
let db = get_test_db().await;
|
||||||
TestStoreContext {
|
TestStoreContext {
|
||||||
db: db.clone(),
|
db: db.clone(),
|
||||||
addr_store: SqliteAddressbookStore::new(db.clone(), send_addr, false),
|
addr_store: SqliteAddressbookStore::new(db.clone(), send_addr),
|
||||||
cal_store: SqliteCalendarStore::new(db.clone(), send_cal, false),
|
cal_store: SqliteCalendarStore::new(db.clone(), send_cal),
|
||||||
principal_store: SqlitePrincipalStore::new(db.clone()),
|
principal_store: SqlitePrincipalStore::new(db.clone()),
|
||||||
sub_store: SqliteStore::new(db),
|
sub_store: SqliteStore::new(db),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ impl NamedStruct {
|
|||||||
#(#builder_field_inits),*
|
#(#builder_field_inits),*
|
||||||
};
|
};
|
||||||
|
|
||||||
let (ns, name) = reader.resolver().resolve_element(start.name());
|
let (ns, name) = reader.resolve_element(start.name());
|
||||||
#(#tagname_field_branches);*
|
#(#tagname_field_branches);*
|
||||||
#(#namespace_field_branches);*
|
#(#namespace_field_branches);*
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ impl NamedStruct {
|
|||||||
// 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.resolver().resolve_element(start.name());
|
let (ns, name) = reader.resolve_element(start.name());
|
||||||
match (ns, name.as_ref()) {
|
match (ns, name.as_ref()) {
|
||||||
#(#named_field_branches),*
|
#(#named_field_branches),*
|
||||||
#(#untagged_field_branches),*
|
#(#untagged_field_branches),*
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ impl<T: XmlRootTag + XmlDeserialize> XmlDocument for T {
|
|||||||
match event {
|
match event {
|
||||||
Event::Decl(_) | Event::Comment(_) => { /* ignore this */ }
|
Event::Decl(_) | Event::Comment(_) => { /* ignore this */ }
|
||||||
Event::Start(start) | Event::Empty(start) => {
|
Event::Start(start) | Event::Empty(start) => {
|
||||||
let (ns, name) = reader.resolver().resolve_element(start.name());
|
let (ns, name) = reader.resolve_element(start.name());
|
||||||
let matches = match (Self::root_ns(), &ns, name) {
|
let matches = match (Self::root_ns(), &ns, name) {
|
||||||
// Wrong tag
|
// Wrong tag
|
||||||
(_, _, name) if name.as_ref() != Self::root_tag().as_bytes() => false,
|
(_, _, name) if name.as_ref() != Self::root_tag().as_bytes() => false,
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ pub fn cmd_gen_config(_args: GenConfigArgs) -> anyhow::Result<()> {
|
|||||||
http: HttpConfig::default(),
|
http: HttpConfig::default(),
|
||||||
data_store: DataStoreConfig::Sqlite(SqliteDataStoreConfig {
|
data_store: DataStoreConfig::Sqlite(SqliteDataStoreConfig {
|
||||||
db_url: "/var/lib/rustical/db.sqlite3".to_owned(),
|
db_url: "/var/lib/rustical/db.sqlite3".to_owned(),
|
||||||
run_repairs: true,
|
|
||||||
skip_broken: true,
|
|
||||||
}),
|
}),
|
||||||
tracing: TracingConfig::default(),
|
tracing: TracingConfig::default(),
|
||||||
frontend: FrontendConfig {
|
frontend: FrontendConfig {
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ impl Default for HttpConfig {
|
|||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct SqliteDataStoreConfig {
|
pub struct SqliteDataStoreConfig {
|
||||||
pub db_url: String,
|
pub db_url: String,
|
||||||
#[serde(default = "default_true")]
|
|
||||||
pub run_repairs: bool,
|
|
||||||
#[serde(default = "default_true")]
|
|
||||||
pub skip_broken: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use rustical_store::{CalendarMetadata, CalendarStore};
|
|||||||
use rustical_store_sqlite::tests::{TestStoreContext, test_store_context};
|
use rustical_store_sqlite::tests::{TestStoreContext, test_store_context};
|
||||||
use tower::ServiceExt;
|
use tower::ServiceExt;
|
||||||
|
|
||||||
pub fn mkcalendar_template(
|
fn mkcalendar_template(
|
||||||
CalendarMetadata {
|
CalendarMetadata {
|
||||||
displayname,
|
displayname,
|
||||||
order: _order,
|
order: _order,
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
use axum::body::Body;
|
|
||||||
use headers::{Authorization, HeaderMapExt};
|
|
||||||
use http::{Request, StatusCode};
|
|
||||||
use rstest::rstest;
|
|
||||||
use rustical_store::CalendarMetadata;
|
|
||||||
use rustical_store_sqlite::tests::{TestStoreContext, test_store_context};
|
|
||||||
use tower::ServiceExt;
|
|
||||||
|
|
||||||
use crate::integration_tests::{
|
|
||||||
ResponseExtractString, caldav::calendar::mkcalendar_template, get_app,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[rstest]
|
|
||||||
#[tokio::test]
|
|
||||||
async fn test_put_invalid(
|
|
||||||
#[from(test_store_context)]
|
|
||||||
#[future]
|
|
||||||
context: TestStoreContext,
|
|
||||||
) {
|
|
||||||
let context = context.await;
|
|
||||||
let app = get_app(context.clone());
|
|
||||||
|
|
||||||
let calendar_meta = CalendarMetadata {
|
|
||||||
displayname: Some("Calendar".to_string()),
|
|
||||||
description: Some("Description".to_string()),
|
|
||||||
color: Some("#00FF00".to_string()),
|
|
||||||
order: 0,
|
|
||||||
};
|
|
||||||
let (principal, cal_id) = ("user", "calendar");
|
|
||||||
let url = format!("/caldav/principal/{principal}/{cal_id}");
|
|
||||||
|
|
||||||
let mut request = Request::builder()
|
|
||||||
.method("MKCALENDAR")
|
|
||||||
.uri(&url)
|
|
||||||
.body(Body::from(mkcalendar_template(&calendar_meta)))
|
|
||||||
.unwrap();
|
|
||||||
request
|
|
||||||
.headers_mut()
|
|
||||||
.typed_insert(Authorization::basic("user", "pass"));
|
|
||||||
let response = app.clone().oneshot(request).await.unwrap();
|
|
||||||
assert_eq!(response.status(), StatusCode::CREATED);
|
|
||||||
|
|
||||||
// Invalid calendar data
|
|
||||||
let ical = r"BEGIN:VCALENDAR
|
|
||||||
VERSION:2.0
|
|
||||||
PRODID:-//Example Corp.//CalDAV Client//EN
|
|
||||||
BEGIN:VEVENT
|
|
||||||
UID:20010712T182145Z-123401@example.com
|
|
||||||
DTSTAMP:20060712T182145Z
|
|
||||||
DTSTART:20060714T170000Z
|
|
||||||
RRULE:UNTIL=123
|
|
||||||
DTEND:20060715T040000Z
|
|
||||||
SUMMARY:Bastille Day Party
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR";
|
|
||||||
|
|
||||||
let mut request = Request::builder()
|
|
||||||
.method("PUT")
|
|
||||||
.uri(format!("{url}/qwue23489.ics"))
|
|
||||||
.header("If-None-Match", "*")
|
|
||||||
.header("Content-Type", "text/calendar")
|
|
||||||
.body(Body::from(ical))
|
|
||||||
.unwrap();
|
|
||||||
request
|
|
||||||
.headers_mut()
|
|
||||||
.typed_insert(Authorization::basic("user", "pass"));
|
|
||||||
|
|
||||||
let response = app.clone().oneshot(request).await.unwrap();
|
|
||||||
assert_eq!(response.status(), StatusCode::FORBIDDEN);
|
|
||||||
let body = response.extract_string().await;
|
|
||||||
insta::assert_snapshot!(body, @r#"
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<error 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">
|
|
||||||
<CAL:valid-calendar-data/>
|
|
||||||
</error>
|
|
||||||
"#);
|
|
||||||
}
|
|
||||||
@@ -87,79 +87,70 @@ const REPORT_7_8_3: &str = r#"
|
|||||||
</C:calendar-query>
|
</C:calendar-query>
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
// Adapted from Example 7.8.3 of RFC 4791
|
const OUTPUT_7_8_3: &str = r#"
|
||||||
// In the RFC the output is wrong since it returns DTSTART in UTC as local time, e.g.
|
<D:response>
|
||||||
// DTSTART:20060103T170000
|
<D:href>http://cal.example.com/bernard/work/abcd2.ics</D:href>
|
||||||
// instead of
|
<D:propstat>
|
||||||
// DTSTART:20060103T170000Z
|
<D:prop>
|
||||||
// In https://datatracker.ietf.org/doc/html/rfc4791#section-9.6.5
|
<D:getetag>"fffff-abcd2"</D:getetag>
|
||||||
// it is clearly stated that times with timezone information MUST be returned in UTC.
|
<C:calendar-data>BEGIN:VCALENDAR
|
||||||
// Also, the RECURRENCE-ID needs to include the TIMEZONE, which is fixed here by converting it to
|
VERSION:2.0
|
||||||
// UTC
|
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||||
const OUTPUT_7_8_3: &str = r#"<?xml version="1.0" encoding="utf-8"?>
|
BEGIN:VEVENT
|
||||||
<multistatus 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">
|
DTSTAMP:20060206T001121Z
|
||||||
<response>
|
DTSTART:20060103T170000
|
||||||
<href>/caldav/principal/user/calendar/abcd2.ics</href>
|
DURATION:PT1H
|
||||||
<propstat>
|
RECURRENCE-ID:20060103T170000
|
||||||
<prop>
|
SUMMARY:Event #2
|
||||||
<CAL:calendar-data>BEGIN:VCALENDAR
|
UID:00959BC664CA650E933C892C@example.com
|
||||||
VERSION:2.0
|
END:VEVENT
|
||||||
PRODID:-//Example Corp.//CalDAV Client//EN
|
BEGIN:VEVENT
|
||||||
BEGIN:VEVENT
|
DTSTAMP:20060206T001121Z
|
||||||
DTSTAMP:20060206T001121Z
|
DTSTART:20060104T190000
|
||||||
DTSTART:20060103T170000Z
|
DURATION:PT1H
|
||||||
DURATION:PT1H
|
RECURRENCE-ID:20060104T170000
|
||||||
SUMMARY:Event #2
|
SUMMARY:Event #2 bis
|
||||||
UID:abcd2
|
UID:00959BC664CA650E933C892C@example.com
|
||||||
RECURRENCE-ID:20060103T170000Z
|
END:VEVENT
|
||||||
END:VEVENT
|
END:VCALENDAR
|
||||||
BEGIN:VEVENT
|
</C:calendar-data>
|
||||||
DTSTAMP:20060206T001121Z
|
</D:prop>
|
||||||
DTSTART:20060104T190000Z
|
<D:status>HTTP/1.1 200 OK</D:status>
|
||||||
DURATION:PT1H
|
</D:propstat>
|
||||||
RECURRENCE-ID:20060104T170000Z
|
</D:response>
|
||||||
SUMMARY:Event #2 bis
|
<D:response>
|
||||||
UID:abcd2
|
<D:href>http://cal.example.com/bernard/work/abcd3.ics</D:href>
|
||||||
END:VEVENT
|
<D:propstat>
|
||||||
END:VCALENDAR
|
<D:prop>
|
||||||
</CAL:calendar-data>
|
<D:getetag>"fffff-abcd3"</D:getetag>
|
||||||
</prop>
|
<C:calendar-data>BEGIN:VCALENDAR
|
||||||
<status>HTTP/1.1 200 OK</status>
|
VERSION:2.0
|
||||||
</propstat>
|
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||||
</response>
|
BEGIN:VEVENT
|
||||||
<response>
|
ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:cyrus@example.com
|
||||||
<href>/caldav/principal/user/calendar/abcd3.ics</href>
|
ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
|
||||||
<propstat>
|
DTSTAMP:20060206T001220Z
|
||||||
<prop>
|
DTSTART:20060104T150000
|
||||||
<CAL:calendar-data>BEGIN:VCALENDAR
|
DURATION:PT1H
|
||||||
VERSION:2.0
|
LAST-MODIFIED:20060206T001330Z
|
||||||
PRODID:-//Example Corp.//CalDAV Client//EN
|
ORGANIZER:mailto:cyrus@example.com
|
||||||
BEGIN:VEVENT
|
SEQUENCE:1
|
||||||
ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:cyrus@example.com
|
STATUS:TENTATIVE
|
||||||
ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
|
SUMMARY:Event #3
|
||||||
DTSTAMP:20060206T001220Z
|
UID:DC6C50A017428C5216A2F1CD@example.com
|
||||||
DTSTART:20060104T150000Z
|
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
||||||
DURATION:PT1H
|
END:VEVENT
|
||||||
LAST-MODIFIED:20060206T001330Z
|
END:VCALENDAR
|
||||||
ORGANIZER:mailto:cyrus@example.com
|
</C:calendar-data>
|
||||||
SEQUENCE:1
|
</D:prop>
|
||||||
STATUS:TENTATIVE
|
<D:status>HTTP/1.1 200 OK</D:status>
|
||||||
SUMMARY:Event #3
|
</D:propstat>
|
||||||
UID:abcd3
|
"#;
|
||||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR
|
|
||||||
</CAL:calendar-data>
|
|
||||||
</prop>
|
|
||||||
<status>HTTP/1.1 200 OK</status>
|
|
||||||
</propstat>
|
|
||||||
</response>
|
|
||||||
</multistatus>"#;
|
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[case(0, ICS_1, REPORT_7_8_1, None)]
|
#[case(0, ICS_1, REPORT_7_8_1)]
|
||||||
#[case(1, ICS_1, REPORT_7_8_2, None)]
|
#[case(1, ICS_1, REPORT_7_8_2)]
|
||||||
#[case(2, ICS_1, REPORT_7_8_3, Some(OUTPUT_7_8_3))]
|
#[case(2, ICS_1, REPORT_7_8_3)]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_report(
|
async fn test_report(
|
||||||
#[from(test_store_context)]
|
#[from(test_store_context)]
|
||||||
@@ -168,7 +159,6 @@ async fn test_report(
|
|||||||
#[case] case: usize,
|
#[case] case: usize,
|
||||||
#[case] ics: &'static str,
|
#[case] ics: &'static str,
|
||||||
#[case] report: &'static str,
|
#[case] report: &'static str,
|
||||||
#[case] output: Option<&'static str>,
|
|
||||||
) {
|
) {
|
||||||
let context = context.await;
|
let context = context.await;
|
||||||
let app = get_app(context.clone());
|
let app = get_app(context.clone());
|
||||||
@@ -203,7 +193,4 @@ async fn test_report(
|
|||||||
assert_eq!(response.status(), StatusCode::MULTI_STATUS);
|
assert_eq!(response.status(), StatusCode::MULTI_STATUS);
|
||||||
let body = response.extract_string().await;
|
let body = response.extract_string().await;
|
||||||
insta::assert_snapshot!(format!("{case}_report_body"), body);
|
insta::assert_snapshot!(format!("{case}_report_body"), body);
|
||||||
if let Some(output) = output {
|
|
||||||
similar_asserts::assert_eq!(output, body.replace('\r', ""));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ use tower::ServiceExt;
|
|||||||
|
|
||||||
mod calendar;
|
mod calendar;
|
||||||
mod calendar_import;
|
mod calendar_import;
|
||||||
mod calendar_put;
|
// mod calendar_report;
|
||||||
mod calendar_report;
|
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ SEQUENCE:1
|
|||||||
STATUS:TENTATIVE
|
STATUS:TENTATIVE
|
||||||
SUMMARY:Event #3
|
SUMMARY:Event #3
|
||||||
UID:abcd3
|
UID:abcd3
|
||||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VTODO
|
BEGIN:VTODO
|
||||||
DTSTAMP:20060205T235335Z
|
DTSTAMP:20060205T235335Z
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ SEQUENCE:1
|
|||||||
STATUS:TENTATIVE
|
STATUS:TENTATIVE
|
||||||
SUMMARY:Event #3
|
SUMMARY:Event #3
|
||||||
UID:[UID]
|
UID:[UID]
|
||||||
X-ABC-GUID:[UID]
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VTODO
|
BEGIN:VTODO
|
||||||
DTSTAMP:20060205T235335Z
|
DTSTAMP:20060205T235335Z
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ END:VCALENDAR
|
|||||||
<href>/caldav/principal/user/calendar/abcd3.ics</href>
|
<href>/caldav/principal/user/calendar/abcd3.ics</href>
|
||||||
<propstat>
|
<propstat>
|
||||||
<prop>
|
<prop>
|
||||||
<getetag>"a84fd022dfc742bf8f17ac04fca3aad687e9ae724180185e8e0df11e432dae30"</getetag>
|
<getetag>"c6a5b1cf6985805686df99e7f2e1cf286567dcb3383fc6fa1b12ce42d3fbc01c"</getetag>
|
||||||
<CAL:calendar-data>BEGIN:VCALENDAR
|
<CAL:calendar-data>BEGIN:VCALENDAR
|
||||||
VERSION:2.0
|
VERSION:2.0
|
||||||
PRODID:-//Example Corp.//CalDAV Client//EN
|
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||||
@@ -90,7 +90,6 @@ SEQUENCE:1
|
|||||||
STATUS:TENTATIVE
|
STATUS:TENTATIVE
|
||||||
SUMMARY:Event #3
|
SUMMARY:Event #3
|
||||||
UID:abcd3
|
UID:abcd3
|
||||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
</CAL:calendar-data>
|
</CAL:calendar-data>
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ SEQUENCE:1
|
|||||||
STATUS:TENTATIVE
|
STATUS:TENTATIVE
|
||||||
SUMMARY:Event #3
|
SUMMARY:Event #3
|
||||||
UID:abcd3
|
UID:abcd3
|
||||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
</CAL:calendar-data>
|
</CAL:calendar-data>
|
||||||
|
|||||||
@@ -13,19 +13,19 @@ VERSION:2.0
|
|||||||
PRODID:-//Example Corp.//CalDAV Client//EN
|
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTAMP:20060206T001121Z
|
DTSTAMP:20060206T001121Z
|
||||||
DTSTART:20060103T170000Z
|
|
||||||
DURATION:PT1H
|
DURATION:PT1H
|
||||||
SUMMARY:Event #2
|
SUMMARY:Event #2
|
||||||
UID:abcd2
|
UID:abcd2
|
||||||
RECURRENCE-ID:20060103T170000Z
|
RECURRENCE-ID:20060103T170000Z
|
||||||
|
DTSTART:20060103T170000Z
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTAMP:20060206T001121Z
|
DTSTAMP:20060206T001121Z
|
||||||
DTSTART:20060104T190000Z
|
|
||||||
DURATION:PT1H
|
DURATION:PT1H
|
||||||
RECURRENCE-ID:20060104T170000Z
|
SUMMARY:Event #2
|
||||||
SUMMARY:Event #2 bis
|
|
||||||
UID:abcd2
|
UID:abcd2
|
||||||
|
RECURRENCE-ID:20060104T170000Z
|
||||||
|
DTSTART:20060104T170000Z
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
</CAL:calendar-data>
|
</CAL:calendar-data>
|
||||||
@@ -44,7 +44,7 @@ BEGIN:VEVENT
|
|||||||
ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:cyrus@example.com
|
ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:cyrus@example.com
|
||||||
ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
|
ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
|
||||||
DTSTAMP:20060206T001220Z
|
DTSTAMP:20060206T001220Z
|
||||||
DTSTART:20060104T150000Z
|
DTSTART;TZID=US/Eastern:20060104T100000
|
||||||
DURATION:PT1H
|
DURATION:PT1H
|
||||||
LAST-MODIFIED:20060206T001330Z
|
LAST-MODIFIED:20060206T001330Z
|
||||||
ORGANIZER:mailto:cyrus@example.com
|
ORGANIZER:mailto:cyrus@example.com
|
||||||
@@ -52,7 +52,6 @@ SEQUENCE:1
|
|||||||
STATUS:TENTATIVE
|
STATUS:TENTATIVE
|
||||||
SUMMARY:Event #3
|
SUMMARY:Event #3
|
||||||
UID:abcd3
|
UID:abcd3
|
||||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
</CAL:calendar-data>
|
</CAL:calendar-data>
|
||||||
|
|||||||
27
src/main.rs
27
src/main.rs
@@ -25,7 +25,7 @@ use std::sync::Arc;
|
|||||||
use tokio::sync::mpsc::Receiver;
|
use tokio::sync::mpsc::Receiver;
|
||||||
use tower::Layer;
|
use tower::Layer;
|
||||||
use tower_http::normalize_path::NormalizePathLayer;
|
use tower_http::normalize_path::NormalizePathLayer;
|
||||||
use tracing::{info, warn};
|
use tracing::info;
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
mod commands;
|
mod commands;
|
||||||
@@ -67,36 +67,17 @@ async fn get_data_stores(
|
|||||||
Receiver<CollectionOperation>,
|
Receiver<CollectionOperation>,
|
||||||
)> {
|
)> {
|
||||||
Ok(match &config {
|
Ok(match &config {
|
||||||
DataStoreConfig::Sqlite(SqliteDataStoreConfig {
|
DataStoreConfig::Sqlite(SqliteDataStoreConfig { db_url }) => {
|
||||||
db_url,
|
|
||||||
run_repairs,
|
|
||||||
skip_broken,
|
|
||||||
}) => {
|
|
||||||
let db = create_db_pool(db_url, migrate).await?;
|
let db = create_db_pool(db_url, migrate).await?;
|
||||||
// Channel to watch for changes (for DAV Push)
|
// Channel to watch for changes (for DAV Push)
|
||||||
let (send, recv) = tokio::sync::mpsc::channel(1000);
|
let (send, recv) = tokio::sync::mpsc::channel(1000);
|
||||||
|
|
||||||
let addressbook_store = Arc::new(SqliteAddressbookStore::new(
|
let addressbook_store = Arc::new(SqliteAddressbookStore::new(db.clone(), send.clone()));
|
||||||
db.clone(),
|
|
||||||
send.clone(),
|
|
||||||
*skip_broken,
|
|
||||||
));
|
|
||||||
let cal_store = Arc::new(SqliteCalendarStore::new(db.clone(), send, *skip_broken));
|
|
||||||
if *run_repairs {
|
|
||||||
info!("Running repair tasks");
|
|
||||||
addressbook_store.repair_orphans().await?;
|
addressbook_store.repair_orphans().await?;
|
||||||
cal_store.repair_invalid_version_4_0().await?;
|
let cal_store = Arc::new(SqliteCalendarStore::new(db.clone(), send));
|
||||||
cal_store.repair_orphans().await?;
|
cal_store.repair_orphans().await?;
|
||||||
}
|
|
||||||
let subscription_store = Arc::new(SqliteStore::new(db.clone()));
|
let subscription_store = Arc::new(SqliteStore::new(db.clone()));
|
||||||
let principal_store = Arc::new(SqlitePrincipalStore::new(db));
|
let principal_store = Arc::new(SqlitePrincipalStore::new(db));
|
||||||
|
|
||||||
// Validate all calendar objects
|
|
||||||
for principal in principal_store.get_principals().await? {
|
|
||||||
cal_store.validate_objects(&principal.id).await?;
|
|
||||||
addressbook_store.validate_objects(&principal.id).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
(
|
(
|
||||||
addressbook_store,
|
addressbook_store,
|
||||||
cal_store,
|
cal_store,
|
||||||
|
|||||||
Reference in New Issue
Block a user