diff --git a/server/Cargo.lock b/server/Cargo.lock index 1c9708b88..40cfdbafd 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.7.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb9843d84c775696c37d9a418bbb01b932629d01870722c0f13eb3f95e2536d" +checksum = "3ae682f693a9cd7b058f2b0b5d9a6d7728a8555779bedbbc35dd88528611d020" dependencies = [ "actix-codec", "actix-rt", @@ -109,7 +109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -128,9 +128,9 @@ dependencies = [ [[package]] name = "actix-rt" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28f32d40287d3f402ae0028a9d54bef51af15c8769492826a69d28f81893151d" +checksum = "24eda4e2a6e042aa4e55ac438a2ae052d3b5da0ecf83d7411e1a368946925208" dependencies = [ "futures-core", "tokio", @@ -138,9 +138,9 @@ dependencies = [ [[package]] name = "actix-server" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb13e7eef0423ea6eab0e59f6c72e7cb46d33691ad56a726b3cd07ddec2c2d4" +checksum = "b02303ce8d4e8be5b855af6cf3c3a08f3eff26880faad82bab679c22d3650cb5" dependencies = [ "actix-rt", "actix-service", @@ -223,7 +223,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -243,9 +243,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -352,9 +352,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -371,9 +371,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "approx" @@ -404,7 +404,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -415,9 +415,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-compression" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c90a406b4495d129f00461241616194cb8a032c8d1c53c657f0961d5f8e0498" +checksum = "cd066d0b4ef8ecb03a55319dc13aa6910616d0f44008a045bb1835af830abff5" dependencies = [ "brotli", "flate2", @@ -437,7 +437,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -449,6 +449,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" @@ -480,9 +486,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -546,9 +552,9 @@ dependencies = [ [[package]] name = "bitstream-io" -version = "2.3.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c12d1856e42f0d817a835fe55853957c85c8c8a470114029143d3f12671446e" +checksum = "415f8399438eb5e4b2f73ed3152a3448b98149dda642a957ee704e1daa5cf1d8" [[package]] name = "block-buffer" @@ -622,9 +628,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6221fe77a248b9117d431ad93761222e1cf8ff282d9d1d5d9f53d6299a1cf76" +checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -632,9 +638,9 @@ dependencies = [ [[package]] name = "built" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41bfbdb21256b87a8b5e80fab81a8eed158178e812fd7ba451907518b2742f16" +checksum = "c6a6c0b39c38fd754ac338b00a88066436389c0f029da5d37d1e01091d9b7c17" [[package]] name = "bumpalo" @@ -644,9 +650,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.15.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -706,7 +712,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -717,9 +723,9 @@ checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" [[package]] name = "cc" -version = "1.0.97" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" dependencies = [ "jobserver", "libc", @@ -769,6 +775,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "conquer-once" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d008a441c0f269f36ca13712528069a86a3e60dffee1d98b976eb3b0b2160b4" +dependencies = [ + "conquer-util", +] + +[[package]] +name = "conquer-util" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582" + [[package]] name = "const-oid" version = "0.9.6" @@ -843,9 +864,9 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -880,9 +901,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crunchy" @@ -902,9 +923,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ "darling_core", "darling_macro", @@ -912,27 +933,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] name = "darling_macro" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -977,15 +998,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", + "syn 2.0.67", ] [[package]] @@ -1080,7 +1101,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -1114,11 +1135,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erased-serde" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b73807008a3c7f171cc40312f37d95ef0396e048b5848d775f54b1a4dd4a0d3" +checksum = "24e2389d65ab4fab27dc2a5de7b191e1f6617d1f1c8855c0dc569c94a4cbb18d" dependencies = [ "serde", + "typeid", ] [[package]] @@ -1179,12 +1201,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "finl_unicode" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" - [[package]] name = "flate2" version = "1.0.30" @@ -1296,7 +1312,7 @@ checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", - "parking_lot 0.12.2", + "parking_lot 0.12.3", ] [[package]] @@ -1313,7 +1329,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -1396,9 +1412,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "governor" @@ -1412,7 +1428,7 @@ dependencies = [ "futures-timer", "no-std-compat", "nonzero_ext", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "portable-atomic", "quanta", "rand", @@ -1441,15 +1457,15 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", "http 1.1.0", "indexmap 2.2.6", "slab", @@ -1556,7 +1572,7 @@ dependencies = [ "ipconfig", "lru-cache", "once_cell", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "rand", "resolv-conf", "smallvec", @@ -1648,12 +1664,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", + "futures-util", "http 1.1.0", "http-body 1.0.0", "pin-project-lite", @@ -1661,9 +1677,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -1679,9 +1695,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -1710,7 +1726,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.4", + "h2 0.4.5", "http 1.1.0", "http-body 1.0.0", "httparse", @@ -1744,7 +1760,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.28", + "hyper 0.14.29", "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", @@ -1767,7 +1783,7 @@ dependencies = [ "tokio", "tokio-rustls 0.25.0", "tower-service", - "webpki-roots 0.26.1", + "webpki-roots 0.26.3", ] [[package]] @@ -1785,7 +1801,7 @@ dependencies = [ "tokio", "tokio-rustls 0.26.0", "tower-service", - "webpki-roots 0.26.1", + "webpki-roots 0.26.3", ] [[package]] @@ -1806,9 +1822,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" dependencies = [ "bytes", "futures-channel", @@ -1969,9 +1985,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] @@ -1984,7 +2000,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -2097,9 +2113,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libfuzzer-sys" @@ -2147,9 +2163,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "local-channel" @@ -2209,7 +2225,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -2285,7 +2301,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -2317,9 +2333,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" @@ -2335,9 +2351,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", "simd-adler32", @@ -2357,9 +2373,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.5" +version = "0.32.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea4908d4f23254adda3daa60ffef0f1ac7b8c3e9a864cf3cc154b251908a2ef" +checksum = "7b5c17de023a86f59ed79891b2e5d5a94c705dbe904a5b5c9c952ea6221b03e4" dependencies = [ "approx", "matrixmultiply", @@ -2526,7 +2542,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -2602,9 +2618,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -2674,7 +2690,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -2723,9 +2739,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core 0.9.10", @@ -2753,16 +2769,16 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.1", + "redox_syscall 0.5.2", "smallvec", "windows-targets 0.52.5", ] [[package]] name = "parse-display" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06af5f9333eb47bd9ba8462d612e37a8328a5cb80b13f0af4de4c3b89f52dee5" +checksum = "914a1c2265c98e2446911282c6ac86d8524f495792c38c5bd884f80499c7538a" dependencies = [ "parse-display-derive", "regex", @@ -2771,16 +2787,16 @@ dependencies = [ [[package]] name = "parse-display-derive" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc9252f259500ee570c75adcc4e317fa6f57a1e47747d622e0bf838002a7b790" +checksum = "2ae7800a4c974efd12df917266338e79a7a74415173caf7e70aa0a0707345281" dependencies = [ "proc-macro2", "quote", "regex", "regex-syntax", "structmeta", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -2831,7 +2847,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -2916,9 +2932,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -2939,7 +2955,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -2952,7 +2968,7 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "thiserror", ] @@ -3125,9 +3141,9 @@ dependencies = [ [[package]] name = "ravif" -version = "0.11.5" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc13288f5ab39e6d7c9d501759712e6969fcc9734220846fc9ed26cae2cc4234" +checksum = "67376f469e7e7840d0040bbf4b9b3334005bb167f814621326e4c7ab8cd6e944" dependencies = [ "avif-serialize", "imgref", @@ -3193,9 +3209,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] @@ -3225,9 +3241,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -3236,15 +3252,15 @@ dependencies = [ [[package]] name = "regex-lite" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" @@ -3260,7 +3276,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-rustls 0.24.2", "ipnet", "js-sys", @@ -3299,7 +3315,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.4.4", + "h2 0.4.5", "hickory-resolver", "http 1.1.0", "http-body 1.0.0", @@ -3334,7 +3350,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.26.1", + "webpki-roots 0.26.3", "winreg 0.52.0", ] @@ -3555,9 +3571,9 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "safe_arch" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" +checksum = "c3460605018fdc9612bce72735cba0d27efbcd9904780d44c7e3a9948f96148a" dependencies = [ "bytemuck", ] @@ -3642,7 +3658,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -3683,14 +3699,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -3734,7 +3750,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -3772,6 +3788,16 @@ dependencies = [ "digest", ] +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -3864,23 +3890,23 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snafu" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75976f4748ab44f6e5332102be424e7c2dc18daeaf7e725f2040c3ebb133512e" +checksum = "418b8136fec49956eba89be7da2847ec1909df92a9ae4178b5ff0ff092c8d95e" dependencies = [ "snafu-derive", ] [[package]] name = "snafu-derive" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b19911debfb8c2fb1107bc6cb2d61868aaf53a988449213959bb1b5b1ed95f" +checksum = "1a4812a669da00d17d8266a0439eddcacbc88b17f732f927e52eeb9d196f7fb5" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -3923,11 +3949,10 @@ dependencies = [ [[package]] name = "sqlformat" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" +checksum = "f895e3734318cc55f1fe66258926c9b910c124d47520339efecbb6c59cec7c1f" dependencies = [ - "itertools", "nom", "unicode_categories", ] @@ -4141,20 +4166,20 @@ checksum = "7a8348af2d9fc3258c8733b8d9d8db2e56f54b2363a4b5b81585c7875ed65e65" [[package]] name = "stringprep" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" dependencies = [ - "finl_unicode", "unicode-bidi", "unicode-normalization", + "unicode-properties", ] [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "structmeta" @@ -4165,7 +4190,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -4176,7 +4201,7 @@ checksum = "152a0b65a590ff6c3da95cabe2353ee04e6167c896b28e3b14478c2636c922fc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -4186,7 +4211,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16524b1ef57fd2e253216ab20ec44f0dc32b29155a4b3e6bef0a857d8c9f5f08" dependencies = [ "log", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "serde", "serde_json", "tokio", @@ -4194,9 +4219,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" [[package]] name = "sval" @@ -4289,9 +4314,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.61" +version = "2.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" dependencies = [ "proc-macro2", "quote", @@ -4372,6 +4397,7 @@ dependencies = [ "bollard", "bollard-stubs", "bytes", + "conquer-once", "dirs", "docker_credential", "either", @@ -4383,6 +4409,7 @@ dependencies = [ "serde", "serde_json", "serde_with", + "signal-hook", "thiserror", "tokio", "tokio-stream", @@ -4401,22 +4428,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -4487,7 +4514,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot 0.12.2", + "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", "socket2", @@ -4503,7 +4530,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -4574,9 +4601,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", @@ -4586,18 +4613,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.12" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", "serde", @@ -4672,7 +4699,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] @@ -4692,9 +4719,15 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "ttf-parser" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb71ffab0ca84cecd986dd52e873c8d0b013f3d5d9ce25a6f7d0513ed933d562" +checksum = "2c591d83f69777866b9126b24c6dd9a18351f177e49d625920d19f989fd31cf8" + +[[package]] +name = "typeid" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "059d83cc991e7a42fc37bd50941885db0888e34209f8cfd9aab07ddec03bc9cf" [[package]] name = "typenum" @@ -4723,6 +4756,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-properties" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" + [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -4741,9 +4780,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode_categories" @@ -4765,9 +4804,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna 0.5.0", @@ -4783,9 +4822,9 @@ checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -4904,7 +4943,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", "wasm-bindgen-shared", ] @@ -4938,7 +4977,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4980,9 +5019,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.26.1" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ "rustls-pki-types", ] @@ -5005,9 +5044,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.17" +version = "0.7.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0e39d2c603fdc0504b12b458cf1f34e0b937ed2f4f2dc20796e3e86f34e11f" +checksum = "8a040b111774ab63a19ef46bbc149398ab372b4ccdcfd719e9814dbd7dfd76c8" dependencies = [ "bytemuck", "safe_arch", @@ -5191,9 +5230,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] @@ -5251,14 +5290,14 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.61", + "syn 2.0.67", ] [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" [[package]] name = "zstd" @@ -5280,9 +5319,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.10+zstd.1.5.6" +version = "2.0.11+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4" dependencies = [ "cc", "pkg-config", diff --git a/server/main-api/Cargo.toml b/server/main-api/Cargo.toml index ed8d9b2b3..69a29f235 100644 --- a/server/main-api/Cargo.toml +++ b/server/main-api/Cargo.toml @@ -66,10 +66,11 @@ actix-governor = { version = "0.5.0", features = ["logger"] } tempfile = "3.10.1" base64 = "0.22.1" time = "0.3.36" +testcontainers-modules = { version = "0.6.1", features = ["postgres"] } [dev-dependencies] pretty_assertions = "1.4.0" -testcontainers = "0.18.0" +testcontainers = { version = "0.18.0", features = ["watchdog"] } testcontainers-modules = {version = "0.6.1",features = ["postgres"] } [features] diff --git a/server/main-api/src/calendar/mod.rs b/server/main-api/src/calendar/mod.rs index 785800ac9..3755e5f32 100644 --- a/server/main-api/src/calendar/mod.rs +++ b/server/main-api/src/calendar/mod.rs @@ -1,8 +1,9 @@ use std::collections::HashMap; + use actix_web::{get, web, HttpResponse}; use chrono::{DateTime, Utc}; use log::error; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use sqlx::PgPool; use crate::calendar::models::{CalendarLocation, Event, LocationEvents}; @@ -11,8 +12,8 @@ mod connectum; mod models; pub mod refresh; -#[derive(Deserialize, Debug)] -pub struct QueryArguments { +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct Arguments { ids: Vec, /// eg. 2039-01-19T03:14:07+1 start_after: DateTime, @@ -20,25 +21,38 @@ pub struct QueryArguments { end_before: DateTime, } +impl Arguments { + fn validate_ids(&self) -> Result, HttpResponse> { + let ids = self + .ids + .clone() + .into_iter() + .map(|s| s.replace(|c: char| c.is_whitespace() || c.is_control(), "")) + .collect::>(); + if ids.len() > 10 { + return Err(HttpResponse::BadRequest().body("Too many ids to query. We suspect that users don't need this. If you need this limit increased, please send us a message")); + }; + if ids.is_empty() { + return Err(HttpResponse::BadRequest().body("No id requested")); + }; + Ok(ids) + } +} + #[get("/api/calendar")] pub async fn calendar_handler( - web::Query(args): web::Query, + web::Json(args): web::Json, data: web::Data, ) -> HttpResponse { - let ids = args.ids.into_iter().map(|s| s.replace(|c: char| c.is_whitespace() || c.is_control(), "")).collect::>(); - if ids.len() > 10 { - return HttpResponse::BadRequest() - .body("Too many ids to query. We suspect that users don't need this. If you need this limit increased, please send us a message"); - }; - if ids.is_empty() { - return HttpResponse::BadRequest() - .body("No id requested"); + let ids = match args.validate_ids() { + Ok(ids) => ids, + Err(e) => return e, }; let locations = match get_locations(&data.db, &ids).await { Ok(l) => l, - Err(e) => return e + Err(e) => return e, }; - if let Err(e) = validate_locations(&ids,&locations){ + if let Err(e) = validate_locations(&ids, &locations) { return e; } match get_from_db(&data.db, &locations, &args.start_after, &args.end_before).await { @@ -51,38 +65,40 @@ pub async fn calendar_handler( } } -fn validate_locations(ids: &[String],locations:&[CalendarLocation])->Result<(),HttpResponse>{ - for id in ids{ - if !locations.iter().any(|l|&l.key==id) { - return Err(HttpResponse::BadRequest() - .body("Requested id {id} does not exist")); +fn validate_locations(ids: &[String], locations: &[CalendarLocation]) -> Result<(), HttpResponse> { + for id in ids { + if !locations.iter().any(|l| &l.key == id) { + return Err(HttpResponse::BadRequest().body("Requested id {id} does not exist")); } } assert_eq!(locations.len(), ids.len()); for loc in locations { if loc.last_calendar_scrape_at.is_none() { - return Err(HttpResponse::ServiceUnavailable() - .body(format!("Room {key}/{url:?} calendar entry is currently in the process of being scraped, please try again later", key = loc.key, url = loc.calendar_url))); + return Err(HttpResponse::ServiceUnavailable().body(format!("Room {key}/{url:?} calendar entry is currently in the process of being scraped, please try again later", key = loc.key, url = loc.calendar_url))); }; } for loc in locations { if loc.calendar_url.is_none() { return Err(HttpResponse::NotFound() .content_type("text/plain") - .body(format!("Room {key}/{url:?} does not have a calendar", key = loc.key, url = loc.calendar_url))); + .body(format!( + "Room {key}/{url:?} does not have a calendar", + key = loc.key, + url = loc.calendar_url + ))); }; } Ok(()) } -async fn get_locations(pool: &PgPool, ids: &[String]) -> Result, HttpResponse> { - match sqlx::query_as!(CalendarLocation, "SELECT key,name,last_calendar_scrape_at,calendar_url,type,type_common_name FROM de WHERE key = ANY($1::text[])", ids) - .fetch_all(pool) - .await { +async fn get_locations( + pool: &PgPool, + ids: &[String], +) -> Result, HttpResponse> { + match sqlx::query_as!(CalendarLocation, "SELECT key,name,last_calendar_scrape_at,calendar_url,type,type_common_name FROM de WHERE key = ANY($1::text[])", ids).fetch_all(pool).await { Err(e) => { error!("could not refetch due to {e:?}"); - Err(HttpResponse::InternalServerError() - .body("could not get calendar entries, please try again later")) + Err(HttpResponse::InternalServerError().body("could not get calendar entries, please try again later")) } Ok(locations) => Ok(locations), } @@ -99,15 +115,346 @@ async fn get_from_db( let events = sqlx::query_as!(Event, r#"SELECT id,room_code,start_at,end_at,stp_title_de,stp_title_en,stp_type,entry_type AS "entry_type!:crate::calendar::models::EventType",detailed_entry_type FROM calendar WHERE room_code = $1 AND start_at >= $2 AND end_at <= $3"#, - location.key, start_after, end_before) - .fetch_all(pool) - .await?; + location.key, start_after, end_before).fetch_all(pool).await?; located_events.insert( location.key.clone(), LocationEvents { location: location.clone(), events, - }); + }, + ); } Ok(located_events) } + +#[cfg(test)] +mod tests { + use actix_web::http::header::ContentType; + use actix_web::test; + use actix_web::App; + use lazy_static::lazy_static; + use pretty_assertions::assert_eq; + use serde_json::Value; + + use crate::setup::tests::PostgresTestContainer; + use crate::AppData; + + use super::*; + + lazy_static! { + static ref TIME_Y2K: DateTime = + DateTime::parse_from_rfc3339("2000-01-01T00:00:00-00:00") + .unwrap() + .to_utc(); + static ref TIME_2010: DateTime = + DateTime::parse_from_rfc3339("2010-01-01T00:00:00-00:00") + .unwrap() + .to_utc(); + static ref TIME_2012: DateTime = + DateTime::parse_from_rfc3339("2012-01-01T00:00:00-00:00") + .unwrap() + .to_utc(); + static ref TIME_2014: DateTime = + DateTime::parse_from_rfc3339("2014-01-01T00:00:00-00:00") + .unwrap() + .to_utc(); + static ref TIME_2016: DateTime = + DateTime::parse_from_rfc3339("2016-01-01T00:00:00-00:00") + .unwrap() + .to_utc(); + static ref TIME_2018: DateTime = + DateTime::parse_from_rfc3339("2018-01-01T00:00:00-00:00") + .unwrap() + .to_utc(); + static ref TIME_2020: DateTime = + DateTime::parse_from_rfc3339("2020-01-01T00:00:00-00:00") + .unwrap() + .to_utc(); + } + fn sample_data() -> (Vec<(String, Value)>, Vec) { + ( + vec![ + ( + "5121.EG.003".into(), + serde_json::json!({"aliases":["003@5121"],"coords":{"accuracy":"building","lat":48.26842603718826,"lon":11.677995005953209,"source":"inferred"},"id":"5121.EG.003","maps":{"default":"interactive"},"name":"5121.EG.003 (Computerraum)","parent_names":["Standorte","Garching Forschungszentrum","Physik","Maier-Leibnitz-Laboratorium (MLL), TUM & LMU","Atlashalle"],"parents":["root","garching","physik","mll","5121"],"poi":{"nearby_public_transport":{"mvg":[]}},"props":{"calendar_url":"https://campus.tum.de/3","computed":[{"name":"Raumkennung","text":"5121.EG.003"},{"name":"Architekten-Name","text":"003"},{"name":"Stockwerk","text":"Erdgeschoss"},{"name":"Adresse","text":"Am Coulombwall 6, 85748 Garching b. München"}],"operator":{"code":"TUPELMU","id":39536,"name":"Ludwig-Maximilians-Universität München (LMU)","url":"https://campus.tum.de/tumonline/webnav.navigate_to?corg=39536"},"tumonline_room_nr":45064},"ranking_factors":{"rank_combined":10,"rank_type":100,"rank_usage":10},"sources":{"base":[{"name":"TUMonline","url":"https://campus.tum.de/tumonline/ee/ui/ca2/app/desktop/#/pl/ui/$ctx/45064"}]},"type":"room","type_common_name":"Serverraum","usage":{"din_277":"TF8.9","din_277_desc":"Sonstige betriebstechnische Anlagen","name":"Serverraum"},"redirect_url":"/room/5121.EG.003"}), + ), + ( + "5121.EG.002".into(), + serde_json::json!({"aliases":["002@5121"],"coords":{"accuracy":"building","lat":48.26842603718826,"lon":11.677995005953209,"source":"inferred"},"id":"5121.EG.002","maps":{"default":"interactive"},"name":"5121.EG.002 (Testroom)","parent_names":["Standorte","Garching Forschungszentrum","Physik","Maier-Leibnitz-Laboratorium (MLL),TUM & LMU","Atlashalle"],"parents":["root","garching","physik","mll","5121"],"poi":{"nearby_public_transport":{"mvg":[]}},"props":{"computed":[{"name":"Raumkennung","text":"5121.EG.002"},{"name":"Architekten-Name","text":"002"},{"name":"Stockwerk","text":"Erdgeschoss"},{"name":"Adresse","text":"Am Coulombwall 6,85748 Garching b. München"} ],"operator":{"code":"TUPELMU","id":39536,"name":"Ludwig-Maximilians-Universität München (LMU)","url":"https://campus.tum.de/tumonline/webnav.navigate_to?corg=39536"},"tumonline_room_nr":44904},"ranking_factors":{"rank_combined":10,"rank_type":100,"rank_usage":10},"sources":{"base":[{"name":"TUMonline","url":"https://campus.tum.de/tumonline/ee/ui/ca2/app/desktop/#/pl/ui/$ctx/44904"} ]},"type":"room","type_common_name":"Versuchshalle","usage":{"din_277":"NF3.3","din_277_desc":"Technologische Labors","name":"Versuchshalle"},"redirect_url":"/room/5121.EG.002"}), + ), + ( + "5121.EG.001".into(), + serde_json::json!({"aliases":["001@5121"],"coords":{"accuracy":"building","lat":48.26842603718826,"lon":11.677995005953209,"source":"inferred"},"id":"5121.EG.001","maps":{"default":"interactive"},"name":"5121.EG.001 (Montage- und Versuchshalle)","parent_names":["Standorte","Garching Forschungszentrum","Physik","Maier-Leibnitz-Laboratorium (MLL),TUM & LMU","Atlashalle"],"parents":["root","garching","physik","mll","5121"],"poi":{"nearby_public_transport":{"mvg":[]}},"props":{"calendar_url":"https://campus.tum.de/1","computed":[{"name":"Raumkennung","text":"5121.EG.001"},{"name":"Architekten-Name","text":"001"},{"name":"Stockwerk","text":"Erdgeschoss"},{"name":"Adresse","text":"Am Coulombwall 6,85748 Garching b. München"} ],"operator":{"code":"TUPELMU","id":39536,"name":"Ludwig-Maximilians-Universität München (LMU)","url":"https://campus.tum.de/tumonline/webnav.navigate_to?corg=39536"},"tumonline_room_nr":44904},"ranking_factors":{"rank_combined":10,"rank_type":100,"rank_usage":10},"sources":{"base":[{"name":"TUMonline","url":"https://campus.tum.de/tumonline/ee/ui/ca2/app/desktop/#/pl/ui/$ctx/44904"} ]},"type":"room","type_common_name":"Versuchshalle","usage":{"din_277":"NF3.3","din_277_desc":"Technologische Labors","name":"Versuchshalle"},"redirect_url":"/room/5121.EG.001"}), + ), + ], + vec![ + Event { + id: 1, + room_code: "5121.EG.003".into(), + start_at: *TIME_2012, + end_at: *TIME_2014, + stp_title_de: "Quantenteleportation".into(), + stp_title_en: "Quantum teleportation".into(), + stp_type: "Vorlesung mit Zentralübung".into(), + entry_type: models::EventType::Lecture, + detailed_entry_type: "Abhaltung".into(), + }, + Event { + id: 2, + room_code: "5121.EG.003".into(), + start_at: *TIME_2014, + end_at: *TIME_2016, + stp_title_de: "Quantenteleportation 2".into(), + stp_title_en: "Quantum teleportation 2".into(), + stp_type: "Vorlesung mit Zentralübung".into(), + entry_type: models::EventType::Lecture, + detailed_entry_type: "Abhaltung".into(), + }, + Event { + id: 3, + room_code: "5121.EG.001".into(), + start_at: *TIME_2014, + end_at: *TIME_2016, + stp_title_de: "Wartung".into(), + stp_title_en: "maintenance".into(), + stp_type: "Vorlesung mit Zentralübung".into(), + entry_type: models::EventType::Barred, + detailed_entry_type: "Abhaltung".into(), + }, + Event { + id: 4, + room_code: "5121.EG.001".into(), + start_at: *TIME_Y2K, + end_at: *TIME_2020, + stp_title_de: "Quantenteleportation 3".into(), + stp_title_en: "Quantum teleportation 3".into(), + stp_type: "Vorlesung".into(), + entry_type: models::EventType::Other, + detailed_entry_type: "Abhaltung".into(), + }, + Event { + id: 5, + room_code: "5121.EG.001".into(), + start_at: *TIME_Y2K, + end_at: *TIME_2010, + stp_title_de: "Quantenteleportation 3".into(), + stp_title_en: "Quantum teleportation 3".into(), + stp_type: "Vorlesung".into(), + entry_type: models::EventType::Exam, + detailed_entry_type: "Abhaltung".into(), + }, + ], + ) + } + + async fn load_sample_data(pool: &PgPool, now_rfc3339: &str) { + let mut tx = pool.begin().await.unwrap(); + let (locations, events) = sample_data(); + for (key, data) in locations { + for lang in ["de", "en"] { + let query =format!("INSERT INTO {lang}(key,data,last_calendar_scrape_at) VALUES ('{key}','{data}','{now_rfc3339}')"); + sqlx::query(&query).execute(&mut *tx).await.unwrap(); + } + } + + for event in events { + event.store(&mut tx).await.unwrap(); + } + tx.commit().await.unwrap(); + } + + #[actix_web::test] + async fn test_index_get() { + // setup + load data into postgres + let pg = PostgresTestContainer::new().await; + let now = Utc::now(); + let now = now.to_rfc3339_opts(chrono::SecondsFormat::Secs, true); // throwing away accuracy for simpler testing + load_sample_data(&pg.pool, &now).await; + // set up the http service/api/calendar + let app = test::init_service( + App::new() + .app_data(web::Data::new(AppData { + db: pg.pool.clone(), + })) + .service(calendar_handler), + ) + .await; + // -- send requests and assert response -- + { + // missing required query parameters + let req = test::TestRequest::get() + .uri("/api/calendar") + .insert_header(ContentType::json()) + .to_request(); + let (_, resp) = test::call_service(&app, req).await.into_parts(); + run_testcase( + resp, + 400, + "Json deserialize error: EOF while parsing a value at line 1 column 0", + ) + .await; + } + { + // missing required query parameters + let args = Arguments { + end_before: Utc::now(), + start_after: Utc::now(), + ids: vec![], + }; + let req = test::TestRequest::get() + .uri("/api/calendar") + .set_json(args) + .insert_header(ContentType::json()) + .to_request(); + let (_, resp) = test::call_service(&app, req).await.into_parts(); + run_testcase(resp, 400, "No id requested").await; + } + { + // way too many parameters + let args = Arguments { + end_before: Utc::now(), + start_after: Utc::now(), + ids: (0..10_000).map(|i| i.to_string()).collect(), + }; + let req = test::TestRequest::get() + .uri("/api/calendar") + .set_json(args) + .insert_header(ContentType::json()) + .to_request(); + let (_, resp) = test::call_service(&app, req).await.into_parts(); + run_testcase(resp, 400, "Too many ids to query. We suspect that users don't need this. If you need this limit increased, please send us a message").await; + } + { + // room without a calendar + let args = Arguments { + end_before: Utc::now(), + start_after: Utc::now(), + ids: vec!["5121.EG.002".into()], + }; + let req = test::TestRequest::get() + .uri("/api/calendar") + .set_json(args) + .insert_header(ContentType::json()) + .to_request(); + let (_, resp) = test::call_service(&app, req).await.into_parts(); + run_testcase(resp, 404, "Room 5121.EG.002/None does not have a calendar").await; + } + { + // show all entries of 5121.EG.003 + let args = Arguments { + start_after: *TIME_Y2K, + end_before: *TIME_2020, + ids: vec!["5121.EG.003".into()], + }; + let req = test::TestRequest::get() + .uri("/api/calendar") + .set_json(args) + .insert_header(ContentType::json()) + .to_request(); + let (_, resp) = test::call_service(&app, req).await.into_parts(); + let expected = serde_json::json!({ + "5121.EG.003": { + "events": [ + { + "id": 1, + "room_code": "5121.EG.003", + "start_at": "2012-01-01T00:00:00Z", + "end_at": "2014-01-01T00:00:00Z", + "stp_title_de": "Quantenteleportation", + "stp_title_en": "Quantum teleportation", + "stp_type": "Vorlesung mit Zentralübung", + "entry_type": "lecture", + "detailed_entry_type": "Abhaltung" + }, + { + "id": 2, + "room_code": "5121.EG.003", + "start_at": "2014-01-01T00:00:00Z", + "end_at": "2016-01-01T00:00:00Z", + "stp_title_de": "Quantenteleportation 2", + "stp_title_en": "Quantum teleportation 2", + "stp_type": "Vorlesung mit Zentralübung", + "entry_type": "lecture", + "detailed_entry_type": "Abhaltung" + } + ], + "location": { + "key": "5121.EG.003", + "name": "5121.EG.003 (Computerraum)", + "last_calendar_scrape_at": now, + "calendar_url": "https://campus.tum.de/3", + "type_common_name": "Serverraum", + "type": "room" + } + } + }); + run_testcase(resp, 200, &expected.to_string()).await; + } + { + // show both rooms, but a limited timeframe + let args = Arguments { + start_after: *TIME_2012, + end_before: *TIME_2014, + ids: vec!["5121.EG.003".into(), "5121.EG.001".into()], + }; + let req = test::TestRequest::get() + .uri("/api/calendar") + .set_json(args) + .insert_header(ContentType::json()) + .to_request(); + let (_, resp) = test::call_service(&app, req).await.into_parts(); + let expected = serde_json::json!({ + "5121.EG.001": { + "events": [], + "location": { + "calendar_url": "https://campus.tum.de/1", + "key": "5121.EG.001", + "last_calendar_scrape_at": now, + "name": "5121.EG.001 (Montage- und Versuchshalle)", + "type": "room", + "type_common_name": "Versuchshalle", + }, + }, + "5121.EG.003": { + "events": [ + { + "detailed_entry_type": "Abhaltung", + "end_at": "2014-01-01T00:00:00Z", + "entry_type": "lecture", + "id": 1, + "room_code": "5121.EG.003", + "start_at": "2012-01-01T00:00:00Z", + "stp_title_de": "Quantenteleportation", + "stp_title_en": "Quantum teleportation", + "stp_type": "Vorlesung mit Zentralübung", + }, + ], + "location": { + "calendar_url": "https://campus.tum.de/3", + "key": "5121.EG.003", + "last_calendar_scrape_at": now, + "name": "5121.EG.003 (Computerraum)", + "type": "room", + "type_common_name": "Serverraum", + }, + }, + }); + run_testcase(resp, 200, &expected.to_string()).await; + } + } + + async fn run_testcase(resp: HttpResponse, expected_status: u16, expected_body: &str) { + let actual_status = resp.status().as_u16(); + let body_box = resp.into_body(); + let body_bytes = actix_web::body::to_bytes(body_box).await.unwrap(); + let body_text = String::from_utf8(body_bytes.into_iter().collect()).unwrap(); + // if the expected value cleanly deserializes into json, we should compare using this + if let Ok(expected_value) = serde_json::from_str::(expected_body) { + let actual_value = serde_json::from_str::(&body_text).unwrap(); + assert_eq!(actual_value, expected_value); + } else { + assert_eq!(body_text, expected_body); + } + assert_eq!(actual_status, expected_status); + } +} diff --git a/server/main-api/src/calendar/models.rs b/server/main-api/src/calendar/models.rs index 9d4e069eb..8e0971c70 100644 --- a/server/main-api/src/calendar/models.rs +++ b/server/main-api/src/calendar/models.rs @@ -1,7 +1,7 @@ -use std::collections::HashMap; +use crate::models::Location; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; -use crate::models::Location; +use std::collections::HashMap; #[derive(Serialize, Deserialize, Clone, Debug)] pub(super) struct EventsCollection { @@ -32,7 +32,6 @@ impl From for CalendarLocation { } } - #[derive(Serialize, Deserialize, Clone, Debug)] pub(super) struct LocationEvents { pub(super) events: Vec, diff --git a/server/main-api/src/models.rs b/server/main-api/src/models.rs index a1cb7a0ba..17e0c26f6 100644 --- a/server/main-api/src/models.rs +++ b/server/main-api/src/models.rs @@ -1,6 +1,7 @@ use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone)] pub struct Location { pub key: String, pub name: String,