mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 22:28:22 +00:00
Compare commits
14 Commits
v0.12.0
...
d9da123ff4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
- feat/*
|
||||
branches: ["main"]
|
||||
release:
|
||||
types: ["published"]
|
||||
|
||||
@@ -48,8 +45,7 @@ jobs:
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
${{ github.ref_name == 'main' && 'type=ref,event=branch' || '' }}
|
||||
type=ref,event=branch,prefix=br-
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
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"
|
||||
}
|
||||
202
Cargo.lock
generated
202
Cargo.lock
generated
@@ -573,9 +573,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.53"
|
||||
version = "1.2.52"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "755d2fce177175ffca841e9a06afdb2c4ab0f593d53b4dee48147dfaade85932"
|
||||
checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
@@ -595,9 +595,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.43"
|
||||
version = "0.4.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fac4744fb15ae8337dc853fee7fb3f4e48c0fbaa23d0afe49c447b4fab126118"
|
||||
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
@@ -689,9 +689,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.7"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32"
|
||||
checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
@@ -1241,9 +1241,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.8"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db"
|
||||
checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41"
|
||||
|
||||
[[package]]
|
||||
name = "flume"
|
||||
@@ -1770,8 +1770,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ical"
|
||||
version = "0.12.0-dev"
|
||||
source = "git+https://github.com/lennart-k/ical-rs?rev=f1ad6456fd6cbd1e6da095297febddd2cfe61422#f1ad6456fd6cbd1e6da095297febddd2cfe61422"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/lennart-k/ical-rs?branch=dev#28e982f928a73f5af13f1e59e28da419567bf93f"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
@@ -1781,7 +1781,7 @@ dependencies = [
|
||||
"phf 0.13.1",
|
||||
"regex",
|
||||
"rrule",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1923,9 +1923,9 @@ checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb"
|
||||
|
||||
[[package]]
|
||||
name = "insta"
|
||||
version = "1.46.1"
|
||||
version = "1.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "248b42847813a1550dafd15296fd9748c651d0c32194559dbc05d804d54b21e8"
|
||||
checksum = "1b66886d14d18d420ab5052cbff544fc5d34d0b2cdd35eb5976aaa10a4a472e5"
|
||||
dependencies = [
|
||||
"console",
|
||||
"once_cell",
|
||||
@@ -1991,9 +1991,9 @@ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.85"
|
||||
version = "0.3.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3"
|
||||
checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
@@ -2118,7 +2118,7 @@ dependencies = [
|
||||
"matchit 0.9.1",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2370,7 +2370,7 @@ dependencies = [
|
||||
"futures-sink",
|
||||
"js-sys",
|
||||
"pin-project-lite",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
@@ -2400,7 +2400,7 @@ dependencies = [
|
||||
"opentelemetry_sdk",
|
||||
"prost",
|
||||
"reqwest",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tonic",
|
||||
"tracing",
|
||||
@@ -2437,7 +2437,7 @@ dependencies = [
|
||||
"opentelemetry",
|
||||
"percent-encoding",
|
||||
"rand 0.9.2",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
]
|
||||
@@ -2870,9 +2870,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.39.0"
|
||||
version = "0.38.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2e3bf4aa9d243beeb01a7b3bc30b77cfe2c44e24ec02d751a7104a53c2c49a1"
|
||||
checksum = "b66c2058c55a409d601666cffe35f04333cf1013010882cec174a7467cd4e21c"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@@ -2891,7 +2891,7 @@ dependencies = [
|
||||
"rustc-hash",
|
||||
"rustls",
|
||||
"socket2",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"web-time",
|
||||
@@ -2912,7 +2912,7 @@ dependencies = [
|
||||
"rustls",
|
||||
"rustls-pki-types",
|
||||
"slab",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tinyvec",
|
||||
"tracing",
|
||||
"web-time",
|
||||
@@ -2965,7 +2965,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
|
||||
dependencies = [
|
||||
"rand_chacha 0.9.0",
|
||||
"rand_core 0.9.5",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2985,7 +2985,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.9.5",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2999,9 +2999,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.5"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
|
||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
]
|
||||
@@ -3187,7 +3187,7 @@ dependencies = [
|
||||
"chrono-tz",
|
||||
"log",
|
||||
"regex",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3262,9 +3262,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed"
|
||||
version = "8.11.0"
|
||||
version = "8.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04113cb9355a377d83f06ef1f0a45b8ab8cd7d8b1288160717d66df5c7988d27"
|
||||
checksum = "947d7f3fad52b283d261c4c99a084937e2fe492248cb9a68a8435a861b8798ca"
|
||||
dependencies = [
|
||||
"rust-embed-impl",
|
||||
"rust-embed-utils",
|
||||
@@ -3273,9 +3273,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed-impl"
|
||||
version = "8.11.0"
|
||||
version = "8.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da0902e4c7c8e997159ab384e6d0fc91c221375f6894346ae107f47dd0f3ccaa"
|
||||
checksum = "5fa2c8c9e8711e10f9c4fd2d64317ef13feaab820a4c51541f1a8c8e2e851ab2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -3286,9 +3286,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed-utils"
|
||||
version = "8.11.0"
|
||||
version = "8.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bcdef0be6fe7f6fa333b1073c949729274b05f123a0ad7efcb8efd878e5c3b1"
|
||||
checksum = "60b161f275cb337fe0a44d924a5f4df0ed69c2c39519858f931ce61c779d3475"
|
||||
dependencies = [
|
||||
"sha2",
|
||||
"walkdir",
|
||||
@@ -3296,9 +3296,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.27"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b50b8869d9fc858ce7266cce0194bd74df58b9d0e3f6df3a9fc8eb470d95c09d"
|
||||
checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
@@ -3317,7 +3317,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"argon2",
|
||||
@@ -3328,7 +3328,6 @@ dependencies = [
|
||||
"figment",
|
||||
"headers",
|
||||
"http",
|
||||
"ical",
|
||||
"insta",
|
||||
"opentelemetry",
|
||||
"opentelemetry-otlp",
|
||||
@@ -3349,7 +3348,6 @@ dependencies = [
|
||||
"rustical_store",
|
||||
"rustical_store_sqlite",
|
||||
"serde",
|
||||
"similar-asserts",
|
||||
"sqlx",
|
||||
"tokio",
|
||||
"toml 0.9.11+spec-1.1.0",
|
||||
@@ -3364,7 +3362,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_caldav"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"async-trait",
|
||||
@@ -3394,7 +3392,7 @@ dependencies = [
|
||||
"similar-asserts",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
@@ -3406,7 +3404,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_carddav"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
@@ -3429,7 +3427,7 @@ dependencies = [
|
||||
"serde",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
@@ -3440,7 +3438,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_dav"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
@@ -3458,7 +3456,7 @@ dependencies = [
|
||||
"rustical_xml",
|
||||
"serde",
|
||||
"strum",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tracing",
|
||||
@@ -3466,7 +3464,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_dav_push"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
@@ -3484,14 +3482,14 @@ dependencies = [
|
||||
"rustical_store",
|
||||
"rustical_xml",
|
||||
"serde",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustical_frontend"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"askama_web",
|
||||
@@ -3514,7 +3512,7 @@ dependencies = [
|
||||
"rustical_store",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
@@ -3527,7 +3525,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_ical"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -3541,12 +3539,12 @@ dependencies = [
|
||||
"serde",
|
||||
"sha2",
|
||||
"similar-asserts",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustical_oidc"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
@@ -3555,14 +3553,14 @@ dependencies = [
|
||||
"openidconnect",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tower-sessions",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustical_store"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -3585,7 +3583,7 @@ dependencies = [
|
||||
"rustical_xml",
|
||||
"serde",
|
||||
"sha2",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-sessions",
|
||||
@@ -3595,7 +3593,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_store_sqlite"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"chrono",
|
||||
@@ -3605,14 +3603,13 @@ dependencies = [
|
||||
"password-auth",
|
||||
"password-hash",
|
||||
"pbkdf2",
|
||||
"regex",
|
||||
"rstest",
|
||||
"rustical_ical",
|
||||
"rustical_store",
|
||||
"serde",
|
||||
"sha2",
|
||||
"sqlx",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"uuid",
|
||||
@@ -3620,10 +3617,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_xml"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"quick-xml",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"xml_derive",
|
||||
]
|
||||
|
||||
@@ -3656,9 +3653,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.14.0"
|
||||
version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd"
|
||||
checksum = "21e6f2ab2928ca4291b86736a8bd920a277a399bba1589409d72154ff87c1282"
|
||||
dependencies = [
|
||||
"web-time",
|
||||
"zeroize",
|
||||
@@ -3666,9 +3663,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.103.9"
|
||||
version = "0.103.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53"
|
||||
checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
@@ -4048,7 +4045,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"smallvec",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
@@ -4132,7 +4129,7 @@ dependencies = [
|
||||
"smallvec",
|
||||
"sqlx-core",
|
||||
"stringprep",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
"uuid",
|
||||
"whoami",
|
||||
@@ -4171,7 +4168,7 @@ dependencies = [
|
||||
"smallvec",
|
||||
"sqlx-core",
|
||||
"stringprep",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
"uuid",
|
||||
"whoami",
|
||||
@@ -4197,7 +4194,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_urlencoded",
|
||||
"sqlx-core",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
"url",
|
||||
"uuid",
|
||||
@@ -4316,11 +4313,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.18"
|
||||
version = "2.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
|
||||
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
|
||||
dependencies = [
|
||||
"thiserror-impl 2.0.18",
|
||||
"thiserror-impl 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4336,9 +4333,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.18"
|
||||
version = "2.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
|
||||
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -4356,30 +4353,30 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.45"
|
||||
version = "0.3.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd"
|
||||
checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa",
|
||||
"num-conv",
|
||||
"powerfmt",
|
||||
"serde_core",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.7"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca"
|
||||
checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.25"
|
||||
version = "0.2.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd"
|
||||
checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3"
|
||||
dependencies = [
|
||||
"num-conv",
|
||||
"time-core",
|
||||
@@ -4614,9 +4611,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tower"
|
||||
version = "0.5.3"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4"
|
||||
checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
@@ -4720,7 +4717,7 @@ dependencies = [
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"time",
|
||||
"tokio",
|
||||
"tracing",
|
||||
@@ -4987,9 +4984,9 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.2+wasi-0.2.9"
|
||||
version = "1.0.1+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
|
||||
checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
|
||||
dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
@@ -5002,9 +4999,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.108"
|
||||
version = "0.2.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566"
|
||||
checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
@@ -5015,12 +5012,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.58"
|
||||
version = "0.4.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70a6e77fd0ae8029c9ea0063f87c46fde723e7d887703d74ad2616d792e51e6f"
|
||||
checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-util",
|
||||
"js-sys",
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
@@ -5029,9 +5025,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.108"
|
||||
version = "0.2.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608"
|
||||
checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -5039,9 +5035,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.108"
|
||||
version = "0.2.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55"
|
||||
checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
@@ -5052,18 +5048,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.108"
|
||||
version = "0.2.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12"
|
||||
checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.85"
|
||||
version = "0.3.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "312e32e551d92129218ea9a2452120f4aabc03529ef03e4d0d82fb2780608598"
|
||||
checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
@@ -5430,9 +5426,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.51.0"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
|
||||
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
|
||||
|
||||
[[package]]
|
||||
name = "writeable"
|
||||
@@ -5442,7 +5438,7 @@ checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
|
||||
|
||||
[[package]]
|
||||
name = "xml_derive"
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"darling 0.23.0",
|
||||
"heck",
|
||||
@@ -5563,6 +5559,6 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.15"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94f63c051f4fe3c1509da62131a678643c5b6fbdc9273b2b79d4378ebda003d2"
|
||||
checksum = "ac93432f5b761b22864c774aac244fa5c0fd877678a4c37ebf6cf42208f9c9ec"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
members = ["crates/*"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.12.0"
|
||||
version = "0.11.10"
|
||||
rust-version = "1.92"
|
||||
edition = "2024"
|
||||
description = "A CalDAV server"
|
||||
@@ -73,7 +73,7 @@ tokio = { version = "1.48", features = [
|
||||
url = "2.5"
|
||||
base64 = "0.22"
|
||||
thiserror = "2.0"
|
||||
quick-xml = { version = "0.39" }
|
||||
quick-xml = { version = "0.38" }
|
||||
rust-embed = "8.9"
|
||||
tower-sessions = "0.14"
|
||||
futures-core = "0.3"
|
||||
@@ -107,7 +107,7 @@ strum = "0.27"
|
||||
strum_macros = "0.27"
|
||||
serde_json = { version = "1.0", features = ["raw_value"] }
|
||||
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",
|
||||
] }
|
||||
toml = "0.9"
|
||||
@@ -153,7 +153,6 @@ criterion = { version = "0.8", features = ["async_tokio"] }
|
||||
rstest.workspace = true
|
||||
rustical_store_sqlite = { workspace = true, features = ["test"] }
|
||||
insta.workspace = true
|
||||
similar-asserts.workspace = true
|
||||
|
||||
[dependencies]
|
||||
rustical_store.workspace = true
|
||||
@@ -161,7 +160,6 @@ rustical_store_sqlite.workspace = true
|
||||
rustical_caldav.workspace = true
|
||||
rustical_carddav.workspace = true
|
||||
rustical_frontend.workspace = true
|
||||
ical.workspace = true
|
||||
toml.workspace = true
|
||||
serde.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)"
|
||||
|
||||
COPY . .
|
||||
RUN cargo install --locked --target "$(cat /tmp/rust_target)" --path .
|
||||
RUN cargo install --target "$(cat /tmp/rust_target)" --path .
|
||||
|
||||
FROM scratch
|
||||
COPY --from=builder /usr/local/cargo/bin/rustical /usr/local/bin/rustical
|
||||
|
||||
@@ -11,6 +11,7 @@ use rustical_ical::CalendarObjectType;
|
||||
use rustical_store::{
|
||||
Calendar, CalendarMetadata, CalendarStore, SubscriptionStore, auth::Principal,
|
||||
};
|
||||
use std::io::BufReader;
|
||||
use tracing::instrument;
|
||||
|
||||
#[instrument(skip(resource_service))]
|
||||
@@ -25,11 +26,11 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
||||
return Err(Error::Unauthorized);
|
||||
}
|
||||
|
||||
let parser = ical::IcalParser::from_slice(body.as_bytes());
|
||||
let mut cal = match parser.expect_one() {
|
||||
Ok(cal) => cal.mutable(),
|
||||
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
|
||||
};
|
||||
let parser = ical::IcalParser::new(BufReader::new(body.as_bytes()));
|
||||
let mut cal = parser
|
||||
.expect_one()
|
||||
.map_err(rustical_ical::Error::ParserError)?
|
||||
.mutable();
|
||||
|
||||
// Extract calendar metadata
|
||||
let displayname = cal
|
||||
@@ -70,10 +71,12 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
||||
cal_components.push(CalendarObjectType::Todo);
|
||||
}
|
||||
|
||||
let objects = match cal.into_objects() {
|
||||
Ok(objects) => objects.into_iter().map(Into::into).collect(),
|
||||
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
|
||||
};
|
||||
let objects = cal
|
||||
.into_objects()
|
||||
.map_err(rustical_ical::Error::ParserError)?
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
.collect();
|
||||
let new_cal = Calendar {
|
||||
principal,
|
||||
id: cal_id,
|
||||
|
||||
@@ -87,7 +87,7 @@ pub async fn route_mkcalendar<C: CalendarStore, S: SubscriptionStore>(
|
||||
Some(tzid)
|
||||
} else if let Some(tz) = request.calendar_timezone {
|
||||
// TODO: Proper error (calendar-timezone precondition)
|
||||
let calendar = IcalParser::from_slice(tz.as_bytes())
|
||||
let calendar = IcalParser::new(tz.as_bytes())
|
||||
.next()
|
||||
.ok_or_else(|| rustical_dav::Error::BadRequest("No timezone data provided".to_owned()))?
|
||||
.map_err(|_| rustical_dav::Error::BadRequest("Error parsing timezone".to_owned()))?;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use crate::calendar::methods::report::calendar_query::{
|
||||
TimeRangeElement,
|
||||
prop_filter::{PropFilterElement, PropFilterable},
|
||||
TimeRangeElement, prop_filter::PropFilterElement,
|
||||
};
|
||||
use ical::{
|
||||
component::{CalendarInnerData, IcalAlarm, IcalCalendarObject, IcalEvent, IcalTodo},
|
||||
component::IcalCalendarObject,
|
||||
parser::{Component, ical::component::IcalTimeZone},
|
||||
};
|
||||
use rustical_xml::XmlDeserialize;
|
||||
@@ -26,9 +25,7 @@ pub struct CompFilterElement {
|
||||
pub(crate) name: String,
|
||||
}
|
||||
|
||||
pub trait CompFilterable: PropFilterable + Sized {
|
||||
fn get_comp_name(&self) -> &'static str;
|
||||
|
||||
pub trait CompFilterable: Component + Sized {
|
||||
fn match_time_range(&self, time_range: &TimeRangeElement) -> bool;
|
||||
|
||||
fn match_subcomponents(&self, comp_filter: &CompFilterElement) -> bool;
|
||||
@@ -70,100 +67,7 @@ pub trait CompFilterable: PropFilterable + Sized {
|
||||
}
|
||||
}
|
||||
|
||||
impl CompFilterable for CalendarInnerData {
|
||||
fn get_comp_name(&self) -> &'static str {
|
||||
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 {
|
||||
// VCALENDAR has no concept of time range
|
||||
false
|
||||
@@ -174,36 +78,23 @@ impl CompFilterable for IcalCalendarObject {
|
||||
.get_vtimezones()
|
||||
.values()
|
||||
.map(|tz| tz.matches(comp_filter))
|
||||
.chain([self.get_inner().matches(comp_filter)]);
|
||||
.chain([self.matches(comp_filter)]);
|
||||
|
||||
if comp_filter.is_not_defined.is_some() {
|
||||
matches.all(|x| !x)
|
||||
matches.all(|x| x)
|
||||
} else {
|
||||
matches.any(|x| x)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PropFilterable for IcalTimeZone {
|
||||
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 IcalTimeZone {
|
||||
fn get_comp_name(&self) -> &'static str {
|
||||
Component::get_comp_name(self)
|
||||
}
|
||||
fn match_time_range(&self, _time_range: &TimeRangeElement) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn match_subcomponents(&self, comp_filter: &CompFilterElement) -> bool {
|
||||
// VTIMEZONE has no subcomponents
|
||||
comp_filter.is_not_defined.is_some()
|
||||
fn match_subcomponents(&self, _comp_filter: &CompFilterElement) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +111,6 @@ mod tests {
|
||||
const ICS: &str = r"BEGIN:VCALENDAR
|
||||
CALSCALE:GREGORIAN
|
||||
VERSION:2.0
|
||||
PRODID:me
|
||||
BEGIN:VTIMEZONE
|
||||
TZID:Europe/Berlin
|
||||
X-LIC-LOCATION:Europe/Berlin
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::{ParamFilterElement, TimeRangeElement};
|
||||
use ical::{property::ContentLine, types::CalDateTime};
|
||||
use ical::{parser::Component, property::ContentLine, types::CalDateTime};
|
||||
use rustical_dav::xml::TextMatchElement;
|
||||
use rustical_ical::UtcDateTime;
|
||||
use rustical_xml::XmlDeserialize;
|
||||
@@ -21,10 +21,6 @@ pub struct PropFilterElement {
|
||||
pub(crate) name: String,
|
||||
}
|
||||
|
||||
pub trait PropFilterable {
|
||||
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine>;
|
||||
}
|
||||
|
||||
impl PropFilterElement {
|
||||
#[must_use]
|
||||
pub fn match_property(&self, property: &ContentLine) -> bool {
|
||||
@@ -64,7 +60,7 @@ impl PropFilterElement {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn match_component(&self, comp: &impl PropFilterable) -> bool {
|
||||
pub fn match_component(&self, comp: &impl Component) -> bool {
|
||||
let mut properties = comp.get_named_properties(&self.name);
|
||||
if self.is_not_defined.is_some() {
|
||||
return properties.next().is_none();
|
||||
|
||||
@@ -202,7 +202,7 @@ impl Resource for CalendarResource {
|
||||
CalendarProp::CalendarTimezone(timezone) => {
|
||||
if let Some(tz) = timezone {
|
||||
// TODO: Proper error (calendar-timezone precondition)
|
||||
let calendar = IcalParser::from_slice(tz.as_bytes())
|
||||
let calendar = IcalParser::new(tz.as_bytes())
|
||||
.next()
|
||||
.ok_or_else(|| {
|
||||
rustical_dav::Error::BadRequest(
|
||||
|
||||
@@ -11,7 +11,7 @@ use rustical_ical::CalendarObject;
|
||||
use rustical_store::CalendarStore;
|
||||
use rustical_store::auth::Principal;
|
||||
use std::str::FromStr;
|
||||
use tracing::{instrument, warn};
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
#[instrument(skip(cal_store))]
|
||||
pub async fn get_event<C: CalendarStore>(
|
||||
@@ -94,13 +94,9 @@ pub async fn put_event<C: CalendarStore>(
|
||||
true
|
||||
};
|
||||
|
||||
let object = match CalendarObject::from_ics(body.clone()) {
|
||||
Ok(object) => object,
|
||||
Err(err) => {
|
||||
warn!("invalid calendar data:\n{body}");
|
||||
warn!("{err}");
|
||||
let Ok(object) = CalendarObject::from_ics(body.clone()) else {
|
||||
debug!("invalid calendar data:\n{body}");
|
||||
return Err(Error::PreconditionFailed(Precondition::ValidCalendarData));
|
||||
}
|
||||
};
|
||||
let etag = object.get_etag();
|
||||
cal_store
|
||||
|
||||
@@ -23,7 +23,7 @@ impl IntoResponse for Precondition {
|
||||
if let Err(err) = error.serialize_root(&mut writer) {
|
||||
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.body(Body::from(output)).unwrap()
|
||||
}
|
||||
@@ -52,6 +52,9 @@ pub enum Error {
|
||||
#[error(transparent)]
|
||||
XmlDecodeError(#[from] rustical_xml::XmlError),
|
||||
|
||||
#[error(transparent)]
|
||||
IcalError(#[from] rustical_ical::Error),
|
||||
|
||||
#[error(transparent)]
|
||||
PreconditionFailed(Precondition),
|
||||
}
|
||||
@@ -72,20 +75,18 @@ impl Error {
|
||||
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
|
||||
Self::ChronoParseError(_) | Self::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Self::NotFound => StatusCode::NOT_FOUND,
|
||||
// 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(_err) => StatusCode::FORBIDDEN,
|
||||
Self::IcalError(err) => err.status_code(),
|
||||
Self::PreconditionFailed(_err) => StatusCode::PRECONDITION_FAILED,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoResponse for Error {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
if let Self::PreconditionFailed(precondition) = self {
|
||||
return precondition.into_response();
|
||||
}
|
||||
if matches!(self.status_code(), StatusCode::INTERNAL_SERVER_ERROR) {
|
||||
if matches!(
|
||||
self.status_code(),
|
||||
StatusCode::INTERNAL_SERVER_ERROR | StatusCode::PRECONDITION_FAILED
|
||||
) {
|
||||
error!("{self}");
|
||||
}
|
||||
(self.status_code(), self.to_string()).into_response()
|
||||
|
||||
@@ -103,10 +103,7 @@ pub async fn put_object<AS: AddressbookStore>(
|
||||
true
|
||||
};
|
||||
|
||||
let object = match AddressObject::from_vcf(body) {
|
||||
Ok(object) => object,
|
||||
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
|
||||
};
|
||||
let object = AddressObject::from_vcf(body)?;
|
||||
let etag = object.get_etag();
|
||||
addr_store
|
||||
.put_object(&principal, &addressbook_id, &object_id, object, overwrite)
|
||||
|
||||
@@ -8,7 +8,6 @@ use crate::{
|
||||
},
|
||||
};
|
||||
use derive_more::derive::{From, Into};
|
||||
use ical::parser::VcardFNProperty;
|
||||
use rustical_dav::{
|
||||
extensions::CommonPropertiesExtension,
|
||||
privileges::UserPrivilegeSet,
|
||||
@@ -71,11 +70,8 @@ impl Resource for AddressObjectResource {
|
||||
}
|
||||
|
||||
fn get_displayname(&self) -> Option<&str> {
|
||||
self.object
|
||||
.get_vcard()
|
||||
.full_name
|
||||
.first()
|
||||
.map(|VcardFNProperty(name, _)| name.as_str())
|
||||
todo!()
|
||||
// self.object.get_full_name()
|
||||
}
|
||||
|
||||
fn get_owner(&self) -> Option<&str> {
|
||||
|
||||
@@ -10,6 +10,7 @@ use ical::{
|
||||
property::ContentLine,
|
||||
};
|
||||
use rustical_store::{Addressbook, AddressbookStore, SubscriptionStore, auth::Principal};
|
||||
use std::io::BufReader;
|
||||
use tracing::instrument;
|
||||
|
||||
#[instrument(skip(resource_service))]
|
||||
@@ -23,7 +24,7 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
|
||||
return Err(Error::Unauthorized);
|
||||
}
|
||||
|
||||
let parser = vcard::VcardParser::from_slice(body.as_bytes());
|
||||
let parser = vcard::VcardParser::new(BufReader::new(body.as_bytes()));
|
||||
|
||||
let mut objects = vec![];
|
||||
for res in parser {
|
||||
|
||||
@@ -23,6 +23,9 @@ pub enum Error {
|
||||
|
||||
#[error(transparent)]
|
||||
XmlDecodeError(#[from] rustical_xml::XmlError),
|
||||
|
||||
#[error(transparent)]
|
||||
IcalError(#[from] rustical_ical::Error),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
@@ -40,6 +43,7 @@ impl Error {
|
||||
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
|
||||
Self::ChronoParseError(_) | Self::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Self::NotFound => StatusCode::NOT_FOUND,
|
||||
Self::IcalError(err) => err.status_code(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,18 +51,19 @@ impl Error {
|
||||
_ => StatusCode::BAD_REQUEST,
|
||||
},
|
||||
Self::PropReadOnly => StatusCode::CONFLICT,
|
||||
Self::PreconditionFailed => StatusCode::PRECONDITION_FAILED,
|
||||
Self::InternalError | Self::IOError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
// 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,
|
||||
Self::Forbidden => StatusCode::FORBIDDEN,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl axum::response::IntoResponse for Error {
|
||||
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}");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,15 +6,12 @@ use axum::{
|
||||
extract::{MatchedPath, Path, State},
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use axum_extra::TypedHeader;
|
||||
use headers::Host;
|
||||
use http::{HeaderMap, StatusCode, Uri};
|
||||
use matchit_serde::ParamsDeserializer;
|
||||
use serde::Deserialize;
|
||||
use tracing::instrument;
|
||||
|
||||
#[instrument(skip(path, resource_service,))]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn axum_route_copy<R: ResourceService>(
|
||||
Path(path): Path<R::PathComponents>,
|
||||
State(resource_service): State<R>,
|
||||
@@ -23,7 +20,6 @@ pub async fn axum_route_copy<R: ResourceService>(
|
||||
Overwrite(overwrite): Overwrite,
|
||||
matched_path: MatchedPath,
|
||||
header_map: HeaderMap,
|
||||
TypedHeader(host): TypedHeader<Host>,
|
||||
) -> Result<Response, R::Error> {
|
||||
let destination = header_map
|
||||
.get("Destination")
|
||||
@@ -31,11 +27,7 @@ pub async fn axum_route_copy<R: ResourceService>(
|
||||
.to_str()
|
||||
.map_err(|_| crate::Error::Forbidden)?;
|
||||
let destination_uri: Uri = destination.parse().map_err(|_| crate::Error::Forbidden)?;
|
||||
if let Some(authority) = destination_uri.authority()
|
||||
&& host != authority.clone().into()
|
||||
{
|
||||
return Err(crate::Error::Forbidden.into());
|
||||
}
|
||||
// TODO: Check that host also matches
|
||||
let destination = destination_uri.path();
|
||||
|
||||
let mut router = matchit::Router::new();
|
||||
|
||||
@@ -6,15 +6,12 @@ use axum::{
|
||||
extract::{MatchedPath, Path, State},
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use axum_extra::TypedHeader;
|
||||
use headers::Host;
|
||||
use http::{HeaderMap, StatusCode, Uri};
|
||||
use matchit_serde::ParamsDeserializer;
|
||||
use serde::Deserialize;
|
||||
use tracing::instrument;
|
||||
|
||||
#[instrument(skip(path, resource_service,))]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn axum_route_move<R: ResourceService>(
|
||||
Path(path): Path<R::PathComponents>,
|
||||
State(resource_service): State<R>,
|
||||
@@ -23,7 +20,6 @@ pub async fn axum_route_move<R: ResourceService>(
|
||||
Overwrite(overwrite): Overwrite,
|
||||
matched_path: MatchedPath,
|
||||
header_map: HeaderMap,
|
||||
TypedHeader(host): TypedHeader<Host>,
|
||||
) -> Result<Response, R::Error> {
|
||||
let destination = header_map
|
||||
.get("Destination")
|
||||
@@ -31,11 +27,7 @@ pub async fn axum_route_move<R: ResourceService>(
|
||||
.to_str()
|
||||
.map_err(|_| crate::Error::Forbidden)?;
|
||||
let destination_uri: Uri = destination.parse().map_err(|_| crate::Error::Forbidden)?;
|
||||
if let Some(authority) = destination_uri.authority()
|
||||
&& host != authority.clone().into()
|
||||
{
|
||||
return Err(crate::Error::Forbidden.into());
|
||||
}
|
||||
// TODO: Check that host also matches
|
||||
let destination = destination_uri.path();
|
||||
|
||||
let mut router = matchit::Router::new();
|
||||
|
||||
@@ -45,7 +45,7 @@ impl<PN: XmlDeserialize> XmlDeserialize for PropElement<PN> {
|
||||
// start of a child element
|
||||
Event::Start(start) | Event::Empty(start) => {
|
||||
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 {
|
||||
ResolveResult::Bound(ns) => Some(NamespaceOwned::from(ns)),
|
||||
ResolveResult::Unknown(_ns) => todo!("handle error"),
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
use crate::{CalendarObject, Error};
|
||||
use chrono::{NaiveDate, Utc};
|
||||
use ical::component::{
|
||||
CalendarInnerDataBuilder, IcalAlarmBuilder, IcalCalendarObjectBuilder, IcalEventBuilder,
|
||||
};
|
||||
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 std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
use std::{collections::HashMap, io::BufReader};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AddressObject {
|
||||
@@ -32,7 +19,7 @@ impl From<VcardContact> for AddressObject {
|
||||
|
||||
impl AddressObject {
|
||||
pub fn from_vcf(vcf: String) -> Result<Self, Error> {
|
||||
let parser = vcard::VcardParser::from_slice(vcf.as_bytes());
|
||||
let parser = vcard::VcardParser::new(BufReader::new(vcf.as_bytes()));
|
||||
let vcard = parser.expect_one()?;
|
||||
Ok(Self { vcf, vcard })
|
||||
}
|
||||
@@ -49,115 +36,24 @@ impl AddressObject {
|
||||
&self.vcf
|
||||
}
|
||||
|
||||
fn get_significant_date_object(
|
||||
&self,
|
||||
date: &PartialDate,
|
||||
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}");
|
||||
|
||||
let event = IcalEventBuilder {
|
||||
properties: vec![
|
||||
IcalDTSTAMPProperty(Utc::now().into(), vec![].into()).into(),
|
||||
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()
|
||||
},
|
||||
],
|
||||
}],
|
||||
};
|
||||
|
||||
Ok(Some(
|
||||
IcalCalendarObjectBuilder {
|
||||
properties: vec![
|
||||
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> {
|
||||
let Some(VcardANNIVERSARYProperty(anniversary, _)) = &self.vcard.anniversary else {
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(date) = &anniversary.date else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
self.get_significant_date_object(date, "💍", "-anniversary")
|
||||
todo!();
|
||||
}
|
||||
|
||||
pub fn get_birthday_object(&self) -> Result<Option<CalendarObject>, Error> {
|
||||
let Some(VcardBDAYProperty(bday, _)) = &self.vcard.birthday else {
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(date) = &bday.date else {
|
||||
return Ok(None);
|
||||
};
|
||||
todo!();
|
||||
}
|
||||
|
||||
self.get_significant_date_object(date, "🎂", "-birthday")
|
||||
/// Get significant dates associated with this address object
|
||||
pub fn get_significant_dates(&self) -> Result<HashMap<&'static str, CalendarObject>, Error> {
|
||||
let mut out = HashMap::new();
|
||||
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)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::Error;
|
||||
use derive_more::Display;
|
||||
use ical::IcalObjectParser;
|
||||
use ical::component::CalendarInnerData;
|
||||
use ical::component::IcalCalendarObject;
|
||||
use ical::generator::Emitter;
|
||||
use ical::parser::ComponentParser;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -69,7 +69,7 @@ pub struct CalendarObject {
|
||||
|
||||
impl CalendarObject {
|
||||
pub fn from_ics(ics: String) -> Result<Self, Error> {
|
||||
let parser = IcalObjectParser::from_slice(ics.as_bytes());
|
||||
let parser: ComponentParser<_, IcalCalendarObject> = ComponentParser::new(ics.as_bytes());
|
||||
let inner = parser.expect_one()?;
|
||||
|
||||
Ok(Self { inner, ics })
|
||||
|
||||
34
crates/ical/src/error.rs
Normal file
34
crates/ical/src/error.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use axum::{http::StatusCode, response::IntoResponse};
|
||||
|
||||
#[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),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
#[must_use]
|
||||
pub const fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Self::InvalidData(_) | Self::MissingCalendar | Self::MissingContact => {
|
||||
StatusCode::BAD_REQUEST
|
||||
}
|
||||
Self::ParserError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoResponse for Error {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
(self.status_code(), self.to_string()).into_response()
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
|
||||
#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
|
||||
mod timestamp;
|
||||
use ical::parser::ParserError;
|
||||
pub use timestamp::*;
|
||||
|
||||
mod calendar_object;
|
||||
pub use calendar_object::*;
|
||||
|
||||
mod error;
|
||||
pub use error::Error;
|
||||
|
||||
mod address_object;
|
||||
pub use address_object::AddressObject;
|
||||
|
||||
pub type Error = ParserError;
|
||||
|
||||
@@ -26,7 +26,7 @@ pub enum Error {
|
||||
Other(#[from] anyhow::Error),
|
||||
|
||||
#[error(transparent)]
|
||||
IcalError(#[from] ical::parser::ParserError),
|
||||
IcalError(#[from] rustical_ical::Error),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
@@ -36,8 +36,7 @@ impl Error {
|
||||
Self::NotFound => StatusCode::NOT_FOUND,
|
||||
Self::AlreadyExists => StatusCode::CONFLICT,
|
||||
Self::ReadOnly => StatusCode::FORBIDDEN,
|
||||
// TODO: Can also be Bad Request, depending on when this is raised
|
||||
Self::IcalError(_err) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Self::IcalError(err) => err.status_code(),
|
||||
Self::InvalidPrincipalType(_) => StatusCode::BAD_REQUEST,
|
||||
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
@@ -53,7 +52,9 @@ impl IntoResponse for Error {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
if matches!(
|
||||
self.status_code(),
|
||||
StatusCode::INTERNAL_SERVER_ERROR | StatusCode::CONFLICT
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
| StatusCode::PRECONDITION_FAILED
|
||||
| StatusCode::CONFLICT
|
||||
) {
|
||||
error!("{self}");
|
||||
}
|
||||
|
||||
@@ -37,4 +37,3 @@ pbkdf2.workspace = true
|
||||
rustical_ical.workspace = true
|
||||
rstest = { workspace = true, optional = true }
|
||||
sha2.workspace = true
|
||||
regex.workspace = true
|
||||
|
||||
@@ -279,7 +279,7 @@ impl CalendarStore for SqliteAddressbookStore {
|
||||
.strip_prefix(BIRTHDAYS_PREFIX)
|
||||
.ok_or(Error::NotFound)?
|
||||
.to_string();
|
||||
Self::_update_birthday_calendar(&self.db, principal, &calendar).await
|
||||
Self::_update_birthday_calendar(&self.db, &principal, &calendar).await
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
@@ -330,29 +330,14 @@ impl CalendarStore for SqliteAddressbookStore {
|
||||
.ok_or(Error::NotFound)?;
|
||||
let (objects, deleted_objects, new_synctoken) =
|
||||
AddressbookStore::sync_changes(self, principal, cal_id, synctoken).await?;
|
||||
|
||||
let mut out_objects = vec![];
|
||||
|
||||
for (object_id, object) in objects {
|
||||
if let Some(birthday) = object.get_birthday_object()? {
|
||||
out_objects.push((format!("{object_id}-birthday"), birthday));
|
||||
}
|
||||
if let Some(anniversary) = object.get_anniversary_object()? {
|
||||
out_objects.push((format!("{object_id}-anniversayr"), anniversary));
|
||||
}
|
||||
}
|
||||
|
||||
let deleted_objects = deleted_objects
|
||||
.into_iter()
|
||||
.flat_map(|object_id| {
|
||||
[
|
||||
format!("{object_id}-birthday"),
|
||||
format!("{object_id}-anniversary"),
|
||||
]
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok((out_objects, deleted_objects, new_synctoken))
|
||||
todo!();
|
||||
// let objects: Result<Vec<Option<CalendarObject>>, rustical_ical::Error> = objects
|
||||
// .iter()
|
||||
// .map(AddressObject::get_birthday_object)
|
||||
// .collect();
|
||||
// let objects = objects?.into_iter().flatten().collect();
|
||||
//
|
||||
// Ok((objects, deleted_objects, new_synctoken))
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
@@ -373,19 +358,22 @@ impl CalendarStore for SqliteAddressbookStore {
|
||||
principal: &str,
|
||||
cal_id: &str,
|
||||
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
||||
let mut objects = vec![];
|
||||
let cal_id = cal_id
|
||||
.strip_prefix(BIRTHDAYS_PREFIX)
|
||||
.ok_or(Error::NotFound)?;
|
||||
for (object_id, object) in AddressbookStore::get_objects(self, principal, cal_id).await? {
|
||||
if let Some(birthday) = object.get_birthday_object()? {
|
||||
objects.push((format!("{object_id}-birthday"), birthday));
|
||||
}
|
||||
if let Some(anniversary) = object.get_anniversary_object()? {
|
||||
objects.push((format!("{object_id}-anniversayr"), anniversary));
|
||||
}
|
||||
}
|
||||
Ok(objects)
|
||||
todo!()
|
||||
// let cal_id = cal_id
|
||||
// .strip_prefix(BIRTHDAYS_PREFIX)
|
||||
// .ok_or(Error::NotFound)?;
|
||||
// let objects: Result<Vec<HashMap<&'static str, CalendarObject>>, rustical_ical::Error> =
|
||||
// AddressbookStore::get_objects(self, principal, cal_id)
|
||||
// .await?
|
||||
// .iter()
|
||||
// .map(AddressObject::get_significant_dates)
|
||||
// .collect();
|
||||
// let objects = objects?
|
||||
// .into_iter()
|
||||
// .flat_map(HashMap::into_values)
|
||||
// .collect();
|
||||
//
|
||||
// Ok(objects)
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
@@ -400,14 +388,11 @@ impl CalendarStore for SqliteAddressbookStore {
|
||||
.strip_prefix(BIRTHDAYS_PREFIX)
|
||||
.ok_or(Error::NotFound)?;
|
||||
let (addressobject_id, date_type) = object_id.rsplit_once('-').ok_or(Error::NotFound)?;
|
||||
let obj =
|
||||
AddressbookStore::get_object(self, principal, cal_id, addressobject_id, show_deleted)
|
||||
.await?;
|
||||
match date_type {
|
||||
"birthday" => Ok(obj.get_birthday_object()?.ok_or(Error::NotFound)?),
|
||||
"anniversary" => Ok(obj.get_anniversary_object()?.ok_or(Error::NotFound)?),
|
||||
_ => Err(Error::NotFound),
|
||||
}
|
||||
.await?
|
||||
.get_significant_dates()?
|
||||
.remove(date_type)
|
||||
.ok_or(Error::NotFound)
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
|
||||
@@ -2,7 +2,6 @@ use super::ChangeOperation;
|
||||
use crate::BEGIN_IMMEDIATE;
|
||||
use async_trait::async_trait;
|
||||
use derive_more::derive::Constructor;
|
||||
use ical::parser::ParserError;
|
||||
use rustical_ical::AddressObject;
|
||||
use rustical_store::{
|
||||
Addressbook, AddressbookStore, CollectionMetadata, CollectionOperation,
|
||||
@@ -10,7 +9,7 @@ use rustical_store::{
|
||||
};
|
||||
use sqlx::{Acquire, Executor, Sqlite, SqlitePool, Transaction};
|
||||
use tokio::sync::mpsc::Sender;
|
||||
use tracing::{error, error_span, instrument, warn};
|
||||
use tracing::{error_span, instrument, warn};
|
||||
|
||||
pub mod birthday_calendar;
|
||||
|
||||
@@ -19,12 +18,6 @@ struct AddressObjectRow {
|
||||
id: 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) {
|
||||
type Error = rustical_store::Error;
|
||||
@@ -38,7 +31,6 @@ impl TryFrom<AddressObjectRow> for (String, AddressObject) {
|
||||
pub struct SqliteAddressbookStore {
|
||||
db: SqlitePool,
|
||||
sender: Sender<CollectionOperation>,
|
||||
skip_broken: bool,
|
||||
}
|
||||
|
||||
impl SqliteAddressbookStore {
|
||||
@@ -96,36 +88,6 @@ impl SqliteAddressbookStore {
|
||||
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
|
||||
async fn log_object_operation(
|
||||
tx: &mut Transaction<'_, Sqlite>,
|
||||
@@ -172,7 +134,7 @@ impl SqliteAddressbookStore {
|
||||
if let Err(err) = self.sender.try_send(CollectionOperation { topic, data }) {
|
||||
error_span!(
|
||||
"Error trying to send addressbook update notification:",
|
||||
err = format!("{err}"),
|
||||
err = format!("{err:?}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -391,8 +353,8 @@ impl SqliteAddressbookStore {
|
||||
executor: E,
|
||||
principal: &str,
|
||||
addressbook_id: &str,
|
||||
) -> Result<impl Iterator<Item = (String, Result<AddressObject, ParserError>)>, Error> {
|
||||
Ok(sqlx::query_as!(
|
||||
) -> Result<Vec<(String, AddressObject)>, rustical_store::Error> {
|
||||
sqlx::query_as!(
|
||||
AddressObjectRow,
|
||||
"SELECT id, vcf FROM addressobjects WHERE principal = ? AND addressbook_id = ? AND deleted_at IS NULL",
|
||||
principal,
|
||||
@@ -401,8 +363,8 @@ impl SqliteAddressbookStore {
|
||||
.fetch_all(executor)
|
||||
.await.map_err(crate::Error::from)?
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
)
|
||||
.map(std::convert::TryInto::try_into)
|
||||
.collect()
|
||||
}
|
||||
|
||||
async fn _get_object<'e, E: Executor<'e, Database = Sqlite>>(
|
||||
@@ -547,7 +509,7 @@ impl AddressbookStore for SqliteAddressbookStore {
|
||||
) -> Result<(), rustical_store::Error> {
|
||||
assert_eq!(principal, &addressbook.principal);
|
||||
assert_eq!(id, &addressbook.id);
|
||||
Self::_update_addressbook(&self.db, principal, id, &addressbook).await
|
||||
Self::_update_addressbook(&self.db, &principal, &id, &addressbook).await
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
@@ -645,16 +607,7 @@ impl AddressbookStore for SqliteAddressbookStore {
|
||||
principal: &str,
|
||||
addressbook_id: &str,
|
||||
) -> Result<Vec<(String, AddressObject)>, rustical_store::Error> {
|
||||
let objects = 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<_>, _>>()?)
|
||||
}
|
||||
Self::_get_objects(&self.db, principal, addressbook_id).await
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
@@ -695,9 +648,9 @@ impl AddressbookStore for SqliteAddressbookStore {
|
||||
|
||||
let sync_token = Self::log_object_operation(
|
||||
&mut tx,
|
||||
principal,
|
||||
addressbook_id,
|
||||
object_id,
|
||||
&principal,
|
||||
&addressbook_id,
|
||||
&object_id,
|
||||
ChangeOperation::Add,
|
||||
)
|
||||
.await
|
||||
|
||||
@@ -3,9 +3,7 @@ use crate::BEGIN_IMMEDIATE;
|
||||
use async_trait::async_trait;
|
||||
use chrono::TimeDelta;
|
||||
use derive_more::derive::Constructor;
|
||||
use ical::parser::ParserError;
|
||||
use ical::types::CalDateTime;
|
||||
use regex::Regex;
|
||||
use rustical_ical::{CalendarObject, CalendarObjectType};
|
||||
use rustical_store::calendar_store::CalendarQuery;
|
||||
use rustical_store::synctoken::format_synctoken;
|
||||
@@ -14,7 +12,7 @@ use rustical_store::{CollectionOperation, CollectionOperationInfo};
|
||||
use sqlx::types::chrono::NaiveDateTime;
|
||||
use sqlx::{Acquire, Executor, Sqlite, SqlitePool, Transaction};
|
||||
use tokio::sync::mpsc::Sender;
|
||||
use tracing::{error, error_span, instrument, warn};
|
||||
use tracing::{error_span, instrument, warn};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct CalendarObjectRow {
|
||||
@@ -23,37 +21,21 @@ struct CalendarObjectRow {
|
||||
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) {
|
||||
type Error = rustical_store::Error;
|
||||
|
||||
fn try_from(row: CalendarObjectRow) -> Result<Self, Self::Error> {
|
||||
let object = CalendarObject::from_ics(row.ics)?;
|
||||
if object.get_uid() != row.uid {
|
||||
warn!(
|
||||
"Calendar object {}.ics: UID={} and row uid={} do not match",
|
||||
row.id,
|
||||
object.get_uid(),
|
||||
row.uid
|
||||
);
|
||||
fn try_from(value: CalendarObjectRow) -> Result<Self, Self::Error> {
|
||||
let object = CalendarObject::from_ics(value.ics)?;
|
||||
if object.get_uid() != value.uid {
|
||||
return Err(rustical_store::Error::IcalError(
|
||||
rustical_ical::Error::InvalidData(format!(
|
||||
"uid={} and UID={} don't match",
|
||||
value.uid,
|
||||
object.get_uid()
|
||||
)),
|
||||
));
|
||||
}
|
||||
Ok((row.id, object))
|
||||
Ok((value.id, object))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +92,6 @@ impl From<CalendarRow> for Calendar {
|
||||
pub struct SqliteCalendarStore {
|
||||
db: SqlitePool,
|
||||
sender: Sender<CollectionOperation>,
|
||||
skip_broken: bool,
|
||||
}
|
||||
|
||||
impl SqliteCalendarStore {
|
||||
@@ -160,117 +141,11 @@ impl SqliteCalendarStore {
|
||||
if let Err(err) = self.sender.try_send(CollectionOperation { topic, data }) {
|
||||
error_span!(
|
||||
"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
|
||||
pub async fn repair_orphans(&self) -> Result<(), Error> {
|
||||
struct Row {
|
||||
@@ -504,8 +379,8 @@ impl SqliteCalendarStore {
|
||||
executor: E,
|
||||
principal: &str,
|
||||
cal_id: &str,
|
||||
) -> Result<impl Iterator<Item = (String, Result<CalendarObject, ParserError>)>, Error> {
|
||||
Ok(sqlx::query_as!(
|
||||
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
||||
sqlx::query_as!(
|
||||
CalendarObjectRow,
|
||||
"SELECT id, uid, ics FROM calendarobjects WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL",
|
||||
principal,
|
||||
@@ -514,8 +389,8 @@ impl SqliteCalendarStore {
|
||||
.fetch_all(executor)
|
||||
.await.map_err(crate::Error::from)?
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
)
|
||||
.map(std::convert::TryInto::try_into)
|
||||
.collect()
|
||||
}
|
||||
|
||||
async fn _calendar_query<'e, E: Executor<'e, Database = Sqlite>>(
|
||||
@@ -523,14 +398,14 @@ impl SqliteCalendarStore {
|
||||
principal: &str,
|
||||
cal_id: &str,
|
||||
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
|
||||
// miss any objects because of timezone differences
|
||||
// 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 end = query.time_end.map(|end| end + TimeDelta::days(1));
|
||||
|
||||
Ok(sqlx::query_as!(
|
||||
sqlx::query_as!(
|
||||
CalendarObjectRow,
|
||||
r"SELECT id, uid, ics FROM calendarobjects
|
||||
WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL
|
||||
@@ -548,7 +423,8 @@ impl SqliteCalendarStore {
|
||||
.await
|
||||
.map_err(crate::Error::from)?
|
||||
.into_iter()
|
||||
.map(Into::into))
|
||||
.map(std::convert::TryInto::try_into)
|
||||
.collect()
|
||||
}
|
||||
|
||||
async fn _get_object<'e, E: Executor<'e, Database = Sqlite>>(
|
||||
@@ -688,7 +564,6 @@ impl SqliteCalendarStore {
|
||||
principal: &str,
|
||||
cal_id: &str,
|
||||
synctoken: i64,
|
||||
skip_broken: bool,
|
||||
) -> Result<(Vec<(String, CalendarObject)>, Vec<String>, i64), Error> {
|
||||
struct Row {
|
||||
object_id: String,
|
||||
@@ -718,8 +593,6 @@ impl SqliteCalendarStore {
|
||||
match Self::_get_object(&mut *conn, principal, cal_id, &object_id, false).await {
|
||||
Ok(object) => objects.push((object_id, object)),
|
||||
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),
|
||||
}
|
||||
}
|
||||
@@ -870,16 +743,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
cal_id: &str,
|
||||
query: CalendarQuery,
|
||||
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
||||
let objects = 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<_>, _>>()?)
|
||||
}
|
||||
Self::_calendar_query(&self.db, principal, cal_id, query).await
|
||||
}
|
||||
|
||||
async fn calendar_metadata(
|
||||
@@ -910,16 +774,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
principal: &str,
|
||||
cal_id: &str,
|
||||
) -> Result<Vec<(String, CalendarObject)>, Error> {
|
||||
let objects = 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<_>, _>>()?)
|
||||
}
|
||||
Self::_get_objects(&self.db, principal, cal_id).await
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
@@ -947,7 +802,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
.await
|
||||
.map_err(crate::Error::from)?;
|
||||
|
||||
let calendar = Self::_get_calendar(&mut *tx, principal, cal_id, true).await?;
|
||||
let calendar = Self::_get_calendar(&mut *tx, &principal, &cal_id, true).await?;
|
||||
if calendar.subscription_url.is_some() {
|
||||
// We cannot commit an object to a subscription calendar
|
||||
return Err(Error::ReadOnly);
|
||||
@@ -958,14 +813,17 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
sync_token = Some(
|
||||
Self::log_object_operation(
|
||||
&mut tx,
|
||||
principal,
|
||||
cal_id,
|
||||
&principal,
|
||||
&cal_id,
|
||||
&object_id,
|
||||
ChangeOperation::Add,
|
||||
)
|
||||
.await?,
|
||||
);
|
||||
Self::_put_object(&mut *tx, principal, cal_id, &object_id, &object, overwrite).await?;
|
||||
Self::_put_object(
|
||||
&mut *tx, &principal, &cal_id, &object_id, &object, overwrite,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
tx.commit().await.map_err(crate::Error::from)?;
|
||||
@@ -973,7 +831,9 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
if let Some(sync_token) = sync_token {
|
||||
self.send_push_notification(
|
||||
CollectionOperationInfo::Content { sync_token },
|
||||
self.get_calendar(principal, cal_id, true).await?.push_topic,
|
||||
self.get_calendar(&principal, &cal_id, true)
|
||||
.await?
|
||||
.push_topic,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
@@ -1042,7 +902,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
cal_id: &str,
|
||||
synctoken: i64,
|
||||
) -> 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 {
|
||||
|
||||
@@ -18,7 +18,7 @@ impl From<sqlx::Error> for Error {
|
||||
sqlx::Error::RowNotFound => Self::StoreError(rustical_store::Error::NotFound),
|
||||
sqlx::Error::Database(err) => {
|
||||
if err.is_unique_violation() {
|
||||
warn!("{err}");
|
||||
warn!("{err:?}");
|
||||
Self::StoreError(rustical_store::Error::AlreadyExists)
|
||||
} else {
|
||||
Self::SqlxError(sqlx::Error::Database(err))
|
||||
|
||||
@@ -52,8 +52,8 @@ pub async fn test_store_context() -> TestStoreContext {
|
||||
let db = get_test_db().await;
|
||||
TestStoreContext {
|
||||
db: db.clone(),
|
||||
addr_store: SqliteAddressbookStore::new(db.clone(), send_addr, false),
|
||||
cal_store: SqliteCalendarStore::new(db.clone(), send_cal, false),
|
||||
addr_store: SqliteAddressbookStore::new(db.clone(), send_addr),
|
||||
cal_store: SqliteCalendarStore::new(db.clone(), send_cal),
|
||||
principal_store: SqlitePrincipalStore::new(db.clone()),
|
||||
sub_store: SqliteStore::new(db),
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ impl NamedStruct {
|
||||
#(#builder_field_inits),*
|
||||
};
|
||||
|
||||
let (ns, name) = reader.resolver().resolve_element(start.name());
|
||||
let (ns, name) = reader.resolve_element(start.name());
|
||||
#(#tagname_field_branches);*
|
||||
#(#namespace_field_branches);*
|
||||
|
||||
@@ -161,7 +161,7 @@ impl NamedStruct {
|
||||
// start of a child element
|
||||
Event::Start(start) | Event::Empty(start) => {
|
||||
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()) {
|
||||
#(#named_field_branches),*
|
||||
#(#untagged_field_branches),*
|
||||
|
||||
@@ -42,7 +42,7 @@ impl<T: XmlRootTag + XmlDeserialize> XmlDocument for T {
|
||||
match event {
|
||||
Event::Decl(_) | Event::Comment(_) => { /* ignore this */ }
|
||||
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) {
|
||||
// Wrong tag
|
||||
(_, _, 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(),
|
||||
data_store: DataStoreConfig::Sqlite(SqliteDataStoreConfig {
|
||||
db_url: "/var/lib/rustical/db.sqlite3".to_owned(),
|
||||
run_repairs: true,
|
||||
skip_broken: true,
|
||||
}),
|
||||
tracing: TracingConfig::default(),
|
||||
frontend: FrontendConfig {
|
||||
|
||||
@@ -26,10 +26,6 @@ impl Default for HttpConfig {
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct SqliteDataStoreConfig {
|
||||
pub db_url: String,
|
||||
#[serde(default = "default_true")]
|
||||
pub run_repairs: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub skip_broken: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
|
||||
@@ -8,7 +8,7 @@ use rustical_store::{CalendarMetadata, CalendarStore};
|
||||
use rustical_store_sqlite::tests::{TestStoreContext, test_store_context};
|
||||
use tower::ServiceExt;
|
||||
|
||||
pub fn mkcalendar_template(
|
||||
fn mkcalendar_template(
|
||||
CalendarMetadata {
|
||||
displayname,
|
||||
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>
|
||||
"#;
|
||||
|
||||
// Adapted from Example 7.8.3 of RFC 4791
|
||||
// In the RFC the output is wrong since it returns DTSTART in UTC as local time, e.g.
|
||||
// DTSTART:20060103T170000
|
||||
// instead of
|
||||
// DTSTART:20060103T170000Z
|
||||
// In https://datatracker.ietf.org/doc/html/rfc4791#section-9.6.5
|
||||
// it is clearly stated that times with timezone information MUST be returned in UTC.
|
||||
// Also, the RECURRENCE-ID needs to include the TIMEZONE, which is fixed here by converting it to
|
||||
// UTC
|
||||
const OUTPUT_7_8_3: &str = r#"<?xml version="1.0" encoding="utf-8"?>
|
||||
<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">
|
||||
<response>
|
||||
<href>/caldav/principal/user/calendar/abcd2.ics</href>
|
||||
<propstat>
|
||||
<prop>
|
||||
<CAL:calendar-data>BEGIN:VCALENDAR
|
||||
const OUTPUT_7_8_3: &str = r#"
|
||||
<D:response>
|
||||
<D:href>http://cal.example.com/bernard/work/abcd2.ics</D:href>
|
||||
<D:propstat>
|
||||
<D:prop>
|
||||
<D:getetag>"fffff-abcd2"</D:getetag>
|
||||
<C:calendar-data>BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||
BEGIN:VEVENT
|
||||
DTSTAMP:20060206T001121Z
|
||||
DTSTART:20060103T170000Z
|
||||
DTSTART:20060103T170000
|
||||
DURATION:PT1H
|
||||
RECURRENCE-ID:20060103T170000
|
||||
SUMMARY:Event #2
|
||||
UID:abcd2
|
||||
RECURRENCE-ID:20060103T170000Z
|
||||
UID:00959BC664CA650E933C892C@example.com
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
DTSTAMP:20060206T001121Z
|
||||
DTSTART:20060104T190000Z
|
||||
DTSTART:20060104T190000
|
||||
DURATION:PT1H
|
||||
RECURRENCE-ID:20060104T170000Z
|
||||
RECURRENCE-ID:20060104T170000
|
||||
SUMMARY:Event #2 bis
|
||||
UID:abcd2
|
||||
UID:00959BC664CA650E933C892C@example.com
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
</CAL:calendar-data>
|
||||
</prop>
|
||||
<status>HTTP/1.1 200 OK</status>
|
||||
</propstat>
|
||||
</response>
|
||||
<response>
|
||||
<href>/caldav/principal/user/calendar/abcd3.ics</href>
|
||||
<propstat>
|
||||
<prop>
|
||||
<CAL:calendar-data>BEGIN:VCALENDAR
|
||||
</C:calendar-data>
|
||||
</D:prop>
|
||||
<D:status>HTTP/1.1 200 OK</D:status>
|
||||
</D:propstat>
|
||||
</D:response>
|
||||
<D:response>
|
||||
<D:href>http://cal.example.com/bernard/work/abcd3.ics</D:href>
|
||||
<D:propstat>
|
||||
<D:prop>
|
||||
<D:getetag>"fffff-abcd3"</D:getetag>
|
||||
<C:calendar-data>BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||
BEGIN:VEVENT
|
||||
ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:cyrus@example.com
|
||||
ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
|
||||
DTSTAMP:20060206T001220Z
|
||||
DTSTART:20060104T150000Z
|
||||
DTSTART:20060104T150000
|
||||
DURATION:PT1H
|
||||
LAST-MODIFIED:20060206T001330Z
|
||||
ORGANIZER:mailto:cyrus@example.com
|
||||
SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:abcd3
|
||||
UID:DC6C50A017428C5216A2F1CD@example.com
|
||||
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>"#;
|
||||
</C:calendar-data>
|
||||
</D:prop>
|
||||
<D:status>HTTP/1.1 200 OK</D:status>
|
||||
</D:propstat>
|
||||
"#;
|
||||
|
||||
#[rstest]
|
||||
#[case(0, ICS_1, REPORT_7_8_1, None)]
|
||||
#[case(1, ICS_1, REPORT_7_8_2, None)]
|
||||
#[case(2, ICS_1, REPORT_7_8_3, Some(OUTPUT_7_8_3))]
|
||||
#[case(0, ICS_1, REPORT_7_8_1)]
|
||||
#[case(1, ICS_1, REPORT_7_8_2)]
|
||||
#[case(2, ICS_1, REPORT_7_8_3)]
|
||||
#[tokio::test]
|
||||
async fn test_report(
|
||||
#[from(test_store_context)]
|
||||
@@ -168,7 +159,6 @@ async fn test_report(
|
||||
#[case] case: usize,
|
||||
#[case] ics: &'static str,
|
||||
#[case] report: &'static str,
|
||||
#[case] output: Option<&'static str>,
|
||||
) {
|
||||
let context = context.await;
|
||||
let app = get_app(context.clone());
|
||||
@@ -203,7 +193,4 @@ async fn test_report(
|
||||
assert_eq!(response.status(), StatusCode::MULTI_STATUS);
|
||||
let body = response.extract_string().await;
|
||||
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_import;
|
||||
mod calendar_put;
|
||||
mod calendar_report;
|
||||
// mod calendar_report;
|
||||
|
||||
#[rstest]
|
||||
#[tokio::test]
|
||||
|
||||
@@ -55,7 +55,6 @@ SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:abcd3
|
||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
||||
END:VEVENT
|
||||
BEGIN:VTODO
|
||||
DTSTAMP:20060205T235335Z
|
||||
|
||||
@@ -60,7 +60,6 @@ SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:[UID]
|
||||
X-ABC-GUID:[UID]
|
||||
END:VEVENT
|
||||
BEGIN:VTODO
|
||||
DTSTAMP:20060205T235335Z
|
||||
|
||||
@@ -56,7 +56,7 @@ END:VCALENDAR
|
||||
<href>/caldav/principal/user/calendar/abcd3.ics</href>
|
||||
<propstat>
|
||||
<prop>
|
||||
<getetag>"a84fd022dfc742bf8f17ac04fca3aad687e9ae724180185e8e0df11e432dae30"</getetag>
|
||||
<getetag>"c6a5b1cf6985805686df99e7f2e1cf286567dcb3383fc6fa1b12ce42d3fbc01c"</getetag>
|
||||
<CAL:calendar-data>BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||
@@ -90,7 +90,6 @@ SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:abcd3
|
||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
</CAL:calendar-data>
|
||||
|
||||
@@ -88,7 +88,6 @@ SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:abcd3
|
||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
</CAL:calendar-data>
|
||||
|
||||
@@ -13,19 +13,19 @@ VERSION:2.0
|
||||
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||
BEGIN:VEVENT
|
||||
DTSTAMP:20060206T001121Z
|
||||
DTSTART:20060103T170000Z
|
||||
DURATION:PT1H
|
||||
SUMMARY:Event #2
|
||||
UID:abcd2
|
||||
RECURRENCE-ID:20060103T170000Z
|
||||
DTSTART:20060103T170000Z
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
DTSTAMP:20060206T001121Z
|
||||
DTSTART:20060104T190000Z
|
||||
DURATION:PT1H
|
||||
RECURRENCE-ID:20060104T170000Z
|
||||
SUMMARY:Event #2 bis
|
||||
SUMMARY:Event #2
|
||||
UID:abcd2
|
||||
RECURRENCE-ID:20060104T170000Z
|
||||
DTSTART:20060104T170000Z
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
</CAL:calendar-data>
|
||||
@@ -44,7 +44,7 @@ BEGIN:VEVENT
|
||||
ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:cyrus@example.com
|
||||
ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
|
||||
DTSTAMP:20060206T001220Z
|
||||
DTSTART:20060104T150000Z
|
||||
DTSTART;TZID=US/Eastern:20060104T100000
|
||||
DURATION:PT1H
|
||||
LAST-MODIFIED:20060206T001330Z
|
||||
ORGANIZER:mailto:cyrus@example.com
|
||||
@@ -52,7 +52,6 @@ SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:abcd3
|
||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
</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 tower::Layer;
|
||||
use tower_http::normalize_path::NormalizePathLayer;
|
||||
use tracing::{info, warn};
|
||||
use tracing::info;
|
||||
|
||||
mod app;
|
||||
mod commands;
|
||||
@@ -67,36 +67,17 @@ async fn get_data_stores(
|
||||
Receiver<CollectionOperation>,
|
||||
)> {
|
||||
Ok(match &config {
|
||||
DataStoreConfig::Sqlite(SqliteDataStoreConfig {
|
||||
db_url,
|
||||
run_repairs,
|
||||
skip_broken,
|
||||
}) => {
|
||||
DataStoreConfig::Sqlite(SqliteDataStoreConfig { db_url }) => {
|
||||
let db = create_db_pool(db_url, migrate).await?;
|
||||
// Channel to watch for changes (for DAV Push)
|
||||
let (send, recv) = tokio::sync::mpsc::channel(1000);
|
||||
|
||||
let addressbook_store = Arc::new(SqliteAddressbookStore::new(
|
||||
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");
|
||||
let addressbook_store = Arc::new(SqliteAddressbookStore::new(db.clone(), send.clone()));
|
||||
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?;
|
||||
}
|
||||
let subscription_store = Arc::new(SqliteStore::new(db.clone()));
|
||||
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,
|
||||
cal_store,
|
||||
|
||||
Reference in New Issue
Block a user