mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 21:18:19 +00:00
Compare commits
19 Commits
main
...
b9c2a4cc27
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9c2a4cc27 | ||
|
|
c91205558e | ||
|
|
cd9e3ed8d6 | ||
|
|
200d5e7170 | ||
|
|
5cb538d3fb | ||
|
|
d9da123ff4 | ||
|
|
eba2f0da9f | ||
|
|
291bd967da | ||
|
|
002814a564 | ||
|
|
ba13aaa703 | ||
|
|
7a02bfeffc | ||
|
|
1b69148d6f | ||
|
|
f4de80c6b9 | ||
|
|
7a1ec3e351 | ||
|
|
eb7bdd0018 | ||
|
|
8e583e24cb | ||
|
|
5e5017a185 | ||
|
|
3c87191f69 | ||
|
|
d1947a159b |
8
.github/workflows/docker-publish.yml
vendored
8
.github/workflows/docker-publish.yml
vendored
@@ -2,10 +2,7 @@ name: Docker
|
||||
|
||||
on:
|
||||
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}}
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,7 +3,7 @@ crates/*/target
|
||||
# For libraries ignore Cargo.lock
|
||||
crates/*/Cargo.lock
|
||||
|
||||
**/*.sqlite3*
|
||||
db.sqlite3*
|
||||
config.toml
|
||||
principals.toml
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
217
Cargo.lock
generated
217
Cargo.lock
generated
@@ -181,9 +181,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "askama_web"
|
||||
version = "0.15.1"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5911a65ac3916ef133167a855d52978f9fbf54680a093e0ef29e20b7e94a4523"
|
||||
checksum = "c0d6576f8e59513752a3e2673ca602fb403be7d0d0aacba5cd8b219838ab58fe"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"askama_web_derive",
|
||||
@@ -565,24 +565,6 @@ version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3"
|
||||
|
||||
[[package]]
|
||||
name = "caldata"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f36de4a8034d98c95e7fe874b828272d823cfbd68e9571fe7bf6c419e852cbe2"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
"derive_more",
|
||||
"itertools 0.14.0",
|
||||
"lazy_static",
|
||||
"phf 0.13.1",
|
||||
"regex",
|
||||
"rrule",
|
||||
"thiserror 2.0.18",
|
||||
"vtimezones-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cast"
|
||||
version = "0.3.0"
|
||||
@@ -591,9 +573,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.54"
|
||||
version = "1.2.52"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6354c81bbfd62d9cfa9cb3c773c2b7b2a3a482d569de977fd0e961f6e7c00583"
|
||||
checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
@@ -1259,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"
|
||||
@@ -1786,6 +1768,22 @@ dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ical"
|
||||
version = "0.12.0-dev"
|
||||
source = "git+https://github.com/lennart-k/ical-rs?branch=dev#5e61c25646c3785448d349e7d18b2833fc483c53"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
"derive_more",
|
||||
"itertools 0.14.0",
|
||||
"lazy_static",
|
||||
"phf 0.13.1",
|
||||
"regex",
|
||||
"rrule",
|
||||
"thiserror 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_collections"
|
||||
version = "2.1.1"
|
||||
@@ -2027,9 +2025,9 @@ checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.16"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
|
||||
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
@@ -2120,7 +2118,7 @@ dependencies = [
|
||||
"matchit 0.9.1",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2202,9 +2200,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.2.0"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050"
|
||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
@@ -2372,7 +2370,7 @@ dependencies = [
|
||||
"futures-sink",
|
||||
"js-sys",
|
||||
"pin-project-lite",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
@@ -2402,7 +2400,7 @@ dependencies = [
|
||||
"opentelemetry_sdk",
|
||||
"prost",
|
||||
"reqwest",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tonic",
|
||||
"tracing",
|
||||
@@ -2439,7 +2437,7 @@ dependencies = [
|
||||
"opentelemetry",
|
||||
"percent-encoding",
|
||||
"rand 0.9.2",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
]
|
||||
@@ -2612,12 +2610,22 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "phf_codegen"
|
||||
version = "0.13.1"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1"
|
||||
checksum = "efbdcb6f01d193b17f0b9c3360fa7e0e620991b193ff08702f78b3ce365d7e61"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_shared 0.13.1",
|
||||
"phf_generator 0.12.1",
|
||||
"phf_shared 0.12.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cbb1126afed61dd6368748dae63b1ee7dc480191c6262a3b4ff1e29d86a6c5b"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"phf_shared 0.12.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2636,7 +2644,7 @@ version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_generator 0.13.1",
|
||||
"phf_shared 0.13.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -2817,9 +2825,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.106"
|
||||
version = "1.0.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||
checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -2862,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",
|
||||
]
|
||||
@@ -2883,7 +2891,7 @@ dependencies = [
|
||||
"rustc-hash",
|
||||
"rustls",
|
||||
"socket2",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"web-time",
|
||||
@@ -2904,7 +2912,7 @@ dependencies = [
|
||||
"rustls",
|
||||
"rustls-pki-types",
|
||||
"slab",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tinyvec",
|
||||
"tracing",
|
||||
"web-time",
|
||||
@@ -2926,9 +2934,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.44"
|
||||
version = "1.0.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
|
||||
checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -3179,7 +3187,7 @@ dependencies = [
|
||||
"chrono-tz",
|
||||
"log",
|
||||
"regex",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3309,17 +3317,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"argon2",
|
||||
"async-trait",
|
||||
"axum",
|
||||
"axum-extra",
|
||||
"caldata",
|
||||
"clap",
|
||||
"figment",
|
||||
"futures-util",
|
||||
"headers",
|
||||
"http",
|
||||
"insta",
|
||||
@@ -3342,11 +3348,8 @@ dependencies = [
|
||||
"rustical_store",
|
||||
"rustical_store_sqlite",
|
||||
"serde",
|
||||
"similar-asserts",
|
||||
"sqlx",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"toml 0.9.11+spec-1.1.0",
|
||||
"tower",
|
||||
"tower-http",
|
||||
@@ -3359,20 +3362,20 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_caldav"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"async-trait",
|
||||
"axum",
|
||||
"axum-extra",
|
||||
"base64 0.22.1",
|
||||
"caldata",
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
"derive_more",
|
||||
"futures-util",
|
||||
"headers",
|
||||
"http",
|
||||
"ical",
|
||||
"insta",
|
||||
"percent-encoding",
|
||||
"quick-xml",
|
||||
@@ -3389,7 +3392,7 @@ dependencies = [
|
||||
"similar-asserts",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
@@ -3401,17 +3404,17 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_carddav"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
"axum-extra",
|
||||
"base64 0.22.1",
|
||||
"caldata",
|
||||
"chrono",
|
||||
"derive_more",
|
||||
"futures-util",
|
||||
"http",
|
||||
"ical",
|
||||
"insta",
|
||||
"percent-encoding",
|
||||
"quick-xml",
|
||||
@@ -3424,7 +3427,7 @@ dependencies = [
|
||||
"serde",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
@@ -3435,16 +3438,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_dav"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
"axum-extra",
|
||||
"caldata",
|
||||
"derive_more",
|
||||
"futures-util",
|
||||
"headers",
|
||||
"http",
|
||||
"ical",
|
||||
"itertools 0.14.0",
|
||||
"log",
|
||||
"matchit 0.9.1",
|
||||
@@ -3453,7 +3456,7 @@ dependencies = [
|
||||
"rustical_xml",
|
||||
"serde",
|
||||
"strum",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tracing",
|
||||
@@ -3461,7 +3464,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_dav_push"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
@@ -3479,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.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"askama_web",
|
||||
@@ -3509,7 +3512,7 @@ dependencies = [
|
||||
"rustical_store",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
@@ -3522,13 +3525,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_ical"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"caldata",
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
"derive_more",
|
||||
"ical",
|
||||
"regex",
|
||||
"rrule",
|
||||
"rstest",
|
||||
@@ -3536,12 +3539,12 @@ dependencies = [
|
||||
"serde",
|
||||
"sha2",
|
||||
"similar-asserts",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustical_oidc"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
@@ -3550,19 +3553,18 @@ dependencies = [
|
||||
"openidconnect",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tower-sessions",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustical_store"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"axum",
|
||||
"caldata",
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
"clap",
|
||||
@@ -3570,6 +3572,7 @@ dependencies = [
|
||||
"futures-core",
|
||||
"headers",
|
||||
"http",
|
||||
"ical",
|
||||
"regex",
|
||||
"rrule",
|
||||
"rstest",
|
||||
@@ -3580,7 +3583,7 @@ dependencies = [
|
||||
"rustical_xml",
|
||||
"serde",
|
||||
"sha2",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-sessions",
|
||||
@@ -3590,24 +3593,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_store_sqlite"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"caldata",
|
||||
"chrono",
|
||||
"criterion",
|
||||
"derive_more",
|
||||
"ical",
|
||||
"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",
|
||||
@@ -3615,10 +3617,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustical_xml"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"quick-xml",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"xml_derive",
|
||||
]
|
||||
|
||||
@@ -3651,9 +3653,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.14.0"
|
||||
version = "1.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd"
|
||||
checksum = "4910321ebe4151be888e35fe062169554e74aad01beafed60410131420ceffbc"
|
||||
dependencies = [
|
||||
"web-time",
|
||||
"zeroize",
|
||||
@@ -3661,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",
|
||||
@@ -3975,9 +3977,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.6.2"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0"
|
||||
checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.60.2",
|
||||
@@ -4043,7 +4045,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"smallvec",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
@@ -4127,7 +4129,7 @@ dependencies = [
|
||||
"smallvec",
|
||||
"sqlx-core",
|
||||
"stringprep",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
"uuid",
|
||||
"whoami",
|
||||
@@ -4166,7 +4168,7 @@ dependencies = [
|
||||
"smallvec",
|
||||
"sqlx-core",
|
||||
"stringprep",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
"uuid",
|
||||
"whoami",
|
||||
@@ -4192,7 +4194,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_urlencoded",
|
||||
"sqlx-core",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
"url",
|
||||
"uuid",
|
||||
@@ -4311,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]]
|
||||
@@ -4331,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",
|
||||
@@ -4351,9 +4353,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.46"
|
||||
version = "0.3.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9da98b7d9b7dad93488a84b8248efc35352b0b2657397d4167e7ad67e5d535e5"
|
||||
checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa",
|
||||
@@ -4366,15 +4368,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.8"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca"
|
||||
checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.26"
|
||||
version = "0.2.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78cc610bac2dcee56805c99642447d4c5dbde4d01f752ffea0199aee1f601dc4"
|
||||
checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd"
|
||||
dependencies = [
|
||||
"num-conv",
|
||||
"time-core",
|
||||
@@ -4474,7 +4476,6 @@ dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
@@ -4716,7 +4717,7 @@ dependencies = [
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.18",
|
||||
"thiserror 2.0.17",
|
||||
"time",
|
||||
"tokio",
|
||||
"tracing",
|
||||
@@ -4947,12 +4948,12 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "vtimezones-rs"
|
||||
version = "0.3.1"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e4e9cf6888a927b6cec4aa2416f379885b92dd2aa4476bc83718fe58051f67e"
|
||||
checksum = "f6728de8767c8dea44f41b88115a205ed23adc3302e1b4342be59d922934dae5"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"phf 0.13.1",
|
||||
"phf 0.12.1",
|
||||
"phf_codegen",
|
||||
]
|
||||
|
||||
@@ -5438,7 +5439,7 @@ checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
|
||||
|
||||
[[package]]
|
||||
name = "xml_derive"
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
dependencies = [
|
||||
"darling 0.23.0",
|
||||
"heck",
|
||||
@@ -5559,6 +5560,6 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.16"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfcd145825aace48cff44a8844de64bf75feec3080e0aa5cdbde72961ae51a65"
|
||||
checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea"
|
||||
|
||||
23
Cargo.toml
23
Cargo.toml
@@ -2,7 +2,7 @@
|
||||
members = ["crates/*"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.12.3"
|
||||
version = "0.11.10"
|
||||
rust-version = "1.92"
|
||||
edition = "2024"
|
||||
description = "A CalDAV server"
|
||||
@@ -32,11 +32,8 @@ opentelemetry = [
|
||||
"dep:tracing-opentelemetry",
|
||||
]
|
||||
|
||||
[lib]
|
||||
doc = true
|
||||
name = "rustical"
|
||||
path = "src/lib.rs"
|
||||
test = true
|
||||
[profile.dev]
|
||||
debug = 0
|
||||
|
||||
[workspace.dependencies]
|
||||
rustical_dav = { path = "./crates/dav/", features = ["ical"] }
|
||||
@@ -73,11 +70,10 @@ tokio = { version = "1.48", features = [
|
||||
"rt-multi-thread",
|
||||
"full",
|
||||
] }
|
||||
tokio-util = { version = "0.7", features = ["rt"] }
|
||||
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"
|
||||
@@ -111,7 +107,9 @@ strum = "0.27"
|
||||
strum_macros = "0.27"
|
||||
serde_json = { version = "1.0", features = ["raw_value"] }
|
||||
sqlx-sqlite = { version = "0.8", features = ["bundled"] }
|
||||
caldata = { version = "0.14.0", features = ["chrono-tz", "vtimezones-rs"] }
|
||||
ical = { git = "https://github.com/lennart-k/ical-rs", branch = "dev", features = [
|
||||
"chrono-tz",
|
||||
] }
|
||||
toml = "0.9"
|
||||
tower = "0.5"
|
||||
tower-http = { version = "0.6", features = [
|
||||
@@ -141,7 +139,7 @@ reqwest = { version = "0.12", features = [
|
||||
openidconnect = "4.0"
|
||||
clap = { version = "4.5", features = ["derive", "env"] }
|
||||
matchit-serde = { git = "https://github.com/lennart-k/matchit-serde", rev = "e18e65d7" }
|
||||
vtimezones-rs = "0.3"
|
||||
vtimezones-rs = "0.2"
|
||||
ece = { version = "2.3", default-features = false, features = [
|
||||
"backend-openssl",
|
||||
] }
|
||||
@@ -155,8 +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
|
||||
tempfile = "3.24"
|
||||
|
||||
[dependencies]
|
||||
rustical_store.workspace = true
|
||||
@@ -164,11 +160,9 @@ rustical_store_sqlite.workspace = true
|
||||
rustical_caldav.workspace = true
|
||||
rustical_carddav.workspace = true
|
||||
rustical_frontend.workspace = true
|
||||
caldata.workspace = true
|
||||
toml.workspace = true
|
||||
serde.workspace = true
|
||||
tokio.workspace = true
|
||||
tokio-util.workspace = true
|
||||
tracing.workspace = true
|
||||
anyhow.workspace = true
|
||||
clap.workspace = true
|
||||
@@ -207,4 +201,3 @@ tower-http.workspace = true
|
||||
axum-extra.workspace = true
|
||||
headers.workspace = true
|
||||
http.workspace = true
|
||||
futures-util.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
|
||||
|
||||
@@ -24,7 +24,6 @@ a CalDAV/CardDAV server
|
||||
- Apple configuration profiles (skip copy-pasting passwords and instead generate the configuration in the frontend)
|
||||
- **OpenID Connect** support (with option to disable password login)
|
||||
- Group-based **sharing**
|
||||
- Partial [RFC 7809](https://datatracker.ietf.org/doc/html/rfc7809) support. RustiCal will accept timezones by reference and handle omitted timezones in objects.
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ rustical_store.workspace = true
|
||||
chrono.workspace = true
|
||||
chrono-tz.workspace = true
|
||||
sha2.workspace = true
|
||||
caldata.workspace = true
|
||||
ical.workspace = true
|
||||
percent-encoding.workspace = true
|
||||
rustical_xml.workspace = true
|
||||
uuid.workspace = true
|
||||
|
||||
@@ -3,11 +3,11 @@ use crate::calendar::CalendarResourceService;
|
||||
use axum::body::Body;
|
||||
use axum::extract::State;
|
||||
use axum::{extract::Path, response::Response};
|
||||
use caldata::component::IcalCalendar;
|
||||
use caldata::generator::Emitter;
|
||||
use caldata::parser::ContentLine;
|
||||
use headers::{ContentType, HeaderMapExt};
|
||||
use http::{HeaderValue, Method, StatusCode, header};
|
||||
use ical::component::IcalCalendar;
|
||||
use ical::generator::Emitter;
|
||||
use ical::property::ContentLine;
|
||||
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
||||
use rustical_store::{CalendarStore, SubscriptionStore, auth::Principal};
|
||||
use std::str::FromStr;
|
||||
|
||||
@@ -4,9 +4,8 @@ use axum::{
|
||||
extract::{Path, State},
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use caldata::component::{Component, ComponentMut};
|
||||
use caldata::{IcalParser, parser::ParserOptions};
|
||||
use http::StatusCode;
|
||||
use ical::parser::{Component, ComponentMut};
|
||||
use rustical_dav::header::Overwrite;
|
||||
use rustical_ical::CalendarObjectType;
|
||||
use rustical_store::{
|
||||
@@ -26,11 +25,8 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
||||
return Err(Error::Unauthorized);
|
||||
}
|
||||
|
||||
let parser = 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::from_slice(body.as_bytes());
|
||||
let mut cal = parser.expect_one()?.mutable();
|
||||
|
||||
// Extract calendar metadata
|
||||
let displayname = cal
|
||||
@@ -50,7 +46,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
||||
cal.remove_property("X-WR-CALDESC");
|
||||
cal.remove_property("X-WR-CALCOLOR");
|
||||
cal.remove_property("X-WR-TIMEZONE");
|
||||
let cal = cal.build(&ParserOptions::default(), None).unwrap();
|
||||
let cal = cal.build(None).unwrap();
|
||||
|
||||
// Make sure timezone is valid
|
||||
if let Some(timezone_id) = timezone_id.as_ref() {
|
||||
@@ -71,10 +67,7 @@ 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()?.into_iter().map(Into::into).collect();
|
||||
let new_cal = Calendar {
|
||||
principal,
|
||||
id: cal_id,
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::Error;
|
||||
use crate::calendar::CalendarResourceService;
|
||||
use crate::calendar::prop::SupportedCalendarComponentSet;
|
||||
use crate::error::Precondition;
|
||||
use axum::extract::{Path, State};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use caldata::IcalParser;
|
||||
use http::{Method, StatusCode};
|
||||
use ical::IcalParser;
|
||||
use rustical_dav::xml::HrefElement;
|
||||
use rustical_ical::CalendarObjectType;
|
||||
use rustical_store::auth::Principal;
|
||||
@@ -87,33 +84,21 @@ pub async fn route_mkcalendar<C: CalendarStore, S: SubscriptionStore>(
|
||||
}
|
||||
|
||||
let timezone_id = if let Some(tzid) = request.calendar_timezone_id {
|
||||
if chrono_tz::Tz::from_str(&tzid).is_err() {
|
||||
return Err(Error::PreconditionFailed(Precondition::CalendarTimezone(
|
||||
"Invalid timezone ID in calendar-timezone-id",
|
||||
)));
|
||||
}
|
||||
Some(tzid)
|
||||
} else if let Some(tz) = request.calendar_timezone {
|
||||
// TODO: Proper error (calendar-timezone precondition)
|
||||
let calendar = IcalParser::from_slice(tz.as_bytes())
|
||||
.next()
|
||||
.ok_or(Error::PreconditionFailed(Precondition::CalendarTimezone(
|
||||
"No timezone data provided",
|
||||
)))?
|
||||
.map_err(|_| {
|
||||
Error::PreconditionFailed(Precondition::CalendarTimezone("Error parsing timezone"))
|
||||
})?;
|
||||
.ok_or_else(|| rustical_dav::Error::BadRequest("No timezone data provided".to_owned()))?
|
||||
.map_err(|_| rustical_dav::Error::BadRequest("Error parsing timezone".to_owned()))?;
|
||||
|
||||
let timezone = calendar
|
||||
.vtimezones
|
||||
.values()
|
||||
.next()
|
||||
.ok_or(Error::PreconditionFailed(Precondition::CalendarTimezone(
|
||||
"No timezone data provided",
|
||||
)))?;
|
||||
let timezone = calendar.vtimezones.values().next().ok_or_else(|| {
|
||||
rustical_dav::Error::BadRequest("No timezone data provided".to_owned())
|
||||
})?;
|
||||
let timezone: Option<chrono_tz::Tz> = timezone.into();
|
||||
let timezone = timezone.ok_or(Error::PreconditionFailed(
|
||||
Precondition::CalendarTimezone("No timezone data provided"),
|
||||
))?;
|
||||
let timezone = timezone.ok_or_else(|| {
|
||||
rustical_dav::Error::BadRequest("Cannot translate VTIMEZONE into IANA TZID".to_owned())
|
||||
})?;
|
||||
|
||||
Some(timezone.name().to_owned())
|
||||
} else {
|
||||
|
||||
@@ -2,12 +2,9 @@ use crate::calendar::methods::report::calendar_query::{
|
||||
TimeRangeElement,
|
||||
prop_filter::{PropFilterElement, PropFilterable},
|
||||
};
|
||||
use caldata::{
|
||||
component::{
|
||||
CalendarInnerData, Component, IcalAlarm, IcalCalendarObject, IcalEvent, IcalTimeZone,
|
||||
IcalTodo,
|
||||
},
|
||||
parser::ContentLine,
|
||||
use ical::{
|
||||
component::{CalendarInnerData, IcalAlarm, IcalCalendarObject, IcalEvent, IcalTodo},
|
||||
parser::{Component, ical::component::IcalTimeZone},
|
||||
};
|
||||
use rustical_xml::XmlDeserialize;
|
||||
|
||||
@@ -115,7 +112,10 @@ impl CompFilterable for CalendarInnerData {
|
||||
}
|
||||
|
||||
impl PropFilterable for IcalAlarm {
|
||||
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine> {
|
||||
fn get_named_properties<'a>(
|
||||
&'a self,
|
||||
name: &'a str,
|
||||
) -> impl Iterator<Item = &'a ical::property::ContentLine> {
|
||||
Component::get_named_properties(self, name)
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ impl PropFilterable for CalendarInnerData {
|
||||
fn get_named_properties<'a>(
|
||||
&'a self,
|
||||
name: &'a str,
|
||||
) -> Box<dyn Iterator<Item = &'a ContentLine> + 'a> {
|
||||
) -> 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 {
|
||||
@@ -151,7 +151,10 @@ impl PropFilterable for CalendarInnerData {
|
||||
}
|
||||
|
||||
impl PropFilterable for IcalCalendarObject {
|
||||
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine> {
|
||||
fn get_named_properties<'a>(
|
||||
&'a self,
|
||||
name: &'a str,
|
||||
) -> impl Iterator<Item = &'a ical::property::ContentLine> {
|
||||
Component::get_named_properties(self, name)
|
||||
}
|
||||
}
|
||||
@@ -182,7 +185,10 @@ impl CompFilterable for IcalCalendarObject {
|
||||
}
|
||||
|
||||
impl PropFilterable for IcalTimeZone {
|
||||
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine> {
|
||||
fn get_named_properties<'a>(
|
||||
&'a self,
|
||||
name: &'a str,
|
||||
) -> impl Iterator<Item = &'a ical::property::ContentLine> {
|
||||
Component::get_named_properties(self, name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::comp_filter::{CompFilterElement, CompFilterable};
|
||||
use crate::calendar_object::CalendarObjectPropWrapperName;
|
||||
use caldata::{component::IcalCalendarObject, parser::ContentLine};
|
||||
use ical::{component::IcalCalendarObject, property::ContentLine};
|
||||
use rustical_dav::xml::{PropfindType, TextMatchElement};
|
||||
use rustical_ical::UtcDateTime;
|
||||
use rustical_store::calendar_store::CalendarQuery;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::{ParamFilterElement, TimeRangeElement};
|
||||
use caldata::{parser::ContentLine, types::CalDateTime};
|
||||
use ical::{property::ContentLine, types::CalDateTime};
|
||||
use rustical_dav::xml::TextMatchElement;
|
||||
use rustical_ical::UtcDateTime;
|
||||
use rustical_xml::XmlDeserialize;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use super::prop::{SupportedCalendarComponentSet, SupportedCalendarData};
|
||||
use crate::Error;
|
||||
use crate::calendar::prop::{ReportMethod, SupportedCollationSet};
|
||||
use caldata::IcalParser;
|
||||
use caldata::types::CalDateTime;
|
||||
use chrono::{DateTime, Utc};
|
||||
use derive_more::derive::{From, Into};
|
||||
use ical::IcalParser;
|
||||
use ical::types::CalDateTime;
|
||||
use rustical_dav::extensions::{
|
||||
CommonPropertiesExtension, CommonPropertiesProp, SyncTokenExtension, SyncTokenExtensionProp,
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::calendar::methods::report::route_report_calendar;
|
||||
use crate::calendar::resource::CalendarResource;
|
||||
use crate::calendar_object::CalendarObjectResourceService;
|
||||
use crate::calendar_object::resource::CalendarObjectResource;
|
||||
use crate::{CalDavConfig, CalDavPrincipalUri, Error};
|
||||
use crate::{CalDavPrincipalUri, Error};
|
||||
use async_trait::async_trait;
|
||||
use axum::Router;
|
||||
use axum::extract::Request;
|
||||
@@ -23,7 +23,6 @@ use tower::Service;
|
||||
pub struct CalendarResourceService<C: CalendarStore, S: SubscriptionStore> {
|
||||
pub(crate) cal_store: Arc<C>,
|
||||
pub(crate) sub_store: Arc<S>,
|
||||
pub(crate) config: Arc<CalDavConfig>,
|
||||
}
|
||||
|
||||
impl<C: CalendarStore, S: SubscriptionStore> Clone for CalendarResourceService<C, S> {
|
||||
@@ -31,17 +30,15 @@ impl<C: CalendarStore, S: SubscriptionStore> Clone for CalendarResourceService<C
|
||||
Self {
|
||||
cal_store: self.cal_store.clone(),
|
||||
sub_store: self.sub_store.clone(),
|
||||
config: self.config.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: CalendarStore, S: SubscriptionStore> CalendarResourceService<C, S> {
|
||||
pub const fn new(cal_store: Arc<C>, sub_store: Arc<S>, config: Arc<CalDavConfig>) -> Self {
|
||||
pub const fn new(cal_store: Arc<C>, sub_store: Arc<S>) -> Self {
|
||||
Self {
|
||||
cal_store,
|
||||
sub_store,
|
||||
config,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,8 +112,7 @@ impl<C: CalendarStore, S: SubscriptionStore> ResourceService for CalendarResourc
|
||||
Router::new()
|
||||
.nest(
|
||||
"/{object_id}",
|
||||
CalendarObjectResourceService::new(self.cal_store.clone(), self.config.clone())
|
||||
.axum_router(),
|
||||
CalendarObjectResourceService::new(self.cal_store.clone()).axum_router(),
|
||||
)
|
||||
.route_service("/", self.axum_service())
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ PRODID:-//github.com/lennart-k/vzic-rs//RustiCal Calendar server//EN
|
||||
VERSION:2.0
|
||||
BEGIN:VTIMEZONE
|
||||
TZID:Europe/Berlin
|
||||
LAST-MODIFIED:20260124T185655Z
|
||||
LAST-MODIFIED:20250723T190331Z
|
||||
X-LIC-LOCATION:Europe/Berlin
|
||||
X-PROLEPTIC-TZNAME:LMT
|
||||
BEGIN:STANDARD
|
||||
|
||||
@@ -5,14 +5,13 @@ use axum::body::Body;
|
||||
use axum::extract::{Path, State};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum_extra::TypedHeader;
|
||||
use caldata::parser::ParserOptions;
|
||||
use headers::{ContentType, ETag, HeaderMapExt, IfNoneMatch};
|
||||
use http::{HeaderMap, HeaderValue, Method, StatusCode};
|
||||
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>(
|
||||
@@ -21,10 +20,7 @@ pub async fn get_event<C: CalendarStore>(
|
||||
calendar_id,
|
||||
object_id,
|
||||
}): Path<CalendarObjectPathComponents>,
|
||||
State(CalendarObjectResourceService {
|
||||
cal_store,
|
||||
config: _,
|
||||
}): State<CalendarObjectResourceService<C>>,
|
||||
State(CalendarObjectResourceService { cal_store }): State<CalendarObjectResourceService<C>>,
|
||||
user: Principal,
|
||||
method: Method,
|
||||
) -> Result<Response, Error> {
|
||||
@@ -61,9 +57,7 @@ pub async fn put_event<C: CalendarStore>(
|
||||
calendar_id,
|
||||
object_id,
|
||||
}): Path<CalendarObjectPathComponents>,
|
||||
State(CalendarObjectResourceService { cal_store, config }): State<
|
||||
CalendarObjectResourceService<C>,
|
||||
>,
|
||||
State(CalendarObjectResourceService { cal_store }): State<CalendarObjectResourceService<C>>,
|
||||
user: Principal,
|
||||
mut if_none_match: Option<TypedHeader<IfNoneMatch>>,
|
||||
header_map: HeaderMap,
|
||||
@@ -100,18 +94,9 @@ pub async fn put_event<C: CalendarStore>(
|
||||
true
|
||||
};
|
||||
|
||||
let object = match CalendarObject::import(
|
||||
&body,
|
||||
Some(ParserOptions {
|
||||
rfc7809: config.rfc7809,
|
||||
}),
|
||||
) {
|
||||
Ok(object) => object,
|
||||
Err(err) => {
|
||||
warn!("invalid calendar data:\n{body}");
|
||||
warn!("{err}");
|
||||
return Err(Error::PreconditionFailed(Precondition::ValidCalendarData));
|
||||
}
|
||||
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
|
||||
|
||||
@@ -3,8 +3,8 @@ use super::prop::{
|
||||
CalendarObjectPropWrapperName,
|
||||
};
|
||||
use crate::Error;
|
||||
use caldata::generator::Emitter;
|
||||
use derive_more::derive::{From, Into};
|
||||
use ical::generator::Emitter;
|
||||
use rustical_dav::{
|
||||
extensions::CommonPropertiesExtension,
|
||||
privileges::UserPrivilegeSet,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
CalDavConfig, CalDavPrincipalUri, Error,
|
||||
CalDavPrincipalUri, Error,
|
||||
calendar_object::{
|
||||
methods::{get_event, put_event},
|
||||
resource::CalendarObjectResource,
|
||||
@@ -24,21 +24,19 @@ pub struct CalendarObjectPathComponents {
|
||||
|
||||
pub struct CalendarObjectResourceService<C: CalendarStore> {
|
||||
pub(crate) cal_store: Arc<C>,
|
||||
pub(crate) config: Arc<CalDavConfig>,
|
||||
}
|
||||
|
||||
impl<C: CalendarStore> Clone for CalendarObjectResourceService<C> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
cal_store: self.cal_store.clone(),
|
||||
config: self.config.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: CalendarStore> CalendarObjectResourceService<C> {
|
||||
pub const fn new(cal_store: Arc<C>, config: Arc<CalDavConfig>) -> Self {
|
||||
Self { cal_store, config }
|
||||
pub const fn new(cal_store: Arc<C>) -> Self {
|
||||
Self { cal_store }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,6 @@ pub enum Precondition {
|
||||
#[error("valid-calendar-data")]
|
||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||
ValidCalendarData,
|
||||
#[error("calendar-timezone")]
|
||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||
CalendarTimezone(&'static str),
|
||||
}
|
||||
|
||||
impl IntoResponse for Precondition {
|
||||
@@ -26,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()
|
||||
}
|
||||
@@ -55,6 +52,9 @@ pub enum Error {
|
||||
#[error(transparent)]
|
||||
XmlDecodeError(#[from] rustical_xml::XmlError),
|
||||
|
||||
#[error(transparent)]
|
||||
IcalError(#[from] rustical_ical::Error),
|
||||
|
||||
#[error(transparent)]
|
||||
PreconditionFailed(Precondition),
|
||||
}
|
||||
@@ -75,20 +75,19 @@ 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,
|
||||
// TODO: Can also be Bad Request, if it's used input
|
||||
Self::IcalError(_err) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
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()
|
||||
|
||||
@@ -8,7 +8,6 @@ use rustical_dav::resources::RootResourceService;
|
||||
use rustical_store::auth::middleware::AuthenticationLayer;
|
||||
use rustical_store::auth::{AuthenticationProvider, Principal};
|
||||
use rustical_store::{CalendarStore, SubscriptionStore};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub mod calendar;
|
||||
@@ -35,7 +34,6 @@ pub fn caldav_router<AP: AuthenticationProvider, C: CalendarStore, S: Subscripti
|
||||
store: Arc<C>,
|
||||
subscription_store: Arc<S>,
|
||||
simplified_home_set: bool,
|
||||
config: Arc<CalDavConfig>,
|
||||
) -> Router {
|
||||
Router::new().nest(
|
||||
prefix,
|
||||
@@ -44,27 +42,9 @@ pub fn caldav_router<AP: AuthenticationProvider, C: CalendarStore, S: Subscripti
|
||||
sub_store: subscription_store,
|
||||
cal_store: store,
|
||||
simplified_home_set,
|
||||
config,
|
||||
})
|
||||
.axum_router()
|
||||
.layer(AuthenticationLayer::new(auth_provider))
|
||||
.layer(Extension(CalDavPrincipalUri(prefix))),
|
||||
)
|
||||
}
|
||||
|
||||
const fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields, default)]
|
||||
pub struct CalDavConfig {
|
||||
#[serde(default = "default_true")]
|
||||
rfc7809: bool,
|
||||
}
|
||||
|
||||
impl Default for CalDavConfig {
|
||||
fn default() -> Self {
|
||||
Self { rfc7809: true }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::calendar::CalendarResourceService;
|
||||
use crate::calendar::resource::CalendarResource;
|
||||
use crate::principal::PrincipalResource;
|
||||
use crate::{CalDavConfig, CalDavPrincipalUri, Error};
|
||||
use crate::{CalDavPrincipalUri, Error};
|
||||
use async_trait::async_trait;
|
||||
use axum::Router;
|
||||
use rustical_dav::resource::{AxumMethods, ResourceService};
|
||||
@@ -20,7 +20,6 @@ pub struct PrincipalResourceService<
|
||||
pub(crate) cal_store: Arc<CS>,
|
||||
// If true only return the principal as the calendar home set, otherwise also groups
|
||||
pub(crate) simplified_home_set: bool,
|
||||
pub(crate) config: Arc<CalDavConfig>,
|
||||
}
|
||||
|
||||
impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Clone
|
||||
@@ -32,7 +31,6 @@ impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Clone
|
||||
sub_store: self.sub_store.clone(),
|
||||
cal_store: self.cal_store.clone(),
|
||||
simplified_home_set: self.simplified_home_set,
|
||||
config: self.config.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,12 +84,8 @@ impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Resour
|
||||
Router::new()
|
||||
.nest(
|
||||
"/{calendar_id}",
|
||||
CalendarResourceService::new(
|
||||
self.cal_store.clone(),
|
||||
self.sub_store.clone(),
|
||||
self.config.clone(),
|
||||
)
|
||||
.axum_router(),
|
||||
CalendarResourceService::new(self.cal_store.clone(), self.sub_store.clone())
|
||||
.axum_router(),
|
||||
)
|
||||
.route_service("/", self.axum_service())
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ async fn test_principal_resource(
|
||||
sub_store: Arc::new(sub_store),
|
||||
auth_provider: Arc::new(auth_provider),
|
||||
simplified_home_set: false,
|
||||
config: Default::default(),
|
||||
};
|
||||
|
||||
// We don't have any calendars here
|
||||
|
||||
@@ -32,7 +32,7 @@ rustical_ical.workspace = true
|
||||
http.workspace = true
|
||||
tower-http.workspace = true
|
||||
percent-encoding.workspace = true
|
||||
caldata.workspace = true
|
||||
ical.workspace = true
|
||||
strum.workspace = true
|
||||
strum_macros.workspace = true
|
||||
rstest.workspace = true
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -7,8 +7,8 @@ use crate::{
|
||||
AddressObjectPropWrapperName,
|
||||
},
|
||||
};
|
||||
use caldata::property::VcardFNProperty;
|
||||
use derive_more::derive::{From, Into};
|
||||
use ical::parser::VcardFNProperty;
|
||||
use rustical_dav::{
|
||||
extensions::CommonPropertiesExtension,
|
||||
privileges::UserPrivilegeSet,
|
||||
|
||||
@@ -4,12 +4,11 @@ use axum::{
|
||||
extract::{Path, State},
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use caldata::{
|
||||
VcardParser,
|
||||
component::{Component, ComponentMut},
|
||||
parser::{ContentLine, ParserOptions},
|
||||
};
|
||||
use http::StatusCode;
|
||||
use ical::{
|
||||
parser::{Component, ComponentMut, vcard},
|
||||
property::ContentLine,
|
||||
};
|
||||
use rustical_store::{Addressbook, AddressbookStore, SubscriptionStore, auth::Principal};
|
||||
use tracing::instrument;
|
||||
|
||||
@@ -24,7 +23,7 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
|
||||
return Err(Error::Unauthorized);
|
||||
}
|
||||
|
||||
let parser = VcardParser::from_slice(body.as_bytes());
|
||||
let parser = vcard::VcardParser::from_slice(body.as_bytes());
|
||||
|
||||
let mut objects = vec![];
|
||||
for res in parser {
|
||||
@@ -37,7 +36,7 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
|
||||
value: Some(uuid::Uuid::new_v4().to_string()),
|
||||
params: vec![].into(),
|
||||
});
|
||||
card = card_mut.build(&ParserOptions::default(), None).unwrap();
|
||||
card = card_mut.build(None).unwrap();
|
||||
}
|
||||
// TODO: Make nicer
|
||||
let uid = card.get_uid().unwrap();
|
||||
|
||||
@@ -2,8 +2,8 @@ use crate::{
|
||||
address_object::AddressObjectPropWrapperName,
|
||||
addressbook::methods::report::addressbook_query::PropFilterElement,
|
||||
};
|
||||
use caldata::parser::ContentLine;
|
||||
use derive_more::{From, Into};
|
||||
use ical::property::ContentLine;
|
||||
use rustical_dav::xml::{PropfindType, TextMatchElement};
|
||||
use rustical_ical::{AddressObject, UtcDateTime};
|
||||
use rustical_xml::{ValueDeserialize, XmlDeserialize, XmlRootTag};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::{Allof, ParamFilterElement};
|
||||
use caldata::{component::Component, parser::ContentLine};
|
||||
use ical::{parser::Component, property::ContentLine};
|
||||
use rustical_dav::xml::TextMatchElement;
|
||||
use rustical_ical::AddressObject;
|
||||
use rustical_xml::XmlDeserialize;
|
||||
|
||||
@@ -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,8 @@ impl Error {
|
||||
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
|
||||
Self::ChronoParseError(_) | Self::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Self::NotFound => StatusCode::NOT_FOUND,
|
||||
// TODO: Can also be Bad Request, if it's used input
|
||||
Self::IcalError(_err) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ headers.workspace = true
|
||||
strum.workspace = true
|
||||
matchit.workspace = true
|
||||
matchit-serde.workspace = true
|
||||
caldata = { workspace = true, optional = true }
|
||||
ical = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
ical = ["dep:caldata"]
|
||||
ical = ["dep:ical"]
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -71,7 +71,6 @@ pub async fn axum_route_proppatch<R: ResourceService>(
|
||||
route_proppatch(&path, uri.path(), &body, &principal, &resource_service).await
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub async fn route_proppatch<R: ResourceService>(
|
||||
path_components: &R::PathComponents,
|
||||
path: &str,
|
||||
@@ -117,14 +116,12 @@ pub async fn route_proppatch<R: ResourceService>(
|
||||
}
|
||||
}
|
||||
SetPropertyPropWrapper::Invalid(invalid) => {
|
||||
let Unparsed(propns, propname) = invalid;
|
||||
let propname = invalid.tag_name();
|
||||
|
||||
if let Some(full_propname) = <R::Resource as Resource>::list_props()
|
||||
.into_iter()
|
||||
.find_map(|(ns, tag)| {
|
||||
if (ns, tag)
|
||||
== (propns.as_ref().map(NamespaceOwned::as_ref), &propname)
|
||||
{
|
||||
if tag == propname.as_str() {
|
||||
Some((ns.map(NamespaceOwned::from), tag.to_owned()))
|
||||
} else {
|
||||
None
|
||||
@@ -136,7 +133,7 @@ pub async fn route_proppatch<R: ResourceService>(
|
||||
// - internal properties
|
||||
props_conflict.push(full_propname);
|
||||
} else {
|
||||
props_not_found.push((propns, propname));
|
||||
props_not_found.push((None, propname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,4 +1,4 @@
|
||||
use caldata::parser::ContentLine;
|
||||
use ical::property::ContentLine;
|
||||
use rustical_xml::{ValueDeserialize, XmlDeserialize};
|
||||
use std::borrow::Cow;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ chrono-tz.workspace = true
|
||||
thiserror.workspace = true
|
||||
derive_more.workspace = true
|
||||
rustical_xml.workspace = true
|
||||
caldata.workspace = true
|
||||
ical.workspace = true
|
||||
regex.workspace = true
|
||||
rrule.workspace = true
|
||||
serde.workspace = true
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
use crate::{CalendarObject, Error};
|
||||
use caldata::{
|
||||
VcardParser,
|
||||
component::{
|
||||
CalendarInnerDataBuilder, ComponentMut, IcalAlarmBuilder, IcalCalendarObjectBuilder,
|
||||
IcalEventBuilder, VcardContact,
|
||||
},
|
||||
generator::Emitter,
|
||||
parser::{ContentLine, ParserOptions},
|
||||
property::{
|
||||
Calscale, IcalCALSCALEProperty, IcalDTENDProperty, IcalDTSTAMPProperty,
|
||||
IcalDTSTARTProperty, IcalPRODIDProperty, IcalRRULEProperty, IcalSUMMARYProperty,
|
||||
IcalUIDProperty, IcalVERSIONProperty, IcalVersion, VcardANNIVERSARYProperty,
|
||||
VcardBDAYProperty, VcardFNProperty,
|
||||
},
|
||||
types::{CalDate, PartialDate, Timezone},
|
||||
};
|
||||
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::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -35,7 +32,7 @@ impl From<VcardContact> for AddressObject {
|
||||
|
||||
impl AddressObject {
|
||||
pub fn from_vcf(vcf: String) -> Result<Self, Error> {
|
||||
let parser = VcardParser::from_slice(vcf.as_bytes());
|
||||
let parser = vcard::VcardParser::from_slice(vcf.as_bytes());
|
||||
let vcard = parser.expect_one()?;
|
||||
Ok(Self { vcf, vcard })
|
||||
}
|
||||
@@ -73,7 +70,7 @@ impl AddressObject {
|
||||
let Some(dtstart) = NaiveDate::from_ymd_opt(year.unwrap_or(1900), month, day) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let start_date = CalDate(dtstart, Timezone::Local);
|
||||
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);
|
||||
@@ -134,9 +131,9 @@ impl AddressObject {
|
||||
.into(),
|
||||
],
|
||||
inner: Some(CalendarInnerDataBuilder::Event(vec![event])),
|
||||
vtimezones: BTreeMap::default(),
|
||||
vtimezones: HashMap::default(),
|
||||
}
|
||||
.build(&ParserOptions::default(), None)?
|
||||
.build(None)?
|
||||
.into(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use crate::Error;
|
||||
use caldata::{
|
||||
IcalObjectParser,
|
||||
component::{CalendarInnerData, IcalCalendarObject},
|
||||
generator::Emitter,
|
||||
parser::ParserOptions,
|
||||
};
|
||||
use derive_more::Display;
|
||||
use ical::IcalObjectParser;
|
||||
use ical::component::CalendarInnerData;
|
||||
use ical::component::IcalCalendarObject;
|
||||
use ical::generator::Emitter;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -68,35 +64,15 @@ impl rustical_xml::ValueDeserialize for CalendarObjectType {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CalendarObject {
|
||||
inner: IcalCalendarObject,
|
||||
ics: OnceLock<String>,
|
||||
ics: String,
|
||||
}
|
||||
|
||||
impl CalendarObject {
|
||||
// This function parses iCalendar data but doesn't cache it
|
||||
// This is meant for iCalendar data coming from outside that might need to be normalised.
|
||||
// For example if timezones are omitted this can be fixed by this function.
|
||||
pub fn import(ics: &str, options: Option<ParserOptions>) -> Result<Self, Error> {
|
||||
let parser =
|
||||
IcalObjectParser::from_slice(ics.as_bytes()).with_options(options.unwrap_or_default());
|
||||
let inner = parser.expect_one()?;
|
||||
|
||||
Ok(Self {
|
||||
inner,
|
||||
ics: OnceLock::new(),
|
||||
})
|
||||
}
|
||||
|
||||
// This function parses iCalendar data and then caches the parsed iCalendar data.
|
||||
// This function is only meant for loading data from a data store where we know the iCalendar
|
||||
// is already in the desired form.
|
||||
pub fn from_ics(ics: String) -> Result<Self, Error> {
|
||||
let parser = IcalObjectParser::from_slice(ics.as_bytes());
|
||||
let inner = parser.expect_one()?;
|
||||
|
||||
Ok(Self {
|
||||
inner,
|
||||
ics: ics.into(),
|
||||
})
|
||||
Ok(Self { inner, ics })
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -119,7 +95,7 @@ impl CalendarObject {
|
||||
|
||||
#[must_use]
|
||||
pub fn get_ics(&self) -> &str {
|
||||
self.ics.get_or_init(|| self.inner.generate())
|
||||
&self.ics
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -137,7 +113,7 @@ impl From<CalendarObject> for IcalCalendarObject {
|
||||
impl From<IcalCalendarObject> for CalendarObject {
|
||||
fn from(value: IcalCalendarObject) -> Self {
|
||||
Self {
|
||||
ics: value.generate().into(),
|
||||
ics: value.generate(),
|
||||
inner: value,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
|
||||
#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
|
||||
mod timestamp;
|
||||
use caldata::parser::ParserError;
|
||||
use ical::parser::ParserError;
|
||||
pub use timestamp::*;
|
||||
|
||||
mod calendar_object;
|
||||
|
||||
@@ -13,7 +13,7 @@ anyhow.workspace = true
|
||||
async-trait.workspace = true
|
||||
serde.workspace = true
|
||||
sha2.workspace = true
|
||||
caldata.workspace = true
|
||||
ical.workspace = true
|
||||
chrono.workspace = true
|
||||
regex.workspace = true
|
||||
thiserror.workspace = true
|
||||
|
||||
@@ -26,7 +26,7 @@ pub enum Error {
|
||||
Other(#[from] anyhow::Error),
|
||||
|
||||
#[error(transparent)]
|
||||
IcalError(#[from] caldata::parser::ParserError),
|
||||
IcalError(#[from] ical::parser::ParserError),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
@@ -36,6 +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::InvalidPrincipalType(_) => StatusCode::BAD_REQUEST,
|
||||
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
@@ -52,7 +53,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}");
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ rstest.workspace = true
|
||||
criterion.workspace = true
|
||||
|
||||
[dependencies]
|
||||
caldata.workspace = true
|
||||
ical.workspace = true
|
||||
tokio.workspace = true
|
||||
rustical_store.workspace = true
|
||||
async-trait.workspace = true
|
||||
@@ -37,4 +37,3 @@ pbkdf2.workspace = true
|
||||
rustical_ical.workspace = true
|
||||
rstest = { workspace = true, optional = true }
|
||||
sha2.workspace = true
|
||||
regex.workspace = true
|
||||
|
||||
@@ -338,7 +338,7 @@ impl CalendarStore for SqliteAddressbookStore {
|
||||
out_objects.push((format!("{object_id}-birthday"), birthday));
|
||||
}
|
||||
if let Some(anniversary) = object.get_anniversary_object()? {
|
||||
out_objects.push((format!("{object_id}-anniversary"), anniversary));
|
||||
out_objects.push((format!("{object_id}-anniversayr"), anniversary));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ impl CalendarStore for SqliteAddressbookStore {
|
||||
objects.push((format!("{object_id}-birthday"), birthday));
|
||||
}
|
||||
if let Some(anniversary) = object.get_anniversary_object()? {
|
||||
objects.push((format!("{object_id}-anniversary"), anniversary));
|
||||
objects.push((format!("{object_id}-anniversayr"), anniversary));
|
||||
}
|
||||
}
|
||||
Ok(objects)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use super::ChangeOperation;
|
||||
use crate::BEGIN_IMMEDIATE;
|
||||
use async_trait::async_trait;
|
||||
use caldata::parser::ParserError;
|
||||
use derive_more::derive::Constructor;
|
||||
use rustical_ical::AddressObject;
|
||||
use rustical_store::{
|
||||
@@ -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>>(
|
||||
@@ -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]
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use super::ChangeOperation;
|
||||
use crate::BEGIN_IMMEDIATE;
|
||||
use async_trait::async_trait;
|
||||
use caldata::parser::ParserError;
|
||||
use caldata::types::CalDateTime;
|
||||
use chrono::TimeDelta;
|
||||
use derive_more::derive::Constructor;
|
||||
use regex::Regex;
|
||||
use ical::types::CalDateTime;
|
||||
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,23 +21,6 @@ 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;
|
||||
|
||||
@@ -110,7 +91,6 @@ impl From<CalendarRow> for Calendar {
|
||||
pub struct SqliteCalendarStore {
|
||||
db: SqlitePool,
|
||||
sender: Sender<CollectionOperation>,
|
||||
skip_broken: bool,
|
||||
}
|
||||
|
||||
impl SqliteCalendarStore {
|
||||
@@ -160,117 +140,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 +378,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 +388,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 +397,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 +422,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 +563,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 +592,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 +742,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 +773,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]
|
||||
@@ -1042,7 +896,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))
|
||||
|
||||
@@ -37,11 +37,11 @@ impl SqliteStore {
|
||||
}
|
||||
|
||||
pub async fn create_db_pool(db_url: &str, migrate: bool) -> Result<Pool<Sqlite>, sqlx::Error> {
|
||||
let options: SqliteConnectOptions = db_url.parse()?;
|
||||
|
||||
let db = SqlitePool::connect_with(
|
||||
options
|
||||
SqliteConnectOptions::new()
|
||||
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)
|
||||
.synchronous(sqlx::sqlite::SqliteSynchronous::Normal)
|
||||
.filename(db_url)
|
||||
.create_if_missing(true),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
SqliteStore, addressbook_store::SqliteAddressbookStore, calendar_store::SqliteCalendarStore,
|
||||
create_db_pool, principal_store::SqlitePrincipalStore,
|
||||
principal_store::SqlitePrincipalStore,
|
||||
};
|
||||
use rstest::fixture;
|
||||
use rustical_store::auth::{AuthenticationProvider, Principal, PrincipalType};
|
||||
@@ -9,23 +9,12 @@ use sqlx::SqlitePool;
|
||||
mod addressbook_store;
|
||||
mod calendar_store;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TestStoreContext {
|
||||
pub db: SqlitePool,
|
||||
pub addr_store: SqliteAddressbookStore,
|
||||
pub cal_store: SqliteCalendarStore,
|
||||
pub principal_store: SqlitePrincipalStore,
|
||||
pub sub_store: SqliteStore,
|
||||
}
|
||||
async fn get_test_db() -> SqlitePool {
|
||||
let db = SqlitePool::connect("sqlite::memory:").await.unwrap();
|
||||
sqlx::migrate!("./migrations").run(&db).await.unwrap();
|
||||
|
||||
#[fixture]
|
||||
pub async fn test_store_context() -> TestStoreContext {
|
||||
let (send_addr, _recv) = tokio::sync::mpsc::channel(1);
|
||||
let (send_cal, _recv) = tokio::sync::mpsc::channel(1);
|
||||
let db = create_db_pool(":memory:", true).await.unwrap();
|
||||
|
||||
let principal_store = SqlitePrincipalStore::new(db.clone());
|
||||
// Populate with test data
|
||||
let principal_store = SqlitePrincipalStore::new(db.clone());
|
||||
principal_store
|
||||
.insert_principal(
|
||||
Principal {
|
||||
@@ -44,11 +33,28 @@ pub async fn test_store_context() -> TestStoreContext {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
db
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TestStoreContext {
|
||||
pub db: SqlitePool,
|
||||
pub addr_store: SqliteAddressbookStore,
|
||||
pub cal_store: SqliteCalendarStore,
|
||||
pub principal_store: SqlitePrincipalStore,
|
||||
pub sub_store: SqliteStore,
|
||||
}
|
||||
|
||||
#[fixture]
|
||||
pub async fn test_store_context() -> TestStoreContext {
|
||||
let (send_addr, _recv) = tokio::sync::mpsc::channel(1);
|
||||
let (send_cal, _recv) = tokio::sync::mpsc::channel(1);
|
||||
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),
|
||||
principal_store,
|
||||
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,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use quick_xml::name::Namespace;
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct NamespaceOwned(pub Vec<u8>);
|
||||
|
||||
impl<'a> From<Namespace<'a>> for NamespaceOwned {
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
use std::io::BufRead;
|
||||
|
||||
use quick_xml::{events::BytesStart, name::ResolveResult};
|
||||
use quick_xml::events::BytesStart;
|
||||
|
||||
use crate::{NamespaceOwned, XmlDeserialize, XmlError};
|
||||
use crate::{XmlDeserialize, XmlError};
|
||||
|
||||
// TODO: actually implement
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Unparsed(pub Option<NamespaceOwned>, pub String);
|
||||
pub struct Unparsed(String);
|
||||
|
||||
impl Unparsed {
|
||||
#[must_use]
|
||||
pub const fn ns(&self) -> Option<&NamespaceOwned> {
|
||||
self.0.as_ref()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn tag_name(&self) -> &str {
|
||||
self.1.as_str()
|
||||
pub fn tag_name(&self) -> String {
|
||||
// TODO: respect namespace?
|
||||
self.0.clone()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +27,7 @@ impl XmlDeserialize for Unparsed {
|
||||
let mut buf = vec![];
|
||||
reader.read_to_end_into(start.name(), &mut buf)?;
|
||||
}
|
||||
let (ns, tag_name) = reader.resolver().resolve_element(start.name());
|
||||
let ns: Option<NamespaceOwned> = match ns {
|
||||
ResolveResult::Bound(ns) => Some(ns.into()),
|
||||
ResolveResult::Unbound | ResolveResult::Unknown(_) => None,
|
||||
};
|
||||
let tag_name = String::from_utf8_lossy(tag_name.as_ref()).to_string();
|
||||
Ok(Self(ns, tag_name))
|
||||
let tag_name = String::from_utf8_lossy(start.local_name().as_ref()).to_string();
|
||||
Ok(Self(tag_name))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,26 +48,3 @@ Since the app tokens are random they use the faster `pbkdf2` algorithm.
|
||||
```sh
|
||||
cargo install --locked --git https://github.com/lennart-k/rustical
|
||||
```
|
||||
|
||||
## NixOS (community-maintained by [@PopeRigby](https://github.com/PopeRigby))
|
||||
|
||||
!!! warning
|
||||
The NixOS package is not maintained by myself but since I appreciate [@PopeRigby](https://github.com/PopeRigby)'s work on it I want to mention it.
|
||||
Since rustical's development is still quite active I **strongly** recommend installing from the `nixpkgs-unstable` branch.
|
||||
|
||||
In the `nixpkgs-unstable` you'll find a `rustical` package you can install.
|
||||
|
||||
There's also a service that has not been merged yet. If you know how to add modules from PRs in Nix
|
||||
you can already install it <https://github.com/NixOS/nixpkgs/pull/424188>
|
||||
and then setup rustical as a service:
|
||||
|
||||
```nix title="In your configuration.nix"
|
||||
services.rustical = {
|
||||
enable = true;
|
||||
package = inputs.rustical.legacyPackages.${pkgs.stdenv.hostPlatform.system}.rustical;
|
||||
settings = {
|
||||
# Settings the same as in config.toml but in Nix syntax
|
||||
# http.port = 3002;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
14
src/app.rs
14
src/app.rs
@@ -9,7 +9,7 @@ use axum_extra::TypedHeader;
|
||||
use headers::{HeaderMapExt, UserAgent};
|
||||
use http::header::CONNECTION;
|
||||
use http::{HeaderValue, StatusCode};
|
||||
use rustical_caldav::{CalDavConfig, caldav_router};
|
||||
use rustical_caldav::caldav_router;
|
||||
use rustical_carddav::carddav_router;
|
||||
use rustical_frontend::nextcloud_login::nextcloud_login_router;
|
||||
use rustical_frontend::{FrontendConfig, frontend_router};
|
||||
@@ -32,8 +32,7 @@ use tracing::field::display;
|
||||
#[allow(
|
||||
clippy::too_many_arguments,
|
||||
clippy::too_many_lines,
|
||||
clippy::cognitive_complexity,
|
||||
clippy::missing_panics_doc
|
||||
clippy::cognitive_complexity
|
||||
)]
|
||||
pub fn make_app<
|
||||
AS: AddressbookStore + PrefixedCalendarStore,
|
||||
@@ -46,7 +45,6 @@ pub fn make_app<
|
||||
auth_provider: Arc<impl AuthenticationProvider>,
|
||||
frontend_config: FrontendConfig,
|
||||
oidc_config: Option<OidcConfig>,
|
||||
caldav_config: CalDavConfig,
|
||||
nextcloud_login_config: &NextcloudLoginConfig,
|
||||
dav_push_enabled: bool,
|
||||
session_cookie_samesite_strict: bool,
|
||||
@@ -56,8 +54,6 @@ pub fn make_app<
|
||||
let combined_cal_store =
|
||||
Arc::new(CombinedCalendarStore::new(cal_store).with_store(birthday_store));
|
||||
|
||||
let caldav_config = Arc::new(caldav_config);
|
||||
|
||||
let mut router = Router::new()
|
||||
// endpoint to be used by healthcheck to see if rustical is online
|
||||
.route("/ping", axum::routing::get(async || "Pong!"))
|
||||
@@ -67,7 +63,6 @@ pub fn make_app<
|
||||
combined_cal_store.clone(),
|
||||
subscription_store.clone(),
|
||||
false,
|
||||
caldav_config.clone(),
|
||||
))
|
||||
.merge(caldav_router(
|
||||
"/caldav-compat",
|
||||
@@ -75,7 +70,6 @@ pub fn make_app<
|
||||
combined_cal_store.clone(),
|
||||
subscription_store.clone(),
|
||||
true,
|
||||
caldav_config,
|
||||
))
|
||||
.route(
|
||||
"/.well-known/caldav",
|
||||
@@ -110,9 +104,9 @@ pub fn make_app<
|
||||
options(async || {
|
||||
let mut resp = Response::builder().status(StatusCode::OK);
|
||||
resp.headers_mut()
|
||||
.expect("this always works")
|
||||
.unwrap()
|
||||
.insert("DAV", HeaderValue::from_static("1"));
|
||||
resp.body(Body::empty()).expect("empty body always works")
|
||||
resp.body(Body::empty()).unwrap()
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -2,12 +2,11 @@ use crate::config::HttpConfig;
|
||||
use clap::Parser;
|
||||
use http::Method;
|
||||
|
||||
#[derive(Parser, Debug, Default)]
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct HealthArgs {}
|
||||
|
||||
/// Healthcheck for running rustical instance
|
||||
/// Currently just pings to see if it's reachable via HTTP
|
||||
#[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
|
||||
pub async fn cmd_health(http_config: HttpConfig, _health_args: HealthArgs) -> anyhow::Result<()> {
|
||||
let client = reqwest::ClientBuilder::new().build().unwrap();
|
||||
|
||||
|
||||
@@ -33,8 +33,7 @@ pub struct MembershipArgs {
|
||||
command: MembershipCommand,
|
||||
}
|
||||
|
||||
#[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
|
||||
pub async fn cmd_membership(
|
||||
pub async fn handle_membership_command(
|
||||
user_store: &impl AuthenticationProvider,
|
||||
MembershipArgs { command }: MembershipArgs,
|
||||
) -> anyhow::Result<()> {
|
||||
|
||||
@@ -3,28 +3,20 @@ use crate::config::{
|
||||
SqliteDataStoreConfig, TracingConfig,
|
||||
};
|
||||
use clap::Parser;
|
||||
use rustical_caldav::CalDavConfig;
|
||||
use rustical_frontend::FrontendConfig;
|
||||
|
||||
mod health;
|
||||
pub mod health;
|
||||
pub mod membership;
|
||||
pub mod principals;
|
||||
|
||||
pub use health::{HealthArgs, cmd_health};
|
||||
pub use principals::{PrincipalsArgs, cmd_principals};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct GenConfigArgs {}
|
||||
|
||||
#[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
|
||||
pub fn cmd_gen_config(_args: GenConfigArgs) -> anyhow::Result<()> {
|
||||
let config = Config {
|
||||
http: HttpConfig::default(),
|
||||
caldav: CalDavConfig::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 {
|
||||
|
||||
@@ -1,49 +1,56 @@
|
||||
use super::membership::MembershipArgs;
|
||||
use crate::{config::Config, get_data_stores, membership::cmd_membership};
|
||||
use super::membership::{MembershipArgs, handle_membership_command};
|
||||
use crate::{config::Config, get_data_stores};
|
||||
use clap::{Parser, Subcommand};
|
||||
use figment::{
|
||||
Figment,
|
||||
providers::{Env, Format, Toml},
|
||||
};
|
||||
use password_hash::{PasswordHasher, SaltString, rand_core::OsRng};
|
||||
use rustical_store::auth::{AuthenticationProvider, Principal, PrincipalType};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct PrincipalsArgs {
|
||||
#[arg(short, long, env, default_value = "/etc/rustical/config.toml")]
|
||||
config_file: String,
|
||||
|
||||
#[command(subcommand)]
|
||||
pub command: PrincipalsCommand,
|
||||
command: Command,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct CreateArgs {
|
||||
pub id: String,
|
||||
struct CreateArgs {
|
||||
id: String,
|
||||
#[arg(value_enum, short, long)]
|
||||
pub principal_type: Option<PrincipalType>,
|
||||
principal_type: Option<PrincipalType>,
|
||||
#[arg(short, long)]
|
||||
pub name: Option<String>,
|
||||
name: Option<String>,
|
||||
#[arg(long, help = "Ask for password input")]
|
||||
pub password: bool,
|
||||
password: bool,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct RemoveArgs {
|
||||
pub id: String,
|
||||
struct RemoveArgs {
|
||||
id: String,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct EditArgs {
|
||||
pub id: String,
|
||||
struct EditArgs {
|
||||
id: String,
|
||||
#[arg(long, help = "Ask for password input")]
|
||||
pub password: bool,
|
||||
password: bool,
|
||||
#[arg(
|
||||
long,
|
||||
help = "Remove password (If you only want to use OIDC for example)"
|
||||
)]
|
||||
pub remove_password: bool,
|
||||
remove_password: bool,
|
||||
#[arg(short, long, help = "Change principal displayname")]
|
||||
pub name: Option<String>,
|
||||
name: Option<String>,
|
||||
#[arg(value_enum, short, long, help = "Change the principal type")]
|
||||
pub principal_type: Option<PrincipalType>,
|
||||
principal_type: Option<PrincipalType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum PrincipalsCommand {
|
||||
enum Command {
|
||||
List,
|
||||
Create(CreateArgs),
|
||||
Remove(RemoveArgs),
|
||||
@@ -51,12 +58,16 @@ pub enum PrincipalsCommand {
|
||||
Membership(MembershipArgs),
|
||||
}
|
||||
|
||||
#[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
|
||||
pub async fn cmd_principals(args: PrincipalsArgs, config: Config) -> anyhow::Result<()> {
|
||||
pub async fn cmd_principals(args: PrincipalsArgs) -> anyhow::Result<()> {
|
||||
let config: Config = Figment::new()
|
||||
.merge(Toml::file(&args.config_file))
|
||||
.merge(Env::prefixed("RUSTICAL_").split("__"))
|
||||
.extract()?;
|
||||
|
||||
let (_, _, _, principal_store, _) = get_data_stores(true, &config.data_store).await?;
|
||||
|
||||
match args.command {
|
||||
PrincipalsCommand::List => {
|
||||
Command::List => {
|
||||
for principal in principal_store.get_principals().await? {
|
||||
println!(
|
||||
"{} (displayname={}) [{}]",
|
||||
@@ -66,7 +77,7 @@ pub async fn cmd_principals(args: PrincipalsArgs, config: Config) -> anyhow::Res
|
||||
);
|
||||
}
|
||||
}
|
||||
PrincipalsCommand::Create(CreateArgs {
|
||||
Command::Create(CreateArgs {
|
||||
id,
|
||||
principal_type,
|
||||
name,
|
||||
@@ -100,11 +111,11 @@ pub async fn cmd_principals(args: PrincipalsArgs, config: Config) -> anyhow::Res
|
||||
.await?;
|
||||
println!("Principal created");
|
||||
}
|
||||
PrincipalsCommand::Remove(RemoveArgs { id }) => {
|
||||
Command::Remove(RemoveArgs { id }) => {
|
||||
principal_store.remove_principal(&id).await?;
|
||||
println!("Principal {id} removed");
|
||||
}
|
||||
PrincipalsCommand::Edit(EditArgs {
|
||||
Command::Edit(EditArgs {
|
||||
id,
|
||||
remove_password,
|
||||
password,
|
||||
@@ -140,8 +151,8 @@ pub async fn cmd_principals(args: PrincipalsArgs, config: Config) -> anyhow::Res
|
||||
principal_store.insert_principal(principal, true).await?;
|
||||
println!("Principal {id} updated");
|
||||
}
|
||||
PrincipalsCommand::Membership(args) => {
|
||||
cmd_membership(principal_store.as_ref(), args).await?;
|
||||
Command::Membership(args) => {
|
||||
handle_membership_command(principal_store.as_ref(), args).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rustical_caldav::CalDavConfig;
|
||||
use rustical_frontend::FrontendConfig;
|
||||
use rustical_oidc::OidcConfig;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -27,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)]
|
||||
@@ -98,6 +93,4 @@ pub struct Config {
|
||||
pub dav_push: DavPushConfig,
|
||||
#[serde(default)]
|
||||
pub nextcloud_login: NextcloudLoginConfig,
|
||||
#[serde(default)]
|
||||
pub caldav: CalDavConfig,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{ResponseExtractString, get_app};
|
||||
use crate::integration_tests::{ResponseExtractString, get_app};
|
||||
use axum::body::Body;
|
||||
use axum::extract::Request;
|
||||
use headers::{Authorization, HeaderMapExt};
|
||||
@@ -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,4 +1,4 @@
|
||||
use super::{ResponseExtractString, get_app};
|
||||
use crate::integration_tests::{ResponseExtractString, get_app};
|
||||
use axum::body::Body;
|
||||
use axum::extract::Request;
|
||||
use headers::{Authorization, HeaderMapExt};
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{ResponseExtractString, get_app};
|
||||
use crate::integration_tests::{ResponseExtractString, get_app};
|
||||
use axum::body::Body;
|
||||
use axum::extract::Request;
|
||||
use headers::{Authorization, HeaderMapExt};
|
||||
@@ -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
|
||||
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
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
DTSTAMP:20060206T001121Z
|
||||
DTSTART:20060104T190000Z
|
||||
DURATION:PT1H
|
||||
RECURRENCE-ID:20060104T170000Z
|
||||
SUMMARY:Event #2 bis
|
||||
UID:abcd2
|
||||
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
|
||||
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
|
||||
DURATION:PT1H
|
||||
LAST-MODIFIED:20060206T001330Z
|
||||
ORGANIZER:mailto:cyrus@example.com
|
||||
SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:abcd3
|
||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
</CAL:calendar-data>
|
||||
</prop>
|
||||
<status>HTTP/1.1 200 OK</status>
|
||||
</propstat>
|
||||
</response>
|
||||
</multistatus>"#;
|
||||
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:20060103T170000
|
||||
DURATION:PT1H
|
||||
RECURRENCE-ID:20060103T170000
|
||||
SUMMARY:Event #2
|
||||
UID:00959BC664CA650E933C892C@example.com
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
DTSTAMP:20060206T001121Z
|
||||
DTSTART:20060104T190000
|
||||
DURATION:PT1H
|
||||
RECURRENCE-ID:20060104T170000
|
||||
SUMMARY:Event #2 bis
|
||||
UID:00959BC664CA650E933C892C@example.com
|
||||
END:VEVENT
|
||||
END: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:20060104T150000
|
||||
DURATION:PT1H
|
||||
LAST-MODIFIED:20060206T001330Z
|
||||
ORGANIZER:mailto:cyrus@example.com
|
||||
SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:DC6C50A017428C5216A2F1CD@example.com
|
||||
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
</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', ""));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{ResponseExtractString, get_app};
|
||||
use crate::integration_tests::{ResponseExtractString, get_app};
|
||||
use axum::body::Body;
|
||||
use axum::extract::Request;
|
||||
use headers::{Authorization, HeaderMapExt};
|
||||
@@ -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
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/caldav/calendar.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/calendar.rs
|
||||
source: src/integration_tests/caldav/calendar.rs
|
||||
expression: body
|
||||
---
|
||||
BEGIN:VCALENDAR
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/caldav/calendar.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/calendar.rs
|
||||
source: src/integration_tests/caldav/calendar.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -8,7 +8,7 @@ expression: body
|
||||
<href>/caldav/principal/user/calendar/qwue23489.ics</href>
|
||||
<propstat>
|
||||
<prop>
|
||||
<getetag>"f781224669f0db2674e9e45a9be2b01774c02136e3fb72792ef217bccf49fafa"</getetag>
|
||||
<getetag>"aea50382a7775bb9742bfec277382e3a260b6066f503b5f5ae34548d7215ee46"</getetag>
|
||||
</prop>
|
||||
<status>HTTP/1.1 200 OK</status>
|
||||
</propstat>
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/calendar.rs
|
||||
source: src/integration_tests/caldav/calendar.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -14,10 +14,9 @@ expression: body
|
||||
PRODID:-//github.com/lennart-k/vzic-rs//RustiCal Calendar server//EN
|
||||
VERSION:2.0
|
||||
BEGIN:VTIMEZONE
|
||||
TZID:US/Eastern
|
||||
TZID-ALIAS-OF:America/New_York
|
||||
LAST-MODIFIED:20260124T185655Z
|
||||
X-LIC-LOCATION:US/Eastern
|
||||
TZID:America/New_York
|
||||
LAST-MODIFIED:20250723T190331Z
|
||||
X-LIC-LOCATION:America/New_York
|
||||
X-PROLEPTIC-TZNAME:LMT
|
||||
BEGIN:STANDARD
|
||||
TZNAME:EST
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/calendar.rs
|
||||
source: src/integration_tests/caldav/calendar.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/calendar_import.rs
|
||||
source: src/integration_tests/caldav/calendar_import.rs
|
||||
expression: body
|
||||
---
|
||||
BEGIN:VCALENDAR
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/caldav/calendar_import.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/calendar_import.rs
|
||||
source: src/integration_tests/caldav/calendar_import.rs
|
||||
expression: body
|
||||
---
|
||||
BEGIN:VCALENDAR
|
||||
@@ -60,7 +60,6 @@ SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:[UID]
|
||||
X-ABC-GUID:[UID]
|
||||
END:VEVENT
|
||||
BEGIN:VTODO
|
||||
DTSTAMP:20060205T235335Z
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/caldav/calendar_import.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
---
|
||||
source: src/integration_tests/caldav/calendar_import.rs
|
||||
expression: body
|
||||
---
|
||||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
PRODID:RustiCal
|
||||
BEGIN:VTIMEZONE
|
||||
LAST-MODIFIED:20040110T032845Z
|
||||
TZID:US/Eastern
|
||||
BEGIN:DAYLIGHT
|
||||
DTSTART:20000404T020000
|
||||
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
|
||||
TZNAME:EDT
|
||||
TZOFFSETFROM:-0500
|
||||
TZOFFSETTO:-0400
|
||||
END:DAYLIGHT
|
||||
BEGIN:STANDARD
|
||||
DTSTART:20001026T020000
|
||||
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
|
||||
TZNAME:EST
|
||||
TZOFFSETFROM:-0400
|
||||
TZOFFSETTO:-0500
|
||||
END:STANDARD
|
||||
END:VTIMEZONE
|
||||
BEGIN:VEVENT
|
||||
DTSTAMP:20060206T001121Z
|
||||
DTSTART;TZID=US/Eastern:20060104T140000
|
||||
DURATION:PT1H
|
||||
RECURRENCE-ID;TZID=US/Eastern:20060104T120000
|
||||
SUMMARY:Event #2 bis
|
||||
UID:[UID]
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
DTSTAMP:20060206T001102Z
|
||||
DTSTART;TZID=US/Eastern:20060102T100000
|
||||
DURATION:PT1H
|
||||
SUMMARY:Event #1
|
||||
Description:Go Steelers!
|
||||
UID:[UID]
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
DTSTAMP:20060206T001121Z
|
||||
DTSTART;TZID=US/Eastern:20060102T120000
|
||||
DURATION:PT1H
|
||||
RRULE:FREQ=DAILY;COUNT=5
|
||||
SUMMARY:Event #2
|
||||
UID:[UID]
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:cyrus@example.com
|
||||
ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
|
||||
DTSTAMP:20060206T001220Z
|
||||
DTSTART;TZID=US/Eastern:20060104T100000
|
||||
DURATION:PT1H
|
||||
LAST-MODIFIED:20060206T001330Z
|
||||
ORGANIZER:mailto:cyrus@example.com
|
||||
SEQUENCE:1
|
||||
STATUS:TENTATIVE
|
||||
SUMMARY:Event #3
|
||||
UID:[UID]
|
||||
END:VEVENT
|
||||
BEGIN:VTODO
|
||||
DTSTAMP:20060205T235335Z
|
||||
DUE;VALUE=DATE:20060104
|
||||
STATUS:NEEDS-ACTION
|
||||
SUMMARY:Task #1
|
||||
UID:[UID]
|
||||
BEGIN:VALARM
|
||||
ACTION:AUDIO
|
||||
TRIGGER;RELATED=START:-PT10M
|
||||
END:VALARM
|
||||
END:VTODO
|
||||
BEGIN:VTODO
|
||||
DTSTAMP:20060205T235300Z
|
||||
DUE;VALUE=DATE:20060106
|
||||
LAST-MODIFIED:20060205T235308Z
|
||||
SEQUENCE:1
|
||||
STATUS:NEEDS-ACTION
|
||||
SUMMARY:Task #2
|
||||
UID:[UID]
|
||||
BEGIN:VALARM
|
||||
ACTION:AUDIO
|
||||
TRIGGER;RELATED=START:-PT10M
|
||||
END:VALARM
|
||||
END:VTODO
|
||||
BEGIN:VTODO
|
||||
COMPLETED:20051223T122322Z
|
||||
DTSTAMP:20060205T235400Z
|
||||
DUE;VALUE=DATE:20051225
|
||||
LAST-MODIFIED:20060205T235308Z
|
||||
SEQUENCE:1
|
||||
STATUS:COMPLETED
|
||||
SUMMARY:Task #3
|
||||
UID:[UID]
|
||||
END:VTODO
|
||||
BEGIN:VTODO
|
||||
DTSTAMP:20060205T235600Z
|
||||
DUE;VALUE=DATE:20060101
|
||||
LAST-MODIFIED:20060205T235308Z
|
||||
SEQUENCE:1
|
||||
STATUS:CANCELLED
|
||||
SUMMARY:Task #4
|
||||
UID:[UID]
|
||||
END:VTODO
|
||||
END:VCALENDAR
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/caldav/calendar_import.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/calendar_report.rs
|
||||
source: src/integration_tests/caldav/calendar_report.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -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>
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/calendar_report.rs
|
||||
source: src/integration_tests/caldav/calendar_report.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -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>
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/calendar_report.rs
|
||||
source: src/integration_tests/caldav/calendar_report.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -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>
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/mod.rs
|
||||
source: src/integration_tests/caldav/mod.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/mod.rs
|
||||
source: src/integration_tests/caldav/mod.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/caldav/mod.rs
|
||||
source: src/integration_tests/caldav/mod.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{ResponseExtractString, get_app};
|
||||
use crate::integration_tests::{ResponseExtractString, get_app};
|
||||
use axum::body::Body;
|
||||
use axum::extract::Request;
|
||||
use headers::{Authorization, HeaderMapExt};
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{ResponseExtractString, get_app};
|
||||
use crate::integration_tests::{ResponseExtractString, get_app};
|
||||
use axum::body::Body;
|
||||
use axum::extract::Request;
|
||||
use headers::{Authorization, HeaderMapExt};
|
||||
@@ -27,10 +27,11 @@ async fn test_import(
|
||||
.body(Body::from(
|
||||
r"BEGIN:VCARD
|
||||
VERSION:4.0
|
||||
FN:John Doe
|
||||
N:Doe;John;;;,
|
||||
FN:Simon Perreault
|
||||
N:Perreault;Simon;;;ing. jr,M.Sc.
|
||||
BDAY:--0203
|
||||
GENDER:M
|
||||
EMAIL;TYPE=work:simon.perreault@viagenie.ca
|
||||
END:VCARD",
|
||||
))
|
||||
.unwrap()
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{ResponseExtractString, get_app};
|
||||
use crate::integration_tests::{ResponseExtractString, get_app};
|
||||
use axum::body::Body;
|
||||
use axum::extract::Request;
|
||||
use headers::{Authorization, HeaderMapExt};
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/carddav/addressbook.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/carddav/addressbook.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/carddav/addressbook.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/carddav/addressbook.rs
|
||||
source: src/integration_tests/carddav/addressbook.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/carddav/addressbook.rs
|
||||
source: src/integration_tests/carddav/addressbook.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/carddav/addressbook.rs
|
||||
source: src/integration_tests/carddav/addressbook.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: src/integration_tests/carddav/addressbook_import.rs
|
||||
expression: body
|
||||
---
|
||||
BEGIN:VCARD
|
||||
VERSION:4.0
|
||||
FN:Simon Perreault
|
||||
N:Perreault;Simon;;;ing. jr,M.Sc.
|
||||
BDAY:--0203
|
||||
GENDER:M
|
||||
EMAIL;TYPE=work:simon.perreault@viagenie.ca
|
||||
UID:[UID]
|
||||
END:VCARD
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/carddav/addressbook_import.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: src/integration_tests/carddav/mod.rs
|
||||
expression: body
|
||||
---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
source: tests/integration_tests/carddav/mod.rs
|
||||
source: src/integration_tests/carddav/mod.rs
|
||||
expression: body
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user