mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 23:38:19 +00:00
Compare commits
150 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fabf74333 | ||
|
|
7b154adec3 | ||
|
|
951a1e4bdc | ||
|
|
8c44733d0a | ||
|
|
829f7b727f | ||
|
|
037e6f5c92 | ||
|
|
311ceb6bc5 | ||
|
|
1174af3a4b | ||
|
|
845b3e61e3 | ||
|
|
e5d6541ffb | ||
|
|
b632ff6fe8 | ||
|
|
1ee873ac93 | ||
|
|
bf5bdb96bc | ||
|
|
47c2a55941 | ||
|
|
bfcd94f096 | ||
|
|
8cbb72719d | ||
|
|
ff0246c4fc | ||
|
|
15124a2fd5 | ||
|
|
5c6f63a5f3 | ||
|
|
17ba8faef2 | ||
|
|
578ddde36d | ||
|
|
9c3972e21c | ||
|
|
816c26565a | ||
|
|
4de0f9f665 | ||
|
|
cf31a51965 | ||
|
|
9fc099f6f4 | ||
|
|
498be172c9 | ||
|
|
b8c395e746 | ||
|
|
4b8a8c61f2 | ||
|
|
f778c470d0 | ||
|
|
d44a172261 | ||
|
|
e0ba34baea | ||
|
|
a7893ddbda | ||
|
|
ed7becffc2 | ||
|
|
c29400a799 | ||
|
|
047552a726 | ||
|
|
1cfc8e7c23 | ||
|
|
b0fdca1b64 | ||
|
|
b65cca9d17 | ||
|
|
55ecbdcd41 | ||
|
|
89d3d3b7a4 | ||
|
|
a74b74369c | ||
|
|
85c49a0bdf | ||
|
|
f2e4e2c1a7 | ||
|
|
28c925301e | ||
|
|
b50ea478db | ||
|
|
2c7748255c | ||
|
|
f40a23a1f1 | ||
|
|
2a4ba33e45 | ||
|
|
6bc4bd3fa3 | ||
|
|
7b32d478b8 | ||
|
|
fb0bd67176 | ||
|
|
ecad0d4490 | ||
|
|
e702e77656 | ||
|
|
141f881382 | ||
|
|
b8d2ac0654 | ||
|
|
16aae73cd1 | ||
|
|
120d45eb0a | ||
|
|
0bdfb786ff | ||
|
|
d9cca5a298 | ||
|
|
50a74e3a25 | ||
|
|
ed8a9e718a | ||
|
|
38b5a3812e | ||
|
|
d3e7ede93c | ||
|
|
4e90f725e0 | ||
|
|
ef40f5ea8c | ||
|
|
1230e29243 | ||
|
|
1b2296c00a | ||
|
|
ac6ab0ca9a | ||
|
|
6312f52b10 | ||
|
|
ec28cb9d9a | ||
|
|
4b4210b4d7 | ||
|
|
8fadff1b57 | ||
|
|
61a8c32af4 | ||
|
|
a45e0b2efd | ||
|
|
eecc03b7b7 | ||
|
|
e8303b9c82 | ||
|
|
a686286d06 | ||
|
|
d81074de3b | ||
|
|
42386adcfa | ||
|
|
d2f5f7c89b | ||
|
|
15e431ce12 | ||
|
|
96a16951f4 | ||
|
|
a32b766c0c | ||
|
|
7a101b7364 | ||
|
|
57275a10b4 | ||
|
|
af239e34bf | ||
|
|
e99b1d9123 | ||
|
|
e39657eb29 | ||
|
|
607db62859 | ||
|
|
eba377b980 | ||
|
|
d5c1ddc590 | ||
|
|
a79e1901b8 | ||
|
|
f29c8fa925 | ||
|
|
54f1ee0788 | ||
|
|
96f221f721 | ||
|
|
ba3b64a9c4 | ||
|
|
22a0337375 | ||
|
|
21902e108a | ||
|
|
08f526fa5b | ||
|
|
ac73f3aaff | ||
|
|
9fdc8434db | ||
|
|
85f3d89235 | ||
|
|
092604694a | ||
|
|
8ef24668ba | ||
|
|
416658d069 | ||
|
|
80eae5db9e | ||
|
|
66f541f1c7 | ||
|
|
ea7196501e | ||
|
|
33d14a9ba0 | ||
|
|
d843909084 | ||
|
|
873b40ad10 | ||
|
|
5588137f73 | ||
|
|
7bf00da0e5 | ||
|
|
be08275cd3 | ||
|
|
3a10a695f5 | ||
|
|
53c6e3b1f4 | ||
|
|
6838e8e379 | ||
|
|
9f28aaec41 | ||
|
|
381af1b877 | ||
|
|
7ec62bc6ab | ||
|
|
9538b68e77 | ||
|
|
ea5175387b | ||
|
|
0095491a20 | ||
|
|
e9392cc00b | ||
|
|
425d10cb99 | ||
|
|
5cdbb3b9d3 | ||
|
|
547e477eca | ||
|
|
c19c3492c3 | ||
|
|
5878b93d62 | ||
|
|
888591c952 | ||
|
|
de77223170 | ||
|
|
c42f8e5614 | ||
|
|
f72559d027 | ||
|
|
167492318f | ||
|
|
32f43951ac | ||
|
|
cd9993cd97 | ||
|
|
9f911fe5d7 | ||
|
|
6361907152 | ||
|
|
0c0be859f9 | ||
|
|
d2c786eba6 | ||
|
|
dabddc6282 | ||
|
|
76b4194b94 | ||
|
|
db144ebcae | ||
|
|
a53c333f1f | ||
|
|
a05baea472 | ||
|
|
f34f7e420e | ||
|
|
24ab323aa0 | ||
|
|
f34f56ca89 | ||
|
|
8ed4db5824 |
19
.github/workflows/cicd.yml
vendored
19
.github/workflows/cicd.yml
vendored
@@ -5,6 +5,7 @@ permissions:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
RUST_VERSION: "1.92"
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -12,7 +13,9 @@ jobs:
|
|||||||
name: Check
|
name: Check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: rustup update
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- run: cargo check
|
- run: cargo check
|
||||||
@@ -21,7 +24,9 @@ jobs:
|
|||||||
name: Test Suite
|
name: Test Suite
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: rustup update
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- run: cargo test --all-features --verbose --workspace
|
- run: cargo test --all-features --verbose --workspace
|
||||||
@@ -30,7 +35,9 @@ jobs:
|
|||||||
name: Test Coverage
|
name: Test Coverage
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: rustup update
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
- name: Install tarpaulin
|
- name: Install tarpaulin
|
||||||
run: cargo install cargo-tarpaulin
|
run: cargo install cargo-tarpaulin
|
||||||
|
|
||||||
@@ -44,8 +51,10 @@ jobs:
|
|||||||
name: Lints
|
name: Lints
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: rustup update
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
- run: rustup component add rustfmt clippy
|
with:
|
||||||
|
toolchain: ${{ env.RUST_VERSION }}
|
||||||
|
components: rustfmt, clippy
|
||||||
|
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
6
.github/workflows/docker-publish.yml
vendored
6
.github/workflows/docker-publish.yml
vendored
@@ -26,12 +26,12 @@ jobs:
|
|||||||
|
|
||||||
# https://github.com/docker/setup-buildx-action
|
# https://github.com/docker/setup-buildx-action
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# https://github.com/docker/login-action
|
# https://github.com/docker/login-action
|
||||||
- name: Log into registry ${{ env.REGISTRY }}
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
# https://github.com/docker/build-push-action
|
# https://github.com/docker/build-push-action
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
id: build-and-push
|
id: build-and-push
|
||||||
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/arm64,linux/amd64
|
platforms: linux/arm64,linux/amd64
|
||||||
|
|||||||
2
.github/workflows/docs.yml
vendored
2
.github/workflows/docs.yml
vendored
@@ -17,6 +17,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
|
|
||||||
|
- run: rustup update
|
||||||
|
|
||||||
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Set up build cache
|
- name: Set up build cache
|
||||||
|
|||||||
38
.sqlx/query-053c17f3b54ae3e153137926115486eb19a801bd73a74230bcf72a9a7254824a.json
generated
Normal file
38
.sqlx/query-053c17f3b54ae3e153137926115486eb19a801bd73a74230bcf72a9a7254824a.json
generated
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "\n SELECT principal, cal_id, id, (deleted_at IS NOT NULL) AS \"deleted: bool\"\n FROM calendarobjects\n WHERE (principal, cal_id, id) NOT IN (\n SELECT DISTINCT principal, cal_id, object_id FROM calendarobjectchangelog\n )\n ;\n ",
|
||||||
|
"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": "deleted: bool",
|
||||||
|
"ordinal": 3,
|
||||||
|
"type_info": "Integer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 0
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "053c17f3b54ae3e153137926115486eb19a801bd73a74230bcf72a9a7254824a"
|
||||||
|
}
|
||||||
32
.sqlx/query-3a29efff3d3f6e1e05595d1a2d095af5fc963572c90bd10a6616af78757f8c39.json
generated
Normal file
32
.sqlx/query-3a29efff3d3f6e1e05595d1a2d095af5fc963572c90bd10a6616af78757f8c39.json
generated
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "SELECT id, uid, ics FROM calendarobjects\n WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL\n AND (last_occurence IS NULL OR ? IS NULL OR last_occurence >= date(?))\n AND (first_occurence IS NULL OR ? IS NULL OR first_occurence <= date(?))\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "uid",
|
||||||
|
"ordinal": 1,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ics",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 6
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "3a29efff3d3f6e1e05595d1a2d095af5fc963572c90bd10a6616af78757f8c39"
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"db_name": "SQLite",
|
|
||||||
"query": "REPLACE INTO calendarobjects (principal, cal_id, id, ics, first_occurence, last_occurence, etag, object_type) VALUES (?, ?, ?, ?, date(?), date(?), ?, ?)",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 8
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "3e1cca532372e891ab3e604ecb79311d8cd64108d4f238db4c79e9467a3b6d2e"
|
|
||||||
}
|
|
||||||
12
.sqlx/query-4a05eda4e23e8652312548b179a1cc16f43768074ab9e7ab7b7783395384984e.json
generated
Normal file
12
.sqlx/query-4a05eda4e23e8652312548b179a1cc16f43768074ab9e7ab7b7783395384984e.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "UPDATE birthday_calendars SET principal = ?, id = ?, displayname = ?, description = ?, \"order\" = ?, color = ?, timezone_id = ?, push_topic = ?\n WHERE (principal, id) = (?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 10
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "4a05eda4e23e8652312548b179a1cc16f43768074ab9e7ab7b7783395384984e"
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "SQLite",
|
"db_name": "SQLite",
|
||||||
"query": "SELECT id, ics FROM calendarobjects WHERE (principal, cal_id, id) = (?, ?, ?) AND ((deleted_at IS NULL) OR ?)",
|
"query": "SELECT id, uid, ics FROM calendarobjects WHERE (principal, cal_id, id) = (?, ?, ?) AND ((deleted_at IS NULL) OR ?)",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -9,18 +9,24 @@
|
|||||||
"type_info": "Text"
|
"type_info": "Text"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ics",
|
"name": "uid",
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"type_info": "Text"
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ics",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Text"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"Right": 4
|
"Right": 4
|
||||||
},
|
},
|
||||||
"nullable": [
|
"nullable": [
|
||||||
|
false,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "543838c030550cb09d1af08adfeade8b7ce3575d92fddbc6e9582d141bc9e49d"
|
"hash": "505ebe8e64ac709b230dce7150240965e45442aca6c5f3b3115738ef508939ed"
|
||||||
}
|
}
|
||||||
74
.sqlx/query-525fc4eab8a0f3eacff7e3c78ce809943f817abf8c8f9ae50073924bccdea2dc.json
generated
Normal file
74
.sqlx/query-525fc4eab8a0f3eacff7e3c78ce809943f817abf8c8f9ae50073924bccdea2dc.json
generated
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "SELECT principal, id, displayname, description, \"order\", color, timezone_id, deleted_at, addr_synctoken, push_topic\n FROM birthday_calendars\n INNER JOIN (\n SELECT principal AS addr_principal,\n id AS addr_id,\n synctoken AS addr_synctoken\n FROM addressbooks\n ) ON (principal, id) = (addr_principal, addr_id)\n WHERE (principal, id) = (?, ?)\n AND ((deleted_at IS NULL) OR ?)\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "principal",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"ordinal": 1,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "displayname",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "description",
|
||||||
|
"ordinal": 3,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "order",
|
||||||
|
"ordinal": 4,
|
||||||
|
"type_info": "Integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "color",
|
||||||
|
"ordinal": 5,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "timezone_id",
|
||||||
|
"ordinal": 6,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "deleted_at",
|
||||||
|
"ordinal": 7,
|
||||||
|
"type_info": "Datetime"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "addr_synctoken",
|
||||||
|
"ordinal": 8,
|
||||||
|
"type_info": "Integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "push_topic",
|
||||||
|
"ordinal": 9,
|
||||||
|
"type_info": "Text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 3
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "525fc4eab8a0f3eacff7e3c78ce809943f817abf8c8f9ae50073924bccdea2dc"
|
||||||
|
}
|
||||||
12
.sqlx/query-583069cbeba5285c63c2b95e989669d3faed66a75fbfc7cd93e5f64b778f45ab.json
generated
Normal file
12
.sqlx/query-583069cbeba5285c63c2b95e989669d3faed66a75fbfc7cd93e5f64b778f45ab.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "REPLACE INTO davpush_subscriptions (id, topic, expiration, push_resource, public_key, public_key_type, auth_secret) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 7
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "583069cbeba5285c63c2b95e989669d3faed66a75fbfc7cd93e5f64b778f45ab"
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"db_name": "SQLite",
|
|
||||||
"query": "INSERT INTO calendarobjects (principal, cal_id, id, ics, first_occurence, last_occurence, etag, object_type) VALUES (?, ?, ?, ?, date(?), date(?), ?, ?)",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 8
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "6327bee90e5df01536a0ddb15adcc37af3027f6902aa3786365c5ab2fbf06bda"
|
|
||||||
}
|
|
||||||
74
.sqlx/query-66d57f2c99ef37b383a478aff99110e1efbc7ce9332f10da4fa69f7594fb7455.json
generated
Normal file
74
.sqlx/query-66d57f2c99ef37b383a478aff99110e1efbc7ce9332f10da4fa69f7594fb7455.json
generated
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "SELECT principal, id, displayname, description, \"order\", color, timezone_id, deleted_at, addr_synctoken, push_topic\n FROM birthday_calendars\n INNER JOIN (\n SELECT principal AS addr_principal,\n id AS addr_id,\n synctoken AS addr_synctoken\n FROM addressbooks\n ) ON (principal, id) = (addr_principal, addr_id)\n WHERE principal = ?\n AND (\n (deleted_at IS NULL AND NOT ?) -- not deleted, want not deleted\n OR (deleted_at IS NOT NULL AND ?) -- deleted, want deleted\n )\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "principal",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"ordinal": 1,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "displayname",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "description",
|
||||||
|
"ordinal": 3,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "order",
|
||||||
|
"ordinal": 4,
|
||||||
|
"type_info": "Integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "color",
|
||||||
|
"ordinal": 5,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "timezone_id",
|
||||||
|
"ordinal": 6,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "deleted_at",
|
||||||
|
"ordinal": 7,
|
||||||
|
"type_info": "Datetime"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "addr_synctoken",
|
||||||
|
"ordinal": 8,
|
||||||
|
"type_info": "Integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "push_topic",
|
||||||
|
"ordinal": 9,
|
||||||
|
"type_info": "Text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 3
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "66d57f2c99ef37b383a478aff99110e1efbc7ce9332f10da4fa69f7594fb7455"
|
||||||
|
}
|
||||||
12
.sqlx/query-6c039308ad2ec29570ab492d7a0e85fb79c0a4d3b882b74ff1c2786c12324896.json
generated
Normal file
12
.sqlx/query-6c039308ad2ec29570ab492d7a0e85fb79c0a4d3b882b74ff1c2786c12324896.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "UPDATE birthday_calendars SET deleted_at = NULL WHERE (principal, id) = (?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "6c039308ad2ec29570ab492d7a0e85fb79c0a4d3b882b74ff1c2786c12324896"
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"db_name": "SQLite",
|
|
||||||
"query": "INSERT OR REPLACE INTO davpush_subscriptions (id, topic, expiration, push_resource, public_key, public_key_type, auth_secret) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 7
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "6d08d3a014743da9b445ab012437ec11f81fd86d3b02fc1df07a036c6b47ace2"
|
|
||||||
}
|
|
||||||
12
.sqlx/query-72c7c67f4952ad669ecd54d96bbcb717815081f74575f0a65987163faf9fe30a.json
generated
Normal file
12
.sqlx/query-72c7c67f4952ad669ecd54d96bbcb717815081f74575f0a65987163faf9fe30a.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "INSERT INTO birthday_calendars (principal, id, displayname, description, \"order\", color, push_topic)\n VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 7
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "72c7c67f4952ad669ecd54d96bbcb717815081f74575f0a65987163faf9fe30a"
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "SQLite",
|
"db_name": "SQLite",
|
||||||
"query": "SELECT id, ics FROM calendarobjects WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL",
|
"query": "SELECT id, uid, ics FROM calendarobjects WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -9,18 +9,24 @@
|
|||||||
"type_info": "Text"
|
"type_info": "Text"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ics",
|
"name": "uid",
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"type_info": "Text"
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ics",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Text"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"Right": 2
|
"Right": 2
|
||||||
},
|
},
|
||||||
"nullable": [
|
"nullable": [
|
||||||
|
false,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "54c9c0e36a52e6963f11c6aa27f13aafb4204b8aa34b664fd825bd447db80e86"
|
"hash": "804ed2a4a7032e9605d1871297498f5a96de0fc816ce660c705fb28318be0d42"
|
||||||
}
|
}
|
||||||
12
.sqlx/query-83f0aaf406785e323ac12019ac24f603c53125a1b2326f324c1e2d7b6c690adc.json
generated
Normal file
12
.sqlx/query-83f0aaf406785e323ac12019ac24f603c53125a1b2326f324c1e2d7b6c690adc.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "UPDATE birthday_calendars SET deleted_at = datetime() WHERE (principal, id) = (?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "83f0aaf406785e323ac12019ac24f603c53125a1b2326f324c1e2d7b6c690adc"
|
||||||
|
}
|
||||||
12
.sqlx/query-a68a1b96189b854a7ba2a3cd866ba583af5ad84bc1cd8b20cb805e9ce3bad820.json
generated
Normal file
12
.sqlx/query-a68a1b96189b854a7ba2a3cd866ba583af5ad84bc1cd8b20cb805e9ce3bad820.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "REPLACE INTO calendarobjects (principal, cal_id, id, uid, ics, first_occurence, last_occurence, etag, object_type) VALUES (?, ?, ?, ?, ?, date(?), date(?), ?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 9
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "a68a1b96189b854a7ba2a3cd866ba583af5ad84bc1cd8b20cb805e9ce3bad820"
|
||||||
|
}
|
||||||
38
.sqlx/query-c138b1143ac04af4930266ffae0990e82005911c11a683ad565e92335e085f4d.json
generated
Normal file
38
.sqlx/query-c138b1143ac04af4930266ffae0990e82005911c11a683ad565e92335e085f4d.json
generated
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "\n SELECT principal, addressbook_id, id, (deleted_at IS NOT NULL) AS \"deleted: bool\"\n FROM addressobjects\n WHERE (principal, addressbook_id, id) NOT IN (\n SELECT DISTINCT principal, addressbook_id, object_id FROM addressobjectchangelog\n )\n ;\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "principal",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "addressbook_id",
|
||||||
|
"ordinal": 1,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "deleted: bool",
|
||||||
|
"ordinal": 3,
|
||||||
|
"type_info": "Integer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 0
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "c138b1143ac04af4930266ffae0990e82005911c11a683ad565e92335e085f4d"
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"db_name": "SQLite",
|
|
||||||
"query": "SELECT id, ics FROM calendarobjects\n WHERE principal = ? AND cal_id = ? AND deleted_at IS NULL\n AND (last_occurence IS NULL OR ? IS NULL OR last_occurence >= date(?))\n AND (first_occurence IS NULL OR ? IS NULL OR first_occurence <= date(?))\n ",
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"ordinal": 0,
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ics",
|
|
||||||
"ordinal": 1,
|
|
||||||
"type_info": "Text"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 6
|
|
||||||
},
|
|
||||||
"nullable": [
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"hash": "c550dbf3d5ce7069f28d767ea9045e477ef8d29d6186851760757a06dec42339"
|
|
||||||
}
|
|
||||||
12
.sqlx/query-cadc4ac16b7ac22b71c91ab36ad9dbb1dec943798d795fcbc811f4c651fea02a.json
generated
Normal file
12
.sqlx/query-cadc4ac16b7ac22b71c91ab36ad9dbb1dec943798d795fcbc811f4c651fea02a.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "DELETE FROM birthday_calendars WHERE (principal, id) = (?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "cadc4ac16b7ac22b71c91ab36ad9dbb1dec943798d795fcbc811f4c651fea02a"
|
||||||
|
}
|
||||||
12
.sqlx/query-d498a758ed707408b00b7d2675250ea739a681ce1f009f05e97f2e101bd7e556.json
generated
Normal file
12
.sqlx/query-d498a758ed707408b00b7d2675250ea739a681ce1f009f05e97f2e101bd7e556.json
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "INSERT INTO calendarobjects (principal, cal_id, id, uid, ics, first_occurence, last_occurence, etag, object_type) VALUES (?, ?, ?, ?, ?, date(?), date(?), ?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 9
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "d498a758ed707408b00b7d2675250ea739a681ce1f009f05e97f2e101bd7e556"
|
||||||
|
}
|
||||||
963
Cargo.lock
generated
963
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
84
Cargo.toml
84
Cargo.toml
@@ -2,7 +2,8 @@
|
|||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.9.13"
|
version = "0.11.9"
|
||||||
|
rust-version = "1.92"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
description = "A CalDAV server"
|
description = "A CalDAV server"
|
||||||
documentation = "https://lennart-k.github.io/rustical/"
|
documentation = "https://lennart-k.github.io/rustical/"
|
||||||
@@ -12,6 +13,7 @@ license = "AGPL-3.0-or-later"
|
|||||||
[package]
|
[package]
|
||||||
name = "rustical"
|
name = "rustical"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
@@ -30,13 +32,23 @@ opentelemetry = [
|
|||||||
"dep:tracing-opentelemetry",
|
"dep:tracing-opentelemetry",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
debug = 0
|
debug = 0
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
rustical_dav = { path = "./crates/dav/", features = ["ical"] }
|
||||||
|
rustical_dav_push = { path = "./crates/dav_push/" }
|
||||||
|
rustical_store = { path = "./crates/store/" }
|
||||||
|
rustical_store_sqlite = { path = "./crates/store_sqlite/" }
|
||||||
|
rustical_caldav = { path = "./crates/caldav/" }
|
||||||
|
rustical_carddav = { path = "./crates/carddav/" }
|
||||||
|
rustical_frontend = { path = "./crates/frontend/" }
|
||||||
|
rustical_xml = { path = "./crates/xml/" }
|
||||||
|
rustical_oidc = { path = "./crates/oidc/" }
|
||||||
|
rustical_ical = { path = "./crates/ical/" }
|
||||||
|
|
||||||
matchit = "0.9"
|
matchit = "0.9"
|
||||||
uuid = { version = "1.11", features = ["v4", "fast-rng"] }
|
uuid = { version = "1.19", features = ["v4", "fast-rng"] }
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
axum = "0.8"
|
axum = "0.8"
|
||||||
tracing = { version = "0.1", features = ["async-await"] }
|
tracing = { version = "0.1", features = ["async-await"] }
|
||||||
@@ -47,11 +59,11 @@ password-auth = { version = "1.0", features = ["argon2", "pbkdf2"] }
|
|||||||
pbkdf2 = { version = "0.12", features = ["simple"] }
|
pbkdf2 = { version = "0.12", features = ["simple"] }
|
||||||
rand_core = { version = "0.9", features = ["std"] }
|
rand_core = { version = "0.9", features = ["std"] }
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
regex = "1.10"
|
regex = "1.12"
|
||||||
rstest = "0.26"
|
rstest = "0.26"
|
||||||
rstest_reuse = "0.7"
|
rstest_reuse = "0.7"
|
||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
tokio = { version = "1", features = [
|
tokio = { version = "1.48", features = [
|
||||||
"net",
|
"net",
|
||||||
"tracing",
|
"tracing",
|
||||||
"macros",
|
"macros",
|
||||||
@@ -62,14 +74,14 @@ url = "2.5"
|
|||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
thiserror = "2.0"
|
thiserror = "2.0"
|
||||||
quick-xml = { version = "0.38" }
|
quick-xml = { version = "0.38" }
|
||||||
rust-embed = "8.5"
|
rust-embed = "8.9"
|
||||||
tower-sessions = "0.14"
|
tower-sessions = "0.14"
|
||||||
futures-core = "0.3.31"
|
futures-core = "0.3"
|
||||||
hex = { version = "0.4.3", features = ["serde"] }
|
hex = { version = "0.4", features = ["serde"] }
|
||||||
mime_guess = "2.0"
|
mime_guess = "2.0"
|
||||||
itertools = "0.14"
|
itertools = "0.14"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
derive_more = { version = "2.0", features = [
|
derive_more = { version = "2.1", features = [
|
||||||
"from",
|
"from",
|
||||||
"try_into",
|
"try_into",
|
||||||
"into",
|
"into",
|
||||||
@@ -77,8 +89,8 @@ derive_more = { version = "2.0", features = [
|
|||||||
"constructor",
|
"constructor",
|
||||||
"display",
|
"display",
|
||||||
] }
|
] }
|
||||||
askama = { version = "0.14", features = ["serde_json"] }
|
askama = { version = "0.15", features = ["serde_json"] }
|
||||||
askama_web = { version = "0.14.0", features = ["axum-0.8"] }
|
askama_web = { version = "0.15", features = ["axum-0.8"] }
|
||||||
sqlx = { version = "0.8", default-features = false, features = [
|
sqlx = { version = "0.8", default-features = false, features = [
|
||||||
"sqlx-sqlite",
|
"sqlx-sqlite",
|
||||||
"uuid",
|
"uuid",
|
||||||
@@ -89,15 +101,13 @@ sqlx = { version = "0.8", default-features = false, features = [
|
|||||||
"migrate",
|
"migrate",
|
||||||
"json",
|
"json",
|
||||||
] }
|
] }
|
||||||
http = "1.3"
|
http = "1.4"
|
||||||
headers = "0.4"
|
headers = "0.4"
|
||||||
strum = "0.27"
|
strum = "0.27"
|
||||||
strum_macros = "0.27"
|
strum_macros = "0.27"
|
||||||
serde_json = { version = "1.0", features = ["raw_value"] }
|
serde_json = { version = "1.0", features = ["raw_value"] }
|
||||||
sqlx-sqlite = { version = "0.8", features = ["bundled"] }
|
sqlx-sqlite = { version = "0.8", features = ["bundled"] }
|
||||||
ical = { git = "https://github.com/lennart-k/ical-rs", features = [
|
ical = { git = "https://github.com/lennart-k/ical-rs", features = [
|
||||||
"generator",
|
|
||||||
"serde",
|
|
||||||
"chrono-tz",
|
"chrono-tz",
|
||||||
] }
|
] }
|
||||||
toml = "0.9"
|
toml = "0.9"
|
||||||
@@ -108,29 +118,19 @@ tower-http = { version = "0.6", features = [
|
|||||||
"catch-panic",
|
"catch-panic",
|
||||||
] }
|
] }
|
||||||
percent-encoding = "2.3"
|
percent-encoding = "2.3"
|
||||||
rustical_dav = { path = "./crates/dav/" }
|
|
||||||
rustical_dav_push = { path = "./crates/dav_push/" }
|
|
||||||
rustical_store = { path = "./crates/store/" }
|
|
||||||
rustical_store_sqlite = { path = "./crates/store_sqlite/" }
|
|
||||||
rustical_caldav = { path = "./crates/caldav/" }
|
|
||||||
rustical_carddav = { path = "./crates/carddav/" }
|
|
||||||
rustical_frontend = { path = "./crates/frontend/" }
|
|
||||||
rustical_xml = { path = "./crates/xml/" }
|
|
||||||
rustical_oidc = { path = "./crates/oidc/" }
|
|
||||||
rustical_ical = { path = "./crates/ical/" }
|
|
||||||
chrono-tz = "0.10"
|
chrono-tz = "0.10"
|
||||||
chrono-humanize = "0.2"
|
chrono-humanize = "0.2"
|
||||||
rand = "0.9"
|
rand = "0.9"
|
||||||
axum-extra = { version = "0.10", features = ["typed-header"] }
|
axum-extra = { version = "0.12", features = ["typed-header"] }
|
||||||
rrule = "0.14"
|
rrule = "0.14"
|
||||||
argon2 = "0.5"
|
argon2 = "0.5"
|
||||||
rpassword = "7.3"
|
rpassword = "7.4"
|
||||||
password-hash = { version = "0.5" }
|
password-hash = { version = "0.5" }
|
||||||
syn = { version = "2.0", features = ["full"] }
|
syn = { version = "2.0", features = ["full"] }
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
heck = "0.5"
|
heck = "0.5"
|
||||||
darling = "0.21"
|
darling = "0.23"
|
||||||
reqwest = { version = "0.12", features = [
|
reqwest = { version = "0.12", features = [
|
||||||
"rustls-tls",
|
"rustls-tls",
|
||||||
"charset",
|
"charset",
|
||||||
@@ -145,21 +145,29 @@ ece = { version = "2.3", default-features = false, features = [
|
|||||||
] }
|
] }
|
||||||
openssl = { version = "0.10", features = ["vendored"] }
|
openssl = { version = "0.10", features = ["vendored"] }
|
||||||
async-std = { version = "1.13", features = ["attributes"] }
|
async-std = { version = "1.13", features = ["attributes"] }
|
||||||
|
similar-asserts = "1.7"
|
||||||
|
insta = { version = "1.44", features = ["filters"] }
|
||||||
|
criterion = { version = "0.8", features = ["async_tokio"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
rstest.workspace = true
|
||||||
|
rustical_store_sqlite = { workspace = true, features = ["test"] }
|
||||||
|
insta.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustical_store = { workspace = true }
|
rustical_store.workspace = true
|
||||||
rustical_store_sqlite = { workspace = true }
|
rustical_store_sqlite.workspace = true
|
||||||
rustical_caldav = { workspace = true }
|
rustical_caldav.workspace = true
|
||||||
rustical_carddav.workspace = true
|
rustical_carddav.workspace = true
|
||||||
rustical_frontend = { workspace = true }
|
rustical_frontend.workspace = true
|
||||||
toml = { workspace = true }
|
toml.workspace = true
|
||||||
serde = { workspace = true }
|
serde.workspace = true
|
||||||
tokio = { workspace = true }
|
tokio.workspace = true
|
||||||
tracing = { workspace = true }
|
tracing.workspace = true
|
||||||
anyhow = { workspace = true }
|
anyhow.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
sqlx = { workspace = true }
|
sqlx.workspace = true
|
||||||
async-trait = { workspace = true }
|
async-trait.workspace = true
|
||||||
uuid.workspace = true
|
uuid.workspace = true
|
||||||
axum.workspace = true
|
axum.workspace = true
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM --platform=$BUILDPLATFORM rust:1.90-alpine AS chef
|
FROM --platform=$BUILDPLATFORM rust:1.92-alpine AS chef
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
[](https://raw.githubusercontent.com/lennart-k/rustical/main/LICENSE)
|
||||||
|
[](https://coveralls.io/github/lennart-k/rustical?branch=main)
|
||||||
|
|
||||||
# RustiCal
|
# RustiCal
|
||||||
|
|
||||||
a CalDAV/CardDAV server
|
a CalDAV/CardDAV server
|
||||||
|
|||||||
@@ -9,5 +9,7 @@ accepted = [
|
|||||||
"AGPL-3.0",
|
"AGPL-3.0",
|
||||||
"GPL-3.0",
|
"GPL-3.0",
|
||||||
"MPL-2.0",
|
"MPL-2.0",
|
||||||
|
"AGPL-3.0-or-later",
|
||||||
|
"GPL-3.0-or-later",
|
||||||
]
|
]
|
||||||
workarounds = ["ring", "chrono", "rustls"]
|
workarounds = ["ring", "chrono", "rustls"]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rustical_caldav"
|
name = "rustical_caldav"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
@@ -12,26 +13,27 @@ rustical_store_sqlite = { workspace = true, features = ["test"] }
|
|||||||
rstest.workspace = true
|
rstest.workspace = true
|
||||||
async-std.workspace = true
|
async-std.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
insta.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum.workspace = true
|
axum.workspace = true
|
||||||
axum-extra.workspace = true
|
axum-extra.workspace = true
|
||||||
tower.workspace = true
|
tower.workspace = true
|
||||||
async-trait = { workspace = true }
|
async-trait.workspace = true
|
||||||
thiserror = { workspace = true }
|
thiserror.workspace = true
|
||||||
quick-xml = { workspace = true }
|
quick-xml.workspace = true
|
||||||
tracing = { workspace = true }
|
tracing.workspace = true
|
||||||
futures-util = { workspace = true }
|
futures-util.workspace = true
|
||||||
derive_more = { workspace = true }
|
derive_more.workspace = true
|
||||||
base64 = { workspace = true }
|
base64.workspace = true
|
||||||
serde = { workspace = true }
|
serde.workspace = true
|
||||||
tokio = { workspace = true }
|
tokio.workspace = true
|
||||||
url = { workspace = true }
|
url.workspace = true
|
||||||
rustical_dav = { workspace = true }
|
rustical_dav = { workspace = true, features = ["ical"] }
|
||||||
rustical_store = { workspace = true }
|
rustical_store.workspace = true
|
||||||
chrono = { workspace = true }
|
chrono.workspace = true
|
||||||
chrono-tz = { workspace = true }
|
chrono-tz.workspace = true
|
||||||
sha2 = { workspace = true }
|
sha2.workspace = true
|
||||||
ical.workspace = true
|
ical.workspace = true
|
||||||
percent-encoding.workspace = true
|
percent-encoding.workspace = true
|
||||||
rustical_xml.workspace = true
|
rustical_xml.workspace = true
|
||||||
@@ -44,3 +46,4 @@ tower-http.workspace = true
|
|||||||
strum.workspace = true
|
strum.workspace = true
|
||||||
strum_macros.workspace = true
|
strum_macros.workspace = true
|
||||||
vtimezones-rs.workspace = true
|
vtimezones-rs.workspace = true
|
||||||
|
similar-asserts.workspace = true
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ use axum::extract::State;
|
|||||||
use axum::{extract::Path, response::Response};
|
use axum::{extract::Path, response::Response};
|
||||||
use headers::{ContentType, HeaderMapExt};
|
use headers::{ContentType, HeaderMapExt};
|
||||||
use http::{HeaderValue, Method, StatusCode, header};
|
use http::{HeaderValue, Method, StatusCode, header};
|
||||||
use ical::generator::{Emitter, IcalCalendarBuilder};
|
use ical::builder::calendar::IcalCalendarBuilder;
|
||||||
|
use ical::generator::Emitter;
|
||||||
use ical::property::Property;
|
use ical::property::Property;
|
||||||
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
use percent_encoding::{CONTROLS, utf8_percent_encode};
|
||||||
use rustical_ical::{CalendarObjectComponent, EventObject};
|
use rustical_ical::{CalendarObjectComponent, EventObject};
|
||||||
@@ -35,28 +36,28 @@ pub async fn route_get<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
let mut vtimezones = HashMap::new();
|
let mut vtimezones = HashMap::new();
|
||||||
let objects = cal_store.get_objects(&principal, &calendar_id).await?;
|
let objects = cal_store.get_objects(&principal, &calendar_id).await?;
|
||||||
|
|
||||||
let mut ical_calendar_builder = IcalCalendarBuilder::version("4.0")
|
let mut ical_calendar_builder = IcalCalendarBuilder::version("2.0")
|
||||||
.gregorian()
|
.gregorian()
|
||||||
.prodid("RustiCal");
|
.prodid("RustiCal");
|
||||||
if let Some(displayname) = calendar.meta.displayname {
|
if let Some(displayname) = calendar.meta.displayname {
|
||||||
ical_calendar_builder = ical_calendar_builder.set(Property {
|
ical_calendar_builder = ical_calendar_builder.set(Property {
|
||||||
name: "X-WR-CALNAME".to_owned(),
|
name: "X-WR-CALNAME".to_owned(),
|
||||||
value: Some(displayname),
|
value: Some(displayname),
|
||||||
params: None,
|
params: vec![],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if let Some(description) = calendar.meta.description {
|
if let Some(description) = calendar.meta.description {
|
||||||
ical_calendar_builder = ical_calendar_builder.set(Property {
|
ical_calendar_builder = ical_calendar_builder.set(Property {
|
||||||
name: "X-WR-CALDESC".to_owned(),
|
name: "X-WR-CALDESC".to_owned(),
|
||||||
value: Some(description),
|
value: Some(description),
|
||||||
params: None,
|
params: vec![],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if let Some(timezone_id) = calendar.timezone_id {
|
if let Some(timezone_id) = calendar.timezone_id {
|
||||||
ical_calendar_builder = ical_calendar_builder.set(Property {
|
ical_calendar_builder = ical_calendar_builder.set(Property {
|
||||||
name: "X-WR-TIMEZONE".to_owned(),
|
name: "X-WR-TIMEZONE".to_owned(),
|
||||||
value: Some(timezone_id),
|
value: Some(timezone_id),
|
||||||
params: None,
|
params: vec![],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,30 +65,24 @@ pub async fn route_get<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
vtimezones.extend(object.get_vtimezones());
|
vtimezones.extend(object.get_vtimezones());
|
||||||
match object.get_data() {
|
match object.get_data() {
|
||||||
CalendarObjectComponent::Event(EventObject { event, .. }, overrides) => {
|
CalendarObjectComponent::Event(EventObject { event, .. }, overrides) => {
|
||||||
ical_calendar_builder = ical_calendar_builder.add_event(event.clone());
|
ical_calendar_builder = ical_calendar_builder
|
||||||
for ev_override in overrides {
|
.add_event(event.clone())
|
||||||
ical_calendar_builder =
|
.add_events(overrides.iter().map(|ev| ev.event.clone()));
|
||||||
ical_calendar_builder.add_event(ev_override.event.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
CalendarObjectComponent::Todo(todo, overrides) => {
|
CalendarObjectComponent::Todo(todo, overrides) => {
|
||||||
ical_calendar_builder = ical_calendar_builder.add_todo(todo.clone());
|
ical_calendar_builder = ical_calendar_builder
|
||||||
for ev_override in overrides {
|
.add_todo(todo.clone())
|
||||||
ical_calendar_builder = ical_calendar_builder.add_todo(ev_override.clone());
|
.add_todos(overrides.iter().cloned());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
CalendarObjectComponent::Journal(journal, overrides) => {
|
CalendarObjectComponent::Journal(journal, overrides) => {
|
||||||
ical_calendar_builder = ical_calendar_builder.add_journal(journal.clone());
|
ical_calendar_builder = ical_calendar_builder
|
||||||
for ev_override in overrides {
|
.add_journal(journal.clone())
|
||||||
ical_calendar_builder = ical_calendar_builder.add_journal(ev_override.clone());
|
.add_journals(overrides.iter().cloned());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for vtimezone in vtimezones.into_values() {
|
ical_calendar_builder = ical_calendar_builder.add_timezones(vtimezones.into_values().cloned());
|
||||||
ical_calendar_builder = ical_calendar_builder.add_tz(vtimezone.to_owned());
|
|
||||||
}
|
|
||||||
|
|
||||||
let ical_calendar = ical_calendar_builder
|
let ical_calendar = ical_calendar_builder
|
||||||
.build()
|
.build()
|
||||||
@@ -95,7 +90,7 @@ pub async fn route_get<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
|
|
||||||
let mut resp = Response::builder().status(StatusCode::OK);
|
let mut resp = Response::builder().status(StatusCode::OK);
|
||||||
let hdrs = resp.headers_mut().unwrap();
|
let hdrs = resp.headers_mut().unwrap();
|
||||||
hdrs.typed_insert(ContentType::from_str("text/calendar").unwrap());
|
hdrs.typed_insert(ContentType::from_str("text/calendar; charset=utf-8").unwrap());
|
||||||
|
|
||||||
let filename = format!("{}_{}.ics", calendar.principal, calendar.id);
|
let filename = format!("{}_{}.ics", calendar.principal, calendar.id);
|
||||||
let filename = utf8_percent_encode(&filename, CONTROLS);
|
let filename = utf8_percent_encode(&filename, CONTROLS);
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
let objects = expanded_cals
|
let objects = expanded_cals
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|cal| cal.generate())
|
.map(|cal| cal.generate())
|
||||||
.map(CalendarObject::from_ics)
|
.map(|ics| CalendarObject::from_ics(ics, None))
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
let new_cal = Calendar {
|
let new_cal = Calendar {
|
||||||
principal,
|
principal,
|
||||||
|
|||||||
@@ -26,16 +26,18 @@ pub async fn get_objects_calendar_multiget<C: CalendarStore>(
|
|||||||
let mut not_found = vec![];
|
let mut not_found = vec![];
|
||||||
|
|
||||||
for href in &cal_query.href {
|
for href in &cal_query.href {
|
||||||
if let Some(filename) = href.strip_prefix(path) {
|
if let Ok(href) = percent_encoding::percent_decode_str(href).decode_utf8()
|
||||||
|
&& let Some(filename) = href.strip_prefix(path)
|
||||||
|
{
|
||||||
let filename = filename.trim_start_matches('/');
|
let filename = filename.trim_start_matches('/');
|
||||||
if let Some(object_id) = filename.strip_suffix(".ics") {
|
if let Some(object_id) = filename.strip_suffix(".ics") {
|
||||||
match store.get_object(principal, cal_id, object_id, false).await {
|
match store.get_object(principal, cal_id, object_id, false).await {
|
||||||
Ok(object) => result.push(object),
|
Ok(object) => result.push(object),
|
||||||
Err(rustical_store::Error::NotFound) => not_found.push(href.to_owned()),
|
Err(rustical_store::Error::NotFound) => not_found.push(href.to_string()),
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => return Err(err.into()),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
not_found.push(href.to_owned());
|
not_found.push(href.to_string());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
not_found.push(href.to_owned());
|
not_found.push(href.to_owned());
|
||||||
|
|||||||
@@ -0,0 +1,347 @@
|
|||||||
|
use crate::calendar::methods::report::calendar_query::{
|
||||||
|
TimeRangeElement,
|
||||||
|
prop_filter::{PropFilterElement, PropFilterable},
|
||||||
|
};
|
||||||
|
use ical::parser::ical::component::IcalTimeZone;
|
||||||
|
use rustical_ical::{CalendarObject, CalendarObjectComponent, CalendarObjectType};
|
||||||
|
use rustical_xml::XmlDeserialize;
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc4791#section-9.7.1
|
||||||
|
pub struct CompFilterElement {
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
|
pub(crate) is_not_defined: Option<()>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
|
pub(crate) time_range: Option<TimeRangeElement>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
||||||
|
pub(crate) prop_filter: Vec<PropFilterElement>,
|
||||||
|
#[allow(clippy::use_self)]
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
||||||
|
pub(crate) comp_filter: Vec<CompFilterElement>,
|
||||||
|
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait CompFilterable: PropFilterable + Sized {
|
||||||
|
fn get_comp_name(&self) -> &'static str;
|
||||||
|
|
||||||
|
fn match_time_range(&self, time_range: &TimeRangeElement) -> bool;
|
||||||
|
|
||||||
|
fn match_subcomponents(&self, comp_filter: &CompFilterElement) -> bool;
|
||||||
|
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc4791#section-9.7.1
|
||||||
|
// The scope of the
|
||||||
|
// CALDAV:comp-filter XML element is the calendar object when used as
|
||||||
|
// a child of the CALDAV:filter XML element. The scope of the
|
||||||
|
// CALDAV:comp-filter XML element is the enclosing calendar component
|
||||||
|
// when used as a child of another CALDAV:comp-filter XML element
|
||||||
|
fn matches(&self, comp_filter: &CompFilterElement) -> bool {
|
||||||
|
let name_matches = self.get_comp_name() == comp_filter.name;
|
||||||
|
match (comp_filter.is_not_defined.is_some(), name_matches) {
|
||||||
|
// We are the component that's not supposed to be defined
|
||||||
|
(true, true)
|
||||||
|
// We don't match
|
||||||
|
| (false, false) => return false,
|
||||||
|
// We shall not be and indeed we aren't
|
||||||
|
(true, false) => return true,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(time_range) = comp_filter.time_range.as_ref()
|
||||||
|
&& !self.match_time_range(time_range)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for prop_filter in &comp_filter.prop_filter {
|
||||||
|
if !prop_filter.match_component(self) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
comp_filter
|
||||||
|
.comp_filter
|
||||||
|
.iter()
|
||||||
|
.all(|filter| self.match_subcomponents(filter))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CompFilterable for CalendarObject {
|
||||||
|
fn get_comp_name(&self) -> &'static str {
|
||||||
|
"VCALENDAR"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_time_range(&self, _time_range: &TimeRangeElement) -> bool {
|
||||||
|
// VCALENDAR has no concept of time range
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_subcomponents(&self, comp_filter: &CompFilterElement) -> bool {
|
||||||
|
let mut matches = self
|
||||||
|
.get_vtimezones()
|
||||||
|
.values()
|
||||||
|
.map(|tz| tz.matches(comp_filter))
|
||||||
|
.chain([self.get_data().matches(comp_filter)]);
|
||||||
|
|
||||||
|
if comp_filter.is_not_defined.is_some() {
|
||||||
|
matches.all(|x| x)
|
||||||
|
} else {
|
||||||
|
matches.any(|x| x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CompFilterable for IcalTimeZone {
|
||||||
|
fn get_comp_name(&self) -> &'static str {
|
||||||
|
"VTIMEZONE"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_time_range(&self, _time_range: &TimeRangeElement) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_subcomponents(&self, _comp_filter: &CompFilterElement) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CompFilterable for CalendarObjectComponent {
|
||||||
|
fn get_comp_name(&self) -> &'static str {
|
||||||
|
CalendarObjectType::from(self).as_str()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_time_range(&self, time_range: &TimeRangeElement) -> bool {
|
||||||
|
if let Some(start) = &time_range.start
|
||||||
|
&& let Some(last_occurence) = self.get_last_occurence().unwrap_or(None)
|
||||||
|
&& **start > last_occurence.utc()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if let Some(end) = &time_range.end
|
||||||
|
&& let Some(first_occurence) = self.get_first_occurence().unwrap_or(None)
|
||||||
|
&& **end < first_occurence.utc()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_subcomponents(&self, _comp_filter: &CompFilterElement) -> bool {
|
||||||
|
// TODO: Properly check subcomponents
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use chrono::{TimeZone, Utc};
|
||||||
|
use rustical_dav::xml::{MatchType, NegateCondition, TextCollation, TextMatchElement};
|
||||||
|
use rustical_ical::{CalendarObject, UtcDateTime};
|
||||||
|
|
||||||
|
use crate::calendar::methods::report::calendar_query::{
|
||||||
|
CompFilterElement, CompFilterable, PropFilterElement, TimeRangeElement,
|
||||||
|
};
|
||||||
|
|
||||||
|
const ICS: &str = r"BEGIN:VCALENDAR
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
|
VERSION:2.0
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Europe/Berlin
|
||||||
|
X-LIC-LOCATION:Europe/Berlin
|
||||||
|
END:VTIMEZONE
|
||||||
|
|
||||||
|
BEGIN:VEVENT
|
||||||
|
UID:318ec6503573d9576818daf93dac07317058d95c
|
||||||
|
DTSTAMP:20250502T132758Z
|
||||||
|
DTSTART;TZID=Europe/Berlin:20250506T090000
|
||||||
|
DTEND;TZID=Europe/Berlin:20250506T092500
|
||||||
|
SEQUENCE:2
|
||||||
|
SUMMARY:weekly stuff
|
||||||
|
TRANSP:OPAQUE
|
||||||
|
RRULE:FREQ=WEEKLY;COUNT=4;INTERVAL=2;BYDAY=TU,TH,SU
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_comp_filter_matching() {
|
||||||
|
let object = CalendarObject::from_ics(ICS.to_string(), None).unwrap();
|
||||||
|
|
||||||
|
let comp_filter = CompFilterElement {
|
||||||
|
is_not_defined: Some(()),
|
||||||
|
name: "VCALENDAR".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![],
|
||||||
|
};
|
||||||
|
assert!(!object.matches(&comp_filter), "filter: wants no VCALENDAR");
|
||||||
|
|
||||||
|
let comp_filter = CompFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "VCALENDAR".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![CompFilterElement {
|
||||||
|
name: "VTODO".to_string(),
|
||||||
|
is_not_defined: None,
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
assert!(!object.matches(&comp_filter), "filter matches VTODO");
|
||||||
|
|
||||||
|
let comp_filter = CompFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "VCALENDAR".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![CompFilterElement {
|
||||||
|
name: "VEVENT".to_string(),
|
||||||
|
is_not_defined: None,
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
assert!(object.matches(&comp_filter), "filter matches VEVENT");
|
||||||
|
|
||||||
|
let comp_filter = CompFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "VCALENDAR".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![
|
||||||
|
PropFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "VERSION".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
text_match: Some(TextMatchElement {
|
||||||
|
match_type: MatchType::Contains,
|
||||||
|
needle: "2.0".to_string(),
|
||||||
|
collation: TextCollation::default(),
|
||||||
|
negate_condition: NegateCondition::default(),
|
||||||
|
}),
|
||||||
|
param_filter: vec![],
|
||||||
|
},
|
||||||
|
PropFilterElement {
|
||||||
|
is_not_defined: Some(()),
|
||||||
|
name: "STUFF".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
text_match: None,
|
||||||
|
param_filter: vec![],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
comp_filter: vec![CompFilterElement {
|
||||||
|
name: "VEVENT".to_string(),
|
||||||
|
is_not_defined: None,
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![PropFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "SUMMARY".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
text_match: Some(TextMatchElement {
|
||||||
|
match_type: MatchType::Contains,
|
||||||
|
collation: TextCollation::default(),
|
||||||
|
negate_condition: NegateCondition(false),
|
||||||
|
needle: "weekly".to_string(),
|
||||||
|
}),
|
||||||
|
param_filter: vec![],
|
||||||
|
}],
|
||||||
|
comp_filter: vec![],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
assert!(
|
||||||
|
object.matches(&comp_filter),
|
||||||
|
"Some prop filters on VCALENDAR and VEVENT"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_comp_filter_time_range() {
|
||||||
|
let object = CalendarObject::from_ics(ICS.to_string(), None).unwrap();
|
||||||
|
|
||||||
|
let comp_filter = CompFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "VCALENDAR".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![CompFilterElement {
|
||||||
|
name: "VEVENT".to_string(),
|
||||||
|
is_not_defined: None,
|
||||||
|
time_range: Some(TimeRangeElement {
|
||||||
|
start: Some(UtcDateTime(
|
||||||
|
Utc.with_ymd_and_hms(2025, 4, 1, 0, 0, 0).unwrap(),
|
||||||
|
)),
|
||||||
|
end: Some(UtcDateTime(
|
||||||
|
Utc.with_ymd_and_hms(2025, 8, 1, 0, 0, 0).unwrap(),
|
||||||
|
)),
|
||||||
|
}),
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
assert!(
|
||||||
|
object.matches(&comp_filter),
|
||||||
|
"event should lie in time range"
|
||||||
|
);
|
||||||
|
|
||||||
|
let comp_filter = CompFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "VCALENDAR".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![CompFilterElement {
|
||||||
|
name: "VEVENT".to_string(),
|
||||||
|
is_not_defined: None,
|
||||||
|
time_range: Some(TimeRangeElement {
|
||||||
|
start: Some(UtcDateTime(
|
||||||
|
Utc.with_ymd_and_hms(2024, 4, 1, 0, 0, 0).unwrap(),
|
||||||
|
)),
|
||||||
|
end: Some(UtcDateTime(
|
||||||
|
Utc.with_ymd_and_hms(2024, 8, 1, 0, 0, 0).unwrap(),
|
||||||
|
)),
|
||||||
|
}),
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
assert!(
|
||||||
|
!object.matches(&comp_filter),
|
||||||
|
"event should not lie in time range"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_match_timezone() {
|
||||||
|
let object = CalendarObject::from_ics(ICS.to_string(), None).unwrap();
|
||||||
|
|
||||||
|
let comp_filter = CompFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "VCALENDAR".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![CompFilterElement {
|
||||||
|
name: "VTIMEZONE".to_string(),
|
||||||
|
is_not_defined: None,
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![PropFilterElement {
|
||||||
|
is_not_defined: None,
|
||||||
|
name: "TZID".to_string(),
|
||||||
|
time_range: None,
|
||||||
|
text_match: Some(TextMatchElement {
|
||||||
|
match_type: MatchType::Contains,
|
||||||
|
collation: TextCollation::AsciiCasemap,
|
||||||
|
negate_condition: NegateCondition::default(),
|
||||||
|
needle: "Europe/Berlin".to_string(),
|
||||||
|
}),
|
||||||
|
param_filter: vec![],
|
||||||
|
}],
|
||||||
|
comp_filter: vec![],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
assert!(
|
||||||
|
object.matches(&comp_filter),
|
||||||
|
"Timezone should be Europe/Berlin"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
|
use super::comp_filter::{CompFilterElement, CompFilterable};
|
||||||
use crate::calendar_object::CalendarObjectPropWrapperName;
|
use crate::calendar_object::CalendarObjectPropWrapperName;
|
||||||
use rustical_dav::xml::PropfindType;
|
use ical::property::Property;
|
||||||
|
use rustical_dav::xml::{PropfindType, TextMatchElement};
|
||||||
use rustical_ical::{CalendarObject, UtcDateTime};
|
use rustical_ical::{CalendarObject, UtcDateTime};
|
||||||
use rustical_store::calendar_store::CalendarQuery;
|
use rustical_store::calendar_store::CalendarQuery;
|
||||||
use rustical_xml::XmlDeserialize;
|
use rustical_xml::{XmlDeserialize, XmlRootTag};
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@@ -26,113 +28,25 @@ pub struct ParamFilterElement {
|
|||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
impl ParamFilterElement {
|
||||||
#[allow(dead_code)]
|
#[must_use]
|
||||||
pub struct TextMatchElement {
|
pub fn match_property(&self, prop: &Property) -> bool {
|
||||||
#[xml(ty = "attr")]
|
let Some(param) = prop.get_param(&self.name) else {
|
||||||
pub(crate) collation: String,
|
return self.is_not_defined.is_some();
|
||||||
#[xml(ty = "attr")]
|
};
|
||||||
// "yes" or "no", default: "no"
|
if self.is_not_defined.is_some() {
|
||||||
pub(crate) negate_condition: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
|
||||||
#[allow(dead_code)]
|
|
||||||
// https://www.rfc-editor.org/rfc/rfc4791#section-9.7.2
|
|
||||||
pub struct PropFilterElement {
|
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
|
||||||
pub(crate) is_not_defined: Option<()>,
|
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
|
||||||
pub(crate) time_range: Option<TimeRangeElement>,
|
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
|
||||||
pub(crate) text_match: Option<TextMatchElement>,
|
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
|
||||||
pub(crate) param_filter: Vec<ParamFilterElement>,
|
|
||||||
|
|
||||||
#[xml(ty = "attr")]
|
|
||||||
pub(crate) name: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
|
||||||
#[allow(dead_code)]
|
|
||||||
// https://datatracker.ietf.org/doc/html/rfc4791#section-9.7.1
|
|
||||||
pub struct CompFilterElement {
|
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
|
||||||
pub(crate) is_not_defined: Option<()>,
|
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
|
||||||
pub(crate) time_range: Option<TimeRangeElement>,
|
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
|
||||||
pub(crate) prop_filter: Vec<PropFilterElement>,
|
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
|
||||||
pub(crate) comp_filter: Vec<CompFilterElement>,
|
|
||||||
|
|
||||||
#[xml(ty = "attr")]
|
|
||||||
pub(crate) name: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CompFilterElement {
|
|
||||||
// match the VCALENDAR part
|
|
||||||
pub fn matches_root(&self, cal_object: &CalendarObject) -> bool {
|
|
||||||
let comp_vcal = self.name == "VCALENDAR";
|
|
||||||
match (self.is_not_defined, comp_vcal) {
|
|
||||||
// Client wants VCALENDAR to not exist but we are a VCALENDAR
|
|
||||||
(Some(()), true) |
|
|
||||||
// Client is asking for something different than a vcalendar
|
|
||||||
(None, false) => return false,
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.time_range.is_some() {
|
|
||||||
// <time-range> should be applied on VEVENT/VTODO but not on VCALENDAR
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement prop-filter at some point
|
let Some(text_match) = self.text_match.as_ref() else {
|
||||||
|
|
||||||
// Apply sub-comp-filters on VEVENT/VTODO/VJOURNAL component
|
|
||||||
if self
|
|
||||||
.comp_filter
|
|
||||||
.iter()
|
|
||||||
.all(|filter| filter.matches(cal_object))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
text_match.match_text(param)
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
// match the VEVENT/VTODO/VJOURNAL part
|
|
||||||
pub fn matches(&self, cal_object: &CalendarObject) -> bool {
|
|
||||||
let comp_name_matches = self.name == cal_object.get_component_name();
|
|
||||||
match (self.is_not_defined, comp_name_matches) {
|
|
||||||
// Client wants VCALENDAR to not exist but we are a VCALENDAR
|
|
||||||
(Some(()), true) |
|
|
||||||
// Client is asking for something different than a vcalendar
|
|
||||||
(None, false) => return false,
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Implement prop-filter (and comp-filter?) at some point
|
|
||||||
|
|
||||||
if let Some(time_range) = &self.time_range {
|
|
||||||
if let Some(start) = &time_range.start
|
|
||||||
&& let Some(last_occurence) = cal_object.get_last_occurence().unwrap_or(None)
|
|
||||||
&& **start > last_occurence.utc()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if let Some(end) = &time_range.end
|
|
||||||
&& let Some(first_occurence) = cal_object.get_first_occurence().unwrap_or(None)
|
|
||||||
&& **end < first_occurence.utc()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
#[derive(XmlDeserialize, XmlRootTag, Clone, Debug, PartialEq)]
|
||||||
|
#[xml(root = "filter", ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
// https://datatracker.ietf.org/doc/html/rfc4791#section-9.7
|
// https://datatracker.ietf.org/doc/html/rfc4791#section-9.7
|
||||||
pub struct FilterElement {
|
pub struct FilterElement {
|
||||||
@@ -142,8 +56,9 @@ pub struct FilterElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FilterElement {
|
impl FilterElement {
|
||||||
|
#[must_use]
|
||||||
pub fn matches(&self, cal_object: &CalendarObject) -> bool {
|
pub fn matches(&self, cal_object: &CalendarObject) -> bool {
|
||||||
self.comp_filter.matches_root(cal_object)
|
cal_object.matches(&self.comp_filter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,3 +102,45 @@ impl From<&CalendarQueryRequest> for CalendarQuery {
|
|||||||
value.filter.as_ref().map(Self::from).unwrap_or_default()
|
value.filter.as_ref().map(Self::from).unwrap_or_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::calendar::methods::report::calendar_query::{
|
||||||
|
CompFilterElement, FilterElement, TimeRangeElement,
|
||||||
|
};
|
||||||
|
use chrono::{NaiveDate, TimeZone, Utc};
|
||||||
|
use rustical_ical::UtcDateTime;
|
||||||
|
use rustical_store::calendar_store::CalendarQuery;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_filter_element_calendar_query() {
|
||||||
|
let filter = FilterElement {
|
||||||
|
comp_filter: CompFilterElement {
|
||||||
|
name: "VCALENDAR".to_string(),
|
||||||
|
is_not_defined: None,
|
||||||
|
time_range: None,
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![CompFilterElement {
|
||||||
|
name: "VEVENT".to_string(),
|
||||||
|
is_not_defined: None,
|
||||||
|
time_range: Some(TimeRangeElement {
|
||||||
|
start: Some(UtcDateTime(
|
||||||
|
Utc.with_ymd_and_hms(2024, 4, 1, 0, 0, 0).unwrap(),
|
||||||
|
)),
|
||||||
|
end: Some(UtcDateTime(
|
||||||
|
Utc.with_ymd_and_hms(2024, 8, 1, 0, 0, 0).unwrap(),
|
||||||
|
)),
|
||||||
|
}),
|
||||||
|
prop_filter: vec![],
|
||||||
|
comp_filter: vec![],
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let derived_query: CalendarQuery = (&filter).into();
|
||||||
|
let query = CalendarQuery {
|
||||||
|
time_start: Some(NaiveDate::from_ymd_opt(2024, 4, 1).unwrap()),
|
||||||
|
time_end: Some(NaiveDate::from_ymd_opt(2024, 8, 1).unwrap()),
|
||||||
|
};
|
||||||
|
assert_eq!(derived_query, query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,16 @@ use crate::Error;
|
|||||||
use rustical_ical::CalendarObject;
|
use rustical_ical::CalendarObject;
|
||||||
use rustical_store::CalendarStore;
|
use rustical_store::CalendarStore;
|
||||||
|
|
||||||
|
mod comp_filter;
|
||||||
mod elements;
|
mod elements;
|
||||||
|
mod prop_filter;
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use comp_filter::{CompFilterElement, CompFilterable};
|
||||||
pub use elements::*;
|
pub use elements::*;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use prop_filter::{PropFilterElement, PropFilterable};
|
||||||
|
|
||||||
pub async fn get_objects_calendar_query<C: CalendarStore>(
|
pub async fn get_objects_calendar_query<C: CalendarStore>(
|
||||||
cal_query: &CalendarQueryRequest,
|
cal_query: &CalendarQueryRequest,
|
||||||
@@ -21,20 +29,19 @@ pub async fn get_objects_calendar_query<C: CalendarStore>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod xml_tests {
|
||||||
use rustical_dav::xml::PropElement;
|
use super::{
|
||||||
use rustical_xml::XmlDocument;
|
CalendarQueryRequest, FilterElement, ParamFilterElement, comp_filter::CompFilterElement,
|
||||||
|
prop_filter::PropFilterElement,
|
||||||
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
calendar::methods::report::{
|
calendar::methods::report::ReportRequest,
|
||||||
ReportRequest,
|
|
||||||
calendar_query::{
|
|
||||||
CalendarQueryRequest, CompFilterElement, FilterElement, ParamFilterElement,
|
|
||||||
PropFilterElement, TextMatchElement,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
calendar_object::{CalendarData, CalendarObjectPropName, CalendarObjectPropWrapperName},
|
calendar_object::{CalendarData, CalendarObjectPropName, CalendarObjectPropWrapperName},
|
||||||
};
|
};
|
||||||
|
use rustical_dav::xml::{
|
||||||
|
MatchType, NegateCondition, PropElement, TextCollation, TextMatchElement,
|
||||||
|
};
|
||||||
|
use rustical_xml::XmlDocument;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn calendar_query_7_8_7() {
|
fn calendar_query_7_8_7() {
|
||||||
@@ -90,16 +97,20 @@ mod tests {
|
|||||||
prop_filter: vec![PropFilterElement {
|
prop_filter: vec![PropFilterElement {
|
||||||
name: "ATTENDEE".to_owned(),
|
name: "ATTENDEE".to_owned(),
|
||||||
text_match: Some(TextMatchElement {
|
text_match: Some(TextMatchElement {
|
||||||
collation: "i;ascii-casemap".to_owned(),
|
match_type: MatchType::Contains,
|
||||||
negate_condition: None
|
collation: TextCollation::AsciiCasemap,
|
||||||
|
negate_condition: NegateCondition(false),
|
||||||
|
needle: "mailto:lisa@example.com".to_string()
|
||||||
}),
|
}),
|
||||||
is_not_defined: None,
|
is_not_defined: None,
|
||||||
param_filter: vec![ParamFilterElement {
|
param_filter: vec![ParamFilterElement {
|
||||||
is_not_defined: None,
|
is_not_defined: None,
|
||||||
name: "PARTSTAT".to_owned(),
|
name: "PARTSTAT".to_owned(),
|
||||||
text_match: Some(TextMatchElement {
|
text_match: Some(TextMatchElement {
|
||||||
collation: "i;ascii-casemap".to_owned(),
|
match_type: MatchType::Contains,
|
||||||
negate_condition: None
|
collation: TextCollation::AsciiCasemap,
|
||||||
|
negate_condition: NegateCondition(false),
|
||||||
|
needle: "NEEDS-ACTION".to_string()
|
||||||
}),
|
}),
|
||||||
}],
|
}],
|
||||||
time_range: None
|
time_range: None
|
||||||
|
|||||||
@@ -0,0 +1,131 @@
|
|||||||
|
use super::{ParamFilterElement, TimeRangeElement};
|
||||||
|
use ical::{
|
||||||
|
generator::{IcalCalendar, IcalEvent},
|
||||||
|
parser::{
|
||||||
|
Component,
|
||||||
|
ical::component::{IcalJournal, IcalTimeZone, IcalTodo},
|
||||||
|
},
|
||||||
|
property::Property,
|
||||||
|
};
|
||||||
|
use rustical_dav::xml::TextMatchElement;
|
||||||
|
use rustical_ical::{CalDateTime, CalendarObject, CalendarObjectComponent, UtcDateTime};
|
||||||
|
use rustical_xml::XmlDeserialize;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
// https://www.rfc-editor.org/rfc/rfc4791#section-9.7.2
|
||||||
|
pub struct PropFilterElement {
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
|
pub(crate) is_not_defined: Option<()>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
|
pub(crate) time_range: Option<TimeRangeElement>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
|
pub(crate) text_match: Option<TextMatchElement>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
|
||||||
|
pub(crate) param_filter: Vec<ParamFilterElement>,
|
||||||
|
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_property(&self, property: &Property) -> bool {
|
||||||
|
if let Some(TimeRangeElement { start, end }) = &self.time_range {
|
||||||
|
// TODO: Respect timezones
|
||||||
|
let Ok(timestamp) = CalDateTime::parse_prop(property, &HashMap::default()) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
let timestamp = timestamp.utc();
|
||||||
|
if let Some(UtcDateTime(start)) = start
|
||||||
|
&& start > ×tamp
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if let Some(UtcDateTime(end)) = end
|
||||||
|
&& end < ×tamp
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(text_match) = &self.text_match
|
||||||
|
&& !text_match.match_property(property)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !self
|
||||||
|
.param_filter
|
||||||
|
.iter()
|
||||||
|
.all(|param_filter| param_filter.match_property(property))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn match_component(&self, comp: &impl PropFilterable) -> bool {
|
||||||
|
let properties = comp.get_named_properties(&self.name);
|
||||||
|
if self.is_not_defined.is_some() {
|
||||||
|
return properties.is_empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The filter matches when one property instance matches
|
||||||
|
// Example where this matters: We have multiple attendees and want to match one
|
||||||
|
properties.iter().any(|prop| self.match_property(prop))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait PropFilterable {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for CalendarObject {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property> {
|
||||||
|
Self::get_named_properties(self, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for IcalEvent {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property> {
|
||||||
|
Component::get_named_properties(self, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for IcalTodo {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property> {
|
||||||
|
Component::get_named_properties(self, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for IcalJournal {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property> {
|
||||||
|
Component::get_named_properties(self, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for IcalCalendar {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property> {
|
||||||
|
Component::get_named_properties(self, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for IcalTimeZone {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property> {
|
||||||
|
Component::get_named_properties(self, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for CalendarObjectComponent {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property> {
|
||||||
|
match self {
|
||||||
|
Self::Event(event, _) => PropFilterable::get_named_properties(&event.event, name),
|
||||||
|
Self::Todo(todo, _) => PropFilterable::get_named_properties(todo, name),
|
||||||
|
Self::Journal(journal, _) => PropFilterable::get_named_properties(journal, name),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
use super::FilterElement;
|
||||||
|
use rstest::rstest;
|
||||||
|
use rustical_ical::CalendarObject;
|
||||||
|
use rustical_xml::XmlDocument;
|
||||||
|
|
||||||
|
const ICS_1: &str = r"BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Example Corp.//CalDAV Client//EN
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
LAST-MODIFIED:20040110T032845Z
|
||||||
|
TZID:US/Eastern
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
DTSTART:20000404T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
|
||||||
|
TZNAME:EDT
|
||||||
|
TZOFFSETFROM:-0500
|
||||||
|
TZOFFSETTO:-0400
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
DTSTART:20001026T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
|
||||||
|
TZNAME:EST
|
||||||
|
TZOFFSETFROM:-0400
|
||||||
|
TZOFFSETTO:-0500
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
BEGIN:VEVENT
|
||||||
|
ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:cyrus@example.com
|
||||||
|
ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
|
||||||
|
DTSTAMP:20060206T001220Z
|
||||||
|
DTSTART;TZID=US/Eastern:20060104T100000
|
||||||
|
DURATION:PT1H
|
||||||
|
LAST-MODIFIED:20060206T001330Z
|
||||||
|
ORGANIZER:mailto:cyrus@example.com
|
||||||
|
SEQUENCE:1
|
||||||
|
STATUS:TENTATIVE
|
||||||
|
SUMMARY:Event #3
|
||||||
|
UID:DC6C50A017428C5216A2F1CD@example.com
|
||||||
|
X-ABC-GUID:E1CX5Dr-0007ym-Hz@example.com
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
||||||
|
";
|
||||||
|
|
||||||
|
const FILTER_1: &str = r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:filter xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<C:comp-filter name="VCALENDAR">
|
||||||
|
<C:comp-filter name="VEVENT">
|
||||||
|
<C:prop-filter name="ATTENDEE">
|
||||||
|
<C:text-match collation="i;ascii-casemap">mailto:lisa@example.com</C:text-match>
|
||||||
|
<C:param-filter name="PARTSTAT">
|
||||||
|
<C:text-match collation="i;ascii-casemap">NEEDS-ACTION</C:text-match>
|
||||||
|
</C:param-filter>
|
||||||
|
</C:prop-filter>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:filter>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const FILTER_2: &str = r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:filter xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<C:comp-filter name="VCALENDAR">
|
||||||
|
<C:comp-filter name="VEVENT">
|
||||||
|
<C:prop-filter name="ATTENDEE">
|
||||||
|
<C:text-match collation="i;ascii-casemap">mailto:lisa@example.com</C:text-match>
|
||||||
|
<C:param-filter name="PARTSTAT">
|
||||||
|
<C:text-match collation="i;ascii-casemap">ACCEPTED</C:text-match>
|
||||||
|
</C:param-filter>
|
||||||
|
</C:prop-filter>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:filter>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
#[case(ICS_1, FILTER_1, true)]
|
||||||
|
#[case(ICS_1, FILTER_2, false)]
|
||||||
|
fn yeet(#[case] ics: &str, #[case] filter: &str, #[case] matches: bool) {
|
||||||
|
let obj = CalendarObject::from_ics(ics.to_owned(), None).unwrap();
|
||||||
|
let filter = FilterElement::parse_str(filter).unwrap();
|
||||||
|
assert_eq!(matches, filter.matches(&obj));
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ use sync_collection::handle_sync_collection;
|
|||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
mod calendar_multiget;
|
mod calendar_multiget;
|
||||||
mod calendar_query;
|
pub mod calendar_query;
|
||||||
mod sync_collection;
|
mod sync_collection;
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlDocument, Clone, Debug, PartialEq)]
|
#[derive(XmlDeserialize, XmlDocument, Clone, Debug, PartialEq)]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{From, Into};
|
||||||
|
use rustical_dav::xml::TextCollation;
|
||||||
use rustical_ical::CalendarObjectType;
|
use rustical_ical::CalendarObjectType;
|
||||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||||
use strum_macros::VariantArray;
|
use strum_macros::VariantArray;
|
||||||
@@ -36,6 +37,29 @@ impl From<SupportedCalendarComponentSet> for Vec<CalendarObjectType> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
|
||||||
|
pub struct SupportedCollation(#[xml(ty = "text")] pub TextCollation);
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq)]
|
||||||
|
pub struct SupportedCollationSet(
|
||||||
|
#[xml(
|
||||||
|
ns = "rustical_dav::namespace::NS_CALDAV",
|
||||||
|
flatten,
|
||||||
|
rename = "supported-collation"
|
||||||
|
)]
|
||||||
|
pub Vec<SupportedCollation>,
|
||||||
|
);
|
||||||
|
|
||||||
|
impl Default for SupportedCollationSet {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self(vec![
|
||||||
|
SupportedCollation(TextCollation::AsciiCasemap),
|
||||||
|
SupportedCollation(TextCollation::UnicodeCasemap),
|
||||||
|
SupportedCollation(TextCollation::Octet),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
|
||||||
pub struct CalendarData {
|
pub struct CalendarData {
|
||||||
#[xml(ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use super::prop::{SupportedCalendarComponentSet, SupportedCalendarData};
|
use super::prop::{SupportedCalendarComponentSet, SupportedCalendarData};
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use crate::calendar::prop::ReportMethod;
|
use crate::calendar::prop::{ReportMethod, SupportedCollationSet};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{From, Into};
|
||||||
use ical::IcalParser;
|
use ical::IcalParser;
|
||||||
@@ -17,6 +17,7 @@ use rustical_store::auth::Principal;
|
|||||||
use rustical_xml::{EnumVariants, PropName};
|
use rustical_xml::{EnumVariants, PropName};
|
||||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
||||||
#[xml(unit_variants_ident = "CalendarPropName")]
|
#[xml(unit_variants_ident = "CalendarPropName")]
|
||||||
@@ -39,6 +40,8 @@ pub enum CalendarProp {
|
|||||||
SupportedCalendarComponentSet(SupportedCalendarComponentSet),
|
SupportedCalendarComponentSet(SupportedCalendarComponentSet),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
||||||
SupportedCalendarData(SupportedCalendarData),
|
SupportedCalendarData(SupportedCalendarData),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
||||||
|
SupportedCollationSet(SupportedCollationSet),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
MaxResourceSize(i64),
|
MaxResourceSize(i64),
|
||||||
#[xml(skip_deserializing)]
|
#[xml(skip_deserializing)]
|
||||||
@@ -70,8 +73,8 @@ pub struct CalendarResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for CalendarResource {
|
impl ResourceName for CalendarResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
self.cal.id.clone()
|
Cow::from(&self.cal.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +159,9 @@ impl Resource for CalendarResource {
|
|||||||
CalendarPropName::SupportedCalendarData => {
|
CalendarPropName::SupportedCalendarData => {
|
||||||
CalendarProp::SupportedCalendarData(SupportedCalendarData::default())
|
CalendarProp::SupportedCalendarData(SupportedCalendarData::default())
|
||||||
}
|
}
|
||||||
|
CalendarPropName::SupportedCollationSet => {
|
||||||
|
CalendarProp::SupportedCollationSet(SupportedCollationSet::default())
|
||||||
|
}
|
||||||
CalendarPropName::MaxResourceSize => CalendarProp::MaxResourceSize(10_000_000),
|
CalendarPropName::MaxResourceSize => CalendarProp::MaxResourceSize(10_000_000),
|
||||||
CalendarPropName::SupportedReportSet => {
|
CalendarPropName::SupportedReportSet => {
|
||||||
CalendarProp::SupportedReportSet(SupportedReportSet::all())
|
CalendarProp::SupportedReportSet(SupportedReportSet::all())
|
||||||
@@ -183,9 +189,6 @@ impl Resource for CalendarResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_prop(&mut self, prop: Self::Prop) -> Result<(), rustical_dav::Error> {
|
fn set_prop(&mut self, prop: Self::Prop) -> Result<(), rustical_dav::Error> {
|
||||||
if self.read_only {
|
|
||||||
return Err(rustical_dav::Error::PropReadOnly);
|
|
||||||
}
|
|
||||||
match prop {
|
match prop {
|
||||||
CalendarPropWrapper::Calendar(prop) => match prop {
|
CalendarPropWrapper::Calendar(prop) => match prop {
|
||||||
CalendarProp::CalendarColor(color) => {
|
CalendarProp::CalendarColor(color) => {
|
||||||
@@ -244,6 +247,7 @@ impl Resource for CalendarResource {
|
|||||||
}
|
}
|
||||||
CalendarProp::TimezoneServiceSet(_)
|
CalendarProp::TimezoneServiceSet(_)
|
||||||
| CalendarProp::SupportedCalendarData(_)
|
| CalendarProp::SupportedCalendarData(_)
|
||||||
|
| CalendarProp::SupportedCollationSet(_)
|
||||||
| CalendarProp::MaxResourceSize(_)
|
| CalendarProp::MaxResourceSize(_)
|
||||||
| CalendarProp::SupportedReportSet(_)
|
| CalendarProp::SupportedReportSet(_)
|
||||||
| CalendarProp::Source(_)
|
| CalendarProp::Source(_)
|
||||||
@@ -257,9 +261,6 @@ impl Resource for CalendarResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn remove_prop(&mut self, prop: &CalendarPropWrapperName) -> Result<(), rustical_dav::Error> {
|
fn remove_prop(&mut self, prop: &CalendarPropWrapperName) -> Result<(), rustical_dav::Error> {
|
||||||
if self.read_only {
|
|
||||||
return Err(rustical_dav::Error::PropReadOnly);
|
|
||||||
}
|
|
||||||
match prop {
|
match prop {
|
||||||
CalendarPropWrapperName::Calendar(prop) => match prop {
|
CalendarPropWrapperName::Calendar(prop) => match prop {
|
||||||
CalendarPropName::CalendarColor => {
|
CalendarPropName::CalendarColor => {
|
||||||
@@ -283,6 +284,7 @@ impl Resource for CalendarResource {
|
|||||||
}
|
}
|
||||||
CalendarPropName::TimezoneServiceSet
|
CalendarPropName::TimezoneServiceSet
|
||||||
| CalendarPropName::SupportedCalendarData
|
| CalendarPropName::SupportedCalendarData
|
||||||
|
| CalendarPropName::SupportedCollationSet
|
||||||
| CalendarPropName::MaxResourceSize
|
| CalendarPropName::MaxResourceSize
|
||||||
| CalendarPropName::SupportedReportSet
|
| CalendarPropName::SupportedReportSet
|
||||||
| CalendarPropName::Source
|
| CalendarPropName::Source
|
||||||
@@ -310,16 +312,11 @@ impl Resource for CalendarResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_user_privileges(&self, user: &Principal) -> Result<UserPrivilegeSet, Self::Error> {
|
fn get_user_privileges(&self, user: &Principal) -> Result<UserPrivilegeSet, Self::Error> {
|
||||||
if self.cal.subscription_url.is_some() {
|
if self.cal.subscription_url.is_some() || self.read_only {
|
||||||
return Ok(UserPrivilegeSet::owner_write_properties(
|
return Ok(UserPrivilegeSet::owner_write_properties(
|
||||||
user.is_principal(&self.cal.principal),
|
user.is_principal(&self.cal.principal),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if self.read_only {
|
|
||||||
return Ok(UserPrivilegeSet::owner_read(
|
|
||||||
user.is_principal(&self.cal.principal),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(UserPrivilegeSet::owner_only(
|
Ok(UserPrivilegeSet::owner_only(
|
||||||
user.is_principal(&self.cal.principal),
|
user.is_principal(&self.cal.principal),
|
||||||
|
|||||||
@@ -0,0 +1,200 @@
|
|||||||
|
---
|
||||||
|
source: crates/caldav/src/calendar/tests.rs
|
||||||
|
expression: output
|
||||||
|
---
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<response xmlns="DAV:">
|
||||||
|
<href>/caldav/principal/user/calendar/</href>
|
||||||
|
<propstat>
|
||||||
|
<prop xmlns="DAV:">
|
||||||
|
<calendar-timezone xmlns="urn:ietf:params:xml:ns:caldav">BEGIN:VCALENDAR
|
||||||
|
PRODID:-//github.com/lennart-k/vzic-rs//RustiCal Calendar server//EN
|
||||||
|
VERSION:2.0
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Europe/Berlin
|
||||||
|
LAST-MODIFIED:20250723T190331Z
|
||||||
|
X-LIC-LOCATION:Europe/Berlin
|
||||||
|
X-PROLEPTIC-TZNAME:LMT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+005328
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:18930401T000000
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19160430T230000
|
||||||
|
RDATE:19400401T020000
|
||||||
|
RDATE:19430329T020000
|
||||||
|
RDATE:19460414T020000
|
||||||
|
RDATE:19470406T030000
|
||||||
|
RDATE:19480418T020000
|
||||||
|
RDATE:19490410T020000
|
||||||
|
RDATE:19800406T020000
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19161001T010000
|
||||||
|
RDATE:19421102T030000
|
||||||
|
RDATE:19431004T030000
|
||||||
|
RDATE:19441002T030000
|
||||||
|
RDATE:19451118T030000
|
||||||
|
RDATE:19461007T030000
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19170416T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=3MO;UNTIL=19180415T010000Z
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19170917T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=3MO;UNTIL=19180916T010000Z
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19440403T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1MO;UNTIL=19450402T010000Z
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEMT
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0300
|
||||||
|
DTSTART:19450524T020000
|
||||||
|
RDATE:19470511T030000
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0300
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19450924T030000
|
||||||
|
RDATE:19470629T030000
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19460101T000000
|
||||||
|
RDATE:19800101T000000
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19471005T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=1SU;UNTIL=19491002T010000Z
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19800928T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=-1SU;UNTIL=19950924T010000Z
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZNAME:CEST
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
DTSTART:19810329T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZNAME:CET
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
DTSTART:19961027T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
END:VCALENDAR
|
||||||
|
</calendar-timezone>
|
||||||
|
<timezone-service-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<href xmlns="DAV:">https://www.iana.org/time-zones</href>
|
||||||
|
</timezone-service-set>
|
||||||
|
<calendar-timezone-id xmlns="urn:ietf:params:xml:ns:caldav">Europe/Berlin</calendar-timezone-id>
|
||||||
|
<calendar-order xmlns="http://apple.com/ns/ical/">0</calendar-order>
|
||||||
|
<supported-calendar-component-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<comp xmlns="urn:ietf:params:xml:ns:caldav" name="VEVENT"/>
|
||||||
|
<comp xmlns="urn:ietf:params:xml:ns:caldav" name="VTODO"/>
|
||||||
|
</supported-calendar-component-set>
|
||||||
|
<supported-calendar-data xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<calendar-data xmlns="urn:ietf:params:xml:ns:caldav" content-type="text/calendar" version="2.0"/>
|
||||||
|
</supported-calendar-data>
|
||||||
|
<supported-collation-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<supported-collation xmlns="urn:ietf:params:xml:ns:caldav">i;ascii-casemap</supported-collation>
|
||||||
|
<supported-collation xmlns="urn:ietf:params:xml:ns:caldav">i;unicode-casemap</supported-collation>
|
||||||
|
<supported-collation xmlns="urn:ietf:params:xml:ns:caldav">i;octet</supported-collation>
|
||||||
|
</supported-collation-set>
|
||||||
|
<max-resource-size xmlns="DAV:">10000000</max-resource-size>
|
||||||
|
<supported-report-set xmlns="DAV:">
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<calendar-query xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
</report>
|
||||||
|
</supported-report>
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<calendar-multiget xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
</report>
|
||||||
|
</supported-report>
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<sync-collection xmlns="DAV:"/>
|
||||||
|
</report>
|
||||||
|
</supported-report>
|
||||||
|
</supported-report-set>
|
||||||
|
<min-date-time xmlns="urn:ietf:params:xml:ns:caldav">-2621430101T000000Z</min-date-time>
|
||||||
|
<max-date-time xmlns="urn:ietf:params:xml:ns:caldav">+2621421231T235959Z</max-date-time>
|
||||||
|
<sync-token xmlns="DAV:">github.com/lennart-k/rustical/ns/12</sync-token>
|
||||||
|
<getctag xmlns="http://calendarserver.org/ns/">github.com/lennart-k/rustical/ns/12</getctag>
|
||||||
|
<transports xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<web-push xmlns="https://bitfire.at/webdav-push"/>
|
||||||
|
</transports>
|
||||||
|
<topic xmlns="https://bitfire.at/webdav-push">b28b41e9-8801-4fc5-ae29-8efb5fadeb36</topic>
|
||||||
|
<supported-triggers xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<content-update xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<depth xmlns="DAV:">1</depth>
|
||||||
|
</content-update>
|
||||||
|
<property-update xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<depth xmlns="DAV:">1</depth>
|
||||||
|
</property-update>
|
||||||
|
</supported-triggers>
|
||||||
|
<resourcetype xmlns="DAV:">
|
||||||
|
<collection xmlns="DAV:"/>
|
||||||
|
<calendar xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
</resourcetype>
|
||||||
|
<displayname xmlns="DAV:">Calendar</displayname>
|
||||||
|
<current-user-principal xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
|
</current-user-principal>
|
||||||
|
<current-user-privilege-set xmlns="DAV:">
|
||||||
|
<privilege>
|
||||||
|
<read/>
|
||||||
|
</privilege>
|
||||||
|
<privilege>
|
||||||
|
<write-properties/>
|
||||||
|
</privilege>
|
||||||
|
<privilege>
|
||||||
|
<read-acl/>
|
||||||
|
</privilege>
|
||||||
|
<privilege>
|
||||||
|
<read-current-user-privilege-set/>
|
||||||
|
</privilege>
|
||||||
|
</current-user-privilege-set>
|
||||||
|
<owner xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
|
</owner>
|
||||||
|
</prop>
|
||||||
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
|
</propstat>
|
||||||
|
</response>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
source: crates/caldav/src/calendar/tests.rs
|
||||||
|
expression: output
|
||||||
|
---
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<response xmlns="DAV:">
|
||||||
|
<href>/caldav/principal/user/calendar/</href>
|
||||||
|
<propstat>
|
||||||
|
<prop xmlns="DAV:">
|
||||||
|
<calendar-color xmlns="http://apple.com/ns/ical/"/>
|
||||||
|
<calendar-description xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<calendar-timezone xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<timezone-service-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<calendar-timezone-id xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<calendar-order xmlns="http://apple.com/ns/ical/"/>
|
||||||
|
<supported-calendar-component-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<supported-calendar-data xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<supported-collation-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<max-resource-size xmlns="DAV:"/>
|
||||||
|
<supported-report-set xmlns="DAV:"/>
|
||||||
|
<source xmlns="http://calendarserver.org/ns/"/>
|
||||||
|
<min-date-time xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<max-date-time xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<sync-token xmlns="DAV:"/>
|
||||||
|
<getctag xmlns="http://calendarserver.org/ns/"/>
|
||||||
|
<transports xmlns="https://bitfire.at/webdav-push"/>
|
||||||
|
<topic xmlns="https://bitfire.at/webdav-push"/>
|
||||||
|
<supported-triggers xmlns="https://bitfire.at/webdav-push"/>
|
||||||
|
<resourcetype xmlns="DAV:"/>
|
||||||
|
<displayname xmlns="DAV:"/>
|
||||||
|
<current-user-principal xmlns="DAV:"/>
|
||||||
|
<current-user-privilege-set xmlns="DAV:"/>
|
||||||
|
<owner xmlns="DAV:"/>
|
||||||
|
</prop>
|
||||||
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
|
</propstat>
|
||||||
|
</response>
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<response xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CARD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/" xmlns:PUSH="https://bitfire.at/webdav-push">
|
|
||||||
<href>/caldav/principal/user/calendar/</href>
|
|
||||||
<propstat>
|
|
||||||
<prop>
|
|
||||||
<calendar-color xmlns="http://apple.com/ns/ical/"/>
|
|
||||||
<calendar-description xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<calendar-timezone xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<timezone-service-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<calendar-timezone-id xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<calendar-order xmlns="http://apple.com/ns/ical/"/>
|
|
||||||
<supported-calendar-component-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<supported-calendar-data xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<max-resource-size xmlns="DAV:"/>
|
|
||||||
<supported-report-set xmlns="DAV:"/>
|
|
||||||
<source xmlns="http://calendarserver.org/ns/"/>
|
|
||||||
<min-date-time xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<max-date-time xmlns="urn:ietf:params:xml:ns:caldav"/>
|
|
||||||
<sync-token xmlns="DAV:"/>
|
|
||||||
<getctag xmlns="http://calendarserver.org/ns/"/>
|
|
||||||
<transports xmlns="https://bitfire.at/webdav-push"/>
|
|
||||||
<topic xmlns="https://bitfire.at/webdav-push"/>
|
|
||||||
<supported-triggers xmlns="https://bitfire.at/webdav-push"/>
|
|
||||||
<resourcetype xmlns="DAV:"/>
|
|
||||||
<displayname xmlns="DAV:"/>
|
|
||||||
<current-user-principal xmlns="DAV:"/>
|
|
||||||
<current-user-privilege-set xmlns="DAV:"/>
|
|
||||||
<owner xmlns="DAV:"/>
|
|
||||||
</prop>
|
|
||||||
<status>HTTP/1.1 200 OK</status>
|
|
||||||
</propstat>
|
|
||||||
</response>
|
|
||||||
|
|
||||||
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<response xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CARD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/" xmlns:PUSH="https://bitfire.at/webdav-push">
|
|
||||||
<href>/caldav/principal/user/calendar/</href>
|
|
||||||
<propstat>
|
|
||||||
<prop>
|
|
||||||
<CAL:calendar-timezone>BEGIN:VCALENDAR
|
|
||||||
PRODID:-//github.com/lennart-k/vzic-rs//RustiCal Calendar server//EN
|
|
||||||
VERSION:2.0
|
|
||||||
BEGIN:VTIMEZONE
|
|
||||||
TZID:Europe/Berlin
|
|
||||||
LAST-MODIFIED:20250723T190331Z
|
|
||||||
X-LIC-LOCATION:Europe/Berlin
|
|
||||||
X-PROLEPTIC-TZNAME:LMT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+005328
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:18930401T000000
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19160430T230000
|
|
||||||
RDATE:19400401T020000
|
|
||||||
RDATE:19430329T020000
|
|
||||||
RDATE:19460414T020000
|
|
||||||
RDATE:19470406T030000
|
|
||||||
RDATE:19480418T020000
|
|
||||||
RDATE:19490410T020000
|
|
||||||
RDATE:19800406T020000
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19161001T010000
|
|
||||||
RDATE:19421102T030000
|
|
||||||
RDATE:19431004T030000
|
|
||||||
RDATE:19441002T030000
|
|
||||||
RDATE:19451118T030000
|
|
||||||
RDATE:19461007T030000
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19170416T020000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=3MO;UNTIL=19180415T010000Z
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19170917T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=3MO;UNTIL=19180916T010000Z
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19440403T020000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1MO;UNTIL=19450402T010000Z
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEMT
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0300
|
|
||||||
DTSTART:19450524T020000
|
|
||||||
RDATE:19470511T030000
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0300
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19450924T030000
|
|
||||||
RDATE:19470629T030000
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19460101T000000
|
|
||||||
RDATE:19800101T000000
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19471005T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=1SU;UNTIL=19491002T010000Z
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19800928T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=-1SU;UNTIL=19950924T010000Z
|
|
||||||
END:STANDARD
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZNAME:CEST
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
DTSTART:19810329T020000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZNAME:CET
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
DTSTART:19961027T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
|
||||||
END:STANDARD
|
|
||||||
END:VTIMEZONE
|
|
||||||
END:VCALENDAR
|
|
||||||
</CAL:calendar-timezone>
|
|
||||||
<CAL:timezone-service-set>
|
|
||||||
<href>https://www.iana.org/time-zones</href>
|
|
||||||
</CAL:timezone-service-set>
|
|
||||||
<CAL:calendar-timezone-id>Europe/Berlin</CAL:calendar-timezone-id>
|
|
||||||
<calendar-order xmlns="http://apple.com/ns/ical/">0</calendar-order>
|
|
||||||
<CAL:supported-calendar-component-set>
|
|
||||||
<CAL:comp name="VEVENT"/>
|
|
||||||
<CAL:comp name="VTODO"/>
|
|
||||||
</CAL:supported-calendar-component-set>
|
|
||||||
<CAL:supported-calendar-data>
|
|
||||||
<CAL:calendar-data content-type="text/calendar" version="2.0"/>
|
|
||||||
</CAL:supported-calendar-data>
|
|
||||||
<max-resource-size>10000000</max-resource-size>
|
|
||||||
<supported-report-set>
|
|
||||||
<supported-report>
|
|
||||||
<report>
|
|
||||||
<CAL:calendar-query/>
|
|
||||||
</report>
|
|
||||||
</supported-report>
|
|
||||||
<supported-report>
|
|
||||||
<report>
|
|
||||||
<CAL:calendar-multiget/>
|
|
||||||
</report>
|
|
||||||
</supported-report>
|
|
||||||
<supported-report>
|
|
||||||
<report>
|
|
||||||
<sync-collection/>
|
|
||||||
</report>
|
|
||||||
</supported-report>
|
|
||||||
</supported-report-set>
|
|
||||||
<CAL:min-date-time>-2621430101T000000Z</CAL:min-date-time>
|
|
||||||
<CAL:max-date-time>+2621421231T235959Z</CAL:max-date-time>
|
|
||||||
<sync-token>github.com/lennart-k/rustical/ns/12</sync-token>
|
|
||||||
<CS:getctag>github.com/lennart-k/rustical/ns/12</CS:getctag>
|
|
||||||
<PUSH:transports>
|
|
||||||
<PUSH:web-push/>
|
|
||||||
</PUSH:transports>
|
|
||||||
<PUSH:topic>b28b41e9-8801-4fc5-ae29-8efb5fadeb36</PUSH:topic>
|
|
||||||
<PUSH:supported-triggers>
|
|
||||||
<PUSH:content-update>
|
|
||||||
<depth>1</depth>
|
|
||||||
</PUSH:content-update>
|
|
||||||
<PUSH:property-update>
|
|
||||||
<depth>1</depth>
|
|
||||||
</PUSH:property-update>
|
|
||||||
</PUSH:supported-triggers>
|
|
||||||
<resourcetype>
|
|
||||||
<collection/>
|
|
||||||
<CAL:calendar/>
|
|
||||||
</resourcetype>
|
|
||||||
<displayname>Calendar</displayname>
|
|
||||||
<current-user-principal>
|
|
||||||
<href>/caldav/principal/user/</href>
|
|
||||||
</current-user-principal>
|
|
||||||
<current-user-privilege-set>
|
|
||||||
<privilege>
|
|
||||||
<read/>
|
|
||||||
</privilege>
|
|
||||||
<privilege>
|
|
||||||
<read-acl/>
|
|
||||||
</privilege>
|
|
||||||
<privilege>
|
|
||||||
<read-current-user-privilege-set/>
|
|
||||||
</privilege>
|
|
||||||
</current-user-privilege-set>
|
|
||||||
<owner>
|
|
||||||
<href>/caldav/principal/user/</href>
|
|
||||||
</owner>
|
|
||||||
</prop>
|
|
||||||
<status>HTTP/1.1 200 OK</status>
|
|
||||||
</propstat>
|
|
||||||
</response>
|
|
||||||
@@ -14,14 +14,9 @@ async fn test_propfind() {
|
|||||||
from_str(include_str!("./test_files/propfind.principals.json")).unwrap();
|
from_str(include_str!("./test_files/propfind.principals.json")).unwrap();
|
||||||
let resources: Vec<CalendarResource> =
|
let resources: Vec<CalendarResource> =
|
||||||
from_str(include_str!("./test_files/propfind.resources.json")).unwrap();
|
from_str(include_str!("./test_files/propfind.resources.json")).unwrap();
|
||||||
let outputs: Vec<_> = include_str!("./test_files/propfind.outputs")
|
|
||||||
.trim()
|
|
||||||
.split("\n\n")
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
for principal in principals {
|
for principal in principals {
|
||||||
for ((request, resource), &expected_output) in requests.iter().zip(&resources).zip(&outputs)
|
for (request, resource) in requests.iter().zip(&resources) {
|
||||||
{
|
|
||||||
let propfind = CalendarResource::parse_propfind(request).unwrap();
|
let propfind = CalendarResource::parse_propfind(request).unwrap();
|
||||||
|
|
||||||
let response = resource
|
let response = resource
|
||||||
@@ -33,15 +28,12 @@ async fn test_propfind() {
|
|||||||
&principal,
|
&principal,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let expected_output = expected_output.trim();
|
|
||||||
let output = response
|
let output = response
|
||||||
.serialize_to_string()
|
.serialize_to_string()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.trim()
|
.trim()
|
||||||
.replace("\r\n", "\n");
|
.replace("\r\n", "\n");
|
||||||
println!("{output}");
|
insta::assert_snapshot!(output);
|
||||||
println!("{}, {} \n\n\n", output.len(), expected_output.len());
|
|
||||||
assert_eq!(output, expected_output);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use rustical_ical::CalendarObject;
|
|||||||
use rustical_store::CalendarStore;
|
use rustical_store::CalendarStore;
|
||||||
use rustical_store::auth::Principal;
|
use rustical_store::auth::Principal;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use tracing::{debug, error, instrument};
|
use tracing::{debug, instrument};
|
||||||
|
|
||||||
#[instrument(skip(cal_store))]
|
#[instrument(skip(cal_store))]
|
||||||
pub async fn get_event<C: CalendarStore>(
|
pub async fn get_event<C: CalendarStore>(
|
||||||
@@ -42,7 +42,7 @@ pub async fn get_event<C: CalendarStore>(
|
|||||||
let mut resp = Response::builder().status(StatusCode::OK);
|
let mut resp = Response::builder().status(StatusCode::OK);
|
||||||
let hdrs = resp.headers_mut().unwrap();
|
let hdrs = resp.headers_mut().unwrap();
|
||||||
hdrs.typed_insert(ETag::from_str(&event.get_etag()).unwrap());
|
hdrs.typed_insert(ETag::from_str(&event.get_etag()).unwrap());
|
||||||
hdrs.typed_insert(ContentType::from_str("text/calendar").unwrap());
|
hdrs.typed_insert(ContentType::from_str("text/calendar; charset=utf-8").unwrap());
|
||||||
if matches!(method, Method::HEAD) {
|
if matches!(method, Method::HEAD) {
|
||||||
Ok(resp.body(Body::empty()).unwrap())
|
Ok(resp.body(Body::empty()).unwrap())
|
||||||
} else {
|
} else {
|
||||||
@@ -78,18 +78,10 @@ pub async fn put_event<C: CalendarStore>(
|
|||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|
||||||
let Ok(object) = CalendarObject::from_ics(body.clone()) else {
|
let Ok(object) = CalendarObject::from_ics(body.clone(), Some(object_id)) else {
|
||||||
debug!("invalid calendar data:\n{body}");
|
debug!("invalid calendar data:\n{body}");
|
||||||
return Err(Error::PreconditionFailed(Precondition::ValidCalendarData));
|
return Err(Error::PreconditionFailed(Precondition::ValidCalendarData));
|
||||||
};
|
};
|
||||||
if object.get_id() != object_id {
|
|
||||||
error!(
|
|
||||||
"Calendar object UID and file name not matching: UID={}, filename={}",
|
|
||||||
object.get_id(),
|
|
||||||
object_id
|
|
||||||
);
|
|
||||||
return Err(Error::PreconditionFailed(Precondition::MatchingUid));
|
|
||||||
}
|
|
||||||
cal_store
|
cal_store
|
||||||
.put_object(principal, calendar_id, object, overwrite)
|
.put_object(principal, calendar_id, object, overwrite)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use super::prop::{
|
use super::prop::{
|
||||||
CalendarData, CalendarObjectProp, CalendarObjectPropName, CalendarObjectPropWrapper,
|
CalendarData, CalendarObjectProp, CalendarObjectPropName, CalendarObjectPropWrapper,
|
||||||
CalendarObjectPropWrapperName,
|
CalendarObjectPropWrapperName,
|
||||||
@@ -20,8 +22,8 @@ pub struct CalendarObjectResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for CalendarObjectResource {
|
impl ResourceName for CalendarObjectResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
format!("{}.ics", self.object.get_id())
|
Cow::from(format!("{}.ics", self.object.get_id()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ pub enum Precondition {
|
|||||||
#[error("valid-calendar-data")]
|
#[error("valid-calendar-data")]
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||||
ValidCalendarData,
|
ValidCalendarData,
|
||||||
#[error("matching-uid")]
|
|
||||||
MatchingUid,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoResponse for Precondition {
|
impl IntoResponse for Precondition {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use rustical_dav::xml::{
|
|||||||
GroupMemberSet, GroupMembership, Resourcetype, ResourcetypeInner, SupportedReportSet,
|
GroupMemberSet, GroupMembership, Resourcetype, ResourcetypeInner, SupportedReportSet,
|
||||||
};
|
};
|
||||||
use rustical_store::auth::Principal;
|
use rustical_store::auth::Principal;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
mod service;
|
mod service;
|
||||||
pub use service::*;
|
pub use service::*;
|
||||||
@@ -23,8 +24,8 @@ pub struct PrincipalResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for PrincipalResource {
|
impl ResourceName for PrincipalResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
self.principal.id.clone()
|
Cow::from(&self.principal.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use rustical_store::auth::PrincipalType;
|
|||||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
||||||
use strum_macros::VariantArray;
|
use strum_macros::VariantArray;
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName, Debug)]
|
||||||
#[xml(unit_variants_ident = "PrincipalPropName")]
|
#[xml(unit_variants_ident = "PrincipalPropName")]
|
||||||
pub enum PrincipalProp {
|
pub enum PrincipalProp {
|
||||||
// Scheduling Extensions to CalDAV (RFC 6638)
|
// Scheduling Extensions to CalDAV (RFC 6638)
|
||||||
@@ -34,17 +34,17 @@ pub enum PrincipalProp {
|
|||||||
CalendarHomeSet(CalendarHomeSet),
|
CalendarHomeSet(CalendarHomeSet),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct CalendarHomeSet(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
pub struct CalendarHomeSet(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName, Debug)]
|
||||||
#[xml(unit_variants_ident = "PrincipalPropWrapperName", untagged)]
|
#[xml(unit_variants_ident = "PrincipalPropWrapperName", untagged)]
|
||||||
pub enum PrincipalPropWrapper {
|
pub enum PrincipalPropWrapper {
|
||||||
Principal(PrincipalProp),
|
Principal(PrincipalProp),
|
||||||
Common(CommonPropertiesProp),
|
Common(CommonPropertiesProp),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlSerialize, PartialEq, Eq, Clone, VariantArray)]
|
#[derive(XmlSerialize, PartialEq, Eq, Debug, Clone, VariantArray)]
|
||||||
pub enum ReportMethod {
|
pub enum ReportMethod {
|
||||||
// We don't actually support principal-match
|
// We don't actually support principal-match
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
|
|||||||
@@ -0,0 +1,136 @@
|
|||||||
|
---
|
||||||
|
source: crates/caldav/src/principal/tests.rs
|
||||||
|
expression: response
|
||||||
|
---
|
||||||
|
ResponseElement {
|
||||||
|
href: "/caldav/principal/user/",
|
||||||
|
status: None,
|
||||||
|
propstat: [
|
||||||
|
Normal(
|
||||||
|
PropstatElement {
|
||||||
|
prop: PropTagWrapper(
|
||||||
|
[
|
||||||
|
Principal(
|
||||||
|
CalendarUserType(
|
||||||
|
Individual,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
CalendarUserAddressSet(
|
||||||
|
HrefElement {
|
||||||
|
href: "/caldav/principal/user/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
PrincipalUrl(
|
||||||
|
HrefElement {
|
||||||
|
href: "/caldav/principal/user/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
GroupMembership(
|
||||||
|
GroupMembership(
|
||||||
|
[
|
||||||
|
HrefElement {
|
||||||
|
href: "/caldav/principal/group/",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
GroupMemberSet(
|
||||||
|
GroupMemberSet(
|
||||||
|
[],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
AlternateUriSet,
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
SupportedReportSet(
|
||||||
|
SupportedReportSet {
|
||||||
|
supported_report: [
|
||||||
|
ReportWrapper {
|
||||||
|
report: PrincipalMatch,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
CalendarHomeSet(
|
||||||
|
CalendarHomeSet(
|
||||||
|
[
|
||||||
|
HrefElement {
|
||||||
|
href: "/caldav/principal/group/",
|
||||||
|
},
|
||||||
|
HrefElement {
|
||||||
|
href: "/caldav/principal/user/",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
Resourcetype(
|
||||||
|
Resourcetype(
|
||||||
|
[
|
||||||
|
ResourcetypeInner(
|
||||||
|
Some(
|
||||||
|
Namespace("DAV:"),
|
||||||
|
),
|
||||||
|
"collection",
|
||||||
|
),
|
||||||
|
ResourcetypeInner(
|
||||||
|
Some(
|
||||||
|
Namespace("DAV:"),
|
||||||
|
),
|
||||||
|
"principal",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
Displayname(
|
||||||
|
Some(
|
||||||
|
"user",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
CurrentUserPrincipal(
|
||||||
|
HrefElement {
|
||||||
|
href: "/caldav/principal/user/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
CurrentUserPrivilegeSet(
|
||||||
|
UserPrivilegeSet {
|
||||||
|
privileges: {
|
||||||
|
All,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
Owner(
|
||||||
|
Some(
|
||||||
|
HrefElement {
|
||||||
|
href: "/caldav/principal/user/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
status: 200,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
---
|
||||||
|
source: crates/caldav/src/principal/tests.rs
|
||||||
|
expression: response.serialize_to_string().unwrap()
|
||||||
|
---
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<response xmlns="DAV:">
|
||||||
|
<href>/caldav/principal/user/</href>
|
||||||
|
<propstat>
|
||||||
|
<prop xmlns="DAV:">
|
||||||
|
<calendar-user-type xmlns="urn:ietf:params:xml:ns:caldav">INDIVIDUAL</calendar-user-type>
|
||||||
|
<calendar-user-address-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
|
</calendar-user-address-set>
|
||||||
|
<principal-URL xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
|
</principal-URL>
|
||||||
|
<group-membership xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/group/</href>
|
||||||
|
</group-membership>
|
||||||
|
<group-member-set xmlns="DAV:">
|
||||||
|
</group-member-set>
|
||||||
|
<alternate-URI-set xmlns="DAV:"/>
|
||||||
|
<supported-report-set xmlns="DAV:">
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<principal-match xmlns="DAV:"/>
|
||||||
|
</report>
|
||||||
|
</supported-report>
|
||||||
|
</supported-report-set>
|
||||||
|
<calendar-home-set xmlns="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/group/</href>
|
||||||
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
|
</calendar-home-set>
|
||||||
|
<resourcetype xmlns="DAV:">
|
||||||
|
<collection xmlns="DAV:"/>
|
||||||
|
<principal xmlns="DAV:"/>
|
||||||
|
</resourcetype>
|
||||||
|
<displayname xmlns="DAV:">user</displayname>
|
||||||
|
<current-user-principal xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
|
</current-user-principal>
|
||||||
|
<current-user-privilege-set xmlns="DAV:">
|
||||||
|
<privilege>
|
||||||
|
<all/>
|
||||||
|
</privilege>
|
||||||
|
</current-user-privilege-set>
|
||||||
|
<owner xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/caldav/principal/user/</href>
|
||||||
|
</owner>
|
||||||
|
</prop>
|
||||||
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
|
</propstat>
|
||||||
|
</response>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
source: crates/caldav/src/principal/tests.rs
|
||||||
|
expression: propfind
|
||||||
|
---
|
||||||
|
PropfindElement {
|
||||||
|
prop: Allprop,
|
||||||
|
include: None,
|
||||||
|
}
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
CalDavPrincipalUri,
|
CalDavPrincipalUri,
|
||||||
principal::{PrincipalResource, PrincipalResourceService},
|
principal::{PrincipalResource, PrincipalResourceService},
|
||||||
@@ -7,31 +5,27 @@ use crate::{
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use rustical_dav::resource::{Resource, ResourceService};
|
use rustical_dav::resource::{Resource, ResourceService};
|
||||||
use rustical_store::auth::{Principal, PrincipalType::Individual};
|
use rustical_store::auth::{Principal, PrincipalType::Individual};
|
||||||
use rustical_store_sqlite::{
|
use rustical_store_sqlite::tests::{TestStoreContext, test_store_context};
|
||||||
SqliteStore,
|
|
||||||
calendar_store::SqliteCalendarStore,
|
|
||||||
principal_store::SqlitePrincipalStore,
|
|
||||||
tests::{get_test_calendar_store, get_test_principal_store, get_test_subscription_store},
|
|
||||||
};
|
|
||||||
use rustical_xml::XmlSerializeRoot;
|
use rustical_xml::XmlSerializeRoot;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_principal_resource(
|
async fn test_principal_resource(
|
||||||
#[from(get_test_calendar_store)]
|
|
||||||
#[future]
|
#[future]
|
||||||
cal_store: SqliteCalendarStore,
|
#[from(test_store_context)]
|
||||||
#[from(get_test_principal_store)]
|
context: TestStoreContext,
|
||||||
#[future]
|
|
||||||
auth_provider: SqlitePrincipalStore,
|
|
||||||
#[from(get_test_subscription_store)]
|
|
||||||
#[future]
|
|
||||||
sub_store: SqliteStore,
|
|
||||||
) {
|
) {
|
||||||
|
let TestStoreContext {
|
||||||
|
cal_store,
|
||||||
|
sub_store,
|
||||||
|
principal_store: auth_provider,
|
||||||
|
..
|
||||||
|
} = context.await;
|
||||||
let service = PrincipalResourceService {
|
let service = PrincipalResourceService {
|
||||||
cal_store: Arc::new(cal_store.await),
|
cal_store: Arc::new(cal_store),
|
||||||
sub_store: Arc::new(sub_store.await),
|
sub_store: Arc::new(sub_store),
|
||||||
auth_provider: Arc::new(auth_provider.await),
|
auth_provider: Arc::new(auth_provider),
|
||||||
simplified_home_set: false,
|
simplified_home_set: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,6 +58,8 @@ async fn test_propfind() {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
insta::assert_debug_snapshot!(propfind);
|
||||||
|
|
||||||
let principal = Principal {
|
let principal = Principal {
|
||||||
id: "user".to_string(),
|
id: "user".to_string(),
|
||||||
displayname: None,
|
displayname: None,
|
||||||
@@ -88,5 +84,6 @@ async fn test_propfind() {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _output = response.serialize_to_string().unwrap();
|
insta::assert_debug_snapshot!(response);
|
||||||
|
insta::assert_snapshot!(response.serialize_to_string().unwrap());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rustical_carddav"
|
name = "rustical_carddav"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
@@ -11,19 +12,19 @@ publish = false
|
|||||||
axum.workspace = true
|
axum.workspace = true
|
||||||
axum-extra.workspace = true
|
axum-extra.workspace = true
|
||||||
tower.workspace = true
|
tower.workspace = true
|
||||||
async-trait = { workspace = true }
|
async-trait.workspace = true
|
||||||
thiserror = { workspace = true }
|
thiserror.workspace = true
|
||||||
quick-xml = { workspace = true }
|
quick-xml.workspace = true
|
||||||
tracing = { workspace = true }
|
tracing.workspace = true
|
||||||
futures-util = { workspace = true }
|
futures-util.workspace = true
|
||||||
derive_more = { workspace = true }
|
derive_more.workspace = true
|
||||||
base64 = { workspace = true }
|
base64.workspace = true
|
||||||
serde = { workspace = true }
|
serde.workspace = true
|
||||||
tokio = { workspace = true }
|
tokio.workspace = true
|
||||||
url = { workspace = true }
|
url.workspace = true
|
||||||
rustical_dav = { workspace = true }
|
rustical_dav = { workspace = true, features = ["ical"] }
|
||||||
rustical_store = { workspace = true }
|
rustical_store.workspace = true
|
||||||
chrono = { workspace = true }
|
chrono.workspace = true
|
||||||
rustical_xml.workspace = true
|
rustical_xml.workspace = true
|
||||||
uuid.workspace = true
|
uuid.workspace = true
|
||||||
rustical_dav_push.workspace = true
|
rustical_dav_push.workspace = true
|
||||||
@@ -34,3 +35,7 @@ percent-encoding.workspace = true
|
|||||||
ical.workspace = true
|
ical.workspace = true
|
||||||
strum.workspace = true
|
strum.workspace = true
|
||||||
strum_macros.workspace = true
|
strum_macros.workspace = true
|
||||||
|
rstest.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
insta.workspace = true
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ pub async fn get_object<AS: AddressbookStore>(
|
|||||||
let mut resp = Response::builder().status(StatusCode::OK);
|
let mut resp = Response::builder().status(StatusCode::OK);
|
||||||
let hdrs = resp.headers_mut().unwrap();
|
let hdrs = resp.headers_mut().unwrap();
|
||||||
hdrs.typed_insert(ETag::from_str(&object.get_etag()).unwrap());
|
hdrs.typed_insert(ETag::from_str(&object.get_etag()).unwrap());
|
||||||
hdrs.typed_insert(ContentType::from_str("text/vcard").unwrap());
|
hdrs.typed_insert(ContentType::from_str("text/vcard; charset=utf-8").unwrap());
|
||||||
if matches!(method, Method::HEAD) {
|
if matches!(method, Method::HEAD) {
|
||||||
Ok(resp.body(Body::empty()).unwrap())
|
Ok(resp.body(Body::empty()).unwrap())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Error,
|
Error,
|
||||||
address_object::{
|
address_object::{
|
||||||
@@ -22,8 +24,8 @@ pub struct AddressObjectResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for AddressObjectResource {
|
impl ResourceName for AddressObjectResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
format!("{}.vcf", self.object.get_id())
|
Cow::from(format!("{}.vcf", self.object.get_id()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ pub async fn route_get<AS: AddressbookStore, S: SubscriptionStore>(
|
|||||||
|
|
||||||
let mut resp = Response::builder().status(StatusCode::OK);
|
let mut resp = Response::builder().status(StatusCode::OK);
|
||||||
let hdrs = resp.headers_mut().unwrap();
|
let hdrs = resp.headers_mut().unwrap();
|
||||||
hdrs.typed_insert(ContentType::from_str("text/vcard").unwrap());
|
hdrs.typed_insert(ContentType::from_str("text/vcard; charset=utf-8").unwrap());
|
||||||
let filename = format!("{principal}_{addressbook_id}.vcf");
|
let filename = format!("{principal}_{addressbook_id}.vcf");
|
||||||
let filename = utf8_percent_encode(&filename, CONTROLS);
|
let filename = utf8_percent_encode(&filename, CONTROLS);
|
||||||
hdrs.insert(
|
hdrs.insert(
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
|
|||||||
card_mut.set_property(Property {
|
card_mut.set_property(Property {
|
||||||
name: "UID".to_owned(),
|
name: "UID".to_owned(),
|
||||||
value: Some(uuid::Uuid::new_v4().to_string()),
|
value: Some(uuid::Uuid::new_v4().to_string()),
|
||||||
params: None,
|
params: vec![],
|
||||||
});
|
});
|
||||||
card = card_mut.verify().unwrap();
|
card = card_mut.verify().unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ pub async fn get_objects_addressbook_multiget<AS: AddressbookStore>(
|
|||||||
let mut not_found = vec![];
|
let mut not_found = vec![];
|
||||||
|
|
||||||
for href in &addressbook_multiget.href {
|
for href in &addressbook_multiget.href {
|
||||||
if let Some(filename) = href.strip_prefix(path) {
|
if let Ok(href) = percent_encoding::percent_decode_str(href).decode_utf8()
|
||||||
|
&& let Some(filename) = href.strip_prefix(path)
|
||||||
|
{
|
||||||
let filename = filename.trim_start_matches('/');
|
let filename = filename.trim_start_matches('/');
|
||||||
if let Some(object_id) = filename.strip_suffix(".vcf") {
|
if let Some(object_id) = filename.strip_suffix(".vcf") {
|
||||||
match store
|
match store
|
||||||
@@ -42,11 +44,11 @@ pub async fn get_objects_addressbook_multiget<AS: AddressbookStore>(
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(object) => result.push(object),
|
Ok(object) => result.push(object),
|
||||||
Err(rustical_store::Error::NotFound) => not_found.push(href.to_owned()),
|
Err(rustical_store::Error::NotFound) => not_found.push(href.to_string()),
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => return Err(err.into()),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
not_found.push(href.to_owned());
|
not_found.push(href.to_string());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
not_found.push(href.to_owned());
|
not_found.push(href.to_owned());
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
use crate::{
|
||||||
|
address_object::AddressObjectPropWrapperName,
|
||||||
|
addressbook::methods::report::addressbook_query::PropFilterElement,
|
||||||
|
};
|
||||||
|
use derive_more::{From, Into};
|
||||||
|
use ical::property::Property;
|
||||||
|
use rustical_dav::xml::{PropfindType, TextMatchElement};
|
||||||
|
use rustical_ical::{AddressObject, UtcDateTime};
|
||||||
|
use rustical_xml::{ValueDeserialize, XmlDeserialize, XmlRootTag};
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct TimeRangeElement {
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) start: Option<UtcDateTime>,
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) end: Option<UtcDateTime>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
// https://www.rfc-editor.org/rfc/rfc4791#section-9.7.3
|
||||||
|
pub struct ParamFilterElement {
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) is_not_defined: Option<()>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) text_match: Option<TextMatchElement>,
|
||||||
|
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ParamFilterElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_property(&self, prop: &Property) -> bool {
|
||||||
|
let Some(param) = prop.get_param(&self.name) else {
|
||||||
|
return self.is_not_defined.is_some();
|
||||||
|
};
|
||||||
|
if self.is_not_defined.is_some() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let Some(text_match) = self.text_match.as_ref() else {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
text_match.match_text(param)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Default, From, Into)]
|
||||||
|
pub struct Allof(pub bool);
|
||||||
|
|
||||||
|
impl ValueDeserialize for Allof {
|
||||||
|
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
||||||
|
Ok(Self(match val {
|
||||||
|
"allof" => true,
|
||||||
|
"anyof" => false,
|
||||||
|
_ => {
|
||||||
|
return Err(rustical_xml::XmlError::InvalidVariant(format!(
|
||||||
|
"Invalid test parameter: {val}"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <!ELEMENT filter (prop-filter*)>
|
||||||
|
// <!ATTLIST filter test (anyof | allof) "anyof">
|
||||||
|
// <!-- test value:
|
||||||
|
// anyof logical OR for prop-filter matches
|
||||||
|
// allof logical AND for prop-filter matches -->
|
||||||
|
#[derive(XmlDeserialize, XmlRootTag, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[xml(root = "filter", ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct FilterElement {
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub test: Allof,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", flatten)]
|
||||||
|
pub(crate) prop_filter: Vec<PropFilterElement>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FilterElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn matches(&self, addr_object: &AddressObject) -> bool {
|
||||||
|
let Allof(allof) = self.test;
|
||||||
|
let mut results = self
|
||||||
|
.prop_filter
|
||||||
|
.iter()
|
||||||
|
.map(|prop_filter| prop_filter.match_component(addr_object));
|
||||||
|
if allof {
|
||||||
|
results.all(|x| x)
|
||||||
|
} else {
|
||||||
|
results.any(|x| x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
// <!ELEMENT addressbook-query ((DAV:allprop |
|
||||||
|
// DAV:propname |
|
||||||
|
// DAV:prop)?, filter, limit?)>
|
||||||
|
pub struct AddressbookQueryRequest {
|
||||||
|
#[xml(ty = "untagged")]
|
||||||
|
pub prop: PropfindType<AddressObjectPropWrapperName>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) filter: FilterElement,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) limit: Option<LimitElement>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc5323#section-5.17
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub struct LimitElement {
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub nresults: NresultsElement,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<u64> for LimitElement {
|
||||||
|
fn from(value: u64) -> Self {
|
||||||
|
Self {
|
||||||
|
nresults: NresultsElement(value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<LimitElement> for u64 {
|
||||||
|
fn from(value: LimitElement) -> Self {
|
||||||
|
value.nresults.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub struct NresultsElement(#[xml(ty = "text")] pub u64);
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
use crate::Error;
|
||||||
|
mod elements;
|
||||||
|
mod prop_filter;
|
||||||
|
pub use elements::*;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use prop_filter::{PropFilterElement, PropFilterable};
|
||||||
|
use rustical_ical::AddressObject;
|
||||||
|
use rustical_store::AddressbookStore;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
|
|
||||||
|
pub async fn get_objects_addressbook_query<AS: AddressbookStore>(
|
||||||
|
addr_query: &AddressbookQueryRequest,
|
||||||
|
principal: &str,
|
||||||
|
addressbook_id: &str,
|
||||||
|
store: &AS,
|
||||||
|
) -> Result<Vec<AddressObject>, Error> {
|
||||||
|
let mut objects = store.get_objects(principal, addressbook_id).await?;
|
||||||
|
objects.retain(|object| addr_query.filter.matches(object));
|
||||||
|
Ok(objects)
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
use super::{Allof, ParamFilterElement};
|
||||||
|
use ical::{parser::Component, property::Property};
|
||||||
|
use rustical_dav::xml::TextMatchElement;
|
||||||
|
use rustical_ical::AddressObject;
|
||||||
|
use rustical_xml::XmlDeserialize;
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
// <!ELEMENT prop-filter (is-not-defined |
|
||||||
|
// (text-match*, param-filter*))>
|
||||||
|
//
|
||||||
|
// <!ATTLIST prop-filter name CDATA #REQUIRED
|
||||||
|
// test (anyof | allof) "anyof">
|
||||||
|
// <!-- name value: a vCard property name (e.g., "NICKNAME")
|
||||||
|
// test value:
|
||||||
|
// anyof logical OR for text-match/param-filter matches
|
||||||
|
// allof logical AND for text-match/param-filter matches -->
|
||||||
|
pub struct PropFilterElement {
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
pub(crate) is_not_defined: Option<()>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", flatten)]
|
||||||
|
pub(crate) text_match: Vec<TextMatchElement>,
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", flatten)]
|
||||||
|
pub(crate) param_filter: Vec<ParamFilterElement>,
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub test: Allof,
|
||||||
|
|
||||||
|
#[xml(ty = "attr")]
|
||||||
|
pub(crate) name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_property(&self, property: &Property) -> bool {
|
||||||
|
let Allof(allof) = self.test;
|
||||||
|
let text_matches = self
|
||||||
|
.text_match
|
||||||
|
.iter()
|
||||||
|
.map(|text_match| text_match.match_property(property));
|
||||||
|
|
||||||
|
let param_matches = self
|
||||||
|
.param_filter
|
||||||
|
.iter()
|
||||||
|
.map(|param_filter| param_filter.match_property(property));
|
||||||
|
let mut matches = text_matches.chain(param_matches);
|
||||||
|
|
||||||
|
if allof {
|
||||||
|
matches.all(|a| a)
|
||||||
|
} else {
|
||||||
|
matches.any(|a| a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn match_component(&self, comp: &impl PropFilterable) -> bool {
|
||||||
|
let properties = comp.get_named_properties(&self.name);
|
||||||
|
if self.is_not_defined.is_some() {
|
||||||
|
return properties.is_empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The filter matches when one property instance matches
|
||||||
|
properties.iter().any(|prop| self.match_property(prop))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait PropFilterable {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PropFilterable for AddressObject {
|
||||||
|
fn get_named_properties(&self, name: &str) -> Vec<&Property> {
|
||||||
|
self.get_vcard().get_named_properties(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
use super::FilterElement;
|
||||||
|
use rstest::rstest;
|
||||||
|
use rustical_ical::AddressObject;
|
||||||
|
use rustical_xml::XmlDocument;
|
||||||
|
|
||||||
|
const VCF_1: &str = r"BEGIN:VCARD
|
||||||
|
VERSION:4.0
|
||||||
|
FN:Simon Perreault
|
||||||
|
N:Perreault;Simon;;;ing. jr,M.Sc.
|
||||||
|
BDAY:--0203
|
||||||
|
GENDER:M
|
||||||
|
EMAIL;TYPE=work:simon.perreault@viagenie.ca
|
||||||
|
END:VCARD";
|
||||||
|
|
||||||
|
const VCF_2: &str = r"BEGIN:VCARD
|
||||||
|
VERSION:4.0
|
||||||
|
N:Gump;Forrest;;Mr.;
|
||||||
|
FN:Forrest Gump
|
||||||
|
ORG:Bubba Gump Shrimp Co.
|
||||||
|
TITLE:Shrimp Man
|
||||||
|
PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif
|
||||||
|
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212
|
||||||
|
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212
|
||||||
|
ADR;TYPE=WORK;PREF=1;LABEL=100 Waters Edge\\nBaytown\\, LA 30314\\nUnited S
|
||||||
|
tates of America:;;100 Waters Edge;Baytown;LA;30314;United States of Ameri
|
||||||
|
ca
|
||||||
|
ADR;TYPE=HOME;LABEL=42 Plantation St.\\nBaytown\\, LA 30314\\nUnited States
|
||||||
|
of America:;;42 Plantation St.;Baytown;LA;30314;United States of America
|
||||||
|
EMAIL:forrestgump@example.com
|
||||||
|
REV:20080424T195243Z
|
||||||
|
x-qq:21588891
|
||||||
|
UID:890a9da4-bb6d-4afb-9f32-b5eff6494a53
|
||||||
|
END:VCARD
|
||||||
|
";
|
||||||
|
|
||||||
|
const FILTER_1: &str = r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:filter xmlns:C="urn:ietf:params:xml:ns:carddav">
|
||||||
|
<C:prop-filter name="EMAIL" test="allof">
|
||||||
|
<C:text-match collation="i;ascii-casemap">simon.perreault@viagenie.ca</C:text-match>
|
||||||
|
<C:param-filter name="TYPE">
|
||||||
|
<C:text-match match-type="equals" collation="i;unicode-casemap">WORK</C:text-match>
|
||||||
|
</C:param-filter>
|
||||||
|
</C:prop-filter>
|
||||||
|
</C:filter>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
const FILTER_2: &str = r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:filter xmlns:C="urn:ietf:params:xml:ns:carddav">
|
||||||
|
<C:prop-filter name="EMAIL" test="anyof">
|
||||||
|
<C:text-match collation="i;ascii-casemap">forrestgump@example.com</C:text-match>
|
||||||
|
<C:param-filter name="TYPE">
|
||||||
|
<C:text-match match-type="equals" collation="i;ascii-casemap">WORK</C:text-match>
|
||||||
|
</C:param-filter>
|
||||||
|
</C:prop-filter>
|
||||||
|
</C:filter>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
#[case(VCF_1, FILTER_1, true)]
|
||||||
|
#[case(VCF_2, FILTER_1, false)]
|
||||||
|
#[case(VCF_1, FILTER_2, true)]
|
||||||
|
#[case(VCF_2, FILTER_2, true)]
|
||||||
|
fn test_filter(#[case] vcf: &str, #[case] filter: &str, #[case] matches: bool) {
|
||||||
|
dbg!(vcf);
|
||||||
|
let obj = AddressObject::from_vcf(String::new(), vcf.to_owned()).unwrap();
|
||||||
|
let filter = FilterElement::parse_str(filter).unwrap();
|
||||||
|
assert_eq!(matches, filter.matches(&obj));
|
||||||
|
}
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
CardDavPrincipalUri, Error, address_object::AddressObjectPropWrapperName,
|
CardDavPrincipalUri, Error,
|
||||||
addressbook::AddressbookResourceService,
|
address_object::{
|
||||||
|
AddressObjectPropWrapper, AddressObjectPropWrapperName, resource::AddressObjectResource,
|
||||||
|
},
|
||||||
|
addressbook::{
|
||||||
|
AddressbookResourceService,
|
||||||
|
methods::report::addressbook_query::{
|
||||||
|
AddressbookQueryRequest, get_objects_addressbook_query,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use addressbook_multiget::{AddressbookMultigetRequest, handle_addressbook_multiget};
|
use addressbook_multiget::{AddressbookMultigetRequest, handle_addressbook_multiget};
|
||||||
use axum::{
|
use axum::{
|
||||||
@@ -8,19 +16,30 @@ use axum::{
|
|||||||
extract::{OriginalUri, Path, State},
|
extract::{OriginalUri, Path, State},
|
||||||
response::IntoResponse,
|
response::IntoResponse,
|
||||||
};
|
};
|
||||||
use rustical_dav::xml::{PropfindType, sync_collection::SyncCollectionRequest};
|
use http::StatusCode;
|
||||||
|
use rustical_dav::{
|
||||||
|
resource::{PrincipalUri, Resource},
|
||||||
|
xml::{
|
||||||
|
MultistatusElement, PropfindType, multistatus::ResponseElement,
|
||||||
|
sync_collection::SyncCollectionRequest,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use rustical_ical::AddressObject;
|
||||||
use rustical_store::{AddressbookStore, SubscriptionStore, auth::Principal};
|
use rustical_store::{AddressbookStore, SubscriptionStore, auth::Principal};
|
||||||
use rustical_xml::{XmlDeserialize, XmlDocument};
|
use rustical_xml::{XmlDeserialize, XmlDocument};
|
||||||
use sync_collection::handle_sync_collection;
|
use sync_collection::handle_sync_collection;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
mod addressbook_multiget;
|
mod addressbook_multiget;
|
||||||
|
mod addressbook_query;
|
||||||
mod sync_collection;
|
mod sync_collection;
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlDocument, Clone, Debug, PartialEq)]
|
#[derive(XmlDeserialize, XmlDocument, Clone, Debug, PartialEq)]
|
||||||
pub(crate) enum ReportRequest {
|
pub(crate) enum ReportRequest {
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
AddressbookMultiget(AddressbookMultigetRequest),
|
AddressbookMultiget(AddressbookMultigetRequest),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
AddressbookQuery(AddressbookQueryRequest),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
SyncCollection(SyncCollectionRequest<AddressObjectPropWrapperName>),
|
SyncCollection(SyncCollectionRequest<AddressObjectPropWrapperName>),
|
||||||
}
|
}
|
||||||
@@ -29,11 +48,49 @@ impl ReportRequest {
|
|||||||
const fn props(&self) -> &PropfindType<AddressObjectPropWrapperName> {
|
const fn props(&self) -> &PropfindType<AddressObjectPropWrapperName> {
|
||||||
match self {
|
match self {
|
||||||
Self::AddressbookMultiget(AddressbookMultigetRequest { prop, .. })
|
Self::AddressbookMultiget(AddressbookMultigetRequest { prop, .. })
|
||||||
| Self::SyncCollection(SyncCollectionRequest { prop, .. }) => prop,
|
| Self::SyncCollection(SyncCollectionRequest { prop, .. })
|
||||||
|
| Self::AddressbookQuery(AddressbookQueryRequest { prop, .. }) => prop,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn objects_response(
|
||||||
|
objects: Vec<AddressObject>,
|
||||||
|
not_found: Vec<String>,
|
||||||
|
path: &str,
|
||||||
|
principal: &str,
|
||||||
|
puri: &impl PrincipalUri,
|
||||||
|
user: &Principal,
|
||||||
|
prop: &PropfindType<AddressObjectPropWrapperName>,
|
||||||
|
) -> Result<MultistatusElement<AddressObjectPropWrapper, String>, Error> {
|
||||||
|
let mut responses = Vec::new();
|
||||||
|
for object in objects {
|
||||||
|
let path = format!("{}/{}.vcf", path, object.get_id());
|
||||||
|
responses.push(
|
||||||
|
AddressObjectResource {
|
||||||
|
object,
|
||||||
|
principal: principal.to_owned(),
|
||||||
|
}
|
||||||
|
.propfind(&path, prop, None, puri, user)?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let not_found_responses = not_found
|
||||||
|
.into_iter()
|
||||||
|
.map(|path| ResponseElement {
|
||||||
|
href: path,
|
||||||
|
status: Some(StatusCode::NOT_FOUND),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
Ok(MultistatusElement {
|
||||||
|
responses,
|
||||||
|
member_responses: not_found_responses,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[instrument(skip(addr_store))]
|
#[instrument(skip(addr_store))]
|
||||||
pub async fn route_report_addressbook<AS: AddressbookStore, S: SubscriptionStore>(
|
pub async fn route_report_addressbook<AS: AddressbookStore, S: SubscriptionStore>(
|
||||||
Path((principal, addressbook_id)): Path<(String, String)>,
|
Path((principal, addressbook_id)): Path<(String, String)>,
|
||||||
@@ -75,13 +132,36 @@ pub async fn route_report_addressbook<AS: AddressbookStore, S: SubscriptionStore
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
|
ReportRequest::AddressbookQuery(addr_query) => {
|
||||||
|
let objects = get_objects_addressbook_query(
|
||||||
|
addr_query,
|
||||||
|
&principal,
|
||||||
|
&addressbook_id,
|
||||||
|
addr_store.as_ref(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
objects_response(
|
||||||
|
objects,
|
||||||
|
vec![],
|
||||||
|
uri.path(),
|
||||||
|
&principal,
|
||||||
|
&puri,
|
||||||
|
&user,
|
||||||
|
&addr_query.prop,
|
||||||
|
)?
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::address_object::AddressObjectPropName;
|
use crate::{
|
||||||
|
address_object::AddressObjectPropName,
|
||||||
|
addressbook::methods::report::addressbook_query::{
|
||||||
|
Allof, FilterElement, LimitElement, NresultsElement, PropFilterElement,
|
||||||
|
},
|
||||||
|
};
|
||||||
use rustical_dav::xml::{PropElement, sync_collection::SyncLevel};
|
use rustical_dav::xml::{PropElement, sync_collection::SyncLevel};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -144,4 +224,50 @@ mod tests {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_xml_addressbook_query() {
|
||||||
|
let report_request = ReportRequest::parse_str(
|
||||||
|
r#"
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<card:addressbook-query xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">
|
||||||
|
<d:prop>
|
||||||
|
<d:getetag/>
|
||||||
|
</d:prop>
|
||||||
|
<card:filter>
|
||||||
|
<card:prop-filter name="FN"/>
|
||||||
|
</card:filter>
|
||||||
|
<card:limit>
|
||||||
|
<card:nresults>100</card:nresults>
|
||||||
|
</card:limit>
|
||||||
|
</card:addressbook-query>
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
report_request,
|
||||||
|
ReportRequest::AddressbookQuery(AddressbookQueryRequest {
|
||||||
|
prop: rustical_dav::xml::PropfindType::Prop(PropElement(
|
||||||
|
vec![AddressObjectPropWrapperName::AddressObject(
|
||||||
|
AddressObjectPropName::Getetag
|
||||||
|
),],
|
||||||
|
vec![]
|
||||||
|
)),
|
||||||
|
filter: FilterElement {
|
||||||
|
test: Allof::default(),
|
||||||
|
prop_filter: vec![PropFilterElement {
|
||||||
|
name: "FN".to_owned(),
|
||||||
|
is_not_defined: None,
|
||||||
|
text_match: vec![],
|
||||||
|
param_filter: vec![],
|
||||||
|
test: Allof::default()
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
limit: Some(LimitElement {
|
||||||
|
nresults: NresultsElement(100)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,3 +3,5 @@ pub mod prop;
|
|||||||
pub mod resource;
|
pub mod resource;
|
||||||
mod service;
|
mod service;
|
||||||
pub use service::*;
|
pub use service::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests;
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
|
use derive_more::{From, Into};
|
||||||
use rustical_dav::{
|
use rustical_dav::{
|
||||||
extensions::{CommonPropertiesProp, SyncTokenExtensionProp},
|
extensions::{CommonPropertiesProp, SyncTokenExtensionProp},
|
||||||
xml::SupportedReportSet,
|
xml::{SupportedReportSet, TextCollation},
|
||||||
};
|
};
|
||||||
use rustical_dav_push::DavPushExtensionProp;
|
use rustical_dav_push::DavPushExtensionProp;
|
||||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
||||||
use strum_macros::VariantArray;
|
use strum_macros::VariantArray;
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName, Debug)]
|
||||||
#[xml(unit_variants_ident = "AddressbookPropName")]
|
#[xml(unit_variants_ident = "AddressbookPropName")]
|
||||||
pub enum AddressbookProp {
|
pub enum AddressbookProp {
|
||||||
// CardDAV (RFC 6352)
|
// CardDAV (RFC 6352)
|
||||||
@@ -14,13 +15,15 @@ pub enum AddressbookProp {
|
|||||||
AddressbookDescription(Option<String>),
|
AddressbookDescription(Option<String>),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", skip_deserializing)]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", skip_deserializing)]
|
||||||
SupportedAddressData(SupportedAddressData),
|
SupportedAddressData(SupportedAddressData),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV", skip_deserializing)]
|
||||||
|
SupportedCollationSet(SupportedCollationSet),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV", skip_deserializing)]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV", skip_deserializing)]
|
||||||
SupportedReportSet(SupportedReportSet<ReportMethod>),
|
SupportedReportSet(SupportedReportSet<ReportMethod>),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
MaxResourceSize(i64),
|
MaxResourceSize(i64),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName, Debug)]
|
||||||
#[xml(unit_variants_ident = "AddressbookPropWrapperName", untagged)]
|
#[xml(unit_variants_ident = "AddressbookPropWrapperName", untagged)]
|
||||||
pub enum AddressbookPropWrapper {
|
pub enum AddressbookPropWrapper {
|
||||||
Addressbook(AddressbookProp),
|
Addressbook(AddressbookProp),
|
||||||
@@ -60,6 +63,29 @@ impl Default for SupportedAddressData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
|
||||||
|
pub struct SupportedCollation(#[xml(ty = "text")] pub TextCollation);
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq)]
|
||||||
|
pub struct SupportedCollationSet(
|
||||||
|
#[xml(
|
||||||
|
ns = "rustical_dav::namespace::NS_CARDDAV",
|
||||||
|
flatten,
|
||||||
|
rename = "supported-collation"
|
||||||
|
)]
|
||||||
|
pub Vec<SupportedCollation>,
|
||||||
|
);
|
||||||
|
|
||||||
|
impl Default for SupportedCollationSet {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self(vec![
|
||||||
|
SupportedCollation(TextCollation::AsciiCasemap),
|
||||||
|
SupportedCollation(TextCollation::UnicodeCasemap),
|
||||||
|
SupportedCollation(TextCollation::Octet),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq, VariantArray)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq, VariantArray)]
|
||||||
pub enum ReportMethod {
|
pub enum ReportMethod {
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use super::prop::SupportedAddressData;
|
|||||||
use crate::Error;
|
use crate::Error;
|
||||||
use crate::addressbook::prop::{
|
use crate::addressbook::prop::{
|
||||||
AddressbookProp, AddressbookPropName, AddressbookPropWrapper, AddressbookPropWrapperName,
|
AddressbookProp, AddressbookPropName, AddressbookPropWrapper, AddressbookPropWrapperName,
|
||||||
|
SupportedCollationSet,
|
||||||
};
|
};
|
||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{From, Into};
|
||||||
use rustical_dav::extensions::{CommonPropertiesExtension, SyncTokenExtension};
|
use rustical_dav::extensions::{CommonPropertiesExtension, SyncTokenExtension};
|
||||||
@@ -11,13 +12,14 @@ use rustical_dav::xml::{Resourcetype, ResourcetypeInner, SupportedReportSet};
|
|||||||
use rustical_dav_push::DavPushExtension;
|
use rustical_dav_push::DavPushExtension;
|
||||||
use rustical_store::Addressbook;
|
use rustical_store::Addressbook;
|
||||||
use rustical_store::auth::Principal;
|
use rustical_store::auth::Principal;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
#[derive(Clone, Debug, From, Into)]
|
#[derive(Clone, Debug, From, Into)]
|
||||||
pub struct AddressbookResource(pub(crate) Addressbook);
|
pub struct AddressbookResource(pub(crate) Addressbook);
|
||||||
|
|
||||||
impl ResourceName for AddressbookResource {
|
impl ResourceName for AddressbookResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
self.0.id.clone()
|
Cow::from(&self.0.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +63,9 @@ impl Resource for AddressbookResource {
|
|||||||
AddressbookPropName::MaxResourceSize => {
|
AddressbookPropName::MaxResourceSize => {
|
||||||
AddressbookProp::MaxResourceSize(10_000_000)
|
AddressbookProp::MaxResourceSize(10_000_000)
|
||||||
}
|
}
|
||||||
|
AddressbookPropName::SupportedCollationSet => {
|
||||||
|
AddressbookProp::SupportedCollationSet(SupportedCollationSet::default())
|
||||||
|
}
|
||||||
AddressbookPropName::SupportedReportSet => {
|
AddressbookPropName::SupportedReportSet => {
|
||||||
AddressbookProp::SupportedReportSet(SupportedReportSet::all())
|
AddressbookProp::SupportedReportSet(SupportedReportSet::all())
|
||||||
}
|
}
|
||||||
@@ -93,6 +98,7 @@ impl Resource for AddressbookResource {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
AddressbookProp::MaxResourceSize(_)
|
AddressbookProp::MaxResourceSize(_)
|
||||||
|
| AddressbookProp::SupportedCollationSet(_)
|
||||||
| AddressbookProp::SupportedReportSet(_)
|
| AddressbookProp::SupportedReportSet(_)
|
||||||
| AddressbookProp::SupportedAddressData(_) => {
|
| AddressbookProp::SupportedAddressData(_) => {
|
||||||
Err(rustical_dav::Error::PropReadOnly)
|
Err(rustical_dav::Error::PropReadOnly)
|
||||||
@@ -115,6 +121,7 @@ impl Resource for AddressbookResource {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
AddressbookPropName::MaxResourceSize
|
AddressbookPropName::MaxResourceSize
|
||||||
|
| AddressbookPropName::SupportedCollationSet
|
||||||
| AddressbookPropName::SupportedReportSet
|
| AddressbookPropName::SupportedReportSet
|
||||||
| AddressbookPropName::SupportedAddressData => {
|
| AddressbookPropName::SupportedAddressData => {
|
||||||
Err(rustical_dav::Error::PropReadOnly)
|
Err(rustical_dav::Error::PropReadOnly)
|
||||||
|
|||||||
@@ -0,0 +1,168 @@
|
|||||||
|
---
|
||||||
|
source: crates/carddav/src/addressbook/tests.rs
|
||||||
|
expression: response
|
||||||
|
---
|
||||||
|
ResponseElement {
|
||||||
|
href: "/carddav/principal/user/yeet/",
|
||||||
|
status: None,
|
||||||
|
propstat: [
|
||||||
|
Normal(
|
||||||
|
PropstatElement {
|
||||||
|
prop: PropTagWrapper(
|
||||||
|
[
|
||||||
|
Addressbook(
|
||||||
|
AddressbookDescription(
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Addressbook(
|
||||||
|
SupportedAddressData(
|
||||||
|
SupportedAddressData {
|
||||||
|
address_data_type: [
|
||||||
|
AddressDataType {
|
||||||
|
content_type: "text/vcard",
|
||||||
|
version: "3.0",
|
||||||
|
},
|
||||||
|
AddressDataType {
|
||||||
|
content_type: "text/vcard",
|
||||||
|
version: "4.0",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Addressbook(
|
||||||
|
SupportedCollationSet(
|
||||||
|
SupportedCollationSet(
|
||||||
|
[
|
||||||
|
SupportedCollation(
|
||||||
|
AsciiCasemap,
|
||||||
|
),
|
||||||
|
SupportedCollation(
|
||||||
|
UnicodeCasemap,
|
||||||
|
),
|
||||||
|
SupportedCollation(
|
||||||
|
Octet,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Addressbook(
|
||||||
|
SupportedReportSet(
|
||||||
|
SupportedReportSet {
|
||||||
|
supported_report: [
|
||||||
|
ReportWrapper {
|
||||||
|
report: AddressbookMultiget,
|
||||||
|
},
|
||||||
|
ReportWrapper {
|
||||||
|
report: SyncCollection,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Addressbook(
|
||||||
|
MaxResourceSize(
|
||||||
|
10000000,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SyncToken(
|
||||||
|
SyncToken(
|
||||||
|
"github.com/lennart-k/rustical/ns/0",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SyncToken(
|
||||||
|
Getctag(
|
||||||
|
"github.com/lennart-k/rustical/ns/0",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DavPush(
|
||||||
|
Transports(
|
||||||
|
Transports {
|
||||||
|
transports: [
|
||||||
|
WebPush,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DavPush(
|
||||||
|
Topic(
|
||||||
|
"asdasd",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DavPush(
|
||||||
|
SupportedTriggers(
|
||||||
|
SupportedTriggers(
|
||||||
|
[
|
||||||
|
ContentUpdate(
|
||||||
|
ContentUpdate(
|
||||||
|
One,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PropertyUpdate(
|
||||||
|
PropertyUpdate(
|
||||||
|
One,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
Resourcetype(
|
||||||
|
Resourcetype(
|
||||||
|
[
|
||||||
|
ResourcetypeInner(
|
||||||
|
Some(
|
||||||
|
Namespace("DAV:"),
|
||||||
|
),
|
||||||
|
"collection",
|
||||||
|
),
|
||||||
|
ResourcetypeInner(
|
||||||
|
Some(
|
||||||
|
Namespace("urn:ietf:params:xml:ns:carddav"),
|
||||||
|
),
|
||||||
|
"addressbook",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
Displayname(
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
CurrentUserPrincipal(
|
||||||
|
HrefElement {
|
||||||
|
href: "/carddav/principal/user/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
CurrentUserPrivilegeSet(
|
||||||
|
UserPrivilegeSet {
|
||||||
|
privileges: {
|
||||||
|
All,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
Owner(
|
||||||
|
Some(
|
||||||
|
HrefElement {
|
||||||
|
href: "/carddav/principal/user/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
status: 200,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
---
|
||||||
|
source: crates/carddav/src/addressbook/tests.rs
|
||||||
|
expression: response.serialize_to_string().unwrap()
|
||||||
|
---
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<response xmlns="DAV:">
|
||||||
|
<href>/carddav/principal/user/yeet/</href>
|
||||||
|
<propstat>
|
||||||
|
<prop xmlns="DAV:">
|
||||||
|
<supported-address-data xmlns="urn:ietf:params:xml:ns:carddav">
|
||||||
|
<address-data-type xmlns="urn:ietf:params:xml:ns:carddav" content-type="text/vcard" version="3.0"/>
|
||||||
|
<address-data-type xmlns="urn:ietf:params:xml:ns:carddav" content-type="text/vcard" version="4.0"/>
|
||||||
|
</supported-address-data>
|
||||||
|
<supported-collation-set xmlns="urn:ietf:params:xml:ns:carddav">
|
||||||
|
<supported-collation xmlns="urn:ietf:params:xml:ns:carddav">i;ascii-casemap</supported-collation>
|
||||||
|
<supported-collation xmlns="urn:ietf:params:xml:ns:carddav">i;unicode-casemap</supported-collation>
|
||||||
|
<supported-collation xmlns="urn:ietf:params:xml:ns:carddav">i;octet</supported-collation>
|
||||||
|
</supported-collation-set>
|
||||||
|
<supported-report-set xmlns="DAV:">
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<addressbook-multiget xmlns="urn:ietf:params:xml:ns:carddav"/>
|
||||||
|
</report>
|
||||||
|
</supported-report>
|
||||||
|
<supported-report xmlns="DAV:">
|
||||||
|
<report xmlns="DAV:">
|
||||||
|
<sync-collection xmlns="DAV:"/>
|
||||||
|
</report>
|
||||||
|
</supported-report>
|
||||||
|
</supported-report-set>
|
||||||
|
<max-resource-size xmlns="urn:ietf:params:xml:ns:carddav">10000000</max-resource-size>
|
||||||
|
<sync-token xmlns="DAV:">github.com/lennart-k/rustical/ns/0</sync-token>
|
||||||
|
<getctag xmlns="http://calendarserver.org/ns/">github.com/lennart-k/rustical/ns/0</getctag>
|
||||||
|
<transports xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<web-push xmlns="https://bitfire.at/webdav-push"/>
|
||||||
|
</transports>
|
||||||
|
<topic xmlns="https://bitfire.at/webdav-push">asdasd</topic>
|
||||||
|
<supported-triggers xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<content-update xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<depth xmlns="DAV:">1</depth>
|
||||||
|
</content-update>
|
||||||
|
<property-update xmlns="https://bitfire.at/webdav-push">
|
||||||
|
<depth xmlns="DAV:">1</depth>
|
||||||
|
</property-update>
|
||||||
|
</supported-triggers>
|
||||||
|
<resourcetype xmlns="DAV:">
|
||||||
|
<collection xmlns="DAV:"/>
|
||||||
|
<addressbook xmlns="urn:ietf:params:xml:ns:carddav"/>
|
||||||
|
</resourcetype>
|
||||||
|
<current-user-principal xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
|
</current-user-principal>
|
||||||
|
<current-user-privilege-set xmlns="DAV:">
|
||||||
|
<privilege>
|
||||||
|
<all/>
|
||||||
|
</privilege>
|
||||||
|
</current-user-privilege-set>
|
||||||
|
<owner xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
|
</owner>
|
||||||
|
</prop>
|
||||||
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
|
</propstat>
|
||||||
|
</response>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
source: crates/carddav/src/addressbook/tests.rs
|
||||||
|
expression: propfind
|
||||||
|
---
|
||||||
|
PropfindElement {
|
||||||
|
prop: Allprop,
|
||||||
|
include: None,
|
||||||
|
}
|
||||||
49
crates/carddav/src/addressbook/tests.rs
Normal file
49
crates/carddav/src/addressbook/tests.rs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
use crate::{CardDavPrincipalUri, addressbook::resource::AddressbookResource};
|
||||||
|
use rustical_dav::resource::Resource;
|
||||||
|
use rustical_store::{Addressbook, auth::Principal};
|
||||||
|
use rustical_xml::XmlSerializeRoot;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_propfind() {
|
||||||
|
let propfind = AddressbookResource::parse_propfind(
|
||||||
|
r#"<?xml version="1.0" encoding="UTF-8"?><propfind xmlns="DAV:"><allprop/></propfind>"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
insta::assert_debug_snapshot!(propfind);
|
||||||
|
|
||||||
|
let principal = Principal {
|
||||||
|
id: "user".to_string(),
|
||||||
|
displayname: None,
|
||||||
|
principal_type: rustical_store::auth::PrincipalType::Individual,
|
||||||
|
password: None,
|
||||||
|
memberships: vec!["group".to_string()],
|
||||||
|
};
|
||||||
|
|
||||||
|
let addressbook = Addressbook {
|
||||||
|
id: "yeet".to_string(),
|
||||||
|
principal: "user".to_string(),
|
||||||
|
displayname: None,
|
||||||
|
description: None,
|
||||||
|
deleted_at: None,
|
||||||
|
synctoken: 0,
|
||||||
|
push_topic: "asdasd".to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let resource = AddressbookResource(addressbook.clone());
|
||||||
|
let response = resource
|
||||||
|
.propfind(
|
||||||
|
&format!(
|
||||||
|
"/carddav/principal/{}/{}",
|
||||||
|
addressbook.principal, addressbook.id
|
||||||
|
),
|
||||||
|
&propfind.prop,
|
||||||
|
propfind.include.as_ref(),
|
||||||
|
&CardDavPrincipalUri("/carddav"),
|
||||||
|
&principal,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
insta::assert_debug_snapshot!(response);
|
||||||
|
insta::assert_snapshot!(response.serialize_to_string().unwrap());
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
use axum::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use tracing::error;
|
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use rustical_dav::extensions::CommonPropertiesExtension;
|
use rustical_dav::extensions::CommonPropertiesExtension;
|
||||||
use rustical_dav::privileges::UserPrivilegeSet;
|
use rustical_dav::privileges::UserPrivilegeSet;
|
||||||
@@ -11,16 +13,18 @@ mod service;
|
|||||||
pub use service::*;
|
pub use service::*;
|
||||||
mod prop;
|
mod prop;
|
||||||
pub use prop::*;
|
pub use prop::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct PrincipalResource {
|
pub struct PrincipalResource {
|
||||||
principal: Principal,
|
pub principal: Principal,
|
||||||
members: Vec<String>,
|
pub members: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResourceName for PrincipalResource {
|
impl ResourceName for PrincipalResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> Cow<'_, str> {
|
||||||
self.principal.id.clone()
|
Cow::from(&self.principal.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use rustical_dav::{
|
|||||||
};
|
};
|
||||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName, Debug)]
|
||||||
#[xml(unit_variants_ident = "PrincipalPropName")]
|
#[xml(unit_variants_ident = "PrincipalPropName")]
|
||||||
pub enum PrincipalProp {
|
pub enum PrincipalProp {
|
||||||
// WebDAV Access Control (RFC 3744)
|
// WebDAV Access Control (RFC 3744)
|
||||||
@@ -27,10 +27,10 @@ pub enum PrincipalProp {
|
|||||||
PrincipalAddress(Option<HrefElement>),
|
PrincipalAddress(Option<HrefElement>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct AddressbookHomeSet(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
pub struct AddressbookHomeSet(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, EnumVariants, PropName, Debug)]
|
||||||
#[xml(unit_variants_ident = "PrincipalPropWrapperName", untagged)]
|
#[xml(unit_variants_ident = "PrincipalPropWrapperName", untagged)]
|
||||||
pub enum PrincipalPropWrapper {
|
pub enum PrincipalPropWrapper {
|
||||||
Principal(PrincipalProp),
|
Principal(PrincipalProp),
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
---
|
||||||
|
source: crates/carddav/src/principal/tests.rs
|
||||||
|
expression: response
|
||||||
|
---
|
||||||
|
ResponseElement {
|
||||||
|
href: "/carddav/principal/user/",
|
||||||
|
status: None,
|
||||||
|
propstat: [
|
||||||
|
Normal(
|
||||||
|
PropstatElement {
|
||||||
|
prop: PropTagWrapper(
|
||||||
|
[
|
||||||
|
Principal(
|
||||||
|
PrincipalUrl(
|
||||||
|
HrefElement {
|
||||||
|
href: "/carddav/principal/user/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
GroupMembership(
|
||||||
|
GroupMembership(
|
||||||
|
[
|
||||||
|
HrefElement {
|
||||||
|
href: "/carddav/principal/group/",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
GroupMemberSet(
|
||||||
|
GroupMemberSet(
|
||||||
|
[],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
AlternateUriSet,
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
PrincipalCollectionSet(
|
||||||
|
HrefElement {
|
||||||
|
href: "/carddav/principal/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
AddressbookHomeSet(
|
||||||
|
AddressbookHomeSet(
|
||||||
|
[
|
||||||
|
HrefElement {
|
||||||
|
href: "/carddav/principal/group/",
|
||||||
|
},
|
||||||
|
HrefElement {
|
||||||
|
href: "/carddav/principal/user/",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Principal(
|
||||||
|
PrincipalAddress(
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
Resourcetype(
|
||||||
|
Resourcetype(
|
||||||
|
[
|
||||||
|
ResourcetypeInner(
|
||||||
|
Some(
|
||||||
|
Namespace("DAV:"),
|
||||||
|
),
|
||||||
|
"collection",
|
||||||
|
),
|
||||||
|
ResourcetypeInner(
|
||||||
|
Some(
|
||||||
|
Namespace("DAV:"),
|
||||||
|
),
|
||||||
|
"principal",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
Displayname(
|
||||||
|
Some(
|
||||||
|
"user",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
CurrentUserPrincipal(
|
||||||
|
HrefElement {
|
||||||
|
href: "/carddav/principal/user/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
CurrentUserPrivilegeSet(
|
||||||
|
UserPrivilegeSet {
|
||||||
|
privileges: {
|
||||||
|
All,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Common(
|
||||||
|
Owner(
|
||||||
|
Some(
|
||||||
|
HrefElement {
|
||||||
|
href: "/carddav/principal/user/",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
status: 200,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
source: crates/carddav/src/principal/tests.rs
|
||||||
|
expression: response.serialize_to_string().unwrap()
|
||||||
|
---
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<response xmlns="DAV:">
|
||||||
|
<href>/carddav/principal/user/</href>
|
||||||
|
<propstat>
|
||||||
|
<prop xmlns="DAV:">
|
||||||
|
<principal-URL xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
|
</principal-URL>
|
||||||
|
<group-membership xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/carddav/principal/group/</href>
|
||||||
|
</group-membership>
|
||||||
|
<group-member-set xmlns="DAV:">
|
||||||
|
</group-member-set>
|
||||||
|
<alternate-URI-set xmlns="DAV:"/>
|
||||||
|
<principal-collection-set xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/carddav/principal/</href>
|
||||||
|
</principal-collection-set>
|
||||||
|
<addressbook-home-set xmlns="urn:ietf:params:xml:ns:carddav">
|
||||||
|
<href xmlns="DAV:">/carddav/principal/group/</href>
|
||||||
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
|
</addressbook-home-set>
|
||||||
|
<resourcetype xmlns="DAV:">
|
||||||
|
<collection xmlns="DAV:"/>
|
||||||
|
<principal xmlns="DAV:"/>
|
||||||
|
</resourcetype>
|
||||||
|
<displayname xmlns="DAV:">user</displayname>
|
||||||
|
<current-user-principal xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
|
</current-user-principal>
|
||||||
|
<current-user-privilege-set xmlns="DAV:">
|
||||||
|
<privilege>
|
||||||
|
<all/>
|
||||||
|
</privilege>
|
||||||
|
</current-user-privilege-set>
|
||||||
|
<owner xmlns="DAV:">
|
||||||
|
<href xmlns="DAV:">/carddav/principal/user/</href>
|
||||||
|
</owner>
|
||||||
|
</prop>
|
||||||
|
<status xmlns="DAV:">HTTP/1.1 200 OK</status>
|
||||||
|
</propstat>
|
||||||
|
</response>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
source: crates/carddav/src/principal/tests.rs
|
||||||
|
expression: propfind
|
||||||
|
---
|
||||||
|
PropfindElement {
|
||||||
|
prop: Allprop,
|
||||||
|
include: None,
|
||||||
|
}
|
||||||
41
crates/carddav/src/principal/tests.rs
Normal file
41
crates/carddav/src/principal/tests.rs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
use rustical_dav::resource::Resource;
|
||||||
|
use rustical_store::auth::Principal;
|
||||||
|
use rustical_xml::XmlSerializeRoot;
|
||||||
|
|
||||||
|
use crate::{CardDavPrincipalUri, principal::PrincipalResource};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_propfind() {
|
||||||
|
let propfind = PrincipalResource::parse_propfind(
|
||||||
|
r#"<?xml version="1.0" encoding="UTF-8"?><propfind xmlns="DAV:"><allprop/></propfind>"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
insta::assert_debug_snapshot!(propfind);
|
||||||
|
|
||||||
|
let principal = Principal {
|
||||||
|
id: "user".to_string(),
|
||||||
|
displayname: None,
|
||||||
|
principal_type: rustical_store::auth::PrincipalType::Individual,
|
||||||
|
password: None,
|
||||||
|
memberships: vec!["group".to_string()],
|
||||||
|
};
|
||||||
|
|
||||||
|
let resource = PrincipalResource {
|
||||||
|
principal: principal.clone(),
|
||||||
|
members: vec![],
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = resource
|
||||||
|
.propfind(
|
||||||
|
&format!("/carddav/principal/{}", principal.id),
|
||||||
|
&propfind.prop,
|
||||||
|
propfind.include.as_ref(),
|
||||||
|
&CardDavPrincipalUri("/carddav"),
|
||||||
|
&principal,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
insta::assert_debug_snapshot!(response);
|
||||||
|
insta::assert_snapshot!(response.serialize_to_string().unwrap());
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rustical_dav"
|
name = "rustical_dav"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
@@ -11,7 +12,6 @@ publish = false
|
|||||||
axum.workspace = true
|
axum.workspace = true
|
||||||
tower.workspace = true
|
tower.workspace = true
|
||||||
axum-extra.workspace = true
|
axum-extra.workspace = true
|
||||||
|
|
||||||
rustical_xml.workspace = true
|
rustical_xml.workspace = true
|
||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
futures-util.workspace = true
|
futures-util.workspace = true
|
||||||
@@ -28,3 +28,7 @@ headers.workspace = true
|
|||||||
strum.workspace = true
|
strum.workspace = true
|
||||||
matchit.workspace = true
|
matchit.workspace = true
|
||||||
matchit-serde.workspace = true
|
matchit-serde.workspace = true
|
||||||
|
ical = { workspace = true, optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
ical = ["dep:ical"]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, PropName, EnumVariants)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Debug, Clone, PropName, EnumVariants)]
|
||||||
#[xml(unit_variants_ident = "CommonPropertiesPropName")]
|
#[xml(unit_variants_ident = "CommonPropertiesPropName")]
|
||||||
pub enum CommonPropertiesProp {
|
pub enum CommonPropertiesProp {
|
||||||
// WebDAV (RFC 2518)
|
// WebDAV (RFC 2518)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, PropName, EnumVariants)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, PropName, EnumVariants, Debug)]
|
||||||
#[xml(unit_variants_ident = "SyncTokenExtensionPropName")]
|
#[xml(unit_variants_ident = "SyncTokenExtensionPropName")]
|
||||||
pub enum SyncTokenExtensionProp {
|
pub enum SyncTokenExtensionProp {
|
||||||
// Collection Synchronization (RFC 6578)
|
// Collection Synchronization (RFC 6578)
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ pub async fn route_delete<R: ResourceService>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(if_match) = if_match {
|
if let Some(if_match) = if_match {
|
||||||
dbg!(&if_match);
|
|
||||||
if !resource.satisfies_if_match(&if_match) {
|
if !resource.satisfies_if_match(&if_match) {
|
||||||
// Precondition failed
|
// Precondition failed
|
||||||
return Err(crate::Error::PreconditionFailed.into());
|
return Err(crate::Error::PreconditionFailed.into());
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ pub async fn route_proppatch<R: ResourceService>(
|
|||||||
.get_resource(path_components, false)
|
.get_resource(path_components, false)
|
||||||
.await?;
|
.await?;
|
||||||
let privileges = resource.get_user_privileges(principal)?;
|
let privileges = resource.get_user_privileges(principal)?;
|
||||||
if !privileges.has(&UserPrivilege::Write) {
|
if !privileges.has(&UserPrivilege::WriteProperties) {
|
||||||
return Err(Error::Unauthorized.into());
|
return Err(Error::Unauthorized.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ pub use resource_service::ResourceService;
|
|||||||
use rustical_xml::{
|
use rustical_xml::{
|
||||||
EnumVariants, NamespaceOwned, PropName, XmlDeserialize, XmlDocument, XmlSerialize,
|
EnumVariants, NamespaceOwned, PropName, XmlDeserialize, XmlDocument, XmlSerialize,
|
||||||
};
|
};
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
mod axum_methods;
|
mod axum_methods;
|
||||||
@@ -30,7 +31,7 @@ pub trait ResourcePropName: FromStr {}
|
|||||||
impl<T: FromStr> ResourcePropName for T {}
|
impl<T: FromStr> ResourcePropName for T {}
|
||||||
|
|
||||||
pub trait ResourceName {
|
pub trait ResourceName {
|
||||||
fn get_name(&self) -> String;
|
fn get_name(&self) -> Cow<'_, str>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Resource: Clone + Send + 'static {
|
pub trait Resource: Clone + Send + 'static {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use crate::xml::HrefElement;
|
use crate::xml::HrefElement;
|
||||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct GroupMemberSet(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
pub struct GroupMemberSet(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
||||||
|
|||||||
@@ -15,3 +15,7 @@ mod report_set;
|
|||||||
pub use report_set::SupportedReportSet;
|
pub use report_set::SupportedReportSet;
|
||||||
mod group;
|
mod group;
|
||||||
pub use group::*;
|
pub use group::*;
|
||||||
|
#[cfg(feature = "ical")]
|
||||||
|
mod text_match;
|
||||||
|
#[cfg(feature = "ical")]
|
||||||
|
pub use text_match::*;
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ use headers::{CacheControl, ContentType, HeaderMapExt};
|
|||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use quick_xml::name::Namespace;
|
use quick_xml::name::Namespace;
|
||||||
use rustical_xml::{XmlRootTag, XmlSerialize, XmlSerializeRoot};
|
use rustical_xml::{XmlRootTag, XmlSerialize, XmlSerializeRoot};
|
||||||
use std::collections::HashMap;
|
use std::{collections::HashMap, fmt::Debug};
|
||||||
|
|
||||||
#[derive(XmlSerialize)]
|
#[derive(XmlSerialize, Debug)]
|
||||||
pub struct PropTagWrapper<T: XmlSerialize>(#[xml(flatten, ty = "untagged")] pub Vec<T>);
|
pub struct PropTagWrapper<T: XmlSerialize>(#[xml(flatten, ty = "untagged")] pub Vec<T>);
|
||||||
|
|
||||||
// RFC 2518
|
// RFC 2518
|
||||||
@@ -30,7 +30,7 @@ fn xml_serialize_status(
|
|||||||
XmlSerialize::serialize(&format!("HTTP/1.1 {status}"), ns, tag, namespaces, writer)
|
XmlSerialize::serialize(&format!("HTTP/1.1 {status}"), ns, tag, namespaces, writer)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlSerialize)]
|
#[derive(XmlSerialize, Debug)]
|
||||||
#[xml(untagged)]
|
#[xml(untagged)]
|
||||||
pub enum PropstatWrapper<T: XmlSerialize> {
|
pub enum PropstatWrapper<T: XmlSerialize> {
|
||||||
Normal(PropstatElement<PropTagWrapper<T>>),
|
Normal(PropstatElement<PropTagWrapper<T>>),
|
||||||
@@ -40,15 +40,8 @@ pub enum PropstatWrapper<T: XmlSerialize> {
|
|||||||
// RFC 2518
|
// RFC 2518
|
||||||
// <!ELEMENT response (href, ((href*, status)|(propstat+)),
|
// <!ELEMENT response (href, ((href*, status)|(propstat+)),
|
||||||
// responsedescription?) >
|
// responsedescription?) >
|
||||||
#[derive(XmlSerialize, XmlRootTag)]
|
#[derive(XmlSerialize, XmlRootTag, Debug)]
|
||||||
#[xml(ns = "crate::namespace::NS_DAV", root = "response")]
|
#[xml(ns = "crate::namespace::NS_DAV", root = "response")]
|
||||||
#[xml(ns_prefix(
|
|
||||||
crate::namespace::NS_DAV = "",
|
|
||||||
crate::namespace::NS_CARDDAV = "CARD",
|
|
||||||
crate::namespace::NS_CALDAV = "CAL",
|
|
||||||
crate::namespace::NS_CALENDARSERVER = "CS",
|
|
||||||
crate::namespace::NS_DAVPUSH = "PUSH"
|
|
||||||
))]
|
|
||||||
pub struct ResponseElement<PropstatType: XmlSerialize> {
|
pub struct ResponseElement<PropstatType: XmlSerialize> {
|
||||||
pub href: String,
|
pub href: String,
|
||||||
#[xml(serialize_with = "xml_serialize_optional_status")]
|
#[xml(serialize_with = "xml_serialize_optional_status")]
|
||||||
|
|||||||
154
crates/dav/src/xml/text_match.rs
Normal file
154
crates/dav/src/xml/text_match.rs
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
use ical::property::Property;
|
||||||
|
use rustical_xml::{ValueDeserialize, XmlDeserialize};
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
||||||
|
pub enum TextCollation {
|
||||||
|
#[default]
|
||||||
|
AsciiCasemap,
|
||||||
|
UnicodeCasemap,
|
||||||
|
Octet,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TextCollation {
|
||||||
|
#[must_use]
|
||||||
|
pub fn normalise<'a>(&self, value: &'a str) -> Cow<'a, str> {
|
||||||
|
match self {
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc4790#section-9.2
|
||||||
|
Self::AsciiCasemap => Cow::from(value.to_ascii_uppercase()),
|
||||||
|
Self::UnicodeCasemap => Cow::from(value.to_uppercase()),
|
||||||
|
Self::Octet => Cow::from(value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsRef<str> for TextCollation {
|
||||||
|
fn as_ref(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
Self::AsciiCasemap => "i;ascii-casemap",
|
||||||
|
Self::UnicodeCasemap => "i;unicode-casemap",
|
||||||
|
Self::Octet => "i;octet",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ValueDeserialize for TextCollation {
|
||||||
|
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
||||||
|
match val {
|
||||||
|
"i;ascii-casemap" => Ok(Self::AsciiCasemap),
|
||||||
|
"i;unicode-casemap" => Ok(Self::UnicodeCasemap),
|
||||||
|
"i;octet" => Ok(Self::Octet),
|
||||||
|
_ => Err(rustical_xml::XmlError::InvalidVariant(format!(
|
||||||
|
"Invalid collation: {val}"
|
||||||
|
))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
||||||
|
pub struct NegateCondition(pub bool);
|
||||||
|
|
||||||
|
impl ValueDeserialize for NegateCondition {
|
||||||
|
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
||||||
|
match val {
|
||||||
|
"yes" => Ok(Self(true)),
|
||||||
|
"no" => Ok(Self(false)),
|
||||||
|
_ => Err(rustical_xml::XmlError::InvalidVariant(format!(
|
||||||
|
"Invalid negate-condition parameter: {val}"
|
||||||
|
))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
||||||
|
pub enum MatchType {
|
||||||
|
Equals,
|
||||||
|
#[default]
|
||||||
|
Contains,
|
||||||
|
StartsWith,
|
||||||
|
EndsWith,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MatchType {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_text(&self, collation: &TextCollation, needle: &str, haystack: &str) -> bool {
|
||||||
|
let haystack = collation.normalise(haystack);
|
||||||
|
let needle = collation.normalise(needle);
|
||||||
|
|
||||||
|
match &self {
|
||||||
|
Self::Equals => haystack == needle,
|
||||||
|
Self::Contains => haystack.contains(needle.as_ref()),
|
||||||
|
Self::StartsWith => haystack.starts_with(needle.as_ref()),
|
||||||
|
Self::EndsWith => haystack.ends_with(needle.as_ref()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ValueDeserialize for MatchType {
|
||||||
|
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
||||||
|
Ok(match val {
|
||||||
|
"equals" => Self::Equals,
|
||||||
|
"contains" => Self::Contains,
|
||||||
|
"starts-with" => Self::StartsWith,
|
||||||
|
"ends-with" => Self::EndsWith,
|
||||||
|
_ => {
|
||||||
|
return Err(rustical_xml::XmlError::InvalidVariant(format!(
|
||||||
|
"Invalid match-type parameter: {val}"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct TextMatchElement {
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub collation: TextCollation,
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub negate_condition: NegateCondition,
|
||||||
|
#[xml(ty = "attr", default = "Default::default")]
|
||||||
|
pub match_type: MatchType,
|
||||||
|
#[xml(ty = "text")]
|
||||||
|
pub needle: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TextMatchElement {
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_text(&self, haystack: &str) -> bool {
|
||||||
|
let Self {
|
||||||
|
collation,
|
||||||
|
negate_condition,
|
||||||
|
needle,
|
||||||
|
match_type,
|
||||||
|
} = self;
|
||||||
|
|
||||||
|
let matches = match_type.match_text(collation, needle, haystack);
|
||||||
|
// XOR
|
||||||
|
negate_condition.0 ^ matches
|
||||||
|
}
|
||||||
|
#[must_use]
|
||||||
|
pub fn match_property(&self, property: &Property) -> bool {
|
||||||
|
let text = property.value.as_deref().unwrap_or("");
|
||||||
|
self.match_text(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::TextCollation;
|
||||||
|
use crate::xml::MatchType;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_collation() {
|
||||||
|
assert!(!MatchType::Contains.match_text(&TextCollation::AsciiCasemap, "GrÜN", "grünsd"));
|
||||||
|
assert!(MatchType::Contains.match_text(&TextCollation::AsciiCasemap, "GrüN", "grün"));
|
||||||
|
assert!(!MatchType::Contains.match_text(&TextCollation::Octet, "GrüN", "grün"));
|
||||||
|
assert!(MatchType::Contains.match_text(&TextCollation::UnicodeCasemap, "GrÜN", "grün"));
|
||||||
|
assert!(MatchType::Contains.match_text(&TextCollation::AsciiCasemap, "GrüN", "grün"));
|
||||||
|
assert!(MatchType::Contains.match_text(&TextCollation::AsciiCasemap, "GrüN", "grün"));
|
||||||
|
assert!(MatchType::StartsWith.match_text(&TextCollation::Octet, "hello", "hello you"));
|
||||||
|
assert!(MatchType::EndsWith.match_text(&TextCollation::Octet, "mama", "joe mama"));
|
||||||
|
assert!(MatchType::Equals.match_text(&TextCollation::UnicodeCasemap, "GrÜN", "grün"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rustical_dav_push"
|
name = "rustical_dav_push"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
@@ -9,15 +10,15 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustical_xml.workspace = true
|
rustical_xml.workspace = true
|
||||||
async-trait = { workspace = true }
|
async-trait.workspace = true
|
||||||
futures-util = { workspace = true }
|
futures-util.workspace = true
|
||||||
quick-xml = { workspace = true }
|
quick-xml.workspace = true
|
||||||
serde = { workspace = true }
|
serde.workspace = true
|
||||||
thiserror = { workspace = true }
|
thiserror.workspace = true
|
||||||
itertools = { workspace = true }
|
itertools.workspace = true
|
||||||
log = { workspace = true }
|
log.workspace = true
|
||||||
derive_more = { workspace = true }
|
derive_more.workspace = true
|
||||||
tracing = { workspace = true }
|
tracing.workspace = true
|
||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
rustical_dav.workspace = true
|
rustical_dav.workspace = true
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use crate::{ContentUpdate, PropertyUpdate, SupportedTriggers, Transports, Trigge
|
|||||||
use rustical_dav::header::Depth;
|
use rustical_dav::header::Depth;
|
||||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, PropName, EnumVariants)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, PropName, EnumVariants, Debug)]
|
||||||
#[xml(unit_variants_ident = "DavPushExtensionPropName")]
|
#[xml(unit_variants_ident = "DavPushExtensionPropName")]
|
||||||
pub enum DavPushExtensionProp {
|
pub enum DavPushExtensionProp {
|
||||||
// WebDav Push
|
// WebDav Push
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ impl<S: SubscriptionStore> DavPushController<S> {
|
|||||||
let mut latest_messages = HashMap::new();
|
let mut latest_messages = HashMap::new();
|
||||||
for message in messages {
|
for message in messages {
|
||||||
if matches!(message.data, CollectionOperationInfo::Content { .. }) {
|
if matches!(message.data, CollectionOperationInfo::Content { .. }) {
|
||||||
latest_messages.insert(message.topic.to_string(), message);
|
latest_messages.insert(message.topic.clone(), message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let messages = latest_messages.into_values();
|
let messages = latest_messages.into_values();
|
||||||
@@ -156,12 +156,13 @@ impl<S: SubscriptionStore> DavPushController<S> {
|
|||||||
) -> Result<(), NotifierError> {
|
) -> Result<(), NotifierError> {
|
||||||
if subsciption.public_key_type != "p256dh" {
|
if subsciption.public_key_type != "p256dh" {
|
||||||
return Err(NotifierError::InvalidPublicKeyType(
|
return Err(NotifierError::InvalidPublicKeyType(
|
||||||
subsciption.public_key_type.to_string(),
|
subsciption.public_key_type.clone(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let endpoint = subsciption.push_resource.parse().map_err(|_| {
|
let endpoint = subsciption
|
||||||
NotifierError::InvalidEndpointUrl(subsciption.push_resource.to_string())
|
.push_resource
|
||||||
})?;
|
.parse()
|
||||||
|
.map_err(|_| NotifierError::InvalidEndpointUrl(subsciption.push_resource.clone()))?;
|
||||||
let ua_public = base64::engine::general_purpose::URL_SAFE_NO_PAD
|
let ua_public = base64::engine::general_purpose::URL_SAFE_NO_PAD
|
||||||
.decode(&subsciption.public_key)
|
.decode(&subsciption.public_key)
|
||||||
.map_err(|_| NotifierError::InvalidKeyEncoding)?;
|
.map_err(|_| NotifierError::InvalidKeyEncoding)?;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ impl Default for Transports {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone)]
|
#[derive(XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct SupportedTriggers(#[xml(flatten, ty = "untagged")] pub Vec<Trigger>);
|
pub struct SupportedTriggers(#[xml(flatten, ty = "untagged")] pub Vec<Trigger>);
|
||||||
|
|
||||||
#[derive(XmlSerialize, XmlDeserialize, PartialEq, Eq, Debug, Clone)]
|
#[derive(XmlSerialize, XmlDeserialize, PartialEq, Eq, Debug, Clone)]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rustical_frontend"
|
name = "rustical_frontend"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
@@ -39,3 +40,6 @@ headers.workspace = true
|
|||||||
tower-sessions.workspace = true
|
tower-sessions.workspace = true
|
||||||
percent-encoding.workspace = true
|
percent-encoding.workspace = true
|
||||||
tower-http = { workspace = true, optional = true }
|
tower-http = { workspace = true, optional = true }
|
||||||
|
vtimezones-rs.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
itertools.workspace = true
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"@deno/vite-plugin": "npm:@deno/vite-plugin@^1.0.5",
|
"@deno/vite-plugin": "npm:@deno/vite-plugin@^1.0.6",
|
||||||
"lit": "npm:lit@^3.3.1",
|
"lit": "npm:lit@^3.3.1",
|
||||||
"vite": "npm:vite@^7.1.7"
|
"vite": "npm:vite@^7.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
218
crates/frontend/js-components/deno.lock
generated
218
crates/frontend/js-components/deno.lock
generated
@@ -1,145 +1,145 @@
|
|||||||
{
|
{
|
||||||
"version": "5",
|
"version": "5",
|
||||||
"specifiers": {
|
"specifiers": {
|
||||||
"npm:@deno/vite-plugin@^1.0.5": "1.0.5_vite@7.1.7__picomatch@4.0.3",
|
"npm:@deno/vite-plugin@^1.0.6": "1.0.6_vite@7.3.0__picomatch@4.0.3",
|
||||||
"npm:lit@^3.3.1": "3.3.1",
|
"npm:lit@^3.3.1": "3.3.1",
|
||||||
"npm:vite@*": "7.1.7_picomatch@4.0.3",
|
"npm:vite@*": "7.3.0_picomatch@4.0.3",
|
||||||
"npm:vite@^7.1.7": "7.1.7_picomatch@4.0.3"
|
"npm:vite@^7.3.0": "7.3.0_picomatch@4.0.3"
|
||||||
},
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
"@deno/vite-plugin@1.0.5_vite@7.1.7__picomatch@4.0.3": {
|
"@deno/vite-plugin@1.0.6_vite@7.3.0__picomatch@4.0.3": {
|
||||||
"integrity": "sha512-tLja5n4dyMhcze1NzvSs2iiriBymfBlDCZIrjMTxb9O2ru0gvmV6mn5oBD2teNw5Sd92cj3YJzKwsAs8tMJXlg==",
|
"integrity": "sha512-Sh5XqvFuKAwjARTesi0n6xRpEXm1V0UeqKh+SxIrexCofxOaieNDMqXZD02RiZCg0mrJ43V8eCMuVrDfq6mLmg==",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"vite"
|
"vite"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"@esbuild/aix-ppc64@0.25.10": {
|
"@esbuild/aix-ppc64@0.27.1": {
|
||||||
"integrity": "sha512-0NFWnA+7l41irNuaSVlLfgNT12caWJVLzp5eAVhZ0z1qpxbockccEt3s+149rE64VUI3Ml2zt8Nv5JVc4QXTsw==",
|
"integrity": "sha512-HHB50pdsBX6k47S4u5g/CaLjqS3qwaOVE5ILsq64jyzgMhLuCuZ8rGzM9yhsAjfjkbgUPMzZEPa7DAp7yz6vuA==",
|
||||||
"os": ["aix"],
|
"os": ["aix"],
|
||||||
"cpu": ["ppc64"]
|
"cpu": ["ppc64"]
|
||||||
},
|
},
|
||||||
"@esbuild/android-arm64@0.25.10": {
|
"@esbuild/android-arm64@0.27.1": {
|
||||||
"integrity": "sha512-LSQa7eDahypv/VO6WKohZGPSJDq5OVOo3UoFR1E4t4Gj1W7zEQMUhI+lo81H+DtB+kP+tDgBp+M4oNCwp6kffg==",
|
"integrity": "sha512-45fuKmAJpxnQWixOGCrS+ro4Uvb4Re9+UTieUY2f8AEc+t7d4AaZ6eUJ3Hva7dtrxAAWHtlEFsXFMAgNnGU9uQ==",
|
||||||
"os": ["android"],
|
"os": ["android"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/android-arm@0.25.10": {
|
"@esbuild/android-arm@0.27.1": {
|
||||||
"integrity": "sha512-dQAxF1dW1C3zpeCDc5KqIYuZ1tgAdRXNoZP7vkBIRtKZPYe2xVr/d3SkirklCHudW1B45tGiUlz2pUWDfbDD4w==",
|
"integrity": "sha512-kFqa6/UcaTbGm/NncN9kzVOODjhZW8e+FRdSeypWe6j33gzclHtwlANs26JrupOntlcWmB0u8+8HZo8s7thHvg==",
|
||||||
"os": ["android"],
|
"os": ["android"],
|
||||||
"cpu": ["arm"]
|
"cpu": ["arm"]
|
||||||
},
|
},
|
||||||
"@esbuild/android-x64@0.25.10": {
|
"@esbuild/android-x64@0.27.1": {
|
||||||
"integrity": "sha512-MiC9CWdPrfhibcXwr39p9ha1x0lZJ9KaVfvzA0Wxwz9ETX4v5CHfF09bx935nHlhi+MxhA63dKRRQLiVgSUtEg==",
|
"integrity": "sha512-LBEpOz0BsgMEeHgenf5aqmn/lLNTFXVfoWMUox8CtWWYK9X4jmQzWjoGoNb8lmAYml/tQ/Ysvm8q7szu7BoxRQ==",
|
||||||
"os": ["android"],
|
"os": ["android"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/darwin-arm64@0.25.10": {
|
"@esbuild/darwin-arm64@0.27.1": {
|
||||||
"integrity": "sha512-JC74bdXcQEpW9KkV326WpZZjLguSZ3DfS8wrrvPMHgQOIEIG/sPXEN/V8IssoJhbefLRcRqw6RQH2NnpdprtMA==",
|
"integrity": "sha512-veg7fL8eMSCVKL7IW4pxb54QERtedFDfY/ASrumK/SbFsXnRazxY4YykN/THYqFnFwJ0aVjiUrVG2PwcdAEqQQ==",
|
||||||
"os": ["darwin"],
|
"os": ["darwin"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/darwin-x64@0.25.10": {
|
"@esbuild/darwin-x64@0.27.1": {
|
||||||
"integrity": "sha512-tguWg1olF6DGqzws97pKZ8G2L7Ig1vjDmGTwcTuYHbuU6TTjJe5FXbgs5C1BBzHbJ2bo1m3WkQDbWO2PvamRcg==",
|
"integrity": "sha512-+3ELd+nTzhfWb07Vol7EZ+5PTbJ/u74nC6iv4/lwIU99Ip5uuY6QoIf0Hn4m2HoV0qcnRivN3KSqc+FyCHjoVQ==",
|
||||||
"os": ["darwin"],
|
"os": ["darwin"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/freebsd-arm64@0.25.10": {
|
"@esbuild/freebsd-arm64@0.27.1": {
|
||||||
"integrity": "sha512-3ZioSQSg1HT2N05YxeJWYR+Libe3bREVSdWhEEgExWaDtyFbbXWb49QgPvFH8u03vUPX10JhJPcz7s9t9+boWg==",
|
"integrity": "sha512-/8Rfgns4XD9XOSXlzUDepG8PX+AVWHliYlUkFI3K3GB6tqbdjYqdhcb4BKRd7C0BhZSoaCxhv8kTcBrcZWP+xg==",
|
||||||
"os": ["freebsd"],
|
"os": ["freebsd"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/freebsd-x64@0.25.10": {
|
"@esbuild/freebsd-x64@0.27.1": {
|
||||||
"integrity": "sha512-LLgJfHJk014Aa4anGDbh8bmI5Lk+QidDmGzuC2D+vP7mv/GeSN+H39zOf7pN5N8p059FcOfs2bVlrRr4SK9WxA==",
|
"integrity": "sha512-GITpD8dK9C+r+5yRT/UKVT36h/DQLOHdwGVwwoHidlnA168oD3uxA878XloXebK4Ul3gDBBIvEdL7go9gCUFzQ==",
|
||||||
"os": ["freebsd"],
|
"os": ["freebsd"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-arm64@0.25.10": {
|
"@esbuild/linux-arm64@0.27.1": {
|
||||||
"integrity": "sha512-5luJWN6YKBsawd5f9i4+c+geYiVEw20FVW5x0v1kEMWNq8UctFjDiMATBxLvmmHA4bf7F6hTRaJgtghFr9iziQ==",
|
"integrity": "sha512-W9//kCrh/6in9rWIBdKaMtuTTzNj6jSeG/haWBADqLLa9P8O5YSRDzgD5y9QBok4AYlzS6ARHifAb75V6G670Q==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-arm@0.25.10": {
|
"@esbuild/linux-arm@0.27.1": {
|
||||||
"integrity": "sha512-oR31GtBTFYCqEBALI9r6WxoU/ZofZl962pouZRTEYECvNF/dtXKku8YXcJkhgK/beU+zedXfIzHijSRapJY3vg==",
|
"integrity": "sha512-ieMID0JRZY/ZeCrsFQ3Y3NlHNCqIhTprJfDgSB3/lv5jJZ8FX3hqPyXWhe+gvS5ARMBJ242PM+VNz/ctNj//eA==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm"]
|
"cpu": ["arm"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-ia32@0.25.10": {
|
"@esbuild/linux-ia32@0.27.1": {
|
||||||
"integrity": "sha512-NrSCx2Kim3EnnWgS4Txn0QGt0Xipoumb6z6sUtl5bOEZIVKhzfyp/Lyw4C1DIYvzeW/5mWYPBFJU3a/8Yr75DQ==",
|
"integrity": "sha512-VIUV4z8GD8rtSVMfAj1aXFahsi/+tcoXXNYmXgzISL+KB381vbSTNdeZHHHIYqFyXcoEhu9n5cT+05tRv13rlw==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["ia32"]
|
"cpu": ["ia32"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-loong64@0.25.10": {
|
"@esbuild/linux-loong64@0.27.1": {
|
||||||
"integrity": "sha512-xoSphrd4AZda8+rUDDfD9J6FUMjrkTz8itpTITM4/xgerAZZcFW7Dv+sun7333IfKxGG8gAq+3NbfEMJfiY+Eg==",
|
"integrity": "sha512-l4rfiiJRN7sTNI//ff65zJ9z8U+k6zcCg0LALU5iEWzY+a1mVZ8iWC1k5EsNKThZ7XCQ6YWtsZ8EWYm7r1UEsg==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["loong64"]
|
"cpu": ["loong64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-mips64el@0.25.10": {
|
"@esbuild/linux-mips64el@0.27.1": {
|
||||||
"integrity": "sha512-ab6eiuCwoMmYDyTnyptoKkVS3k8fy/1Uvq7Dj5czXI6DF2GqD2ToInBI0SHOp5/X1BdZ26RKc5+qjQNGRBelRA==",
|
"integrity": "sha512-U0bEuAOLvO/DWFdygTHWY8C067FXz+UbzKgxYhXC0fDieFa0kDIra1FAhsAARRJbvEyso8aAqvPdNxzWuStBnA==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["mips64el"]
|
"cpu": ["mips64el"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-ppc64@0.25.10": {
|
"@esbuild/linux-ppc64@0.27.1": {
|
||||||
"integrity": "sha512-NLinzzOgZQsGpsTkEbdJTCanwA5/wozN9dSgEl12haXJBzMTpssebuXR42bthOF3z7zXFWH1AmvWunUCkBE4EA==",
|
"integrity": "sha512-NzdQ/Xwu6vPSf/GkdmRNsOfIeSGnh7muundsWItmBsVpMoNPVpM61qNzAVY3pZ1glzzAxLR40UyYM23eaDDbYQ==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["ppc64"]
|
"cpu": ["ppc64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-riscv64@0.25.10": {
|
"@esbuild/linux-riscv64@0.27.1": {
|
||||||
"integrity": "sha512-FE557XdZDrtX8NMIeA8LBJX3dC2M8VGXwfrQWU7LB5SLOajfJIxmSdyL/gU1m64Zs9CBKvm4UAuBp5aJ8OgnrA==",
|
"integrity": "sha512-7zlw8p3IApcsN7mFw0O1Z1PyEk6PlKMu18roImfl3iQHTnr/yAfYv6s4hXPidbDoI2Q0pW+5xeoM4eTCC0UdrQ==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["riscv64"]
|
"cpu": ["riscv64"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-s390x@0.25.10": {
|
"@esbuild/linux-s390x@0.27.1": {
|
||||||
"integrity": "sha512-3BBSbgzuB9ajLoVZk0mGu+EHlBwkusRmeNYdqmznmMc9zGASFjSsxgkNsqmXugpPk00gJ0JNKh/97nxmjctdew==",
|
"integrity": "sha512-cGj5wli+G+nkVQdZo3+7FDKC25Uh4ZVwOAK6A06Hsvgr8WqBBuOy/1s+PUEd/6Je+vjfm6stX0kmib5b/O2Ykw==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["s390x"]
|
"cpu": ["s390x"]
|
||||||
},
|
},
|
||||||
"@esbuild/linux-x64@0.25.10": {
|
"@esbuild/linux-x64@0.27.1": {
|
||||||
"integrity": "sha512-QSX81KhFoZGwenVyPoberggdW1nrQZSvfVDAIUXr3WqLRZGZqWk/P4T8p2SP+de2Sr5HPcvjhcJzEiulKgnxtA==",
|
"integrity": "sha512-z3H/HYI9MM0HTv3hQZ81f+AKb+yEoCRlUby1F80vbQ5XdzEMyY/9iNlAmhqiBKw4MJXwfgsh7ERGEOhrM1niMA==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/netbsd-arm64@0.25.10": {
|
"@esbuild/netbsd-arm64@0.27.1": {
|
||||||
"integrity": "sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==",
|
"integrity": "sha512-wzC24DxAvk8Em01YmVXyjl96Mr+ecTPyOuADAvjGg+fyBpGmxmcr2E5ttf7Im8D0sXZihpxzO1isus8MdjMCXQ==",
|
||||||
"os": ["netbsd"],
|
"os": ["netbsd"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/netbsd-x64@0.25.10": {
|
"@esbuild/netbsd-x64@0.27.1": {
|
||||||
"integrity": "sha512-7RTytDPGU6fek/hWuN9qQpeGPBZFfB4zZgcz2VK2Z5VpdUxEI8JKYsg3JfO0n/Z1E/6l05n0unDCNc4HnhQGig==",
|
"integrity": "sha512-1YQ8ybGi2yIXswu6eNzJsrYIGFpnlzEWRl6iR5gMgmsrR0FcNoV1m9k9sc3PuP5rUBLshOZylc9nqSgymI+TYg==",
|
||||||
"os": ["netbsd"],
|
"os": ["netbsd"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/openbsd-arm64@0.25.10": {
|
"@esbuild/openbsd-arm64@0.27.1": {
|
||||||
"integrity": "sha512-5Se0VM9Wtq797YFn+dLimf2Zx6McttsH2olUBsDml+lm0GOCRVebRWUvDtkY4BWYv/3NgzS8b/UM3jQNh5hYyw==",
|
"integrity": "sha512-5Z+DzLCrq5wmU7RDaMDe2DVXMRm2tTDvX2KU14JJVBN2CT/qov7XVix85QoJqHltpvAOZUAc3ndU56HSMWrv8g==",
|
||||||
"os": ["openbsd"],
|
"os": ["openbsd"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/openbsd-x64@0.25.10": {
|
"@esbuild/openbsd-x64@0.27.1": {
|
||||||
"integrity": "sha512-XkA4frq1TLj4bEMB+2HnI0+4RnjbuGZfet2gs/LNs5Hc7D89ZQBHQ0gL2ND6Lzu1+QVkjp3x1gIcPKzRNP8bXw==",
|
"integrity": "sha512-Q73ENzIdPF5jap4wqLtsfh8YbYSZ8Q0wnxplOlZUOyZy7B4ZKW8DXGWgTCZmF8VWD7Tciwv5F4NsRf6vYlZtqg==",
|
||||||
"os": ["openbsd"],
|
"os": ["openbsd"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/openharmony-arm64@0.25.10": {
|
"@esbuild/openharmony-arm64@0.27.1": {
|
||||||
"integrity": "sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==",
|
"integrity": "sha512-ajbHrGM/XiK+sXM0JzEbJAen+0E+JMQZ2l4RR4VFwvV9JEERx+oxtgkpoKv1SevhjavK2z2ReHk32pjzktWbGg==",
|
||||||
"os": ["openharmony"],
|
"os": ["openharmony"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/sunos-x64@0.25.10": {
|
"@esbuild/sunos-x64@0.27.1": {
|
||||||
"integrity": "sha512-fswk3XT0Uf2pGJmOpDB7yknqhVkJQkAQOcW/ccVOtfx05LkbWOaRAtn5SaqXypeKQra1QaEa841PgrSL9ubSPQ==",
|
"integrity": "sha512-IPUW+y4VIjuDVn+OMzHc5FV4GubIwPnsz6ubkvN8cuhEqH81NovB53IUlrlBkPMEPxvNnf79MGBoz8rZ2iW8HA==",
|
||||||
"os": ["sunos"],
|
"os": ["sunos"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@esbuild/win32-arm64@0.25.10": {
|
"@esbuild/win32-arm64@0.27.1": {
|
||||||
"integrity": "sha512-ah+9b59KDTSfpaCg6VdJoOQvKjI33nTaQr4UluQwW7aEwZQsbMCfTmfEO4VyewOxx4RaDT/xCy9ra2GPWmO7Kw==",
|
"integrity": "sha512-RIVRWiljWA6CdVu8zkWcRmGP7iRRIIwvhDKem8UMBjPql2TXM5PkDVvvrzMtj1V+WFPB4K7zkIGM7VzRtFkjdg==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@esbuild/win32-ia32@0.25.10": {
|
"@esbuild/win32-ia32@0.27.1": {
|
||||||
"integrity": "sha512-QHPDbKkrGO8/cz9LKVnJU22HOi4pxZnZhhA2HYHez5Pz4JeffhDjf85E57Oyco163GnzNCVkZK0b/n4Y0UHcSw==",
|
"integrity": "sha512-2BR5M8CPbptC1AK5JbJT1fWrHLvejwZidKx3UMSF0ecHMa+smhi16drIrCEggkgviBwLYd5nwrFLSl5Kho96RQ==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["ia32"]
|
"cpu": ["ia32"]
|
||||||
},
|
},
|
||||||
"@esbuild/win32-x64@0.25.10": {
|
"@esbuild/win32-x64@0.27.1": {
|
||||||
"integrity": "sha512-9KpxSVFCu0iK1owoez6aC/s/EdUQLDN3adTxGCqxMVhrPDj6bt5dbrHDXUuq+Bs2vATFBBrQS5vdQ/Ed2P+nbw==",
|
"integrity": "sha512-d5X6RMYv6taIymSk8JBP+nxv8DQAMY6A51GPgusqLdK9wBz5wWIXy1KjTck6HnjE9hqJzJRdk+1p/t5soSbCtw==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
@@ -152,113 +152,113 @@
|
|||||||
"@lit-labs/ssr-dom-shim"
|
"@lit-labs/ssr-dom-shim"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-android-arm-eabi@4.52.2": {
|
"@rollup/rollup-android-arm-eabi@4.52.5": {
|
||||||
"integrity": "sha512-o3pcKzJgSGt4d74lSZ+OCnHwkKBeAbFDmbEm5gg70eA8VkyCuC/zV9TwBnmw6VjDlRdF4Pshfb+WE9E6XY1PoQ==",
|
"integrity": "sha512-8c1vW4ocv3UOMp9K+gToY5zL2XiiVw3k7f1ksf4yO1FlDFQ1C2u72iACFnSOceJFsWskc2WZNqeRhFRPzv+wtQ==",
|
||||||
"os": ["android"],
|
"os": ["android"],
|
||||||
"cpu": ["arm"]
|
"cpu": ["arm"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-android-arm64@4.52.2": {
|
"@rollup/rollup-android-arm64@4.52.5": {
|
||||||
"integrity": "sha512-cqFSWO5tX2vhC9hJTK8WAiPIm4Q8q/cU8j2HQA0L3E1uXvBYbOZMhE2oFL8n2pKB5sOCHY6bBuHaRwG7TkfJyw==",
|
"integrity": "sha512-mQGfsIEFcu21mvqkEKKu2dYmtuSZOBMmAl5CFlPGLY94Vlcm+zWApK7F/eocsNzp8tKmbeBP8yXyAbx0XHsFNA==",
|
||||||
"os": ["android"],
|
"os": ["android"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-darwin-arm64@4.52.2": {
|
"@rollup/rollup-darwin-arm64@4.52.5": {
|
||||||
"integrity": "sha512-vngduywkkv8Fkh3wIZf5nFPXzWsNsVu1kvtLETWxTFf/5opZmflgVSeLgdHR56RQh71xhPhWoOkEBvbehwTlVA==",
|
"integrity": "sha512-takF3CR71mCAGA+v794QUZ0b6ZSrgJkArC+gUiG6LB6TQty9T0Mqh3m2ImRBOxS2IeYBo4lKWIieSvnEk2OQWA==",
|
||||||
"os": ["darwin"],
|
"os": ["darwin"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-darwin-x64@4.52.2": {
|
"@rollup/rollup-darwin-x64@4.52.5": {
|
||||||
"integrity": "sha512-h11KikYrUCYTrDj6h939hhMNlqU2fo/X4NB0OZcys3fya49o1hmFaczAiJWVAFgrM1NCP6RrO7lQKeVYSKBPSQ==",
|
"integrity": "sha512-W901Pla8Ya95WpxDn//VF9K9u2JbocwV/v75TE0YIHNTbhqUTv9w4VuQ9MaWlNOkkEfFwkdNhXgcLqPSmHy0fA==",
|
||||||
"os": ["darwin"],
|
"os": ["darwin"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-freebsd-arm64@4.52.2": {
|
"@rollup/rollup-freebsd-arm64@4.52.5": {
|
||||||
"integrity": "sha512-/eg4CI61ZUkLXxMHyVlmlGrSQZ34xqWlZNW43IAU4RmdzWEx0mQJ2mN/Cx4IHLVZFL6UBGAh+/GXhgvGb+nVxw==",
|
"integrity": "sha512-QofO7i7JycsYOWxe0GFqhLmF6l1TqBswJMvICnRUjqCx8b47MTo46W8AoeQwiokAx3zVryVnxtBMcGcnX12LvA==",
|
||||||
"os": ["freebsd"],
|
"os": ["freebsd"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-freebsd-x64@4.52.2": {
|
"@rollup/rollup-freebsd-x64@4.52.5": {
|
||||||
"integrity": "sha512-QOWgFH5X9+p+S1NAfOqc0z8qEpJIoUHf7OWjNUGOeW18Mx22lAUOiA9b6r2/vpzLdfxi/f+VWsYjUOMCcYh0Ng==",
|
"integrity": "sha512-jr21b/99ew8ujZubPo9skbrItHEIE50WdV86cdSoRkKtmWa+DDr6fu2c/xyRT0F/WazZpam6kk7IHBerSL7LDQ==",
|
||||||
"os": ["freebsd"],
|
"os": ["freebsd"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-arm-gnueabihf@4.52.2": {
|
"@rollup/rollup-linux-arm-gnueabihf@4.52.5": {
|
||||||
"integrity": "sha512-kDWSPafToDd8LcBYd1t5jw7bD5Ojcu12S3uT372e5HKPzQt532vW+rGFFOaiR0opxePyUkHrwz8iWYEyH1IIQA==",
|
"integrity": "sha512-PsNAbcyv9CcecAUagQefwX8fQn9LQ4nZkpDboBOttmyffnInRy8R8dSg6hxxl2Re5QhHBf6FYIDhIj5v982ATQ==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm"]
|
"cpu": ["arm"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-arm-musleabihf@4.52.2": {
|
"@rollup/rollup-linux-arm-musleabihf@4.52.5": {
|
||||||
"integrity": "sha512-gKm7Mk9wCv6/rkzwCiUC4KnevYhlf8ztBrDRT9g/u//1fZLapSRc+eDZj2Eu2wpJ+0RzUKgtNijnVIB4ZxyL+w==",
|
"integrity": "sha512-Fw4tysRutyQc/wwkmcyoqFtJhh0u31K+Q6jYjeicsGJJ7bbEq8LwPWV/w0cnzOqR2m694/Af6hpFayLJZkG2VQ==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm"]
|
"cpu": ["arm"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-arm64-gnu@4.52.2": {
|
"@rollup/rollup-linux-arm64-gnu@4.52.5": {
|
||||||
"integrity": "sha512-66lA8vnj5mB/rtDNwPgrrKUOtCLVQypkyDa2gMfOefXK6rcZAxKLO9Fy3GkW8VkPnENv9hBkNOFfGLf6rNKGUg==",
|
"integrity": "sha512-a+3wVnAYdQClOTlyapKmyI6BLPAFYs0JM8HRpgYZQO02rMR09ZcV9LbQB+NL6sljzG38869YqThrRnfPMCDtZg==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-arm64-musl@4.52.2": {
|
"@rollup/rollup-linux-arm64-musl@4.52.5": {
|
||||||
"integrity": "sha512-s+OPucLNdJHvuZHuIz2WwncJ+SfWHFEmlC5nKMUgAelUeBUnlB4wt7rXWiyG4Zn07uY2Dd+SGyVa9oyLkVGOjA==",
|
"integrity": "sha512-AvttBOMwO9Pcuuf7m9PkC1PUIKsfaAJ4AYhy944qeTJgQOqJYJ9oVl2nYgY7Rk0mkbsuOpCAYSs6wLYB2Xiw0Q==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-loong64-gnu@4.52.2": {
|
"@rollup/rollup-linux-loong64-gnu@4.52.5": {
|
||||||
"integrity": "sha512-8wTRM3+gVMDLLDdaT6tKmOE3lJyRy9NpJUS/ZRWmLCmOPIJhVyXwjBo+XbrrwtV33Em1/eCTd5TuGJm4+DmYjw==",
|
"integrity": "sha512-DkDk8pmXQV2wVrF6oq5tONK6UHLz/XcEVow4JTTerdeV1uqPeHxwcg7aFsfnSm9L+OO8WJsWotKM2JJPMWrQtA==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["loong64"]
|
"cpu": ["loong64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-ppc64-gnu@4.52.2": {
|
"@rollup/rollup-linux-ppc64-gnu@4.52.5": {
|
||||||
"integrity": "sha512-6yqEfgJ1anIeuP2P/zhtfBlDpXUb80t8DpbYwXQ3bQd95JMvUaqiX+fKqYqUwZXqdJDd8xdilNtsHM2N0cFm6A==",
|
"integrity": "sha512-W/b9ZN/U9+hPQVvlGwjzi+Wy4xdoH2I8EjaCkMvzpI7wJUs8sWJ03Rq96jRnHkSrcHTpQe8h5Tg3ZzUPGauvAw==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["ppc64"]
|
"cpu": ["ppc64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-riscv64-gnu@4.52.2": {
|
"@rollup/rollup-linux-riscv64-gnu@4.52.5": {
|
||||||
"integrity": "sha512-sshYUiYVSEI2B6dp4jMncwxbrUqRdNApF2c3bhtLAU0qA8Lrri0p0NauOsTWh3yCCCDyBOjESHMExonp7Nzc0w==",
|
"integrity": "sha512-sjQLr9BW7R/ZiXnQiWPkErNfLMkkWIoCz7YMn27HldKsADEKa5WYdobaa1hmN6slu9oWQbB6/jFpJ+P2IkVrmw==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["riscv64"]
|
"cpu": ["riscv64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-riscv64-musl@4.52.2": {
|
"@rollup/rollup-linux-riscv64-musl@4.52.5": {
|
||||||
"integrity": "sha512-duBLgd+3pqC4MMwBrKkFxaZerUxZcYApQVC5SdbF5/e/589GwVvlRUnyqMFbM8iUSb1BaoX/3fRL7hB9m2Pj8Q==",
|
"integrity": "sha512-hq3jU/kGyjXWTvAh2awn8oHroCbrPm8JqM7RUpKjalIRWWXE01CQOf/tUNWNHjmbMHg/hmNCwc/Pz3k1T/j/Lg==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["riscv64"]
|
"cpu": ["riscv64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-s390x-gnu@4.52.2": {
|
"@rollup/rollup-linux-s390x-gnu@4.52.5": {
|
||||||
"integrity": "sha512-tzhYJJidDUVGMgVyE+PmxENPHlvvqm1KILjjZhB8/xHYqAGeizh3GBGf9u6WdJpZrz1aCpIIHG0LgJgH9rVjHQ==",
|
"integrity": "sha512-gn8kHOrku8D4NGHMK1Y7NA7INQTRdVOntt1OCYypZPRt6skGbddska44K8iocdpxHTMMNui5oH4elPH4QOLrFQ==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["s390x"]
|
"cpu": ["s390x"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-x64-gnu@4.52.2": {
|
"@rollup/rollup-linux-x64-gnu@4.52.5": {
|
||||||
"integrity": "sha512-opH8GSUuVcCSSyHHcl5hELrmnk4waZoVpgn/4FDao9iyE4WpQhyWJ5ryl5M3ocp4qkRuHfyXnGqg8M9oKCEKRA==",
|
"integrity": "sha512-hXGLYpdhiNElzN770+H2nlx+jRog8TyynpTVzdlc6bndktjKWyZyiCsuDAlpd+j+W+WNqfcyAWz9HxxIGfZm1Q==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-linux-x64-musl@4.52.2": {
|
"@rollup/rollup-linux-x64-musl@4.52.5": {
|
||||||
"integrity": "sha512-LSeBHnGli1pPKVJ79ZVJgeZWWZXkEe/5o8kcn23M8eMKCUANejchJbF/JqzM4RRjOJfNRhKJk8FuqL1GKjF5oQ==",
|
"integrity": "sha512-arCGIcuNKjBoKAXD+y7XomR9gY6Mw7HnFBv5Rw7wQRvwYLR7gBAgV7Mb2QTyjXfTveBNFAtPt46/36vV9STLNg==",
|
||||||
"os": ["linux"],
|
"os": ["linux"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-openharmony-arm64@4.52.2": {
|
"@rollup/rollup-openharmony-arm64@4.52.5": {
|
||||||
"integrity": "sha512-uPj7MQ6/s+/GOpolavm6BPo+6CbhbKYyZHUDvZ/SmJM7pfDBgdGisFX3bY/CBDMg2ZO4utfhlApkSfZ92yXw7Q==",
|
"integrity": "sha512-QoFqB6+/9Rly/RiPjaomPLmR/13cgkIGfA40LHly9zcH1S0bN2HVFYk3a1eAyHQyjs3ZJYlXvIGtcCs5tko9Cw==",
|
||||||
"os": ["openharmony"],
|
"os": ["openharmony"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-win32-arm64-msvc@4.52.2": {
|
"@rollup/rollup-win32-arm64-msvc@4.52.5": {
|
||||||
"integrity": "sha512-Z9MUCrSgIaUeeHAiNkm3cQyst2UhzjPraR3gYYfOjAuZI7tcFRTOD+4cHLPoS/3qinchth+V56vtqz1Tv+6KPA==",
|
"integrity": "sha512-w0cDWVR6MlTstla1cIfOGyl8+qb93FlAVutcor14Gf5Md5ap5ySfQ7R9S/NjNaMLSFdUnKGEasmVnu3lCMqB7w==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["arm64"]
|
"cpu": ["arm64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-win32-ia32-msvc@4.52.2": {
|
"@rollup/rollup-win32-ia32-msvc@4.52.5": {
|
||||||
"integrity": "sha512-+GnYBmpjldD3XQd+HMejo+0gJGwYIOfFeoBQv32xF/RUIvccUz20/V6Otdv+57NE70D5pa8W/jVGDoGq0oON4A==",
|
"integrity": "sha512-Aufdpzp7DpOTULJCuvzqcItSGDH73pF3ko/f+ckJhxQyHtp67rHw3HMNxoIdDMUITJESNE6a8uh4Lo4SLouOUg==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["ia32"]
|
"cpu": ["ia32"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-win32-x64-gnu@4.52.2": {
|
"@rollup/rollup-win32-x64-gnu@4.52.5": {
|
||||||
"integrity": "sha512-ApXFKluSB6kDQkAqZOKXBjiaqdF1BlKi+/eqnYe9Ee7U2K3pUDKsIyr8EYm/QDHTJIM+4X+lI0gJc3TTRhd+dA==",
|
"integrity": "sha512-UGBUGPFp1vkj6p8wCRraqNhqwX/4kNQPS57BCFc8wYh0g94iVIW33wJtQAx3G7vrjjNtRaxiMUylM0ktp/TRSQ==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
"@rollup/rollup-win32-x64-msvc@4.52.2": {
|
"@rollup/rollup-win32-x64-msvc@4.52.5": {
|
||||||
"integrity": "sha512-ARz+Bs8kY6FtitYM96PqPEVvPXqEZmPZsSkXvyX19YzDqkCaIlhCieLLMI5hxO9SRZ2XtCtm8wxhy0iJ2jxNfw==",
|
"integrity": "sha512-TAcgQh2sSkykPRWLrdyy2AiceMckNf5loITqXxFI5VuQjS5tSuw3WlwdN8qv8vzjLAUTvYaH/mVjSFpbkFbpTg==",
|
||||||
"os": ["win32"],
|
"os": ["win32"],
|
||||||
"cpu": ["x64"]
|
"cpu": ["x64"]
|
||||||
},
|
},
|
||||||
@@ -268,8 +268,8 @@
|
|||||||
"@types/trusted-types@2.0.7": {
|
"@types/trusted-types@2.0.7": {
|
||||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw=="
|
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw=="
|
||||||
},
|
},
|
||||||
"esbuild@0.25.10": {
|
"esbuild@0.27.1": {
|
||||||
"integrity": "sha512-9RiGKvCwaqxO2owP61uQ4BgNborAQskMR6QusfWzQqv7AZOg5oGehdY2pRJMTKuwxd1IDBP4rSbI5lHzU7SMsQ==",
|
"integrity": "sha512-yY35KZckJJuVVPXpvjgxiCuVEJT67F6zDeVTv4rizyPrfGBUpZQsvmxnN+C371c2esD/hNMjj4tpBhuueLN7aA==",
|
||||||
"optionalDependencies": [
|
"optionalDependencies": [
|
||||||
"@esbuild/aix-ppc64",
|
"@esbuild/aix-ppc64",
|
||||||
"@esbuild/android-arm",
|
"@esbuild/android-arm",
|
||||||
@@ -355,8 +355,8 @@
|
|||||||
"source-map-js"
|
"source-map-js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"rollup@4.52.2": {
|
"rollup@4.52.5": {
|
||||||
"integrity": "sha512-I25/2QgoROE1vYV+NQ1En9T9UFB9Cmfm2CJ83zZOlaDpvz29wGQSZXWKw7MiNXau7wYgB/T9fVIdIuEQ+KbiiA==",
|
"integrity": "sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"@types/estree"
|
"@types/estree"
|
||||||
],
|
],
|
||||||
@@ -397,8 +397,8 @@
|
|||||||
"picomatch"
|
"picomatch"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"vite@7.1.7_picomatch@4.0.3": {
|
"vite@7.3.0_picomatch@4.0.3": {
|
||||||
"integrity": "sha512-VbA8ScMvAISJNJVbRDTJdCwqQoAareR/wutevKanhR2/1EkoXVZVkkORaYm/tNVCjP/UDTKtcw3bAkwOUdedmA==",
|
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"esbuild",
|
"esbuild",
|
||||||
"fdir",
|
"fdir",
|
||||||
@@ -415,9 +415,9 @@
|
|||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"npm:@deno/vite-plugin@^1.0.5",
|
"npm:@deno/vite-plugin@^1.0.6",
|
||||||
"npm:lit@^3.3.1",
|
"npm:lit@^3.3.1",
|
||||||
"npm:vite@^7.1.7"
|
"npm:vite@^7.3.0"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Vite + Lit</title>
|
|
||||||
<link rel="stylesheet" href="./src/index.css" />
|
|
||||||
<script type="module" src="/src/my-element.ts"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<my-element>
|
|
||||||
<h1>Vite + Lit</h1>
|
|
||||||
</my-element>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
8
crates/frontend/js-components/lib/bundle.ts
Normal file
8
crates/frontend/js-components/lib/bundle.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export { CreateAddressbookForm } from './create-addressbook-form.ts'
|
||||||
|
export { CreateBirthdayCalendarForm } from './create-birthday-calendar-form.ts'
|
||||||
|
export { CreateCalendarForm } from './create-calendar-form.ts'
|
||||||
|
export { DeleteButton } from './delete-button.ts'
|
||||||
|
export { EditAddressbookForm } from './edit-addressbook-form.ts'
|
||||||
|
export { EditCalendarForm } from './edit-calendar-form.ts'
|
||||||
|
export { ImportAddressbookForm } from './import-addressbook-form.ts'
|
||||||
|
export { ImportCalendarForm } from './import-calendar-form.ts'
|
||||||
@@ -36,27 +36,27 @@ export class CreateAddressbookForm extends LitElement {
|
|||||||
<form @submit=${this.submit} ${ref(this.form)}>
|
<form @submit=${this.submit} ${ref(this.form)}>
|
||||||
<label>
|
<label>
|
||||||
principal (for group addressbooks)
|
principal (for group addressbooks)
|
||||||
<select name="principal" value=${this.user} @change=${e => this.principal = e.target.value}>
|
<select .value=${this.user} @change=${e => this.principal = e.target.value}>
|
||||||
<option value=${this.user}>${this.user}</option>
|
<option .value=${this.user}>${this.user}</option>
|
||||||
${window.rusticalUser.memberships.map(membership => html`
|
${window.rusticalUser.memberships.map(membership => html`
|
||||||
<option value=${membership}>${membership}</option>
|
<option .value=${membership}>${membership}</option>
|
||||||
`)}
|
`)}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
id
|
id
|
||||||
<input type="text" name="id" value=${this.addr_id} @change=${e => this.addr_id = e.target.value} />
|
<input type="text" .value=${this.addr_id} @change=${e => this.addr_id = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
Displayname
|
Displayname
|
||||||
<input type="text" name="displayname" value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
<input type="text" .value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
Description
|
Description
|
||||||
<input type="text" name="description" @change=${e => this.description = e.target.value} />
|
<input type="text" .value=${this.description} @change=${e => this.description = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<button type="submit">Create</button>
|
<button type="submit">Create</button>
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import { html, LitElement } from "lit";
|
||||||
|
import { customElement, property } from "lit/decorators.js";
|
||||||
|
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
||||||
|
import { escapeXml } from ".";
|
||||||
|
import { getTimezones } from "./timezones.ts";
|
||||||
|
|
||||||
|
@customElement("create-birthday-calendar-form")
|
||||||
|
export class CreateBirthdayCalendarForm extends LitElement {
|
||||||
|
protected override createRenderRoot() {
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
@property()
|
||||||
|
principal: string = ''
|
||||||
|
@property()
|
||||||
|
addr_id: string = ''
|
||||||
|
@property()
|
||||||
|
displayname: string = ''
|
||||||
|
@property()
|
||||||
|
description: string = ''
|
||||||
|
@property()
|
||||||
|
color: string = ''
|
||||||
|
|
||||||
|
dialog: Ref<HTMLDialogElement> = createRef()
|
||||||
|
form: Ref<HTMLFormElement> = createRef()
|
||||||
|
@property()
|
||||||
|
timezones: Array<String> = []
|
||||||
|
|
||||||
|
override render() {
|
||||||
|
return html`
|
||||||
|
<button @click=${() => this.dialog.value.showModal()}>Create birthday calendar</button>
|
||||||
|
<dialog ${ref(this.dialog)}>
|
||||||
|
<h3>Create calendar</h3>
|
||||||
|
<form @submit=${this.submit} ${ref(this.form)}>
|
||||||
|
<label>
|
||||||
|
Displayname
|
||||||
|
<input type="text" .value=${this.displayname} required @change=${e => this.displayname = e.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Description
|
||||||
|
<input type="text" .value=${this.description} @change=${e => this.description = e.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
Color
|
||||||
|
<input type="color" .value=${this.color} @change=${e => this.color = e.target.value} />
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<button type="submit">Create</button>
|
||||||
|
<button type="submit" @click=${event => { event.preventDefault(); this.dialog.value.close(); this.form.value.reset() }} class="cancel">Cancel</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
async submit(e: SubmitEvent) {
|
||||||
|
e.preventDefault()
|
||||||
|
if (!this.addr_id) {
|
||||||
|
alert("Empty id")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.displayname) {
|
||||||
|
alert("Empty displayname")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let response = await fetch(`/caldav/principal/${this.principal}/_birthdays_${this.addr_id}`, {
|
||||||
|
method: 'MKCOL',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/xml'
|
||||||
|
},
|
||||||
|
body: `
|
||||||
|
<mkcol xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/" xmlns:ICAL="http://apple.com/ns/ical/">
|
||||||
|
<set>
|
||||||
|
<prop>
|
||||||
|
<displayname>${escapeXml(this.displayname)}</displayname>
|
||||||
|
${this.description ? `<CAL:calendar-description>${escapeXml(this.description)}</CAL:calendar-description>` : ''}
|
||||||
|
${this.color ? `<ICAL:calendar-color>${escapeXml(this.color)}</ICAL:calendar-color>` : ''}
|
||||||
|
<CAL:supported-calendar-component-set>
|
||||||
|
<CAL:comp name="VEVENT" />
|
||||||
|
</CAL:supported-calendar-component-set>
|
||||||
|
</prop>
|
||||||
|
</set>
|
||||||
|
</mkcol>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response.status >= 400) {
|
||||||
|
alert(`Error ${response.status}: ${await response.text()}`)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
window.location.reload()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'create-calendar-form': CreateCalendarForm
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,32 @@
|
|||||||
import { html, LitElement } from "lit";
|
import { html, LitElement } from "lit";
|
||||||
import { customElement, property } from "lit/decorators.js";
|
import { customElement, property } from "lit/decorators.js";
|
||||||
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
||||||
import { escapeXml } from ".";
|
import { escapeXml, SVG_ICON_CALENDAR, SVG_ICON_INTERNET } from ".";
|
||||||
|
import { getTimezones } from "./timezones.ts";
|
||||||
|
|
||||||
@customElement("create-calendar-form")
|
@customElement("create-calendar-form")
|
||||||
export class CreateCalendarForm extends LitElement {
|
export class CreateCalendarForm extends LitElement {
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
|
this.resetForm()
|
||||||
|
this.fetchTimezones()
|
||||||
|
}
|
||||||
|
|
||||||
|
resetForm() {
|
||||||
|
this.form.value?.reset()
|
||||||
|
this.principal = this.user
|
||||||
|
this.cal_id = self.crypto.randomUUID()
|
||||||
|
this.displayname = ''
|
||||||
|
this.description = ''
|
||||||
|
this.timezone_id = ''
|
||||||
|
this.color = ''
|
||||||
|
this.isSubscription = false
|
||||||
|
this.subscriptionUrl = null
|
||||||
|
this.components = new Set(["VEVENT", "VTODO"])
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchTimezones() {
|
||||||
|
this.timezones = await getTimezones()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override createRenderRoot() {
|
protected override createRenderRoot() {
|
||||||
@@ -16,36 +36,38 @@ export class CreateCalendarForm extends LitElement {
|
|||||||
@property()
|
@property()
|
||||||
user: string = ''
|
user: string = ''
|
||||||
@property()
|
@property()
|
||||||
principal: string = ''
|
principal: string
|
||||||
@property()
|
@property()
|
||||||
cal_id: string = self.crypto.randomUUID()
|
cal_id: string
|
||||||
@property()
|
@property()
|
||||||
displayname: string = ''
|
displayname: string
|
||||||
@property()
|
@property()
|
||||||
description: string = ''
|
description: string
|
||||||
@property()
|
@property()
|
||||||
timezone_id: string = ''
|
timezone_id: string
|
||||||
@property()
|
@property()
|
||||||
color: string = ''
|
color: string
|
||||||
@property()
|
@property()
|
||||||
isSubscription: boolean = false
|
isSubscription: boolean
|
||||||
@property()
|
@property()
|
||||||
subscriptionUrl: string = ''
|
subscriptionUrl: string
|
||||||
@property()
|
@property()
|
||||||
components: Set<"VEVENT" | "VTODO" | "VJOURNAL"> = new Set()
|
components: Set<"VEVENT" | "VTODO" | "VJOURNAL">
|
||||||
|
|
||||||
dialog: Ref<HTMLDialogElement> = createRef()
|
dialog: Ref<HTMLDialogElement> = createRef()
|
||||||
form: Ref<HTMLFormElement> = createRef()
|
form: Ref<HTMLFormElement> = createRef()
|
||||||
|
@property()
|
||||||
|
timezones: Array<String> = []
|
||||||
|
|
||||||
override render() {
|
override render() {
|
||||||
return html`
|
return html`
|
||||||
<button @click=${() => this.dialog.value.showModal()}>Create calendar</button>
|
<button @click=${e => this.dialog.value.showModal()}>Create calendar</button>
|
||||||
<dialog ${ref(this.dialog)}>
|
<dialog ${ref(this.dialog)} @close=${e => this.resetForm()}>
|
||||||
<h3>Create calendar</h3>
|
<h3>Create calendar</h3>
|
||||||
<form @submit=${this.submit} ${ref(this.form)}>
|
<form @submit=${this.submit} ${ref(this.form)}>
|
||||||
<label>
|
<label>
|
||||||
principal (for group calendars)
|
principal (for group calendars)
|
||||||
<select name="principal" value=${this.user} @change=${e => this.principal = e.target.value}>
|
<select required value=${this.user} @change=${e => this.principal = e.target.value}>
|
||||||
<option value=${this.user}>${this.user}</option>
|
<option value=${this.user}>${this.user}</option>
|
||||||
${window.rusticalUser.memberships.map(membership => html`
|
${window.rusticalUser.memberships.map(membership => html`
|
||||||
<option value=${membership}>${membership}</option>
|
<option value=${membership}>${membership}</option>
|
||||||
@@ -55,60 +77,77 @@ export class CreateCalendarForm extends LitElement {
|
|||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
id
|
id
|
||||||
<input type="text" name="id" value=${this.cal_id} @change=${e => this.cal_id = e.target.value} />
|
<input type="text" required .value=${this.cal_id} @change=${e => this.cal_id = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
Displayname
|
Displayname
|
||||||
<input type="text" name="displayname" value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
<input type="text" required .value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
Timezone (optional)
|
Timezone (optional)
|
||||||
<input type="text" name="timezone" .value=${this.timezone_id} @change=${e => this.timezone_id = e.target.value} />
|
<select .value=${this.timezone_id} @change=${e => this.timezone_id = e.target.value}>
|
||||||
|
<option value="">No timezone</option>
|
||||||
|
${this.timezones.map(timezone => html`
|
||||||
|
<option value=${timezone} ?selected=${timezone === this.timezone_id}>${timezone}</option>
|
||||||
|
`)}
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
Description
|
Description
|
||||||
<input type="text" name="description" @change=${e => this.description = e.target.value} />
|
<input type="text" .value=${this.description} @change=${e => this.description = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
Color
|
Color
|
||||||
<input type="color" name="color" @change=${e => this.color = e.target.value} />
|
<input type="color" .value=${this.color} @change=${e => this.color = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
<label>Type</label>
|
||||||
|
<div class="tab-radio">
|
||||||
<label>
|
<label>
|
||||||
Calendar is subscription to external calendar
|
<input type="radio" name="type" .checked=${!this.isSubscription} @change=${e => this.isSubscription = false}></input>
|
||||||
<input type="checkbox" name="is_subscription" @change=${e => this.isSubscription = e.target.checked} />
|
${SVG_ICON_CALENDAR}
|
||||||
|
Calendar
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="type" .checked=${this.isSubscription} @change=${e => this.isSubscription = true}></input>
|
||||||
|
${SVG_ICON_INTERNET}
|
||||||
|
webCal Subscription
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<br>
|
<br>
|
||||||
${this.isSubscription ? html`
|
${this.isSubscription ? html`
|
||||||
<label>
|
<label>
|
||||||
Subscription URL
|
Subscription URL
|
||||||
<input type="text" name="subscription_url" @change=${e => this.subscriptionUrl = e.target.value} />
|
<input type="text" pattern="https://.*" .required=${this.isSubscription} .value=${this.subscriptionUrl} @change=${e => this.subscriptionUrl = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
`: html``}
|
|
||||||
<br>
|
<br>
|
||||||
|
`: html``}
|
||||||
|
|
||||||
|
<label>Components</label>
|
||||||
|
<div>
|
||||||
${["VEVENT", "VTODO", "VJOURNAL"].map(comp => html`
|
${["VEVENT", "VTODO", "VJOURNAL"].map(comp => html`
|
||||||
<label>
|
<label>
|
||||||
Support ${comp}
|
Support ${comp}
|
||||||
<input type="checkbox" value=${comp} @change=${e => e.target.checked ? this.components.add(e.target.value) : this.components.delete(e.target.value)} />
|
<input type="checkbox" .value=${comp} @change=${e => e.target.checked ? this.components.add(e.target.value) : this.components.delete(e.target.value)} .checked=${this.components.has(comp)} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
`)}
|
`)}
|
||||||
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<button type="submit">Create</button>
|
<button type="submit">Create</button>
|
||||||
<button type="submit" @click=${event => { event.preventDefault(); this.dialog.value.close(); this.form.value.reset() }} class="cancel">Cancel</button>
|
<button type="submit" @click=${event => { event.preventDefault(); this.dialog.value.close();}} class="cancel">Cancel</button>
|
||||||
</form>
|
</form>
|
||||||
</dialog>
|
</dialog>
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit(e: SubmitEvent) {
|
async submit(e: SubmitEvent) {
|
||||||
console.log(this.displayname)
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (!this.cal_id) {
|
if (!this.cal_id) {
|
||||||
alert("Empty id")
|
alert("Empty id")
|
||||||
@@ -122,6 +161,10 @@ export class CreateCalendarForm extends LitElement {
|
|||||||
alert("No calendar components selected")
|
alert("No calendar components selected")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (this.isSubscription && !this.subscriptionUrl) {
|
||||||
|
alert("Invalid subscription url")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let response = await fetch(`/caldav/principal/${this.principal || this.user}/${this.cal_id}`, {
|
let response = await fetch(`/caldav/principal/${this.principal || this.user}/${this.cal_id}`, {
|
||||||
method: 'MKCOL',
|
method: 'MKCOL',
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ export class EditAddressbookForm extends LitElement {
|
|||||||
<form @submit=${this.submit} ${ref(this.form)}>
|
<form @submit=${this.submit} ${ref(this.form)}>
|
||||||
<label>
|
<label>
|
||||||
Displayname
|
Displayname
|
||||||
<input type="text" name="displayname" .value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
<input type="text" .value=${this.displayname} @change=${e => this.displayname = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<label>
|
<label>
|
||||||
Description
|
Description
|
||||||
<input type="text" name="description" .value=${this.description} @change=${e => this.description = e.target.value} />
|
<input type="text" .value=${this.description} @change=${e => this.description = e.target.value} />
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
<button type="submit">Submit</button>
|
<button type="submit">Submit</button>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user