fix(calendar): address CalDAV review blockers for PR 56
Enable real OS keyring backends, unique series occurrence ids with EXDATE delete, request timeouts, per-calendar fetch errors, and webcal→https.
@@ -23,7 +23,7 @@ dependencies = [
23
23
"atspi-common",
24
24
"phf 0.13.1",
25
25
"serde",
26
"zvariant",
26
"zvariant 5.15.0",
27
27
]
28
28
29
29
[[package]]
@@ -65,7 +65,7 @@ dependencies = [
65
65
"futures-lite",
66
66
"futures-util",
67
67
"serde",
68
"zbus",
68
"zbus 5.19.0",
69
69
]
70
70
71
71
[[package]]
@@ -340,7 +340,7 @@ dependencies = [
340
340
"tray-icon",
341
341
"windows 0.62.2",
342
342
"x11rb",
343
"zbus",
343
"zbus 5.19.0",
344
344
]
345
345
346
346
[[package]]
@@ -494,7 +494,7 @@ dependencies = [
494
494
"wayland-backend",
495
495
"wayland-client",
496
496
"wayland-protocols",
497
"zbus",
497
"zbus 5.19.0",
498
498
]
499
499
500
500
[[package]]
@@ -716,11 +716,11 @@ dependencies = [
716
716
"enumflags2",
717
717
"serde",
718
718
"static_assertions",
719
"zbus",
719
"zbus 5.19.0",
720
720
"zbus-lockstep",
721
721
"zbus-lockstep-macros",
722
"zbus_names",
723
"zvariant",
722
"zbus_names 4.3.4",
723
"zvariant 5.15.0",
724
724
]
725
725
726
726
[[package]]
@@ -731,7 +731,7 @@ checksum = "2230e48787ed3eb4088996eab66a32ca20c0b67bbd4fd6cdfe79f04f1f04c9fc"
731
731
dependencies = [
732
732
"atspi-common",
733
733
"serde",
734
"zbus",
734
"zbus 5.19.0",
735
735
]
736
736
737
737
[[package]]
@@ -2198,6 +2198,35 @@ version = "0.3.2"
2198
2198
source = "registry+https://github.com/rust-lang/crates.io-index"
2199
2199
checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"
2200
2200
2201
[[package]]
2202
name = "dbus"
2203
version = "0.9.11"
2204
source = "registry+https://github.com/rust-lang/crates.io-index"
2205
checksum = "b942602992bb7acfd1f51c49811c58a610ef9181b6e66f3e519d79b540a3bf73"
2206
dependencies = [
2207
"libc",
2208
"libdbus-sys",
2209
"windows-sys 0.61.2",
2210
]
2211
2212
[[package]]
2213
name = "dbus-secret-service"
2214
version = "4.1.0"
2215
source = "registry+https://github.com/rust-lang/crates.io-index"
2216
checksum = "708b509edf7889e53d7efb0ffadd994cc6c2345ccb62f55cfd6b0682165e4fa6"
2217
dependencies = [
2218
"aes",
2219
"block-padding",
2220
"cbc",
2221
"dbus",
2222
"fastrand",
2223
"hkdf",
2224
"num",
2225
"once_cell",
2226
"sha2 0.10.9",
2227
"zeroize",
2228
]
2229
2201
2230
[[package]]
2202
2231
name = "deep_filter"
2203
2232
version = "0.5.7-pre"
@@ -5026,7 +5055,14 @@ version = "3.6.3"
5026
5055
source = "registry+https://github.com/rust-lang/crates.io-index"
5027
5056
checksum = "eebcc3aff044e5944a8fbaf69eb277d11986064cba30c468730e8b9909fb551c"
5028
5057
dependencies = [
5058
"byteorder",
5059
"dbus-secret-service",
5029
5060
"log",
5061
"secret-service",
5062
"security-framework 2.11.1",
5063
"security-framework 3.7.0",
5064
"windows-sys 0.60.2",
5065
"zbus 4.4.0",
5030
5066
"zeroize",
5031
5067
]
5032
5068
@@ -5079,7 +5115,7 @@ dependencies = [
5079
5115
"pastey 0.2.3",
5080
5116
"serde",
5081
5117
"tokio",
5082
"zbus",
5118
"zbus 5.19.0",
5083
5119
]
5084
5120
5085
5121
[[package]]
@@ -5174,6 +5210,15 @@ version = "0.2.190"
5174
5210
source = "registry+https://github.com/rust-lang/crates.io-index"
5175
5211
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
5176
5212
5213
[[package]]
5214
name = "libdbus-sys"
5215
version = "0.2.7"
5216
source = "registry+https://github.com/rust-lang/crates.io-index"
5217
checksum = "328c4789d42200f1eeec05bd86c9c13c7f091d2ba9a6ea35acdf51f31bc0f043"
5218
dependencies = [
5219
"pkg-config",
5220
]
5221
5177
5222
[[package]]
5178
5223
name = "libfuzzer-sys"
5179
5224
version = "0.4.13"
@@ -5822,6 +5867,19 @@ version = "1.0.6"
5822
5867
source = "registry+https://github.com/rust-lang/crates.io-index"
5823
5868
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
5824
5869
5870
[[package]]
5871
name = "nix"
5872
version = "0.29.0"
5873
source = "registry+https://github.com/rust-lang/crates.io-index"
5874
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
5875
dependencies = [
5876
"bitflags 2.13.2",
5877
"cfg-if 1.0.5",
5878
"cfg_aliases",
5879
"libc",
5880
"memoffset",
5881
]
5882
5825
5883
[[package]]
5826
5884
name = "no_std_io2"
5827
5885
version = "0.9.4"
@@ -5975,7 +6033,7 @@ dependencies = [
5975
6033
"mac-notification-sys",
5976
6034
"serde",
5977
6035
"tauri-winrt-notification",
5978
"zbus",
6036
"zbus 5.19.0",
5979
6037
]
5980
6038
5981
6039
[[package]]
@@ -6139,7 +6197,7 @@ version = "0.7.6"
6139
6197
source = "registry+https://github.com/rust-lang/crates.io-index"
6140
6198
checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"
6141
6199
dependencies = [
6142
"proc-macro-crate 3.5.0",
6200
"proc-macro-crate 1.3.1",
6143
6201
"proc-macro2",
6144
6202
"quote",
6145
6203
"syn 2.0.119",
@@ -6595,10 +6653,10 @@ dependencies = [
6595
6653
"serde_bytes",
6596
6654
"sha2 0.10.9",
6597
6655
"subtle",
6598
"zbus",
6599
"zbus_macros",
6656
"zbus 5.19.0",
6657
"zbus_macros 5.19.0",
6600
6658
"zeroize",
6601
"zvariant",
6659
"zvariant 5.15.0",
6602
6660
]
6603
6661
6604
6662
[[package]]
@@ -8116,7 +8174,7 @@ dependencies = [
8116
8174
"errno",
8117
8175
"libc",
8118
8176
"linux-raw-sys 0.4.15",
8119
"windows-sys 0.52.0",
8177
"windows-sys 0.59.0",
8120
8178
]
8121
8179
8122
8180
[[package]]
@@ -8157,7 +8215,7 @@ dependencies = [
8157
8215
"openssl-probe",
8158
8216
"rustls-pki-types",
8159
8217
"schannel",
8160
"security-framework",
8218
"security-framework 3.7.0",
8161
8219
]
8162
8220
8163
8221
[[package]]
@@ -8194,7 +8252,7 @@ dependencies = [
8194
8252
"rustls-native-certs",
8195
8253
"rustls-platform-verifier-android",
8196
8254
"rustls-webpki",
8197
"security-framework",
8255
"security-framework 3.7.0",
8198
8256
"security-framework-sys",
8199
8257
"webpki-root-certs",
8200
8258
"windows-sys 0.61.2",
@@ -8367,6 +8425,38 @@ version = "4.1.0"
8367
8425
source = "registry+https://github.com/rust-lang/crates.io-index"
8368
8426
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
8369
8427
8428
[[package]]
8429
name = "secret-service"
8430
version = "4.0.0"
8431
source = "registry+https://github.com/rust-lang/crates.io-index"
8432
checksum = "e4d35ad99a181be0a60ffcbe85d680d98f87bdc4d7644ade319b87076b9dbfd4"
8433
dependencies = [
8434
"aes",
8435
"cbc",
8436
"futures-util",
8437
"generic-array",
8438
"hkdf",
8439
"num",
8440
"once_cell",
8441
"rand 0.8.8",
8442
"serde",
8443
"sha2 0.10.9",
8444
"zbus 4.4.0",
8445
]
8446
8447
[[package]]
8448
name = "security-framework"
8449
version = "2.11.1"
8450
source = "registry+https://github.com/rust-lang/crates.io-index"
8451
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
8452
dependencies = [
8453
"bitflags 2.13.2",
8454
"core-foundation 0.9.4",
8455
"core-foundation-sys 0.8.7",
8456
"libc",
8457
"security-framework-sys",
8458
]
8459
8370
8460
[[package]]
8371
8461
name = "security-framework"
8372
8462
version = "3.7.0"
@@ -9315,7 +9405,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
9315
9405
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
9316
9406
dependencies = [
9317
9407
"fastrand",
9318
"getrandom 0.4.3",
9408
"getrandom 0.3.4",
9319
9409
"once_cell",
9320
9410
"rustix 1.1.5",
9321
9411
"windows-sys 0.61.2",
@@ -10954,7 +11044,7 @@ version = "0.1.11"
10954
11044
source = "registry+https://github.com/rust-lang/crates.io-index"
10955
11045
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
10956
11046
dependencies = [
10957
"windows-sys 0.61.2",
11047
"windows-sys 0.48.0",
10958
11048
]
10959
11049
10960
11050
[[package]]
@@ -11332,6 +11422,15 @@ dependencies = [
11332
11422
"windows-targets 0.52.6",
11333
11423
]
11334
11424
11425
[[package]]
11426
name = "windows-sys"
11427
version = "0.59.0"
11428
source = "registry+https://github.com/rust-lang/crates.io-index"
11429
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
11430
dependencies = [
11431
"windows-targets 0.52.6",
11432
]
11433
11335
11434
[[package]]
11336
11435
name = "windows-sys"
11337
11436
version = "0.60.2"
@@ -11736,6 +11835,16 @@ version = "0.3.11"
11736
11835
source = "registry+https://github.com/rust-lang/crates.io-index"
11737
11836
checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23"
11738
11837
11838
[[package]]
11839
name = "xdg-home"
11840
version = "1.3.0"
11841
source = "registry+https://github.com/rust-lang/crates.io-index"
11842
checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6"
11843
dependencies = [
11844
"libc",
11845
"windows-sys 0.59.0",
11846
]
11847
11739
11848
[[package]]
11740
11849
name = "xim-ctext"
11741
11850
version = "0.3.0"
@@ -11841,6 +11950,45 @@ dependencies = [
11841
11950
"synstructure",
11842
11951
]
11843
11952
11953
[[package]]
11954
name = "zbus"
11955
version = "4.4.0"
11956
source = "registry+https://github.com/rust-lang/crates.io-index"
11957
checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725"
11958
dependencies = [
11959
"async-broadcast",
11960
"async-executor",
11961
"async-fs",
11962
"async-io",
11963
"async-lock",
11964
"async-process",
11965
"async-recursion",
11966
"async-task",
11967
"async-trait",
11968
"blocking",
11969
"enumflags2",
11970
"event-listener",
11971
"futures-core",
11972
"futures-sink",
11973
"futures-util",
11974
"hex",
11975
"nix",
11976
"ordered-stream",
11977
"rand 0.8.8",
11978
"serde",
11979
"serde_repr",
11980
"sha1",
11981
"static_assertions",
11982
"tokio",
11983
"tracing",
11984
"uds_windows",
11985
"windows-sys 0.52.0",
11986
"xdg-home",
11987
"zbus_macros 4.4.0",
11988
"zbus_names 3.0.0",
11989
"zvariant 4.2.0",
11990
]
11991
11844
11992
[[package]]
11845
11993
name = "zbus"
11846
11994
version = "5.19.0"
@@ -11872,9 +12020,9 @@ dependencies = [
11872
12020
"uuid",
11873
12021
"windows-sys 0.61.2",
11874
12022
"winnow 1.0.4",
11875
"zbus_macros",
11876
"zbus_names",
11877
"zvariant",
12023
"zbus_macros 5.19.0",
12024
"zbus_names 4.3.4",
12025
"zvariant 5.15.0",
11878
12026
]
11879
12027
11880
12028
[[package]]
@@ -11884,7 +12032,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
11884
12032
checksum = "6998de05217a084b7578728a9443d04ea4cd80f2a0839b8d78770b76ccd45863"
11885
12033
dependencies = [
11886
12034
"zbus_xml",
11887
"zvariant",
12035
"zvariant 5.15.0",
11888
12036
]
11889
12037
11890
12038
[[package]]
@@ -11898,7 +12046,20 @@ dependencies = [
11898
12046
"syn 2.0.119",
11899
12047
"zbus-lockstep",
11900
12048
"zbus_xml",
11901
"zvariant",
12049
"zvariant 5.15.0",
12050
]
12051
12052
[[package]]
12053
name = "zbus_macros"
12054
version = "4.4.0"
12055
source = "registry+https://github.com/rust-lang/crates.io-index"
12056
checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e"
12057
dependencies = [
12058
"proc-macro-crate 3.5.0",
12059
"proc-macro2",
12060
"quote",
12061
"syn 2.0.119",
12062
"zvariant_utils 2.1.0",
11902
12063
]
11903
12064
11904
12065
[[package]]
@@ -11911,9 +12072,20 @@ dependencies = [
11911
12072
"proc-macro2",
11912
12073
"quote",
11913
12074
"syn 3.0.6",
11914
"zbus_names",
11915
"zvariant",
11916
"zvariant_utils",
12075
"zbus_names 4.3.4",
12076
"zvariant 5.15.0",
12077
"zvariant_utils 4.2.0",
12078
]
12079
12080
[[package]]
12081
name = "zbus_names"
12082
version = "3.0.0"
12083
source = "registry+https://github.com/rust-lang/crates.io-index"
12084
checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c"
12085
dependencies = [
12086
"serde",
12087
"static_assertions",
12088
"zvariant 4.2.0",
11917
12089
]
11918
12090
11919
12091
[[package]]
@@ -11924,7 +12096,7 @@ checksum = "d8bf88b4a3ff53e883001e0e0115b297a9d53c31b9c1edd2bfdd853e3428624e"
11924
12096
dependencies = [
11925
12097
"serde",
11926
12098
"winnow 1.0.4",
11927
"zvariant",
12099
"zvariant 5.15.0",
11928
12100
]
11929
12101
11930
12102
[[package]]
@@ -11935,8 +12107,8 @@ checksum = "d1586c021a01ca0a9216dcd874e546382e156a5cbab5fab6cb5f10087e22682a"
11935
12107
dependencies = [
11936
12108
"serde",
11937
12109
"winnow 1.0.4",
11938
"zbus_names",
11939
"zvariant",
12110
"zbus_names 4.3.4",
12111
"zvariant 5.15.0",
11940
12112
]
11941
12113
11942
12114
[[package]]
@@ -12172,6 +12344,19 @@ dependencies = [
12172
12344
"zune-core 0.5.3",
12173
12345
]
12174
12346
12347
[[package]]
12348
name = "zvariant"
12349
version = "4.2.0"
12350
source = "registry+https://github.com/rust-lang/crates.io-index"
12351
checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe"
12352
dependencies = [
12353
"endi",
12354
"enumflags2",
12355
"serde",
12356
"static_assertions",
12357
"zvariant_derive 4.2.0",
12358
]
12359
12175
12360
[[package]]
12176
12361
name = "zvariant"
12177
12362
version = "5.15.0"
@@ -12184,8 +12369,21 @@ dependencies = [
12184
12369
"serde_bytes",
12185
12370
"winnow 1.0.4",
12186
12371
"zcheapstr",
12187
"zvariant_derive",
12188
"zvariant_utils",
12372
"zvariant_derive 5.15.0",
12373
"zvariant_utils 4.2.0",
12374
]
12375
12376
[[package]]
12377
name = "zvariant_derive"
12378
version = "4.2.0"
12379
source = "registry+https://github.com/rust-lang/crates.io-index"
12380
checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449"
12381
dependencies = [
12382
"proc-macro-crate 3.5.0",
12383
"proc-macro2",
12384
"quote",
12385
"syn 2.0.119",
12386
"zvariant_utils 2.1.0",
12189
12387
]
12190
12388
12191
12389
[[package]]
@@ -12198,7 +12396,18 @@ dependencies = [
12198
12396
"proc-macro2",
12199
12397
"quote",
12200
12398
"syn 3.0.6",
12201
"zvariant_utils",
12399
"zvariant_utils 4.2.0",
12400
]
12401
12402
[[package]]
12403
name = "zvariant_utils"
12404
version = "2.1.0"
12405
source = "registry+https://github.com/rust-lang/crates.io-index"
12406
checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"
12407
dependencies = [
12408
"proc-macro2",
12409
"quote",
12410
"syn 2.0.119",
12202
12411
]
12203
12412
12204
12413
[[package]]
@@ -23,7 +23,7 @@ dependencies = [23
"atspi-common",23
"atspi-common",24
"phf 0.13.1",24
"phf 0.13.1",25
"serde",25
"serde",26
"zvariant",26
"zvariant 5.15.0",27
]27
]28
28
29
[[package]]29
[[package]]@@ -65,7 +65,7 @@ dependencies = [65
"futures-lite",65
"futures-lite",66
"futures-util",66
"futures-util",67
"serde",67
"serde",68
"zbus",68
"zbus 5.19.0",69
]69
]70
70
71
[[package]]71
[[package]]@@ -340,7 +340,7 @@ dependencies = [340
"tray-icon",340
"tray-icon",341
"windows 0.62.2",341
"windows 0.62.2",342
"x11rb",342
"x11rb",343
"zbus",343
"zbus 5.19.0",344
]344
]345
345
346
[[package]]346
[[package]]@@ -494,7 +494,7 @@ dependencies = [494
"wayland-backend",494
"wayland-backend",495
"wayland-client",495
"wayland-client",496
"wayland-protocols",496
"wayland-protocols",497
"zbus",497
"zbus 5.19.0",498
]498
]499
499
500
[[package]]500
[[package]]@@ -716,11 +716,11 @@ dependencies = [716
"enumflags2",716
"enumflags2",717
"serde",717
"serde",718
"static_assertions",718
"static_assertions",719
"zbus",719
"zbus 5.19.0",720
"zbus-lockstep",720
"zbus-lockstep",721
"zbus-lockstep-macros",721
"zbus-lockstep-macros",722
"zbus_names",722
"zbus_names 4.3.4",723
"zvariant",723
"zvariant 5.15.0",724
]724
]725
725
726
[[package]]726
[[package]]@@ -731,7 +731,7 @@ checksum = "2230e48787ed3eb4088996eab66a32ca20c0b67bbd4fd6cdfe79f04f1f04c9fc"731
dependencies = [731
dependencies = [732
"atspi-common",732
"atspi-common",733
"serde",733
"serde",734
"zbus",734
"zbus 5.19.0",735
]735
]736
736
737
[[package]]737
[[package]]@@ -2198,6 +2198,35 @@ version = "0.3.2"2198
source = "registry+https://github.com/rust-lang/crates.io-index"2198
source = "registry+https://github.com/rust-lang/crates.io-index"2199
checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"2199
checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"2200
2200
2201
[[package]]2202
name = "dbus"2203
version = "0.9.11"2204
source = "registry+https://github.com/rust-lang/crates.io-index"2205
checksum = "b942602992bb7acfd1f51c49811c58a610ef9181b6e66f3e519d79b540a3bf73"2206
dependencies = [2207
"libc",2208
"libdbus-sys",2209
"windows-sys 0.61.2",2210
]2211
2212
[[package]]2213
name = "dbus-secret-service"2214
version = "4.1.0"2215
source = "registry+https://github.com/rust-lang/crates.io-index"2216
checksum = "708b509edf7889e53d7efb0ffadd994cc6c2345ccb62f55cfd6b0682165e4fa6"2217
dependencies = [2218
"aes",2219
"block-padding",2220
"cbc",2221
"dbus",2222
"fastrand",2223
"hkdf",2224
"num",2225
"once_cell",2226
"sha2 0.10.9",2227
"zeroize",2228
]2229
2201
[[package]]2230
[[package]]2202
name = "deep_filter"2231
name = "deep_filter"2203
version = "0.5.7-pre"2232
version = "0.5.7-pre"@@ -5026,7 +5055,14 @@ version = "3.6.3"5026
source = "registry+https://github.com/rust-lang/crates.io-index"5055
source = "registry+https://github.com/rust-lang/crates.io-index"5027
checksum = "eebcc3aff044e5944a8fbaf69eb277d11986064cba30c468730e8b9909fb551c"5056
checksum = "eebcc3aff044e5944a8fbaf69eb277d11986064cba30c468730e8b9909fb551c"5028
dependencies = [5057
dependencies = [5058
"byteorder",5059
"dbus-secret-service",5029
"log",5060
"log",5061
"secret-service",5062
"security-framework 2.11.1",5063
"security-framework 3.7.0",5064
"windows-sys 0.60.2",5065
"zbus 4.4.0",5030
"zeroize",5066
"zeroize",5031
]5067
]5032
5068
@@ -5079,7 +5115,7 @@ dependencies = [5079
"pastey 0.2.3",5115
"pastey 0.2.3",5080
"serde",5116
"serde",5081
"tokio",5117
"tokio",5082
"zbus",5118
"zbus 5.19.0",5083
]5119
]5084
5120
5085
[[package]]5121
[[package]]@@ -5174,6 +5210,15 @@ version = "0.2.190"5174
source = "registry+https://github.com/rust-lang/crates.io-index"5210
source = "registry+https://github.com/rust-lang/crates.io-index"5175
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"5211
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"5176
5212
5213
[[package]]5214
name = "libdbus-sys"5215
version = "0.2.7"5216
source = "registry+https://github.com/rust-lang/crates.io-index"5217
checksum = "328c4789d42200f1eeec05bd86c9c13c7f091d2ba9a6ea35acdf51f31bc0f043"5218
dependencies = [5219
"pkg-config",5220
]5221
5177
[[package]]5222
[[package]]5178
name = "libfuzzer-sys"5223
name = "libfuzzer-sys"5179
version = "0.4.13"5224
version = "0.4.13"@@ -5822,6 +5867,19 @@ version = "1.0.6"5822
source = "registry+https://github.com/rust-lang/crates.io-index"5867
source = "registry+https://github.com/rust-lang/crates.io-index"5823
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"5868
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"5824
5869
5870
[[package]]5871
name = "nix"5872
version = "0.29.0"5873
source = "registry+https://github.com/rust-lang/crates.io-index"5874
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"5875
dependencies = [5876
"bitflags 2.13.2",5877
"cfg-if 1.0.5",5878
"cfg_aliases",5879
"libc",5880
"memoffset",5881
]5882
5825
[[package]]5883
[[package]]5826
name = "no_std_io2"5884
name = "no_std_io2"5827
version = "0.9.4"5885
version = "0.9.4"@@ -5975,7 +6033,7 @@ dependencies = [5975
"mac-notification-sys",6033
"mac-notification-sys",5976
"serde",6034
"serde",5977
"tauri-winrt-notification",6035
"tauri-winrt-notification",5978
"zbus",6036
"zbus 5.19.0",5979
]6037
]5980
6038
5981
[[package]]6039
[[package]]@@ -6139,7 +6197,7 @@ version = "0.7.6"6139
source = "registry+https://github.com/rust-lang/crates.io-index"6197
source = "registry+https://github.com/rust-lang/crates.io-index"6140
checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"6198
checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"6141
dependencies = [6199
dependencies = [6142
"proc-macro-crate 3.5.0",6200
"proc-macro-crate 1.3.1",6143
"proc-macro2",6201
"proc-macro2",6144
"quote",6202
"quote",6145
"syn 2.0.119",6203
"syn 2.0.119",@@ -6595,10 +6653,10 @@ dependencies = [6595
"serde_bytes",6653
"serde_bytes",6596
"sha2 0.10.9",6654
"sha2 0.10.9",6597
"subtle",6655
"subtle",6598
"zbus",6656
"zbus 5.19.0",6599
"zbus_macros",6657
"zbus_macros 5.19.0",6600
"zeroize",6658
"zeroize",6601
"zvariant",6659
"zvariant 5.15.0",6602
]6660
]6603
6661
6604
[[package]]6662
[[package]]@@ -8116,7 +8174,7 @@ dependencies = [8116
"errno",8174
"errno",8117
"libc",8175
"libc",8118
"linux-raw-sys 0.4.15",8176
"linux-raw-sys 0.4.15",8119
"windows-sys 0.52.0",8177
"windows-sys 0.59.0",8120
]8178
]8121
8179
8122
[[package]]8180
[[package]]@@ -8157,7 +8215,7 @@ dependencies = [8157
"openssl-probe",8215
"openssl-probe",8158
"rustls-pki-types",8216
"rustls-pki-types",8159
"schannel",8217
"schannel",8160
"security-framework",8218
"security-framework 3.7.0",8161
]8219
]8162
8220
8163
[[package]]8221
[[package]]@@ -8194,7 +8252,7 @@ dependencies = [8194
"rustls-native-certs",8252
"rustls-native-certs",8195
"rustls-platform-verifier-android",8253
"rustls-platform-verifier-android",8196
"rustls-webpki",8254
"rustls-webpki",8197
"security-framework",8255
"security-framework 3.7.0",8198
"security-framework-sys",8256
"security-framework-sys",8199
"webpki-root-certs",8257
"webpki-root-certs",8200
"windows-sys 0.61.2",8258
"windows-sys 0.61.2",@@ -8367,6 +8425,38 @@ version = "4.1.0"8367
source = "registry+https://github.com/rust-lang/crates.io-index"8425
source = "registry+https://github.com/rust-lang/crates.io-index"8368
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"8426
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"8369
8427
8428
[[package]]8429
name = "secret-service"8430
version = "4.0.0"8431
source = "registry+https://github.com/rust-lang/crates.io-index"8432
checksum = "e4d35ad99a181be0a60ffcbe85d680d98f87bdc4d7644ade319b87076b9dbfd4"8433
dependencies = [8434
"aes",8435
"cbc",8436
"futures-util",8437
"generic-array",8438
"hkdf",8439
"num",8440
"once_cell",8441
"rand 0.8.8",8442
"serde",8443
"sha2 0.10.9",8444
"zbus 4.4.0",8445
]8446
8447
[[package]]8448
name = "security-framework"8449
version = "2.11.1"8450
source = "registry+https://github.com/rust-lang/crates.io-index"8451
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"8452
dependencies = [8453
"bitflags 2.13.2",8454
"core-foundation 0.9.4",8455
"core-foundation-sys 0.8.7",8456
"libc",8457
"security-framework-sys",8458
]8459
8370
[[package]]8460
[[package]]8371
name = "security-framework"8461
name = "security-framework"8372
version = "3.7.0"8462
version = "3.7.0"@@ -9315,7 +9405,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"9315
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"9405
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"9316
dependencies = [9406
dependencies = [9317
"fastrand",9407
"fastrand",9318
"getrandom 0.4.3",9408
"getrandom 0.3.4",9319
"once_cell",9409
"once_cell",9320
"rustix 1.1.5",9410
"rustix 1.1.5",9321
"windows-sys 0.61.2",9411
"windows-sys 0.61.2",@@ -10954,7 +11044,7 @@ version = "0.1.11"10954
source = "registry+https://github.com/rust-lang/crates.io-index"11044
source = "registry+https://github.com/rust-lang/crates.io-index"10955
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"11045
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"10956
dependencies = [11046
dependencies = [10957
"windows-sys 0.61.2",11047
"windows-sys 0.48.0",10958
]11048
]10959
11049
10960
[[package]]11050
[[package]]@@ -11332,6 +11422,15 @@ dependencies = [11332
"windows-targets 0.52.6",11422
"windows-targets 0.52.6",11333
]11423
]11334
11424
11425
[[package]]11426
name = "windows-sys"11427
version = "0.59.0"11428
source = "registry+https://github.com/rust-lang/crates.io-index"11429
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"11430
dependencies = [11431
"windows-targets 0.52.6",11432
]11433
11335
[[package]]11434
[[package]]11336
name = "windows-sys"11435
name = "windows-sys"11337
version = "0.60.2"11436
version = "0.60.2"@@ -11736,6 +11835,16 @@ version = "0.3.11"11736
source = "registry+https://github.com/rust-lang/crates.io-index"11835
source = "registry+https://github.com/rust-lang/crates.io-index"11737
checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23"11836
checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23"11738
11837
11838
[[package]]11839
name = "xdg-home"11840
version = "1.3.0"11841
source = "registry+https://github.com/rust-lang/crates.io-index"11842
checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6"11843
dependencies = [11844
"libc",11845
"windows-sys 0.59.0",11846
]11847
11739
[[package]]11848
[[package]]11740
name = "xim-ctext"11849
name = "xim-ctext"11741
version = "0.3.0"11850
version = "0.3.0"@@ -11841,6 +11950,45 @@ dependencies = [11841
"synstructure",11950
"synstructure",11842
]11951
]11843
11952
11953
[[package]]11954
name = "zbus"11955
version = "4.4.0"11956
source = "registry+https://github.com/rust-lang/crates.io-index"11957
checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725"11958
dependencies = [11959
"async-broadcast",11960
"async-executor",11961
"async-fs",11962
"async-io",11963
"async-lock",11964
"async-process",11965
"async-recursion",11966
"async-task",11967
"async-trait",11968
"blocking",11969
"enumflags2",11970
"event-listener",11971
"futures-core",11972
"futures-sink",11973
"futures-util",11974
"hex",11975
"nix",11976
"ordered-stream",11977
"rand 0.8.8",11978
"serde",11979
"serde_repr",11980
"sha1",11981
"static_assertions",11982
"tokio",11983
"tracing",11984
"uds_windows",11985
"windows-sys 0.52.0",11986
"xdg-home",11987
"zbus_macros 4.4.0",11988
"zbus_names 3.0.0",11989
"zvariant 4.2.0",11990
]11991
11844
[[package]]11992
[[package]]11845
name = "zbus"11993
name = "zbus"11846
version = "5.19.0"11994
version = "5.19.0"@@ -11872,9 +12020,9 @@ dependencies = [11872
"uuid",12020
"uuid",11873
"windows-sys 0.61.2",12021
"windows-sys 0.61.2",11874
"winnow 1.0.4",12022
"winnow 1.0.4",11875
"zbus_macros",12023
"zbus_macros 5.19.0",11876
"zbus_names",12024
"zbus_names 4.3.4",11877
"zvariant",12025
"zvariant 5.15.0",11878
]12026
]11879
12027
11880
[[package]]12028
[[package]]@@ -11884,7 +12032,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"11884
checksum = "6998de05217a084b7578728a9443d04ea4cd80f2a0839b8d78770b76ccd45863"12032
checksum = "6998de05217a084b7578728a9443d04ea4cd80f2a0839b8d78770b76ccd45863"11885
dependencies = [12033
dependencies = [11886
"zbus_xml",12034
"zbus_xml",11887
"zvariant",12035
"zvariant 5.15.0",11888
]12036
]11889
12037
11890
[[package]]12038
[[package]]@@ -11898,7 +12046,20 @@ dependencies = [11898
"syn 2.0.119",12046
"syn 2.0.119",11899
"zbus-lockstep",12047
"zbus-lockstep",11900
"zbus_xml",12048
"zbus_xml",11901
"zvariant",12049
"zvariant 5.15.0",12050
]12051
12052
[[package]]12053
name = "zbus_macros"12054
version = "4.4.0"12055
source = "registry+https://github.com/rust-lang/crates.io-index"12056
checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e"12057
dependencies = [12058
"proc-macro-crate 3.5.0",12059
"proc-macro2",12060
"quote",12061
"syn 2.0.119",12062
"zvariant_utils 2.1.0",11902
]12063
]11903
12064
11904
[[package]]12065
[[package]]@@ -11911,9 +12072,20 @@ dependencies = [11911
"proc-macro2",12072
"proc-macro2",11912
"quote",12073
"quote",11913
"syn 3.0.6",12074
"syn 3.0.6",11914
"zbus_names",12075
"zbus_names 4.3.4",11915
"zvariant",12076
"zvariant 5.15.0",11916
"zvariant_utils",12077
"zvariant_utils 4.2.0",12078
]12079
12080
[[package]]12081
name = "zbus_names"12082
version = "3.0.0"12083
source = "registry+https://github.com/rust-lang/crates.io-index"12084
checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c"12085
dependencies = [12086
"serde",12087
"static_assertions",12088
"zvariant 4.2.0",11917
]12089
]11918
12090
11919
[[package]]12091
[[package]]@@ -11924,7 +12096,7 @@ checksum = "d8bf88b4a3ff53e883001e0e0115b297a9d53c31b9c1edd2bfdd853e3428624e"11924
dependencies = [12096
dependencies = [11925
"serde",12097
"serde",11926
"winnow 1.0.4",12098
"winnow 1.0.4",11927
"zvariant",12099
"zvariant 5.15.0",11928
]12100
]11929
12101
11930
[[package]]12102
[[package]]@@ -11935,8 +12107,8 @@ checksum = "d1586c021a01ca0a9216dcd874e546382e156a5cbab5fab6cb5f10087e22682a"11935
dependencies = [12107
dependencies = [11936
"serde",12108
"serde",11937
"winnow 1.0.4",12109
"winnow 1.0.4",11938
"zbus_names",12110
"zbus_names 4.3.4",11939
"zvariant",12111
"zvariant 5.15.0",11940
]12112
]11941
12113
11942
[[package]]12114
[[package]]@@ -12172,6 +12344,19 @@ dependencies = [12172
"zune-core 0.5.3",12344
"zune-core 0.5.3",12173
]12345
]12174
12346
12347
[[package]]12348
name = "zvariant"12349
version = "4.2.0"12350
source = "registry+https://github.com/rust-lang/crates.io-index"12351
checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe"12352
dependencies = [12353
"endi",12354
"enumflags2",12355
"serde",12356
"static_assertions",12357
"zvariant_derive 4.2.0",12358
]12359
12175
[[package]]12360
[[package]]12176
name = "zvariant"12361
name = "zvariant"12177
version = "5.15.0"12362
version = "5.15.0"@@ -12184,8 +12369,21 @@ dependencies = [12184
"serde_bytes",12369
"serde_bytes",12185
"winnow 1.0.4",12370
"winnow 1.0.4",12186
"zcheapstr",12371
"zcheapstr",12187
"zvariant_derive",12372
"zvariant_derive 5.15.0",12188
"zvariant_utils",12373
"zvariant_utils 4.2.0",12374
]12375
12376
[[package]]12377
name = "zvariant_derive"12378
version = "4.2.0"12379
source = "registry+https://github.com/rust-lang/crates.io-index"12380
checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449"12381
dependencies = [12382
"proc-macro-crate 3.5.0",12383
"proc-macro2",12384
"quote",12385
"syn 2.0.119",12386
"zvariant_utils 2.1.0",12189
]12387
]12190
12388
12191
[[package]]12389
[[package]]@@ -12198,7 +12396,18 @@ dependencies = [12198
"proc-macro2",12396
"proc-macro2",12199
"quote",12397
"quote",12200
"syn 3.0.6",12398
"syn 3.0.6",12201
"zvariant_utils",12399
"zvariant_utils 4.2.0",12400
]12401
12402
[[package]]12403
name = "zvariant_utils"12404
version = "2.1.0"12405
source = "registry+https://github.com/rust-lang/crates.io-index"12406
checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"12407
dependencies = [12408
"proc-macro2",12409
"quote",12410
"syn 2.0.119",12202
]12411
]12203
12412
12204
[[package]]12413
[[package]]@@ -37,7 +37,13 @@ teams-core.workspace = true
37
37
tokio.workspace = true
38
38
uuid.workspace = true
39
39
image = { version = "0.25", default-features = false, features = ["bmp", "gif", "jpeg", "png", "webp"] }
40
keyring = "3"
40
keyring = { version = "3", features = [
41
"apple-native",
42
"windows-native",
43
"async-secret-service",
44
"tokio",
45
"crypto-rust",
46
] }
41
47
reqwest = { version = "0.13", default-features = false, features = ["rustls"] }
42
48
url = "2"
43
49
@@ -37,7 +37,13 @@ teams-core.workspace = true37
tokio.workspace = true37
tokio.workspace = true38
uuid.workspace = true38
uuid.workspace = true39
image = { version = "0.25", default-features = false, features = ["bmp", "gif", "jpeg", "png", "webp"] }39
image = { version = "0.25", default-features = false, features = ["bmp", "gif", "jpeg", "png", "webp"] }40
keyring = "3"40
keyring = { version = "3", features = [41
"apple-native",42
"windows-native",43
"async-secret-service",44
"tokio",45
"crypto-rust",46
] }41
reqwest = { version = "0.13", default-features = false, features = ["rustls"] }47
reqwest = { version = "0.13", default-features = false, features = ["rustls"] }42
url = "2"48
url = "2"43
49
@@ -21,6 +21,24 @@ pub fn delete_password(account_id: &str) -> Result<(), String> {
21
21
}
22
22
}
23
23
24
pub async fn store_password_async(account_id: String, password: String) -> Result<(), String> {
25
tokio::task::spawn_blocking(move || store_password(&account_id, &password))
26
.await
27
.map_err(|error| error.to_string())?
28
}
29
30
pub async fn load_password_async(account_id: String) -> Result<String, String> {
31
tokio::task::spawn_blocking(move || load_password(&account_id))
32
.await
33
.map_err(|error| error.to_string())?
34
}
35
36
pub async fn delete_password_async(account_id: String) -> Result<(), String> {
37
tokio::task::spawn_blocking(move || delete_password(&account_id))
38
.await
39
.map_err(|error| error.to_string())?
40
}
41
24
42
/// Redact credentials that must never appear in diagnostics or support bundles.
25
43
pub fn redact_secret_text(text: &str) -> String {
26
44
let mut out = text.to_owned();
@@ -21,6 +21,24 @@ pub fn delete_password(account_id: &str) -> Result<(), String> {21
}21
}22
}22
}23
23
24
pub async fn store_password_async(account_id: String, password: String) -> Result<(), String> {25
tokio::task::spawn_blocking(move || store_password(&account_id, &password))26
.await27
.map_err(|error| error.to_string())?28
}29
30
pub async fn load_password_async(account_id: String) -> Result<String, String> {31
tokio::task::spawn_blocking(move || load_password(&account_id))32
.await33
.map_err(|error| error.to_string())?34
}35
36
pub async fn delete_password_async(account_id: String) -> Result<(), String> {37
tokio::task::spawn_blocking(move || delete_password(&account_id))38
.await39
.map_err(|error| error.to_string())?40
}41
24
/// Redact credentials that must never appear in diagnostics or support bundles.42
/// Redact credentials that must never appear in diagnostics or support bundles.25
pub fn redact_secret_text(text: &str) -> String {43
pub fn redact_secret_text(text: &str) -> String {26
let mut out = text.to_owned();44
let mut out = text.to_owned();@@ -3,11 +3,11 @@ use store::{CalDavAccount, CalDavCalendarInfo, CalendarAccounts};
3
3
use uuid::Uuid;
4
4
5
5
use chatsvc::{
6
CalDavClient, CalDavEventDraft, CalendarEvent, Reply, discover_caldav, new_event_uid,
7
partstat_for_reply,
6
CalDavClient, CalDavEventDraft, CalendarEvent, Reply, discover_caldav, href_from_object_id,
7
new_event_uid, partstat_for_reply,
8
8
};
9
9
10
use crate::caldav_credentials::{delete_password, load_password, store_password};
10
use crate::caldav_credentials::{delete_password, load_password_async, store_password_async};
11
11
12
12
pub async fn connect_caldav(
13
13
accounts: &mut CalendarAccounts,
@@ -16,7 +16,7 @@ pub async fn connect_caldav(
16
16
password: &str,
17
17
) -> Result<String, String> {
18
18
let url = normalize_url(url)?;
19
let client = CalDavClient::new(username, password);
19
let client = CalDavClient::new(username, password).map_err(|e| e.to_string())?;
20
20
let discovered = discover_caldav(&client, &url)
21
21
.await
22
22
.map_err(|e| e.to_string())?;
@@ -28,7 +28,7 @@ pub async fn connect_caldav(
28
28
return Err("No event calendars found on this CalDAV account".into());
29
29
}
30
30
let id = Uuid::new_v4().to_string();
31
store_password(&id, password)?;
31
store_password_async(id.clone(), password.to_owned()).await?;
32
32
accounts.caldav_accounts.push(CalDavAccount {
33
33
id: id.clone(),
34
34
url,
@@ -56,24 +56,33 @@ pub fn disconnect_caldav(accounts: &mut CalendarAccounts, account_id: &str) -> R
56
56
Ok(())
57
57
}
58
58
59
/// Events plus per-calendar failure messages. One bad calendar does not drop the rest.
59
60
pub async fn fetch_caldav_events(
60
61
accounts: &mut CalendarAccounts,
61
62
start: DateTime<Utc>,
62
63
end: DateTime<Utc>,
63
) -> Result<Vec<CalendarEvent>, String> {
64
) -> Result<(Vec<CalendarEvent>, Vec<String>), String> {
64
65
let mut all = Vec::new();
66
let mut failures = Vec::new();
65
67
for index in 0..accounts.caldav_accounts.len() {
66
68
let account = &accounts.caldav_accounts[index];
67
let password = match load_password(&account.id) {
69
let password = match load_password_async(account.id.clone()).await {
68
70
Ok(password) => password,
69
71
Err(error) => {
70
return Err(format!(
72
failures.push(format!(
71
73
"CalDAV password missing for {}: {error}",
72
74
account.username
73
75
));
76
continue;
77
}
78
};
79
let client = match CalDavClient::new(&account.username, &password) {
80
Ok(client) => client,
81
Err(error) => {
82
failures.push(format!("CalDAV {}: {error}", account.username));
83
continue;
74
84
}
75
85
};
76
let client = CalDavClient::new(&account.username, &password);
77
86
let account_id = account.id.clone();
78
87
let calendars: Vec<(String, String)> = account
79
88
.calendars
@@ -87,13 +96,11 @@ pub async fn fetch_caldav_events(
87
96
.await
88
97
{
89
98
Ok(events) => all.extend(events.into_iter().map(|item| item.event)),
90
Err(error) => {
91
return Err(format!("CalDAV {calendar_name}: {error}"));
92
}
99
Err(error) => failures.push(format!("CalDAV {calendar_name}: {error}")),
93
100
}
94
101
}
95
102
}
96
Ok(all)
103
Ok((all, failures))
97
104
}
98
105
99
106
pub async fn insert_caldav_event(
@@ -105,8 +112,8 @@ pub async fn insert_caldav_event(
105
112
let account = accounts
106
113
.caldav_account(account_id)
107
114
.ok_or_else(|| format!("CalDAV account {account_id} missing"))?;
108
let password = load_password(account_id)?;
109
let client = CalDavClient::new(&account.username, password);
115
let password = load_password_async(account_id.to_owned()).await?;
116
let client = CalDavClient::new(&account.username, password).map_err(|e| e.to_string())?;
110
117
client
111
118
.put_event(calendar_id, draft, Utc::now())
112
119
.await
@@ -123,7 +130,7 @@ pub async fn respond_caldav_event(
123
130
let account = accounts
124
131
.caldav_account(account_id)
125
132
.ok_or_else(|| format!("CalDAV account {account_id} missing"))?;
126
let password = load_password(account_id)?;
133
let password = load_password_async(account_id.to_owned()).await?;
127
134
let mailto = account
128
135
.user_addresses
129
136
.iter()
@@ -137,9 +144,10 @@ pub async fn respond_caldav_event(
137
144
})
138
145
.ok_or_else(|| "CalDAV calendar-user-address missing".to_owned())?;
139
146
let notified = account.schedule_outbox.is_some();
140
let client = CalDavClient::new(&account.username, password);
147
let client = CalDavClient::new(&account.username, password).map_err(|e| e.to_string())?;
148
let href = href_from_object_id(href).to_owned();
141
149
client
142
.update_partstat(href, None, &mailto, partstat_for_reply(reply))
150
.update_partstat(&href, None, &mailto, partstat_for_reply(reply))
143
151
.await
144
152
.map_err(|e| e.to_string())?;
145
153
Ok(notified)
@@ -148,19 +156,24 @@ pub async fn respond_caldav_event(
148
156
pub async fn delete_caldav_event(
149
157
accounts: &mut CalendarAccounts,
150
158
account_id: &str,
151
href: &str,
159
object_id: &str,
160
series: bool,
161
occurrence_start: DateTime<Utc>,
152
162
) -> Result<(), String> {
153
163
let account = accounts
154
164
.caldav_account(account_id)
155
165
.ok_or_else(|| format!("CalDAV account {account_id} missing"))?;
156
let password = load_password(account_id)?;
157
let client = CalDavClient::new(&account.username, password);
158
// Series occurrence exclusion is handled by callers that rewrite EXDATE; single events DELETE.
159
let href = href.split('#').next().unwrap_or(href);
160
client
161
.delete(href, None)
162
.await
163
.map_err(|e| e.to_string())
166
let password = load_password_async(account_id.to_owned()).await?;
167
let client = CalDavClient::new(&account.username, password).map_err(|e| e.to_string())?;
168
let href = href_from_object_id(object_id);
169
if series {
170
client
171
.exclude_occurrence(href, occurrence_start, None)
172
.await
173
.map_err(|e| e.to_string())
174
} else {
175
client.delete(href, None).await.map_err(|e| e.to_string())
176
}
164
177
}
165
178
166
179
pub fn draft_from_meeting(
@@ -3,11 +3,11 @@ use store::{CalDavAccount, CalDavCalendarInfo, CalendarAccounts};3
use uuid::Uuid;3
use uuid::Uuid;4
4
5
use chatsvc::{5
use chatsvc::{6
CalDavClient, CalDavEventDraft, CalendarEvent, Reply, discover_caldav, new_event_uid,6
CalDavClient, CalDavEventDraft, CalendarEvent, Reply, discover_caldav, href_from_object_id,7
partstat_for_reply,7
new_event_uid, partstat_for_reply,8
};8
};9
9
10
use crate::caldav_credentials::{delete_password, load_password, store_password};10
use crate::caldav_credentials::{delete_password, load_password_async, store_password_async};11
11
12
pub async fn connect_caldav(12
pub async fn connect_caldav(13
accounts: &mut CalendarAccounts,13
accounts: &mut CalendarAccounts,@@ -16,7 +16,7 @@ pub async fn connect_caldav(16
password: &str,16
password: &str,17
) -> Result<String, String> {17
) -> Result<String, String> {18
let url = normalize_url(url)?;18
let url = normalize_url(url)?;19
let client = CalDavClient::new(username, password);19
let client = CalDavClient::new(username, password).map_err(|e| e.to_string())?;20
let discovered = discover_caldav(&client, &url)20
let discovered = discover_caldav(&client, &url)21
.await21
.await22
.map_err(|e| e.to_string())?;22
.map_err(|e| e.to_string())?;@@ -28,7 +28,7 @@ pub async fn connect_caldav(28
return Err("No event calendars found on this CalDAV account".into());28
return Err("No event calendars found on this CalDAV account".into());29
}29
}30
let id = Uuid::new_v4().to_string();30
let id = Uuid::new_v4().to_string();31
store_password(&id, password)?;31
store_password_async(id.clone(), password.to_owned()).await?;32
accounts.caldav_accounts.push(CalDavAccount {32
accounts.caldav_accounts.push(CalDavAccount {33
id: id.clone(),33
id: id.clone(),34
url,34
url,@@ -56,24 +56,33 @@ pub fn disconnect_caldav(accounts: &mut CalendarAccounts, account_id: &str) -> R56
Ok(())56
Ok(())57
}57
}58
58
59
/// Events plus per-calendar failure messages. One bad calendar does not drop the rest.59
pub async fn fetch_caldav_events(60
pub async fn fetch_caldav_events(60
accounts: &mut CalendarAccounts,61
accounts: &mut CalendarAccounts,61
start: DateTime<Utc>,62
start: DateTime<Utc>,62
end: DateTime<Utc>,63
end: DateTime<Utc>,63
) -> Result<Vec<CalendarEvent>, String> {64
) -> Result<(Vec<CalendarEvent>, Vec<String>), String> {64
let mut all = Vec::new();65
let mut all = Vec::new();66
let mut failures = Vec::new();65
for index in 0..accounts.caldav_accounts.len() {67
for index in 0..accounts.caldav_accounts.len() {66
let account = &accounts.caldav_accounts[index];68
let account = &accounts.caldav_accounts[index];67
let password = match load_password(&account.id) {69
let password = match load_password_async(account.id.clone()).await {68
Ok(password) => password,70
Ok(password) => password,69
Err(error) => {71
Err(error) => {70
return Err(format!(72
failures.push(format!(71
"CalDAV password missing for {}: {error}",73
"CalDAV password missing for {}: {error}",72
account.username74
account.username73
));75
));76
continue;77
}78
};79
let client = match CalDavClient::new(&account.username, &password) {80
Ok(client) => client,81
Err(error) => {82
failures.push(format!("CalDAV {}: {error}", account.username));83
continue;74
}84
}75
};85
};76
let client = CalDavClient::new(&account.username, &password);77
let account_id = account.id.clone();86
let account_id = account.id.clone();78
let calendars: Vec<(String, String)> = account87
let calendars: Vec<(String, String)> = account79
.calendars88
.calendars@@ -87,13 +96,11 @@ pub async fn fetch_caldav_events(87
.await96
.await88
{97
{89
Ok(events) => all.extend(events.into_iter().map(|item| item.event)),98
Ok(events) => all.extend(events.into_iter().map(|item| item.event)),90
Err(error) => {99
Err(error) => failures.push(format!("CalDAV {calendar_name}: {error}")),91
return Err(format!("CalDAV {calendar_name}: {error}"));92
}93
}100
}94
}101
}95
}102
}96
Ok(all)103
Ok((all, failures))97
}104
}98
105
99
pub async fn insert_caldav_event(106
pub async fn insert_caldav_event(@@ -105,8 +112,8 @@ pub async fn insert_caldav_event(105
let account = accounts112
let account = accounts106
.caldav_account(account_id)113
.caldav_account(account_id)107
.ok_or_else(|| format!("CalDAV account {account_id} missing"))?;114
.ok_or_else(|| format!("CalDAV account {account_id} missing"))?;108
let password = load_password(account_id)?;115
let password = load_password_async(account_id.to_owned()).await?;109
let client = CalDavClient::new(&account.username, password);116
let client = CalDavClient::new(&account.username, password).map_err(|e| e.to_string())?;110
client117
client111
.put_event(calendar_id, draft, Utc::now())118
.put_event(calendar_id, draft, Utc::now())112
.await119
.await@@ -123,7 +130,7 @@ pub async fn respond_caldav_event(123
let account = accounts130
let account = accounts124
.caldav_account(account_id)131
.caldav_account(account_id)125
.ok_or_else(|| format!("CalDAV account {account_id} missing"))?;132
.ok_or_else(|| format!("CalDAV account {account_id} missing"))?;126
let password = load_password(account_id)?;133
let password = load_password_async(account_id.to_owned()).await?;127
let mailto = account134
let mailto = account128
.user_addresses135
.user_addresses129
.iter()136
.iter()@@ -137,9 +144,10 @@ pub async fn respond_caldav_event(137
})144
})138
.ok_or_else(|| "CalDAV calendar-user-address missing".to_owned())?;145
.ok_or_else(|| "CalDAV calendar-user-address missing".to_owned())?;139
let notified = account.schedule_outbox.is_some();146
let notified = account.schedule_outbox.is_some();140
let client = CalDavClient::new(&account.username, password);147
let client = CalDavClient::new(&account.username, password).map_err(|e| e.to_string())?;148
let href = href_from_object_id(href).to_owned();141
client149
client142
.update_partstat(href, None, &mailto, partstat_for_reply(reply))150
.update_partstat(&href, None, &mailto, partstat_for_reply(reply))143
.await151
.await144
.map_err(|e| e.to_string())?;152
.map_err(|e| e.to_string())?;145
Ok(notified)153
Ok(notified)@@ -148,19 +156,24 @@ pub async fn respond_caldav_event(148
pub async fn delete_caldav_event(156
pub async fn delete_caldav_event(149
accounts: &mut CalendarAccounts,157
accounts: &mut CalendarAccounts,150
account_id: &str,158
account_id: &str,151
href: &str,159
object_id: &str,160
series: bool,161
occurrence_start: DateTime<Utc>,152
) -> Result<(), String> {162
) -> Result<(), String> {153
let account = accounts163
let account = accounts154
.caldav_account(account_id)164
.caldav_account(account_id)155
.ok_or_else(|| format!("CalDAV account {account_id} missing"))?;165
.ok_or_else(|| format!("CalDAV account {account_id} missing"))?;156
let password = load_password(account_id)?;166
let password = load_password_async(account_id.to_owned()).await?;157
let client = CalDavClient::new(&account.username, password);167
let client = CalDavClient::new(&account.username, password).map_err(|e| e.to_string())?;158
// Series occurrence exclusion is handled by callers that rewrite EXDATE; single events DELETE.168
let href = href_from_object_id(object_id);159
let href = href.split('#').next().unwrap_or(href);169
if series {160
client170
client161
.delete(href, None)171
.exclude_occurrence(href, occurrence_start, None)162
.await172
.await163
.map_err(|e| e.to_string())173
.map_err(|e| e.to_string())174
} else {175
client.delete(href, None).await.map_err(|e| e.to_string())176
}164
}177
}165
178
166
pub fn draft_from_meeting(179
pub fn draft_from_meeting(@@ -43,38 +43,36 @@ impl AppState {
43
43
let store = self.store.clone();
44
44
let connecting = runtime::spawn(async move {
45
45
let mut accounts = load_calendar_accounts(&store);
46
let id =
47
crate::caldav_sync::connect_caldav(&mut accounts, &url, &username, &password).await?;
46
let id = crate::caldav_sync::connect_caldav(&mut accounts, &url, &username, &password)
47
.await?;
48
48
save_calendar_accounts(&store, &accounts).map_err(|error| error.to_string())?;
49
49
Ok::<_, String>(id)
50
50
});
51
cx.spawn(async move |this, cx| {
52
match connecting.await {
53
Ok(Ok(_)) => {
54
this.update(cx, |state, cx| {
55
state.raise_notice(tr("settings.calendar.caldav_connected"), None, cx);
56
state.refresh_calendar(cx);
57
state.load_calendar_week(cx);
58
cx.notify();
59
})
60
.ok();
61
}
62
Ok(Err(error)) => {
63
this.update(cx, |state, cx| {
64
state.raise_notice(
65
crate::caldav_credentials::redact_secret_text(&error),
66
None,
67
cx,
68
);
69
})
70
.ok();
71
}
72
Err(_) => {
73
this.update(cx, |state, cx| {
74
state.raise_notice(tr("settings.calendar.caldav_connect_failed"), None, cx);
75
})
76
.ok();
77
}
51
cx.spawn(async move |this, cx| match connecting.await {
52
Ok(Ok(_)) => {
53
this.update(cx, |state, cx| {
54
state.raise_notice(tr("settings.calendar.caldav_connected"), None, cx);
55
state.refresh_calendar(cx);
56
state.load_calendar_week(cx);
57
cx.notify();
58
})
59
.ok();
60
}
61
Ok(Err(error)) => {
62
this.update(cx, |state, cx| {
63
state.raise_notice(
64
crate::caldav_credentials::redact_secret_text(&error),
65
None,
66
cx,
67
);
68
})
69
.ok();
70
}
71
Err(_) => {
72
this.update(cx, |state, cx| {
73
state.raise_notice(tr("settings.calendar.caldav_connect_failed"), None, cx);
74
})
75
.ok();
78
76
}
79
77
})
80
78
.detach();
@@ -113,7 +111,12 @@ impl AppState {
113
111
cx.notify();
114
112
}
115
113
116
pub fn connect_ics_subscription(&mut self, url: String, summary: String, cx: &mut Context<Self>) {
114
pub fn connect_ics_subscription(
115
&mut self,
116
url: String,
117
summary: String,
118
cx: &mut Context<Self>,
119
) {
117
120
let store = self.store.clone();
118
121
let connecting = runtime::spawn(async move {
119
122
let mut accounts = load_calendar_accounts(&store);
@@ -121,27 +124,25 @@ impl AppState {
121
124
save_calendar_accounts(&store, &accounts).map_err(|error| error.to_string())?;
122
125
Ok::<_, String>(id)
123
126
});
124
cx.spawn(async move |this, cx| {
125
match connecting.await {
126
Ok(Ok(_)) => {
127
this.update(cx, |state, cx| {
128
state.raise_notice(tr("settings.calendar.ics_connected"), None, cx);
129
state.refresh_calendar(cx);
130
state.load_calendar_week(cx);
131
cx.notify();
132
})
133
.ok();
134
}
135
Ok(Err(error)) => {
136
this.update(cx, |state, cx| state.raise_notice(error, None, cx))
137
.ok();
138
}
139
Err(_) => {
140
this.update(cx, |state, cx| {
141
state.raise_notice(tr("settings.calendar.ics_connect_failed"), None, cx);
142
})
127
cx.spawn(async move |this, cx| match connecting.await {
128
Ok(Ok(_)) => {
129
this.update(cx, |state, cx| {
130
state.raise_notice(tr("settings.calendar.ics_connected"), None, cx);
131
state.refresh_calendar(cx);
132
state.load_calendar_week(cx);
133
cx.notify();
134
})
135
.ok();
136
}
137
Ok(Err(error)) => {
138
this.update(cx, |state, cx| state.raise_notice(error, None, cx))
143
139
.ok();
144
}
140
}
141
Err(_) => {
142
this.update(cx, |state, cx| {
143
state.raise_notice(tr("settings.calendar.ics_connect_failed"), None, cx);
144
})
145
.ok();
145
146
}
146
147
})
147
148
.detach();
@@ -43,38 +43,36 @@ impl AppState {43
let store = self.store.clone();43
let store = self.store.clone();44
let connecting = runtime::spawn(async move {44
let connecting = runtime::spawn(async move {45
let mut accounts = load_calendar_accounts(&store);45
let mut accounts = load_calendar_accounts(&store);46
let id =46
let id = crate::caldav_sync::connect_caldav(&mut accounts, &url, &username, &password)47
crate::caldav_sync::connect_caldav(&mut accounts, &url, &username, &password).await?;47
.await?;48
save_calendar_accounts(&store, &accounts).map_err(|error| error.to_string())?;48
save_calendar_accounts(&store, &accounts).map_err(|error| error.to_string())?;49
Ok::<_, String>(id)49
Ok::<_, String>(id)50
});50
});51
cx.spawn(async move |this, cx| {51
cx.spawn(async move |this, cx| match connecting.await {52
match connecting.await {52
Ok(Ok(_)) => {53
Ok(Ok(_)) => {53
this.update(cx, |state, cx| {54
this.update(cx, |state, cx| {54
state.raise_notice(tr("settings.calendar.caldav_connected"), None, cx);55
state.raise_notice(tr("settings.calendar.caldav_connected"), None, cx);55
state.refresh_calendar(cx);56
state.refresh_calendar(cx);56
state.load_calendar_week(cx);57
state.load_calendar_week(cx);57
cx.notify();58
cx.notify();58
})59
})59
.ok();60
.ok();60
}61
}61
Ok(Err(error)) => {62
Ok(Err(error)) => {62
this.update(cx, |state, cx| {63
this.update(cx, |state, cx| {63
state.raise_notice(64
state.raise_notice(64
crate::caldav_credentials::redact_secret_text(&error),65
crate::caldav_credentials::redact_secret_text(&error),65
None,66
None,66
cx,67
cx,67
);68
);68
})69
})69
.ok();70
.ok();70
}71
}71
Err(_) => {72
Err(_) => {72
this.update(cx, |state, cx| {73
this.update(cx, |state, cx| {73
state.raise_notice(tr("settings.calendar.caldav_connect_failed"), None, cx);74
state.raise_notice(tr("settings.calendar.caldav_connect_failed"), None, cx);74
})75
})75
.ok();76
.ok();77
}78
}76
}79
})77
})80
.detach();78
.detach();@@ -113,7 +111,12 @@ impl AppState {113
cx.notify();111
cx.notify();114
}112
}115
113
116
pub fn connect_ics_subscription(&mut self, url: String, summary: String, cx: &mut Context<Self>) {114
pub fn connect_ics_subscription(115
&mut self,116
url: String,117
summary: String,118
cx: &mut Context<Self>,119
) {117
let store = self.store.clone();120
let store = self.store.clone();118
let connecting = runtime::spawn(async move {121
let connecting = runtime::spawn(async move {119
let mut accounts = load_calendar_accounts(&store);122
let mut accounts = load_calendar_accounts(&store);@@ -121,27 +124,25 @@ impl AppState {121
save_calendar_accounts(&store, &accounts).map_err(|error| error.to_string())?;124
save_calendar_accounts(&store, &accounts).map_err(|error| error.to_string())?;122
Ok::<_, String>(id)125
Ok::<_, String>(id)123
});126
});124
cx.spawn(async move |this, cx| {127
cx.spawn(async move |this, cx| match connecting.await {125
match connecting.await {128
Ok(Ok(_)) => {126
Ok(Ok(_)) => {129
this.update(cx, |state, cx| {127
this.update(cx, |state, cx| {130
state.raise_notice(tr("settings.calendar.ics_connected"), None, cx);128
state.raise_notice(tr("settings.calendar.ics_connected"), None, cx);131
state.refresh_calendar(cx);129
state.refresh_calendar(cx);132
state.load_calendar_week(cx);130
state.load_calendar_week(cx);133
cx.notify();131
cx.notify();134
})132
})135
.ok();133
.ok();136
}134
}137
Ok(Err(error)) => {135
Ok(Err(error)) => {138
this.update(cx, |state, cx| state.raise_notice(error, None, cx))136
this.update(cx, |state, cx| state.raise_notice(error, None, cx))137
.ok();138
}139
Err(_) => {140
this.update(cx, |state, cx| {141
state.raise_notice(tr("settings.calendar.ics_connect_failed"), None, cx);142
})143
.ok();139
.ok();144
}140
}141
Err(_) => {142
this.update(cx, |state, cx| {143
state.raise_notice(tr("settings.calendar.ics_connect_failed"), None, cx);144
})145
.ok();145
}146
}146
})147
})147
.detach();148
.detach();@@ -132,7 +132,10 @@ async fn write_target(
132
132
&draft,
133
133
)
134
134
.await?;
135
Ok(format!("caldav:{}:{}", target.account_id, target.calendar_id))
135
Ok(format!(
136
"caldav:{}:{}",
137
target.account_id, target.calendar_id
138
))
136
139
}
137
140
}
138
141
}
@@ -132,7 +132,10 @@ async fn write_target(132
&draft,132
&draft,133
)133
)134
.await?;134
.await?;135
Ok(format!("caldav:{}:{}", target.account_id, target.calendar_id))135
Ok(format!(136
"caldav:{}:{}",137
target.account_id, target.calendar_id138
))136
}139
}137
}140
}138
}141
}@@ -283,6 +283,8 @@ impl AppState {
283
283
let source = event.source;
284
284
let account_id = event.account_id.clone();
285
285
let calendar_id = event.calendar_id.clone();
286
let series = event.series;
287
let occurrence_start = event.start;
286
288
self.remove_calendar_event(&event_id);
287
289
cx.notify();
288
290
let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);
@@ -320,10 +322,14 @@ impl AppState {
320
322
let mut accounts = store::load_calendar_accounts(&store);
321
323
let account =
322
324
account_id.ok_or_else(|| "CalDAV account missing".to_owned())?;
323
let href = event_id.split('#').next().unwrap_or(&event_id).to_owned();
324
let result =
325
crate::caldav_sync::delete_caldav_event(&mut accounts, &account, &href)
326
.await;
325
let result = crate::caldav_sync::delete_caldav_event(
326
&mut accounts,
327
&account,
328
&event_id,
329
series,
330
occurrence_start,
331
)
332
.await;
327
333
let _ = store::save_calendar_accounts(&store, &accounts);
328
334
result
329
335
}
@@ -562,7 +568,7 @@ impl AppState {
562
568
let mut accounts = store::load_calendar_accounts(&store);
563
569
let account =
564
570
account_id.ok_or_else(|| "CalDAV account missing".to_owned())?;
565
let href = event_id.split('#').next().unwrap_or(&event_id).to_owned();
571
let href = chatsvc::href_from_object_id(&event_id).to_owned();
566
572
let result = crate::caldav_sync::respond_caldav_event(
567
573
&mut accounts,
568
574
&account,
@@ -283,6 +283,8 @@ impl AppState {283
let source = event.source;283
let source = event.source;284
let account_id = event.account_id.clone();284
let account_id = event.account_id.clone();285
let calendar_id = event.calendar_id.clone();285
let calendar_id = event.calendar_id.clone();286
let series = event.series;287
let occurrence_start = event.start;286
self.remove_calendar_event(&event_id);288
self.remove_calendar_event(&event_id);287
cx.notify();289
cx.notify();288
let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);290
let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);@@ -320,10 +322,14 @@ impl AppState {320
let mut accounts = store::load_calendar_accounts(&store);322
let mut accounts = store::load_calendar_accounts(&store);321
let account =323
let account =322
account_id.ok_or_else(|| "CalDAV account missing".to_owned())?;324
account_id.ok_or_else(|| "CalDAV account missing".to_owned())?;323
let href = event_id.split('#').next().unwrap_or(&event_id).to_owned();325
let result = crate::caldav_sync::delete_caldav_event(324
let result =326
&mut accounts,325
crate::caldav_sync::delete_caldav_event(&mut accounts, &account, &href)327
&account,326
.await;328
&event_id,329
series,330
occurrence_start,331
)332
.await;327
let _ = store::save_calendar_accounts(&store, &accounts);333
let _ = store::save_calendar_accounts(&store, &accounts);328
result334
result329
}335
}@@ -562,7 +568,7 @@ impl AppState {562
let mut accounts = store::load_calendar_accounts(&store);568
let mut accounts = store::load_calendar_accounts(&store);563
let account =569
let account =564
account_id.ok_or_else(|| "CalDAV account missing".to_owned())?;570
account_id.ok_or_else(|| "CalDAV account missing".to_owned())?;565
let href = event_id.split('#').next().unwrap_or(&event_id).to_owned();571
let href = chatsvc::href_from_object_id(&event_id).to_owned();566
let result = crate::caldav_sync::respond_caldav_event(572
let result = crate::caldav_sync::respond_caldav_event(567
&mut accounts,573
&mut accounts,568
&account,574
&account,@@ -278,10 +278,16 @@ impl AppState {
278
278
if accounts.has_caldav() {
279
279
match crate::caldav_sync::fetch_caldav_events(&mut fetched_accounts, from, to).await
280
280
{
281
Ok(events) => {
281
Ok((events, partial)) => {
282
282
let _ = store::merge_caldav_metadata(&store, &fetched_accounts);
283
283
caldav_count = Some(events.len());
284
284
combined.extend(events);
285
for message in partial {
286
failures.push(CalendarLoadFailure {
287
source: CalendarSource::CalDav,
288
message,
289
});
290
}
285
291
}
286
292
Err(error) => failures.push(CalendarLoadFailure {
287
293
source: CalendarSource::CalDav,
@@ -291,7 +297,15 @@ impl AppState {
291
297
}
292
298
if accounts.has_ics() {
293
299
match crate::ics_sync::fetch_ics_events(&accounts, from, to).await {
294
Ok(events) => combined.extend(events),
300
Ok((events, partial)) => {
301
combined.extend(events);
302
for message in partial {
303
failures.push(CalendarLoadFailure {
304
source: CalendarSource::Ics,
305
message,
306
});
307
}
308
}
295
309
Err(error) => failures.push(CalendarLoadFailure {
296
310
source: CalendarSource::Ics,
297
311
message: error,
@@ -308,10 +322,7 @@ impl AppState {
308
322
&failures,
309
323
));
310
324
let home = home_calendar(&accounts);
311
(
312
chatsvc::merge_calendar_events(combined, home),
313
failures,
314
)
325
(chatsvc::merge_calendar_events(combined, home), failures)
315
326
});
316
327
cx.spawn(async move |this, cx| {
317
328
let loaded = receiver.await.unwrap_or_else(|_| {
@@ -343,12 +354,17 @@ impl AppState {
343
354
}
344
355
345
356
/// A source that failed keeps its previous events on screen instead of blanking the week.
357
/// When the round already returned some events for that source (partial calendar failure),
358
/// previous events are left out so successful calendars are not duplicated.
346
359
pub(crate) fn keep_failed_sources(
347
360
previous: &[CalendarEvent],
348
361
mut events: Vec<CalendarEvent>,
349
362
failures: &[CalendarLoadFailure],
350
363
) -> Vec<CalendarEvent> {
351
364
for failure in failures {
365
if events.iter().any(|event| event.source == failure.source) {
366
continue;
367
}
352
368
events.extend(
353
369
previous
354
370
.iter()
@@ -678,6 +694,24 @@ mod tests {
678
694
assert_eq!(ids, ["google-new"]);
679
695
}
680
696
697
#[test]
698
fn a_partial_source_failure_does_not_duplicate_fresh_events() {
699
let previous = vec![
700
event("caldav-old-a", CalendarSource::CalDav, 9),
701
event("caldav-old-b", CalendarSource::CalDav, 10),
702
];
703
let fresh = vec![event("caldav-new", CalendarSource::CalDav, 8)];
704
let failures = [CalendarLoadFailure {
705
source: CalendarSource::CalDav,
706
message: "CalDAV Work: timeout".into(),
707
}];
708
let ids: Vec<_> = keep_failed_sources(&previous, fresh, &failures)
709
.into_iter()
710
.map(|event| event.object_id)
711
.collect();
712
assert_eq!(ids, ["caldav-new"]);
713
}
714
681
715
#[test]
682
716
fn the_load_summary_names_counts_and_failures() {
683
717
let from = Utc.with_ymd_and_hms(2026, 11, 15, 23, 0, 0).unwrap();
@@ -278,10 +278,16 @@ impl AppState {278
if accounts.has_caldav() {278
if accounts.has_caldav() {279
match crate::caldav_sync::fetch_caldav_events(&mut fetched_accounts, from, to).await279
match crate::caldav_sync::fetch_caldav_events(&mut fetched_accounts, from, to).await280
{280
{281
Ok(events) => {281
Ok((events, partial)) => {282
let _ = store::merge_caldav_metadata(&store, &fetched_accounts);282
let _ = store::merge_caldav_metadata(&store, &fetched_accounts);283
caldav_count = Some(events.len());283
caldav_count = Some(events.len());284
combined.extend(events);284
combined.extend(events);285
for message in partial {286
failures.push(CalendarLoadFailure {287
source: CalendarSource::CalDav,288
message,289
});290
}285
}291
}286
Err(error) => failures.push(CalendarLoadFailure {292
Err(error) => failures.push(CalendarLoadFailure {287
source: CalendarSource::CalDav,293
source: CalendarSource::CalDav,@@ -291,7 +297,15 @@ impl AppState {291
}297
}292
if accounts.has_ics() {298
if accounts.has_ics() {293
match crate::ics_sync::fetch_ics_events(&accounts, from, to).await {299
match crate::ics_sync::fetch_ics_events(&accounts, from, to).await {294
Ok(events) => combined.extend(events),300
Ok((events, partial)) => {301
combined.extend(events);302
for message in partial {303
failures.push(CalendarLoadFailure {304
source: CalendarSource::Ics,305
message,306
});307
}308
}295
Err(error) => failures.push(CalendarLoadFailure {309
Err(error) => failures.push(CalendarLoadFailure {296
source: CalendarSource::Ics,310
source: CalendarSource::Ics,297
message: error,311
message: error,@@ -308,10 +322,7 @@ impl AppState {308
&failures,322
&failures,309
));323
));310
let home = home_calendar(&accounts);324
let home = home_calendar(&accounts);311
(325
(chatsvc::merge_calendar_events(combined, home), failures)312
chatsvc::merge_calendar_events(combined, home),313
failures,314
)315
});326
});316
cx.spawn(async move |this, cx| {327
cx.spawn(async move |this, cx| {317
let loaded = receiver.await.unwrap_or_else(|_| {328
let loaded = receiver.await.unwrap_or_else(|_| {@@ -343,12 +354,17 @@ impl AppState {343
}354
}344
355
345
/// A source that failed keeps its previous events on screen instead of blanking the week.356
/// A source that failed keeps its previous events on screen instead of blanking the week.357
/// When the round already returned some events for that source (partial calendar failure),358
/// previous events are left out so successful calendars are not duplicated.346
pub(crate) fn keep_failed_sources(359
pub(crate) fn keep_failed_sources(347
previous: &[CalendarEvent],360
previous: &[CalendarEvent],348
mut events: Vec<CalendarEvent>,361
mut events: Vec<CalendarEvent>,349
failures: &[CalendarLoadFailure],362
failures: &[CalendarLoadFailure],350
) -> Vec<CalendarEvent> {363
) -> Vec<CalendarEvent> {351
for failure in failures {364
for failure in failures {365
if events.iter().any(|event| event.source == failure.source) {366
continue;367
}352
events.extend(368
events.extend(353
previous369
previous354
.iter()370
.iter()@@ -678,6 +694,24 @@ mod tests {678
assert_eq!(ids, ["google-new"]);694
assert_eq!(ids, ["google-new"]);679
}695
}680
696
697
#[test]698
fn a_partial_source_failure_does_not_duplicate_fresh_events() {699
let previous = vec![700
event("caldav-old-a", CalendarSource::CalDav, 9),701
event("caldav-old-b", CalendarSource::CalDav, 10),702
];703
let fresh = vec![event("caldav-new", CalendarSource::CalDav, 8)];704
let failures = [CalendarLoadFailure {705
source: CalendarSource::CalDav,706
message: "CalDAV Work: timeout".into(),707
}];708
let ids: Vec<_> = keep_failed_sources(&previous, fresh, &failures)709
.into_iter()710
.map(|event| event.object_id)711
.collect();712
assert_eq!(ids, ["caldav-new"]);713
}714
681
#[test]715
#[test]682
fn the_load_summary_names_counts_and_failures() {716
fn the_load_summary_names_counts_and_failures() {683
let from = Utc.with_ymd_and_hms(2026, 11, 15, 23, 0, 0).unwrap();717
let from = Utc.with_ymd_and_hms(2026, 11, 15, 23, 0, 0).unwrap();@@ -175,20 +175,3 @@ async fn ensure_access_token(
175
175
fn missing_client_id() -> String {
176
176
app_base::ui_locale::tr("settings.calendar.not_in_build")
177
177
}
178
179
#[cfg(test)]
180
mod tests {
181
use super::*;
182
183
#[test]
184
fn refresh_failure_message_is_err_not_empty_ok() {
185
// Contract for week load: auth refresh problems must be Err so CalendarLoadFailure fires.
186
let err: Result<Vec<CalendarEvent>, String> =
187
Err("google token refresh failed: HTTP 400: client_secret is missing".into());
188
assert!(err.is_err());
189
assert!(err.unwrap_err().contains("token refresh failed"));
190
let empty_ok: Result<Vec<CalendarEvent>, String> = Ok(Vec::new());
191
assert!(empty_ok.is_ok());
192
assert!(empty_ok.unwrap().is_empty());
193
}
194
}
@@ -175,20 +175,3 @@ async fn ensure_access_token(175
fn missing_client_id() -> String {175
fn missing_client_id() -> String {176
app_base::ui_locale::tr("settings.calendar.not_in_build")176
app_base::ui_locale::tr("settings.calendar.not_in_build")177
}177
}178
179
#[cfg(test)]180
mod tests {181
use super::*;182
183
#[test]184
fn refresh_failure_message_is_err_not_empty_ok() {185
// Contract for week load: auth refresh problems must be Err so CalendarLoadFailure fires.186
let err: Result<Vec<CalendarEvent>, String> =187
Err("google token refresh failed: HTTP 400: client_secret is missing".into());188
assert!(err.is_err());189
assert!(err.unwrap_err().contains("token refresh failed"));190
let empty_ok: Result<Vec<CalendarEvent>, String> = Ok(Vec::new());191
assert!(empty_ok.is_ok());192
assert!(empty_ok.unwrap().is_empty());193
}194
}@@ -1,23 +1,31 @@
1
1
//! Read-only ICS subscriptions (holidays, Proton share links).
2
2
3
use std::collections::HashSet;
4
use std::time::Duration;
5
3
6
use chrono::{DateTime, Utc};
4
7
use store::{CalendarAccounts, IcsSubscription};
5
8
use uuid::Uuid;
6
9
7
use chatsvc::{CalendarEvent, CalendarSource, expand_events, parse_calendar};
10
use chatsvc::{CalendarEvent, CalendarSource, expand_events, object_id_for, parse_calendar};
11
12
const REQUEST_TIMEOUT: Duration = Duration::from_secs(20);
8
13
9
14
pub async fn add_ics_subscription(
10
15
accounts: &mut CalendarAccounts,
11
16
url: &str,
12
17
summary: &str,
13
18
) -> Result<String, String> {
14
let url = url.trim().to_owned();
15
if url.is_empty() {
16
return Err("ICS URL is empty".into());
17
}
19
let url = normalize_ics_url(url)?;
18
20
// Smoke-fetch once so a bad URL fails at connect time.
19
let _ = fetch_one(&url, "tmp", summary, Utc::now(), Utc::now() + chrono::Duration::days(1))
20
.await?;
21
let _ = fetch_one(
22
&url,
23
"tmp",
24
summary,
25
Utc::now(),
26
Utc::now() + chrono::Duration::days(1),
27
)
28
.await?;
21
29
let id = Uuid::new_v4().to_string();
22
30
accounts.ics_subscriptions.push(IcsSubscription {
23
31
id: id.clone(),
@@ -32,31 +40,54 @@ pub async fn add_ics_subscription(
32
40
Ok(id)
33
41
}
34
42
43
/// Events plus per-subscription failure messages.
35
44
pub async fn fetch_ics_events(
36
45
accounts: &CalendarAccounts,
37
46
start: DateTime<Utc>,
38
47
end: DateTime<Utc>,
39
) -> Result<Vec<CalendarEvent>, String> {
48
) -> Result<(Vec<CalendarEvent>, Vec<String>), String> {
40
49
let mut all = Vec::new();
50
let mut failures = Vec::new();
41
51
for subscription in accounts
42
52
.ics_subscriptions
43
53
.iter()
44
54
.filter(|subscription| subscription.selected)
45
55
{
46
match fetch_one(
47
&subscription.url,
48
&subscription.id,
49
&subscription.summary,
50
start,
51
end,
52
)
53
.await
54
{
56
let url = match normalize_ics_url(&subscription.url) {
57
Ok(url) => url,
58
Err(error) => {
59
failures.push(format!("ICS {}: {error}", subscription.summary));
60
continue;
61
}
62
};
63
match fetch_one(&url, &subscription.id, &subscription.summary, start, end).await {
55
64
Ok(events) => all.extend(events),
56
Err(error) => return Err(format!("ICS {}: {error}", subscription.summary)),
65
Err(error) => failures.push(format!("ICS {}: {error}", subscription.summary)),
57
66
}
58
67
}
59
Ok(all)
68
Ok((all, failures))
69
}
70
71
pub fn normalize_ics_url(url: &str) -> Result<String, String> {
72
let trimmed = url.trim();
73
if trimmed.is_empty() {
74
return Err("ICS URL is empty".into());
75
}
76
let lowered = trimmed.to_ascii_lowercase();
77
let with_scheme = if let Some(rest) = lowered.strip_prefix("webcals://") {
78
format!("https://{}", &trimmed[trimmed.len() - rest.len()..])
79
} else if let Some(rest) = lowered.strip_prefix("webcal://") {
80
format!("https://{}", &trimmed[trimmed.len() - rest.len()..])
81
} else if trimmed.contains("://") {
82
trimmed.to_owned()
83
} else {
84
format!("https://{trimmed}")
85
};
86
let parsed = url::Url::parse(&with_scheme).map_err(|e| e.to_string())?;
87
if parsed.scheme() != "https" && parsed.scheme() != "http" {
88
return Err(format!("Unsupported ICS URL scheme: {}", parsed.scheme()));
89
}
90
Ok(parsed.to_string())
60
91
}
61
92
62
93
async fn fetch_one(
@@ -66,40 +97,69 @@ async fn fetch_one(
66
97
start: DateTime<Utc>,
67
98
end: DateTime<Utc>,
68
99
) -> Result<Vec<CalendarEvent>, String> {
69
let client = reqwest::Client::new();
70
let response = client
71
.get(url)
72
.send()
73
.await
100
let client = reqwest::Client::builder()
101
.timeout(REQUEST_TIMEOUT)
102
.build()
74
103
.map_err(|e| e.to_string())?;
104
let response = client.get(url).send().await.map_err(|e| e.to_string())?;
75
105
if !response.status().is_success() {
76
106
return Err(format!("HTTP {}", response.status()));
77
107
}
78
108
let body = response.text().await.map_err(|e| e.to_string())?;
79
109
let parsed = parse_calendar(&body);
110
let series_uids: HashSet<String> = parsed
111
.iter()
112
.filter(|event| {
113
event.rrule.is_some() || !event.rdates.is_empty() || event.recurrence_id.is_some()
114
})
115
.map(|event| event.uid.clone())
116
.collect();
80
117
let expanded = expand_events(parsed, start, end);
81
118
Ok(expanded
82
119
.into_iter()
83
.map(|item| CalendarEvent {
84
object_id: format!("ics:{}:{}", account_id, item.uid),
85
subject: item.summary,
86
start: item.start,
87
end: item.end,
88
all_day: item.all_day,
89
cancelled: item.cancelled,
90
online: item.join_url.is_some(),
91
join_url: item.join_url,
92
ical_uid: Some(item.uid),
93
source: CalendarSource::Ics,
94
account_id: Some(account_id.to_owned()),
95
calendar_id: Some(url.to_owned()),
96
sources: vec![CalendarSource::Ics],
97
location: item.location,
98
body_preview: item.description.clone(),
99
body_html: item.description,
100
reminders: item.reminders_minutes,
101
calendar_name: Some(calendar_name.to_owned()),
102
..Default::default()
120
.map(|item| {
121
let series = series_uids.contains(&item.uid) || item.recurrence_id.is_some();
122
let object_id =
123
object_id_for(&format!("ics:{account_id}"), &item.uid, series, item.start);
124
CalendarEvent {
125
object_id,
126
subject: item.summary,
127
start: item.start,
128
end: item.end,
129
all_day: item.all_day,
130
cancelled: item.cancelled,
131
online: item.join_url.is_some(),
132
join_url: item.join_url,
133
ical_uid: Some(item.uid),
134
source: CalendarSource::Ics,
135
account_id: Some(account_id.to_owned()),
136
calendar_id: Some(url.to_owned()),
137
sources: vec![CalendarSource::Ics],
138
location: item.location,
139
body_preview: item.description.clone(),
140
body_html: item.description,
141
reminders: item.reminders_minutes,
142
calendar_name: Some(calendar_name.to_owned()),
143
series,
144
..Default::default()
145
}
103
146
})
104
147
.collect())
105
148
}
149
150
#[cfg(test)]
151
mod tests {
152
use super::*;
153
154
#[test]
155
fn webcal_becomes_https() {
156
assert_eq!(
157
normalize_ics_url("webcal://calendar.example/feed.ics").unwrap(),
158
"https://calendar.example/feed.ics"
159
);
160
assert_eq!(
161
normalize_ics_url("webcals://calendar.example/feed.ics").unwrap(),
162
"https://calendar.example/feed.ics"
163
);
164
}
165
}
@@ -1,23 +1,31 @@1
//! Read-only ICS subscriptions (holidays, Proton share links).1
//! Read-only ICS subscriptions (holidays, Proton share links).2
2
3
use std::collections::HashSet;4
use std::time::Duration;5
3
use chrono::{DateTime, Utc};6
use chrono::{DateTime, Utc};4
use store::{CalendarAccounts, IcsSubscription};7
use store::{CalendarAccounts, IcsSubscription};5
use uuid::Uuid;8
use uuid::Uuid;6
9
7
use chatsvc::{CalendarEvent, CalendarSource, expand_events, parse_calendar};10
use chatsvc::{CalendarEvent, CalendarSource, expand_events, object_id_for, parse_calendar};11
12
const REQUEST_TIMEOUT: Duration = Duration::from_secs(20);8
13
9
pub async fn add_ics_subscription(14
pub async fn add_ics_subscription(10
accounts: &mut CalendarAccounts,15
accounts: &mut CalendarAccounts,11
url: &str,16
url: &str,12
summary: &str,17
summary: &str,13
) -> Result<String, String> {18
) -> Result<String, String> {14
let url = url.trim().to_owned();19
let url = normalize_ics_url(url)?;15
if url.is_empty() {16
return Err("ICS URL is empty".into());17
}18
// Smoke-fetch once so a bad URL fails at connect time.20
// Smoke-fetch once so a bad URL fails at connect time.19
let _ = fetch_one(&url, "tmp", summary, Utc::now(), Utc::now() + chrono::Duration::days(1))21
let _ = fetch_one(20
.await?;22
&url,23
"tmp",24
summary,25
Utc::now(),26
Utc::now() + chrono::Duration::days(1),27
)28
.await?;21
let id = Uuid::new_v4().to_string();29
let id = Uuid::new_v4().to_string();22
accounts.ics_subscriptions.push(IcsSubscription {30
accounts.ics_subscriptions.push(IcsSubscription {23
id: id.clone(),31
id: id.clone(),@@ -32,31 +40,54 @@ pub async fn add_ics_subscription(32
Ok(id)40
Ok(id)33
}41
}34
42
43
/// Events plus per-subscription failure messages.35
pub async fn fetch_ics_events(44
pub async fn fetch_ics_events(36
accounts: &CalendarAccounts,45
accounts: &CalendarAccounts,37
start: DateTime<Utc>,46
start: DateTime<Utc>,38
end: DateTime<Utc>,47
end: DateTime<Utc>,39
) -> Result<Vec<CalendarEvent>, String> {48
) -> Result<(Vec<CalendarEvent>, Vec<String>), String> {40
let mut all = Vec::new();49
let mut all = Vec::new();50
let mut failures = Vec::new();41
for subscription in accounts51
for subscription in accounts42
.ics_subscriptions52
.ics_subscriptions43
.iter()53
.iter()44
.filter(|subscription| subscription.selected)54
.filter(|subscription| subscription.selected)45
{55
{46
match fetch_one(56
let url = match normalize_ics_url(&subscription.url) {47
&subscription.url,57
Ok(url) => url,48
&subscription.id,58
Err(error) => {49
&subscription.summary,59
failures.push(format!("ICS {}: {error}", subscription.summary));50
start,60
continue;51
end,61
}52
)62
};53
.await63
match fetch_one(&url, &subscription.id, &subscription.summary, start, end).await {54
{55
Ok(events) => all.extend(events),64
Ok(events) => all.extend(events),56
Err(error) => return Err(format!("ICS {}: {error}", subscription.summary)),65
Err(error) => failures.push(format!("ICS {}: {error}", subscription.summary)),57
}66
}58
}67
}59
Ok(all)68
Ok((all, failures))69
}70
71
pub fn normalize_ics_url(url: &str) -> Result<String, String> {72
let trimmed = url.trim();73
if trimmed.is_empty() {74
return Err("ICS URL is empty".into());75
}76
let lowered = trimmed.to_ascii_lowercase();77
let with_scheme = if let Some(rest) = lowered.strip_prefix("webcals://") {78
format!("https://{}", &trimmed[trimmed.len() - rest.len()..])79
} else if let Some(rest) = lowered.strip_prefix("webcal://") {80
format!("https://{}", &trimmed[trimmed.len() - rest.len()..])81
} else if trimmed.contains("://") {82
trimmed.to_owned()83
} else {84
format!("https://{trimmed}")85
};86
let parsed = url::Url::parse(&with_scheme).map_err(|e| e.to_string())?;87
if parsed.scheme() != "https" && parsed.scheme() != "http" {88
return Err(format!("Unsupported ICS URL scheme: {}", parsed.scheme()));89
}90
Ok(parsed.to_string())60
}91
}61
92
62
async fn fetch_one(93
async fn fetch_one(@@ -66,40 +97,69 @@ async fn fetch_one(66
start: DateTime<Utc>,97
start: DateTime<Utc>,67
end: DateTime<Utc>,98
end: DateTime<Utc>,68
) -> Result<Vec<CalendarEvent>, String> {99
) -> Result<Vec<CalendarEvent>, String> {69
let client = reqwest::Client::new();100
let client = reqwest::Client::builder()70
let response = client101
.timeout(REQUEST_TIMEOUT)71
.get(url)102
.build()72
.send()73
.await74
.map_err(|e| e.to_string())?;103
.map_err(|e| e.to_string())?;104
let response = client.get(url).send().await.map_err(|e| e.to_string())?;75
if !response.status().is_success() {105
if !response.status().is_success() {76
return Err(format!("HTTP {}", response.status()));106
return Err(format!("HTTP {}", response.status()));77
}107
}78
let body = response.text().await.map_err(|e| e.to_string())?;108
let body = response.text().await.map_err(|e| e.to_string())?;79
let parsed = parse_calendar(&body);109
let parsed = parse_calendar(&body);110
let series_uids: HashSet<String> = parsed111
.iter()112
.filter(|event| {113
event.rrule.is_some() || !event.rdates.is_empty() || event.recurrence_id.is_some()114
})115
.map(|event| event.uid.clone())116
.collect();80
let expanded = expand_events(parsed, start, end);117
let expanded = expand_events(parsed, start, end);81
Ok(expanded118
Ok(expanded82
.into_iter()119
.into_iter()83
.map(|item| CalendarEvent {120
.map(|item| {84
object_id: format!("ics:{}:{}", account_id, item.uid),121
let series = series_uids.contains(&item.uid) || item.recurrence_id.is_some();85
subject: item.summary,122
let object_id =86
start: item.start,123
object_id_for(&format!("ics:{account_id}"), &item.uid, series, item.start);87
end: item.end,124
CalendarEvent {88
all_day: item.all_day,125
object_id,89
cancelled: item.cancelled,126
subject: item.summary,90
online: item.join_url.is_some(),127
start: item.start,91
join_url: item.join_url,128
end: item.end,92
ical_uid: Some(item.uid),129
all_day: item.all_day,93
source: CalendarSource::Ics,130
cancelled: item.cancelled,94
account_id: Some(account_id.to_owned()),131
online: item.join_url.is_some(),95
calendar_id: Some(url.to_owned()),132
join_url: item.join_url,96
sources: vec![CalendarSource::Ics],133
ical_uid: Some(item.uid),97
location: item.location,134
source: CalendarSource::Ics,98
body_preview: item.description.clone(),135
account_id: Some(account_id.to_owned()),99
body_html: item.description,136
calendar_id: Some(url.to_owned()),100
reminders: item.reminders_minutes,137
sources: vec![CalendarSource::Ics],101
calendar_name: Some(calendar_name.to_owned()),138
location: item.location,102
..Default::default()139
body_preview: item.description.clone(),140
body_html: item.description,141
reminders: item.reminders_minutes,142
calendar_name: Some(calendar_name.to_owned()),143
series,144
..Default::default()145
}103
})146
})104
.collect())147
.collect())105
}148
}149
150
#[cfg(test)]151
mod tests {152
use super::*;153
154
#[test]155
fn webcal_becomes_https() {156
assert_eq!(157
normalize_ics_url("webcal://calendar.example/feed.ics").unwrap(),158
"https://calendar.example/feed.ics"159
);160
assert_eq!(161
normalize_ics_url("webcals://calendar.example/feed.ics").unwrap(),162
"https://calendar.example/feed.ics"163
);164
}165
}@@ -6,9 +6,9 @@ pub mod app_state;
6
6
pub mod backend;
7
7
pub mod banner_image;
8
8
pub mod browser_sign_in;
9
pub mod calendar_accounts_actions;
10
9
pub mod caldav_credentials;
11
10
pub mod caldav_sync;
11
pub mod calendar_accounts_actions;
12
12
pub mod call;
13
13
pub mod call_rows;
14
14
pub mod card_actions;
@@ -6,9 +6,9 @@ pub mod app_state;6
pub mod backend;6
pub mod backend;7
pub mod banner_image;7
pub mod banner_image;8
pub mod browser_sign_in;8
pub mod browser_sign_in;9
pub mod calendar_accounts_actions;10
pub mod caldav_credentials;9
pub mod caldav_credentials;11
pub mod caldav_sync;10
pub mod caldav_sync;11
pub mod calendar_accounts_actions;12
pub mod call;12
pub mod call;13
pub mod call_rows;13
pub mod call_rows;14
pub mod card_actions;14
pub mod card_actions;@@ -1,3 +1,6 @@
1
use std::collections::HashSet;
2
use std::time::Duration;
3
1
4
use chrono::{DateTime, Utc};
2
5
use reqwest::{Client, Method, StatusCode, header};
3
6
use uuid::Uuid;
@@ -6,12 +9,12 @@ use crate::calendar::{
6
9
AttendeeResponseCounts, CalendarEvent, CalendarSource, EventAttendee, ResponseType, ShowAs,
7
10
};
8
11
use crate::error::{Error, Result};
9
use crate::ical::{CalDavEventDraft, expand_events, parse_calendar};
12
use crate::ical::{CalDavEventDraft, exclude_occurrence_from_ics, expand_events, parse_calendar};
10
13
11
14
use super::discovery::{DiscoverResult, discover, reject_https_downgrade, resolve_url};
12
use super::xml::{
13
calendar_query_body, parse_calendar_query, parse_multistatus, propfind_body,
14
};
15
use super::xml::{calendar_query_body, parse_calendar_query, parse_multistatus, propfind_body};
16
17
const REQUEST_TIMEOUT: Duration = Duration::from_secs(20);
15
18
16
19
#[derive(Debug, Clone)]
17
20
pub struct ListedCalendar {
@@ -35,25 +38,27 @@ pub struct CalDavClient {
35
38
}
36
39
37
40
impl CalDavClient {
38
pub fn new(username: impl Into<String>, password: impl Into<String>) -> Self {
39
CalDavClient {
40
http: Client::builder()
41
.redirect(reqwest::redirect::Policy::custom(|attempt| {
42
let previous = attempt.previous().last().map(|u| u.as_str()).unwrap_or("");
43
let next = attempt.url().as_str();
44
if previous.starts_with("https://") && next.starts_with("http://") {
45
attempt.error(std::io::Error::other("https downgrade"))
46
} else if attempt.previous().len() > 10 {
47
attempt.stop()
48
} else {
49
attempt.follow()
50
}
51
}))
52
.build()
53
.unwrap_or_else(|_| Client::new()),
41
pub fn new(username: impl Into<String>, password: impl Into<String>) -> Result<Self> {
42
let http = Client::builder()
43
.timeout(REQUEST_TIMEOUT)
44
.redirect(reqwest::redirect::Policy::custom(|attempt| {
45
let previous = attempt.previous().last().map(|u| u.as_str()).unwrap_or("");
46
let next = attempt.url().as_str();
47
if previous.starts_with("https://") && next.starts_with("http://") {
48
attempt.error(std::io::Error::other("https downgrade"))
49
} else if attempt.previous().len() > 10 {
50
attempt.stop()
51
} else {
52
attempt.follow()
53
}
54
}))
55
.build()
56
.map_err(map_reqwest)?;
57
Ok(CalDavClient {
58
http,
54
59
username: username.into(),
55
60
password: password.into(),
56
}
61
})
57
62
}
58
63
59
64
pub async fn discover(&self, url: &str) -> Result<DiscoverResult> {
@@ -104,31 +109,35 @@ impl CalDavClient {
104
109
) -> Result<Vec<CalDavEvent>> {
105
110
let start = from.format("%Y%m%dT%H%M%SZ").to_string();
106
111
let end = to.format("%Y%m%dT%H%M%SZ").to_string();
107
let mut resources = self
108
.calendar_query(calendar_href, &start, &end, true)
109
.await;
112
let mut resources = self.calendar_query(calendar_href, &start, &end, true).await;
110
113
if resources.is_err() {
111
resources = self.calendar_query(calendar_href, &start, &end, false).await;
114
resources = self
115
.calendar_query(calendar_href, &start, &end, false)
116
.await;
112
117
}
113
118
let resources = resources?;
114
119
let mut out = Vec::new();
115
120
for (href, etag, data) in resources {
116
121
let absolute = resolve_url(calendar_href, &href).unwrap_or(href);
117
122
let parsed = parse_calendar(&data);
123
let series_uids: HashSet<String> = parsed
124
.iter()
125
.filter(|event| {
126
event.rrule.is_some()
127
|| !event.rdates.is_empty()
128
|| event.recurrence_id.is_some()
129
})
130
.map(|event| event.uid.clone())
131
.collect();
118
132
let expanded = expand_events(parsed, from, to);
119
133
for item in expanded {
120
let mut event = to_calendar_event(
121
&item,
122
account_id,
123
&absolute,
124
calendar_name,
125
);
134
let mut event = to_calendar_event(&item, account_id, &absolute, calendar_name);
135
let uid = event.ical_uid.clone().unwrap_or_default();
136
let series = series_uids.contains(&uid) || item.recurrence_id.is_some();
137
event.series = series;
138
event.object_id = object_id_for(&absolute, &uid, series, item.start);
126
139
out.push(CalDavEvent {
127
event: {
128
// Keep href in object_id for writes.
129
event.object_id = format!("{absolute}#{}", event.ical_uid.clone().unwrap_or_default());
130
event
131
},
140
event,
132
141
href: absolute.clone(),
133
142
etag: etag.clone(),
134
143
});
@@ -143,11 +152,7 @@ impl CalDavClient {
143
152
draft: &CalDavEventDraft,
144
153
stamp: DateTime<Utc>,
145
154
) -> Result<String> {
146
let href = format!(
147
"{}{}.ics",
148
ensure_trailing_slash(calendar_href),
149
draft.uid
150
);
155
let href = format!("{}{}.ics", ensure_trailing_slash(calendar_href), draft.uid);
151
156
let body = crate::ical::build_vevent(draft, stamp);
152
157
let response = self
153
158
.http
@@ -188,6 +193,55 @@ impl CalDavClient {
188
193
)))
189
194
}
190
195
196
/// Exclude one occurrence by EXDATE on the master; does not DELETE the series href.
197
pub async fn exclude_occurrence(
198
&self,
199
href: &str,
200
occurrence: DateTime<Utc>,
201
etag: Option<&str>,
202
) -> Result<()> {
203
let response = self
204
.http
205
.get(href)
206
.basic_auth(&self.username, Some(&self.password))
207
.send()
208
.await
209
.map_err(map_reqwest)?;
210
ensure_auth(response.status())?;
211
let fresh_etag = response
212
.headers()
213
.get(header::ETAG)
214
.and_then(|v| v.to_str().ok())
215
.map(|v| v.trim_matches('"').to_owned());
216
let body = response.text().await.map_err(map_reqwest)?;
217
let updated =
218
exclude_occurrence_from_ics(&body, occurrence).map_err(Error::UnexpectedAnswer)?;
219
let match_etag = etag.or(fresh_etag.as_deref());
220
let mut request = self
221
.http
222
.put(href)
223
.basic_auth(&self.username, Some(&self.password))
224
.header(header::CONTENT_TYPE, "text/calendar; charset=utf-8")
225
.body(updated);
226
if let Some(etag) = match_etag {
227
request = request.header(header::IF_MATCH, format!("\"{etag}\""));
228
}
229
let response = request.send().await.map_err(map_reqwest)?;
230
if response.status() == StatusCode::PRECONDITION_FAILED {
231
return Err(Error::UnexpectedAnswer(
232
"CalDAV event changed on the server; reload and try again".into(),
233
));
234
}
235
ensure_auth(response.status())?;
236
if !response.status().is_success() {
237
return Err(Error::UnexpectedAnswer(format!(
238
"CalDAV EXDATE failed: {}",
239
response.status()
240
)));
241
}
242
Ok(())
243
}
244
191
245
pub async fn update_partstat(
192
246
&self,
193
247
href: &str,
@@ -320,10 +374,7 @@ fn to_calendar_event(
320
374
join_url: parsed.join_url.clone(),
321
375
thread_id: None,
322
376
organizer_name: parsed.organizer.as_ref().map(|(n, _)| n.clone()),
323
organizer_address: parsed
324
.organizer
325
.as_ref()
326
.and_then(|(_, a)| a.clone()),
377
organizer_address: parsed.organizer.as_ref().and_then(|(_, a)| a.clone()),
327
378
ical_uid: Some(parsed.uid.clone()),
328
379
response,
329
380
show_as: if parsed.transparent {
@@ -345,7 +396,10 @@ fn to_calendar_event(
345
396
}
346
397
}),
347
398
body_html: parsed.description.clone(),
348
series: parsed.rrule.is_some() || parsed.recurrence_id.is_some(),
399
// Overridden by fetch_events after expansion (RRULE is cleared on occurrences).
400
series: parsed.rrule.is_some()
401
|| !parsed.rdates.is_empty()
402
|| parsed.recurrence_id.is_some(),
349
403
series_master_id: None,
350
404
response_counts: None::<AttendeeResponseCounts>,
351
405
attendees: parsed
@@ -442,3 +496,32 @@ fn map_reqwest(error: reqwest::Error) -> Error {
442
496
pub fn new_event_uid() -> String {
443
497
format!("{}@rusty-teams", Uuid::new_v4())
444
498
}
499
500
pub fn object_id_for(href: &str, uid: &str, series: bool, start: DateTime<Utc>) -> String {
501
if series {
502
format!("{href}#{uid}#{}", start.format("%Y%m%dT%H%M%SZ"))
503
} else {
504
format!("{href}#{uid}")
505
}
506
}
507
508
pub fn href_from_object_id(object_id: &str) -> &str {
509
object_id.split('#').next().unwrap_or(object_id)
510
}
511
512
#[cfg(test)]
513
mod object_id_tests {
514
use super::*;
515
use chrono::TimeZone;
516
517
#[test]
518
fn series_occurrences_get_distinct_ids() {
519
let start_a = Utc.with_ymd_and_hms(2026, 1, 5, 9, 0, 0).unwrap();
520
let start_b = Utc.with_ymd_and_hms(2026, 1, 12, 9, 0, 0).unwrap();
521
let a = object_id_for("https://dav.example/cal/evt.ics", "series", true, start_a);
522
let b = object_id_for("https://dav.example/cal/evt.ics", "series", true, start_b);
523
assert_ne!(a, b);
524
assert!(a.ends_with("#20260105T090000Z"));
525
assert_eq!(href_from_object_id(&a), "https://dav.example/cal/evt.ics");
526
}
527
}
@@ -1,3 +1,6 @@1
use std::collections::HashSet;2
use std::time::Duration;3
1
use chrono::{DateTime, Utc};4
use chrono::{DateTime, Utc};2
use reqwest::{Client, Method, StatusCode, header};5
use reqwest::{Client, Method, StatusCode, header};3
use uuid::Uuid;6
use uuid::Uuid;@@ -6,12 +9,12 @@ use crate::calendar::{6
AttendeeResponseCounts, CalendarEvent, CalendarSource, EventAttendee, ResponseType, ShowAs,9
AttendeeResponseCounts, CalendarEvent, CalendarSource, EventAttendee, ResponseType, ShowAs,7
};10
};8
use crate::error::{Error, Result};11
use crate::error::{Error, Result};9
use crate::ical::{CalDavEventDraft, expand_events, parse_calendar};12
use crate::ical::{CalDavEventDraft, exclude_occurrence_from_ics, expand_events, parse_calendar};10
13
11
use super::discovery::{DiscoverResult, discover, reject_https_downgrade, resolve_url};14
use super::discovery::{DiscoverResult, discover, reject_https_downgrade, resolve_url};12
use super::xml::{15
use super::xml::{calendar_query_body, parse_calendar_query, parse_multistatus, propfind_body};13
calendar_query_body, parse_calendar_query, parse_multistatus, propfind_body,16
14
};17
const REQUEST_TIMEOUT: Duration = Duration::from_secs(20);15
18
16
#[derive(Debug, Clone)]19
#[derive(Debug, Clone)]17
pub struct ListedCalendar {20
pub struct ListedCalendar {@@ -35,25 +38,27 @@ pub struct CalDavClient {35
}38
}36
39
37
impl CalDavClient {40
impl CalDavClient {38
pub fn new(username: impl Into<String>, password: impl Into<String>) -> Self {41
pub fn new(username: impl Into<String>, password: impl Into<String>) -> Result<Self> {39
CalDavClient {42
let http = Client::builder()40
http: Client::builder()43
.timeout(REQUEST_TIMEOUT)41
.redirect(reqwest::redirect::Policy::custom(|attempt| {44
.redirect(reqwest::redirect::Policy::custom(|attempt| {42
let previous = attempt.previous().last().map(|u| u.as_str()).unwrap_or("");45
let previous = attempt.previous().last().map(|u| u.as_str()).unwrap_or("");43
let next = attempt.url().as_str();46
let next = attempt.url().as_str();44
if previous.starts_with("https://") && next.starts_with("http://") {47
if previous.starts_with("https://") && next.starts_with("http://") {45
attempt.error(std::io::Error::other("https downgrade"))48
attempt.error(std::io::Error::other("https downgrade"))46
} else if attempt.previous().len() > 10 {49
} else if attempt.previous().len() > 10 {47
attempt.stop()50
attempt.stop()48
} else {51
} else {49
attempt.follow()52
attempt.follow()50
}53
}51
}))54
}))52
.build()55
.build()53
.unwrap_or_else(|_| Client::new()),56
.map_err(map_reqwest)?;57
Ok(CalDavClient {58
http,54
username: username.into(),59
username: username.into(),55
password: password.into(),60
password: password.into(),56
}61
})57
}62
}58
63
59
pub async fn discover(&self, url: &str) -> Result<DiscoverResult> {64
pub async fn discover(&self, url: &str) -> Result<DiscoverResult> {@@ -104,31 +109,35 @@ impl CalDavClient {104
) -> Result<Vec<CalDavEvent>> {109
) -> Result<Vec<CalDavEvent>> {105
let start = from.format("%Y%m%dT%H%M%SZ").to_string();110
let start = from.format("%Y%m%dT%H%M%SZ").to_string();106
let end = to.format("%Y%m%dT%H%M%SZ").to_string();111
let end = to.format("%Y%m%dT%H%M%SZ").to_string();107
let mut resources = self112
let mut resources = self.calendar_query(calendar_href, &start, &end, true).await;108
.calendar_query(calendar_href, &start, &end, true)109
.await;110
if resources.is_err() {113
if resources.is_err() {111
resources = self.calendar_query(calendar_href, &start, &end, false).await;114
resources = self115
.calendar_query(calendar_href, &start, &end, false)116
.await;112
}117
}113
let resources = resources?;118
let resources = resources?;114
let mut out = Vec::new();119
let mut out = Vec::new();115
for (href, etag, data) in resources {120
for (href, etag, data) in resources {116
let absolute = resolve_url(calendar_href, &href).unwrap_or(href);121
let absolute = resolve_url(calendar_href, &href).unwrap_or(href);117
let parsed = parse_calendar(&data);122
let parsed = parse_calendar(&data);123
let series_uids: HashSet<String> = parsed124
.iter()125
.filter(|event| {126
event.rrule.is_some()127
|| !event.rdates.is_empty()128
|| event.recurrence_id.is_some()129
})130
.map(|event| event.uid.clone())131
.collect();118
let expanded = expand_events(parsed, from, to);132
let expanded = expand_events(parsed, from, to);119
for item in expanded {133
for item in expanded {120
let mut event = to_calendar_event(134
let mut event = to_calendar_event(&item, account_id, &absolute, calendar_name);121
&item,135
let uid = event.ical_uid.clone().unwrap_or_default();122
account_id,136
let series = series_uids.contains(&uid) || item.recurrence_id.is_some();123
&absolute,137
event.series = series;124
calendar_name,138
event.object_id = object_id_for(&absolute, &uid, series, item.start);125
);126
out.push(CalDavEvent {139
out.push(CalDavEvent {127
event: {140
event,128
// Keep href in object_id for writes.129
event.object_id = format!("{absolute}#{}", event.ical_uid.clone().unwrap_or_default());130
event131
},132
href: absolute.clone(),141
href: absolute.clone(),133
etag: etag.clone(),142
etag: etag.clone(),134
});143
});@@ -143,11 +152,7 @@ impl CalDavClient {143
draft: &CalDavEventDraft,152
draft: &CalDavEventDraft,144
stamp: DateTime<Utc>,153
stamp: DateTime<Utc>,145
) -> Result<String> {154
) -> Result<String> {146
let href = format!(155
let href = format!("{}{}.ics", ensure_trailing_slash(calendar_href), draft.uid);147
"{}{}.ics",148
ensure_trailing_slash(calendar_href),149
draft.uid150
);151
let body = crate::ical::build_vevent(draft, stamp);156
let body = crate::ical::build_vevent(draft, stamp);152
let response = self157
let response = self153
.http158
.http@@ -188,6 +193,55 @@ impl CalDavClient {188
)))193
)))189
}194
}190
195
196
/// Exclude one occurrence by EXDATE on the master; does not DELETE the series href.197
pub async fn exclude_occurrence(198
&self,199
href: &str,200
occurrence: DateTime<Utc>,201
etag: Option<&str>,202
) -> Result<()> {203
let response = self204
.http205
.get(href)206
.basic_auth(&self.username, Some(&self.password))207
.send()208
.await209
.map_err(map_reqwest)?;210
ensure_auth(response.status())?;211
let fresh_etag = response212
.headers()213
.get(header::ETAG)214
.and_then(|v| v.to_str().ok())215
.map(|v| v.trim_matches('"').to_owned());216
let body = response.text().await.map_err(map_reqwest)?;217
let updated =218
exclude_occurrence_from_ics(&body, occurrence).map_err(Error::UnexpectedAnswer)?;219
let match_etag = etag.or(fresh_etag.as_deref());220
let mut request = self221
.http222
.put(href)223
.basic_auth(&self.username, Some(&self.password))224
.header(header::CONTENT_TYPE, "text/calendar; charset=utf-8")225
.body(updated);226
if let Some(etag) = match_etag {227
request = request.header(header::IF_MATCH, format!("\"{etag}\""));228
}229
let response = request.send().await.map_err(map_reqwest)?;230
if response.status() == StatusCode::PRECONDITION_FAILED {231
return Err(Error::UnexpectedAnswer(232
"CalDAV event changed on the server; reload and try again".into(),233
));234
}235
ensure_auth(response.status())?;236
if !response.status().is_success() {237
return Err(Error::UnexpectedAnswer(format!(238
"CalDAV EXDATE failed: {}",239
response.status()240
)));241
}242
Ok(())243
}244
191
pub async fn update_partstat(245
pub async fn update_partstat(192
&self,246
&self,193
href: &str,247
href: &str,@@ -320,10 +374,7 @@ fn to_calendar_event(320
join_url: parsed.join_url.clone(),374
join_url: parsed.join_url.clone(),321
thread_id: None,375
thread_id: None,322
organizer_name: parsed.organizer.as_ref().map(|(n, _)| n.clone()),376
organizer_name: parsed.organizer.as_ref().map(|(n, _)| n.clone()),323
organizer_address: parsed377
organizer_address: parsed.organizer.as_ref().and_then(|(_, a)| a.clone()),324
.organizer325
.as_ref()326
.and_then(|(_, a)| a.clone()),327
ical_uid: Some(parsed.uid.clone()),378
ical_uid: Some(parsed.uid.clone()),328
response,379
response,329
show_as: if parsed.transparent {380
show_as: if parsed.transparent {@@ -345,7 +396,10 @@ fn to_calendar_event(345
}396
}346
}),397
}),347
body_html: parsed.description.clone(),398
body_html: parsed.description.clone(),348
series: parsed.rrule.is_some() || parsed.recurrence_id.is_some(),399
// Overridden by fetch_events after expansion (RRULE is cleared on occurrences).400
series: parsed.rrule.is_some()401
|| !parsed.rdates.is_empty()402
|| parsed.recurrence_id.is_some(),349
series_master_id: None,403
series_master_id: None,350
response_counts: None::<AttendeeResponseCounts>,404
response_counts: None::<AttendeeResponseCounts>,351
attendees: parsed405
attendees: parsed@@ -442,3 +496,32 @@ fn map_reqwest(error: reqwest::Error) -> Error {442
pub fn new_event_uid() -> String {496
pub fn new_event_uid() -> String {443
format!("{}@rusty-teams", Uuid::new_v4())497
format!("{}@rusty-teams", Uuid::new_v4())444
}498
}499
500
pub fn object_id_for(href: &str, uid: &str, series: bool, start: DateTime<Utc>) -> String {501
if series {502
format!("{href}#{uid}#{}", start.format("%Y%m%dT%H%M%SZ"))503
} else {504
format!("{href}#{uid}")505
}506
}507
508
pub fn href_from_object_id(object_id: &str) -> &str {509
object_id.split('#').next().unwrap_or(object_id)510
}511
512
#[cfg(test)]513
mod object_id_tests {514
use super::*;515
use chrono::TimeZone;516
517
#[test]518
fn series_occurrences_get_distinct_ids() {519
let start_a = Utc.with_ymd_and_hms(2026, 1, 5, 9, 0, 0).unwrap();520
let start_b = Utc.with_ymd_and_hms(2026, 1, 12, 9, 0, 0).unwrap();521
let a = object_id_for("https://dav.example/cal/evt.ics", "series", true, start_a);522
let b = object_id_for("https://dav.example/cal/evt.ics", "series", true, start_b);523
assert_ne!(a, b);524
assert!(a.ends_with("#20260105T090000Z"));525
assert_eq!(href_from_object_id(&a), "https://dav.example/cal/evt.ics");526
}527
}@@ -62,10 +62,7 @@ async fn user_scheduling(
62
62
client: &CalDavClient,
63
63
principal: &str,
64
64
) -> Result<(Vec<String>, Option<String>)> {
65
let body = propfind_body(&[
66
"<c:calendar-user-address-set/>",
67
"<c:schedule-outbox-URL/>",
68
]);
65
let body = propfind_body(&["<c:calendar-user-address-set/>", "<c:schedule-outbox-URL/>"]);
69
66
let xml = client.propfind(principal, "0", &body).await?;
70
67
let mut addresses = Vec::new();
71
68
let mut outbox = None;
@@ -62,10 +62,7 @@ async fn user_scheduling(62
client: &CalDavClient,62
client: &CalDavClient,63
principal: &str,63
principal: &str,64
) -> Result<(Vec<String>, Option<String>)> {64
) -> Result<(Vec<String>, Option<String>)> {65
let body = propfind_body(&[65
let body = propfind_body(&["<c:calendar-user-address-set/>", "<c:schedule-outbox-URL/>"]);66
"<c:calendar-user-address-set/>",67
"<c:schedule-outbox-URL/>",68
]);69
let xml = client.propfind(principal, "0", &body).await?;66
let xml = client.propfind(principal, "0", &body).await?;70
let mut addresses = Vec::new();67
let mut addresses = Vec::new();71
let mut outbox = None;68
let mut outbox = None;@@ -6,5 +6,8 @@ mod xml;
6
6
#[cfg(test)]
7
7
mod xml_tests;
8
8
9
pub use client::{CalDavClient, CalDavEvent, ListedCalendar, new_event_uid, partstat_for_reply};
9
pub use client::{
10
CalDavClient, CalDavEvent, ListedCalendar, href_from_object_id, new_event_uid, object_id_for,
11
partstat_for_reply,
12
};
10
13
pub use discovery::{DiscoverResult, discover};
@@ -6,5 +6,8 @@ mod xml;6
#[cfg(test)]6
#[cfg(test)]7
mod xml_tests;7
mod xml_tests;8
8
9
pub use client::{CalDavClient, CalDavEvent, ListedCalendar, new_event_uid, partstat_for_reply};9
pub use client::{10
CalDavClient, CalDavEvent, ListedCalendar, href_from_object_id, new_event_uid, object_id_for,11
partstat_for_reply,12
};10
pub use discovery::{DiscoverResult, discover};13
pub use discovery::{DiscoverResult, discover};@@ -39,7 +39,10 @@ pub fn parse_multistatus(xml: &str) -> Vec<PropfindResponse> {
39
39
if local == "comp" {
40
40
for attr in e.attributes().flatten() {
41
41
if local_name(attr.key.as_ref()) == "name"
42
&& attr.unescape_value().map(|v| v.eq_ignore_ascii_case("VEVENT")).unwrap_or(false)
42
&& attr
43
.unescape_value()
44
.map(|v| v.eq_ignore_ascii_case("VEVENT"))
45
.unwrap_or(false)
43
46
{
44
47
current.supports_vevent = true;
45
48
}
@@ -91,7 +94,9 @@ pub fn parse_multistatus(xml: &str) -> Vec<PropfindResponse> {
91
94
}
92
95
"displayname" => current.displayname = Some(text),
93
96
"calendar-color" | "color" => current.calendar_color = Some(text),
94
"getctag" | "getetag" => current.getctag = Some(text.trim_matches('"').to_owned()),
97
"getctag" | "getetag" => {
98
current.getctag = Some(text.trim_matches('"').to_owned())
99
}
95
100
_ => {}
96
101
}
97
102
}
@@ -39,7 +39,10 @@ pub fn parse_multistatus(xml: &str) -> Vec<PropfindResponse> {39
if local == "comp" {39
if local == "comp" {40
for attr in e.attributes().flatten() {40
for attr in e.attributes().flatten() {41
if local_name(attr.key.as_ref()) == "name"41
if local_name(attr.key.as_ref()) == "name"42
&& attr.unescape_value().map(|v| v.eq_ignore_ascii_case("VEVENT")).unwrap_or(false)42
&& attr43
.unescape_value()44
.map(|v| v.eq_ignore_ascii_case("VEVENT"))45
.unwrap_or(false)43
{46
{44
current.supports_vevent = true;47
current.supports_vevent = true;45
}48
}@@ -91,7 +94,9 @@ pub fn parse_multistatus(xml: &str) -> Vec<PropfindResponse> {91
}94
}92
"displayname" => current.displayname = Some(text),95
"displayname" => current.displayname = Some(text),93
"calendar-color" | "color" => current.calendar_color = Some(text),96
"calendar-color" | "color" => current.calendar_color = Some(text),94
"getctag" | "getetag" => current.getctag = Some(text.trim_matches('"').to_owned()),97
"getctag" | "getetag" => {98
current.getctag = Some(text.trim_matches('"').to_owned())99
}95
_ => {}100
_ => {}96
}101
}97
}102
}@@ -226,7 +226,10 @@ mod tests {
226
226
next_day.start += chrono::Duration::days(1);
227
227
next_day.end += chrono::Duration::days(1);
228
228
let merged = merge_calendar_events(
229
vec![event("o1", CalendarSource::Outlook, Some("uid"), join), next_day],
229
vec![
230
event("o1", CalendarSource::Outlook, Some("uid"), join),
231
next_day,
232
],
230
233
None,
231
234
);
232
235
assert_eq!(merged.len(), 2);
@@ -226,7 +226,10 @@ mod tests {226
next_day.start += chrono::Duration::days(1);226
next_day.start += chrono::Duration::days(1);227
next_day.end += chrono::Duration::days(1);227
next_day.end += chrono::Duration::days(1);228
let merged = merge_calendar_events(228
let merged = merge_calendar_events(229
vec![event("o1", CalendarSource::Outlook, Some("uid"), join), next_day],229
vec![230
event("o1", CalendarSource::Outlook, Some("uid"), join),231
next_day,232
],230
None,233
None,231
);234
);232
assert_eq!(merged.len(), 2);235
assert_eq!(merged.len(), 2);@@ -8,7 +8,10 @@ pub fn teams_join_url(
8
8
skype_url
9
9
.filter(|value| looks_like_teams(value))
10
10
.map(str::to_owned)
11
.or_else(|| url.filter(|value| looks_like_teams(value)).map(str::to_owned))
11
.or_else(|| {
12
url.filter(|value| looks_like_teams(value))
13
.map(str::to_owned)
14
})
12
15
.or_else(|| {
13
16
location
14
17
.filter(|value| looks_like_teams(value))
@@ -8,7 +8,10 @@ pub fn teams_join_url(8
skype_url8
skype_url9
.filter(|value| looks_like_teams(value))9
.filter(|value| looks_like_teams(value))10
.map(str::to_owned)10
.map(str::to_owned)11
.or_else(|| url.filter(|value| looks_like_teams(value)).map(str::to_owned))11
.or_else(|| {12
url.filter(|value| looks_like_teams(value))13
.map(str::to_owned)14
})12
.or_else(|| {15
.or_else(|| {13
location16
location14
.filter(|value| looks_like_teams(value))17
.filter(|value| looks_like_teams(value))@@ -10,4 +10,4 @@ pub use expand::expand_events;
10
10
pub use join::teams_join_url;
11
11
pub use parse::{ParsedEvent, parse_calendar};
12
12
pub use timezone::resolve_tzid;
13
pub use write::{CalDavEventDraft, build_vevent};
13
pub use write::{CalDavEventDraft, build_vevent, exclude_occurrence_from_ics};
@@ -10,4 +10,4 @@ pub use expand::expand_events;10
pub use join::teams_join_url;10
pub use join::teams_join_url;11
pub use parse::{ParsedEvent, parse_calendar};11
pub use parse::{ParsedEvent, parse_calendar};12
pub use timezone::resolve_tzid;12
pub use timezone::resolve_tzid;13
pub use write::{CalDavEventDraft, build_vevent};13
pub use write::{CalDavEventDraft, build_vevent, exclude_occurrence_from_ics};@@ -162,13 +162,15 @@ fn parse_vevent(lines: &[String]) -> Option<ParsedEvent> {
162
162
}
163
163
164
164
let start = start?;
165
let end = end.or_else(|| duration.map(|d| start + d)).unwrap_or_else(|| {
166
if all_day {
167
start + Duration::days(1)
168
} else {
169
start + Duration::hours(1)
170
}
171
});
165
let end = end
166
.or_else(|| duration.map(|d| start + d))
167
.unwrap_or_else(|| {
168
if all_day {
169
start + Duration::days(1)
170
} else {
171
start + Duration::hours(1)
172
}
173
});
172
174
let join = teams_join_url(
173
175
skype.as_deref(),
174
176
url.as_deref(),
@@ -162,13 +162,15 @@ fn parse_vevent(lines: &[String]) -> Option<ParsedEvent> {162
}162
}163
163
164
let start = start?;164
let start = start?;165
let end = end.or_else(|| duration.map(|d| start + d)).unwrap_or_else(|| {165
let end = end166
if all_day {166
.or_else(|| duration.map(|d| start + d))167
start + Duration::days(1)167
.unwrap_or_else(|| {168
} else {168
if all_day {169
start + Duration::hours(1)169
start + Duration::days(1)170
}170
} else {171
});171
start + Duration::hours(1)172
}173
});172
let join = teams_join_url(174
let join = teams_join_url(173
skype.as_deref(),175
skype.as_deref(),174
url.as_deref(),176
url.as_deref(),@@ -46,6 +46,9 @@ mod tests {
46
46
47
47
#[test]
48
48
fn parses_iana() {
49
assert_eq!(resolve_tzid("Europe/Zurich"), Some(chrono_tz::Europe::Zurich));
49
assert_eq!(
50
resolve_tzid("Europe/Zurich"),
51
Some(chrono_tz::Europe::Zurich)
52
);
50
53
}
51
54
}
@@ -46,6 +46,9 @@ mod tests {46
46
47
#[test]47
#[test]48
fn parses_iana() {48
fn parses_iana() {49
assert_eq!(resolve_tzid("Europe/Zurich"), Some(chrono_tz::Europe::Zurich));49
assert_eq!(50
resolve_tzid("Europe/Zurich"),51
Some(chrono_tz::Europe::Zurich)52
);50
}53
}51
}54
}@@ -67,6 +67,95 @@ pub fn build_vevent(draft: &CalDavEventDraft, stamp: DateTime<Utc>) -> String {
67
67
lines.join("\r\n") + "\r\n"
68
68
}
69
69
70
/// Add EXDATE for one occurrence on the series master and bump SEQUENCE.
71
/// Leaves overrides and other VEVENT blocks untouched.
72
pub fn exclude_occurrence_from_ics(ics: &str, occurrence: DateTime<Utc>) -> Result<String, String> {
73
let stamp = format_utc(occurrence);
74
let mut out = Vec::new();
75
let mut in_event = false;
76
let mut is_master = false;
77
let mut event_lines: Vec<String> = Vec::new();
78
let mut patched = false;
79
80
for raw in ics.lines() {
81
let line = raw.trim_end_matches('\r').to_owned();
82
let upper = line.to_ascii_uppercase();
83
if upper == "BEGIN:VEVENT" {
84
in_event = true;
85
is_master = false;
86
event_lines = vec![line];
87
continue;
88
}
89
if !in_event {
90
out.push(line);
91
continue;
92
}
93
if upper == "END:VEVENT" {
94
event_lines.push(line);
95
if is_master {
96
out.extend(patch_master_exdate(event_lines, &stamp)?);
97
patched = true;
98
} else {
99
out.extend(event_lines);
100
}
101
in_event = false;
102
event_lines = Vec::new();
103
continue;
104
}
105
if upper.starts_with("RRULE") || upper.starts_with("RDATE") {
106
is_master = true;
107
}
108
event_lines.push(line);
109
}
110
if !patched {
111
return Err("CalDAV series master with RRULE/RDATE not found".into());
112
}
113
Ok(out.join("\r\n") + "\r\n")
114
}
115
116
fn patch_master_exdate(mut lines: Vec<String>, stamp: &str) -> Result<Vec<String>, String> {
117
let mut sequence_bumped = false;
118
let mut exdate_added = false;
119
for line in &mut lines {
120
let upper = line.to_ascii_uppercase();
121
if upper.starts_with("SEQUENCE:") {
122
let value = line.split_once(':').map(|(_, v)| v).unwrap_or("0");
123
let next = value.trim().parse::<u32>().unwrap_or(0).saturating_add(1);
124
*line = format!("SEQUENCE:{next}");
125
sequence_bumped = true;
126
}
127
if upper.starts_with("EXDATE") {
128
if line.contains(stamp) {
129
exdate_added = true;
130
} else if let Some((name, value)) = line.split_once(':') {
131
*line = format!("{name}:{value},{stamp}");
132
exdate_added = true;
133
}
134
}
135
}
136
if !sequence_bumped {
137
if let Some(idx) = lines
138
.iter()
139
.position(|l| l.to_ascii_uppercase().starts_with("UID:"))
140
{
141
lines.insert(idx + 1, "SEQUENCE:1".to_owned());
142
} else {
143
lines.insert(1, "SEQUENCE:1".to_owned());
144
}
145
}
146
if !exdate_added {
147
if let Some(idx) = lines.iter().position(|l| {
148
l.to_ascii_uppercase().starts_with("RRULE")
149
|| l.to_ascii_uppercase().starts_with("RDATE")
150
}) {
151
lines.insert(idx + 1, format!("EXDATE:{stamp}"));
152
} else {
153
return Err("CalDAV series master missing RRULE/RDATE".into());
154
}
155
}
156
Ok(lines)
157
}
158
70
159
fn format_utc(dt: DateTime<Utc>) -> String {
71
160
dt.format("%Y%m%dT%H%M%SZ").to_string()
72
161
}
@@ -107,4 +196,15 @@ mod tests {
107
196
assert!(ics.contains("URL:https://teams.microsoft.com/l/meetup-join/x"));
108
197
assert!(ics.contains("ATTENDEE:mailto:a@b.c"));
109
198
}
199
200
#[test]
201
fn exclude_occurrence_adds_exdate_and_keeps_rrule() {
202
let ics = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:series\r\nSEQUENCE:2\r\nDTSTART:20260105T090000Z\r\nDTEND:20260105T100000Z\r\nRRULE:FREQ=WEEKLY\r\nSUMMARY:Standup\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
203
let patched =
204
exclude_occurrence_from_ics(ics, Utc.with_ymd_and_hms(2026, 1, 12, 9, 0, 0).unwrap())
205
.unwrap();
206
assert!(patched.contains("RRULE:FREQ=WEEKLY"));
207
assert!(patched.contains("EXDATE:20260112T090000Z"));
208
assert!(patched.contains("SEQUENCE:3"));
209
}
110
210
}
@@ -67,6 +67,95 @@ pub fn build_vevent(draft: &CalDavEventDraft, stamp: DateTime<Utc>) -> String {67
lines.join("\r\n") + "\r\n"67
lines.join("\r\n") + "\r\n"68
}68
}69
69
70
/// Add EXDATE for one occurrence on the series master and bump SEQUENCE.71
/// Leaves overrides and other VEVENT blocks untouched.72
pub fn exclude_occurrence_from_ics(ics: &str, occurrence: DateTime<Utc>) -> Result<String, String> {73
let stamp = format_utc(occurrence);74
let mut out = Vec::new();75
let mut in_event = false;76
let mut is_master = false;77
let mut event_lines: Vec<String> = Vec::new();78
let mut patched = false;79
80
for raw in ics.lines() {81
let line = raw.trim_end_matches('\r').to_owned();82
let upper = line.to_ascii_uppercase();83
if upper == "BEGIN:VEVENT" {84
in_event = true;85
is_master = false;86
event_lines = vec![line];87
continue;88
}89
if !in_event {90
out.push(line);91
continue;92
}93
if upper == "END:VEVENT" {94
event_lines.push(line);95
if is_master {96
out.extend(patch_master_exdate(event_lines, &stamp)?);97
patched = true;98
} else {99
out.extend(event_lines);100
}101
in_event = false;102
event_lines = Vec::new();103
continue;104
}105
if upper.starts_with("RRULE") || upper.starts_with("RDATE") {106
is_master = true;107
}108
event_lines.push(line);109
}110
if !patched {111
return Err("CalDAV series master with RRULE/RDATE not found".into());112
}113
Ok(out.join("\r\n") + "\r\n")114
}115
116
fn patch_master_exdate(mut lines: Vec<String>, stamp: &str) -> Result<Vec<String>, String> {117
let mut sequence_bumped = false;118
let mut exdate_added = false;119
for line in &mut lines {120
let upper = line.to_ascii_uppercase();121
if upper.starts_with("SEQUENCE:") {122
let value = line.split_once(':').map(|(_, v)| v).unwrap_or("0");123
let next = value.trim().parse::<u32>().unwrap_or(0).saturating_add(1);124
*line = format!("SEQUENCE:{next}");125
sequence_bumped = true;126
}127
if upper.starts_with("EXDATE") {128
if line.contains(stamp) {129
exdate_added = true;130
} else if let Some((name, value)) = line.split_once(':') {131
*line = format!("{name}:{value},{stamp}");132
exdate_added = true;133
}134
}135
}136
if !sequence_bumped {137
if let Some(idx) = lines138
.iter()139
.position(|l| l.to_ascii_uppercase().starts_with("UID:"))140
{141
lines.insert(idx + 1, "SEQUENCE:1".to_owned());142
} else {143
lines.insert(1, "SEQUENCE:1".to_owned());144
}145
}146
if !exdate_added {147
if let Some(idx) = lines.iter().position(|l| {148
l.to_ascii_uppercase().starts_with("RRULE")149
|| l.to_ascii_uppercase().starts_with("RDATE")150
}) {151
lines.insert(idx + 1, format!("EXDATE:{stamp}"));152
} else {153
return Err("CalDAV series master missing RRULE/RDATE".into());154
}155
}156
Ok(lines)157
}158
70
fn format_utc(dt: DateTime<Utc>) -> String {159
fn format_utc(dt: DateTime<Utc>) -> String {71
dt.format("%Y%m%dT%H%M%SZ").to_string()160
dt.format("%Y%m%dT%H%M%SZ").to_string()72
}161
}@@ -107,4 +196,15 @@ mod tests {107
assert!(ics.contains("URL:https://teams.microsoft.com/l/meetup-join/x"));196
assert!(ics.contains("URL:https://teams.microsoft.com/l/meetup-join/x"));108
assert!(ics.contains("ATTENDEE:mailto:a@b.c"));197
assert!(ics.contains("ATTENDEE:mailto:a@b.c"));109
}198
}199
200
#[test]201
fn exclude_occurrence_adds_exdate_and_keeps_rrule() {202
let ics = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:series\r\nSEQUENCE:2\r\nDTSTART:20260105T090000Z\r\nDTEND:20260105T100000Z\r\nRRULE:FREQ=WEEKLY\r\nSUMMARY:Standup\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";203
let patched =204
exclude_occurrence_from_ics(ics, Utc.with_ymd_and_hms(2026, 1, 12, 9, 0, 0).unwrap())205
.unwrap();206
assert!(patched.contains("RRULE:FREQ=WEEKLY"));207
assert!(patched.contains("EXDATE:20260112T090000Z"));208
assert!(patched.contains("SEQUENCE:3"));209
}110
}210
}@@ -2,11 +2,10 @@ pub mod activity_feed;
2
2
pub mod activity_mentions;
3
3
pub mod ams;
4
4
pub mod bot_profiles;
5
pub mod calendar;
6
5
pub mod caldav;
6
pub mod calendar;
7
7
pub mod calllog;
8
8
pub mod cards;
9
pub mod ical;
10
9
pub mod channel_notifications;
11
10
pub mod channel_visibility;
12
11
pub mod chat_listing;
@@ -22,6 +21,7 @@ pub mod forward;
22
21
pub mod gifs;
23
22
pub mod google_calendar;
24
23
pub mod graph_events;
24
pub mod ical;
25
25
mod json_id;
26
26
pub use json_id::id_text;
27
27
pub mod language_settings;
@@ -58,6 +58,10 @@ pub use activity_feed::{
58
58
};
59
59
pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};
60
60
pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};
61
pub use caldav::{
62
CalDavClient, CalDavEvent, ListedCalendar, discover as discover_caldav, href_from_object_id,
63
new_event_uid, object_id_for, partstat_for_reply,
64
};
61
65
pub use calendar::{
62
66
Attendee, AttendeeResponseCounts, BusyTime, Calendar, CalendarEvent, CalendarSource,
63
67
CreatedEvent, DialIn, EventAttendee, HomeCalendar, NewEvent, PersonSchedule, Reminder, Repeat,
@@ -65,11 +69,6 @@ pub use calendar::{
65
69
merge_calendar_events, new_event_body, new_event_body_with_join, normalize_join_url,
66
70
parse_calendar_events, parse_created_event, strip_html, truncate_preview,
67
71
};
68
pub use caldav::{
69
CalDavClient, CalDavEvent, ListedCalendar, discover as discover_caldav, new_event_uid,
70
partstat_for_reply,
71
};
72
pub use ical::{CalDavEventDraft, build_vevent, expand_events, parse_calendar, teams_join_url};
73
72
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};
74
73
pub use cards::{
75
74
CardActions, ChatApp, InvokeRequest, InvokeResponse, TaskContent, TaskContinue, TaskResponse,
@@ -92,7 +91,12 @@ pub use gifs::{Gif, Gifs};
92
91
pub use google_calendar::{
93
92
AuthPending, GoogleCalendar, GoogleEventDraft, GoogleOAuth, TokenBundle, allocate_redirect_uri,
94
93
client_id_from_env, exchange_code, google_event_body, google_rsvp_query, google_rsvp_status,
95
parse_calendar_list, parse_google_events, refresh_access_token, rrule_for_repeat, wait_for_code,
94
parse_calendar_list, parse_google_events, refresh_access_token, rrule_for_repeat,
95
wait_for_code,
96
};
97
pub use ical::{
98
CalDavEventDraft, build_vevent, exclude_occurrence_from_ics, expand_events, parse_calendar,
99
teams_join_url,
96
100
};
97
101
pub use language_settings::{
98
102
LanguageSettings, LanguageSettingsClient, TranslationBehavior, authoring_patch, behavior_patch,
@@ -2,11 +2,10 @@ pub mod activity_feed;2
pub mod activity_mentions;2
pub mod activity_mentions;3
pub mod ams;3
pub mod ams;4
pub mod bot_profiles;4
pub mod bot_profiles;5
pub mod calendar;6
pub mod caldav;5
pub mod caldav;6
pub mod calendar;7
pub mod calllog;7
pub mod calllog;8
pub mod cards;8
pub mod cards;9
pub mod ical;10
pub mod channel_notifications;9
pub mod channel_notifications;11
pub mod channel_visibility;10
pub mod channel_visibility;12
pub mod chat_listing;11
pub mod chat_listing;@@ -22,6 +21,7 @@ pub mod forward;22
pub mod gifs;21
pub mod gifs;23
pub mod google_calendar;22
pub mod google_calendar;24
pub mod graph_events;23
pub mod graph_events;24
pub mod ical;25
mod json_id;25
mod json_id;26
pub use json_id::id_text;26
pub use json_id::id_text;27
pub mod language_settings;27
pub mod language_settings;@@ -58,6 +58,10 @@ pub use activity_feed::{58
};58
};59
pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};59
pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};60
pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};60
pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};61
pub use caldav::{62
CalDavClient, CalDavEvent, ListedCalendar, discover as discover_caldav, href_from_object_id,63
new_event_uid, object_id_for, partstat_for_reply,64
};61
pub use calendar::{65
pub use calendar::{62
Attendee, AttendeeResponseCounts, BusyTime, Calendar, CalendarEvent, CalendarSource,66
Attendee, AttendeeResponseCounts, BusyTime, Calendar, CalendarEvent, CalendarSource,63
CreatedEvent, DialIn, EventAttendee, HomeCalendar, NewEvent, PersonSchedule, Reminder, Repeat,67
CreatedEvent, DialIn, EventAttendee, HomeCalendar, NewEvent, PersonSchedule, Reminder, Repeat,@@ -65,11 +69,6 @@ pub use calendar::{65
merge_calendar_events, new_event_body, new_event_body_with_join, normalize_join_url,69
merge_calendar_events, new_event_body, new_event_body_with_join, normalize_join_url,66
parse_calendar_events, parse_created_event, strip_html, truncate_preview,70
parse_calendar_events, parse_created_event, strip_html, truncate_preview,67
};71
};68
pub use caldav::{69
CalDavClient, CalDavEvent, ListedCalendar, discover as discover_caldav, new_event_uid,70
partstat_for_reply,71
};72
pub use ical::{CalDavEventDraft, build_vevent, expand_events, parse_calendar, teams_join_url};73
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};72
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};74
pub use cards::{73
pub use cards::{75
CardActions, ChatApp, InvokeRequest, InvokeResponse, TaskContent, TaskContinue, TaskResponse,74
CardActions, ChatApp, InvokeRequest, InvokeResponse, TaskContent, TaskContinue, TaskResponse,@@ -92,7 +91,12 @@ pub use gifs::{Gif, Gifs};92
pub use google_calendar::{91
pub use google_calendar::{93
AuthPending, GoogleCalendar, GoogleEventDraft, GoogleOAuth, TokenBundle, allocate_redirect_uri,92
AuthPending, GoogleCalendar, GoogleEventDraft, GoogleOAuth, TokenBundle, allocate_redirect_uri,94
client_id_from_env, exchange_code, google_event_body, google_rsvp_query, google_rsvp_status,93
client_id_from_env, exchange_code, google_event_body, google_rsvp_query, google_rsvp_status,95
parse_calendar_list, parse_google_events, refresh_access_token, rrule_for_repeat, wait_for_code,94
parse_calendar_list, parse_google_events, refresh_access_token, rrule_for_repeat,95
wait_for_code,96
};97
pub use ical::{98
CalDavEventDraft, build_vevent, exclude_occurrence_from_ics, expand_events, parse_calendar,99
teams_join_url,96
};100
};97
pub use language_settings::{101
pub use language_settings::{98
LanguageSettings, LanguageSettingsClient, TranslationBehavior, authoring_patch, behavior_patch,102
LanguageSettings, LanguageSettingsClient, TranslationBehavior, authoring_patch, behavior_patch,