diff --git a/Cargo.lock b/Cargo.lock index 6d61333..2171ec2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ checksum = "f728064aca1c318585bf4bb04ffcfac9e75e508ab4e8b1bd9ba5dfe04e2cbed5" dependencies = [ "actix-rt", "actix_derive", - "bitflags", + "bitflags 1.3.2", "bytes", "crossbeam-channel", "futures-core", @@ -28,19 +28,19 @@ dependencies = [ [[package]] name = "actix-codec" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe" +checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bytes", "futures-core", "futures-sink", - "log", "memchr", "pin-project-lite", "tokio", "tokio-util", + "tracing", ] [[package]] @@ -54,7 +54,7 @@ dependencies = [ "actix-utils", "actix-web", "askama_escape", - "bitflags", + "bitflags 1.3.2", "bytes", "derive_more", "futures-core", @@ -68,17 +68,17 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.0.4" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5885cb81a0d4d0d322864bea1bb6c2a8144626b4fdc625d4c51eba197e7797a" +checksum = "c2079246596c18b4a33e274ae10c0e50613f4d32a4198e09c7b93771013fed74" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-utils", - "ahash", - "base64 0.13.0", - "bitflags", + "ahash 0.8.3", + "base64 0.21.2", + "bitflags 1.3.2", "brotli", "bytes", "bytestring", @@ -90,17 +90,19 @@ dependencies = [ "http", "httparse", "httpdate", - "itoa 1.0.3", + "itoa 1.0.6", "language-tags", "local-channel", - "log", "mime", "percent-encoding", "pin-project-lite", - "rand 0.8.5", - "sha-1", + "rand", + "sha1", "smallvec", - "zstd", + "tokio", + "tokio-util", + "tracing", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] @@ -110,46 +112,65 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "actix-multipart" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9edfb0e7663d7fe18c8d5b668c9c1bcf79176b1dcc9d4da9592503209a6bfb0" +checksum = "dee489e3c01eae4d1c35b03c4493f71cb40d93f66b14558feb1b1a807671cc4e" dependencies = [ + "actix-multipart-derive", "actix-utils", "actix-web", "bytes", "derive_more", "futures-core", + "futures-util", "httparse", "local-waker", "log", + "memchr", "mime", - "twoway", + "serde", + "serde_json", + "serde_plain", + "tempfile", + "tokio", +] + +[[package]] +name = "actix-multipart-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ec592f234db8a253cf80531246a4407c8a70530423eea80688a6c5a44a110e7" +dependencies = [ + "darling 0.14.4", + "parse-size", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] name = "actix-router" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb60846b52c118f2f04a56cc90880a274271c489b2498623d58176f8ca21fa80" +checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" dependencies = [ "bytestring", - "firestorm", "http", - "log", "regex", "serde", + "tracing", ] [[package]] name = "actix-rt" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea16c295198e958ef31930a6ef37d0fb64e9ca3b6116e6b93a8bdae96ee1000" +checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" dependencies = [ "futures-core", "tokio", @@ -157,9 +178,9 @@ dependencies = [ [[package]] name = "actix-server" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da34f8e659ea1b077bb4637948b815cd3768ad5a188fdcd74ff4d84240cd824" +checksum = "3e8613a75dd50cc45f473cee3c34d59ed677c0f7b44480ce3b8247d7dc519327" dependencies = [ "actix-rt", "actix-service", @@ -168,7 +189,7 @@ dependencies = [ "futures-util", "mio", "num_cpus", - "socket2", + "socket2 0.4.9", "tokio", "tracing", ] @@ -186,9 +207,9 @@ dependencies = [ [[package]] name = "actix-utils" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94" +checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" dependencies = [ "local-waker", "pin-project-lite", @@ -196,9 +217,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.1.0" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27e8fe9ba4ae613c21f677c2cfaf0696c3744030c6f485b34634e502d6bb379" +checksum = "cd3cb42f9566ab176e1ef0b8b3a896529062b4efc6be0123046095914c4c1c96" dependencies = [ "actix-codec", "actix-http", @@ -209,7 +230,7 @@ dependencies = [ "actix-service", "actix-utils", "actix-web-codegen", - "ahash", + "ahash 0.7.6", "bytes", "bytestring", "cfg-if", @@ -218,7 +239,8 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "itoa 1.0.3", + "http", + "itoa 1.0.6", "language-tags", "log", "mime", @@ -229,16 +251,16 @@ dependencies = [ "serde_json", "serde_urlencoded 0.7.1", "smallvec", - "socket2", - "time 0.3.13", + "socket2 0.4.9", + "time 0.3.21", "url", ] [[package]] name = "actix-web-actors" -version = "4.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31efe7896f3933ce03dd4710be560254272334bb321a18fd8ff62b1a557d9d19" +checksum = "bf6e9ccc371cfddbed7aa842256a4abc7a6dcac9f3fce392fe1d0f68cfd136b2" dependencies = [ "actix", "actix-codec", @@ -249,18 +271,19 @@ dependencies = [ "futures-core", "pin-project-lite", "tokio", + "tokio-util", ] [[package]] name = "actix-web-codegen" -version = "4.0.1" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f270541caec49c15673b0af0e9a00143421ad4f118d2df7edcb68b627632f56" +checksum = "2262160a7ae29e3415554a3f1fc04c764b1540c116aa524683208078b7a75bc9" dependencies = [ "actix-router", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -271,7 +294,7 @@ checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -288,45 +311,13 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "aes" -version = "0.6.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", -] - -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", - "opaque-debug", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher 0.2.5", - "opaque-debug", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher 0.2.5", - "opaque-debug", ] [[package]] @@ -335,40 +326,58 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.7", + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "getrandom", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.18" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" dependencies = [ "memchr", ] [[package]] name = "alloc-no-stdlib" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ef4730490ad1c4eae5c4325b2a95f521d023e5c885853ff7aca0a6a1631db3" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" [[package]] name = "alloc-stdlib" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697ed7edc0f1711de49ce108c541623a0af97c6c60b2f6e2b65229847ac843c2" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" dependencies = [ "alloc-no-stdlib", ] [[package]] -name = "android_system_properties" -version = "0.1.4" +name = "android-tzdata" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ed72e1635e121ca3e79420540282af22da58be50de153d36f81ddc6b83aa9e" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ "libc", ] @@ -404,7 +413,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.13", + "time 0.3.21", ] [[package]] @@ -415,7 +424,7 @@ checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] @@ -427,18 +436,29 @@ checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "async-recursion" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cda8f4bcc10624c4e85bc66b3f452cca98cfa5ca002dc83a16aad2367641bea" +checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", +] + +[[package]] +name = "async-trait" +version = "0.1.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.18", ] [[package]] @@ -485,44 +505,51 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base64ct" -version = "1.0.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "base64urlsafedata" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d02340c3f25c8422ba85d481123406dd7506505485bac1c694b26eb538da8daf" +checksum = "18b3d30abb74120a9d5267463b9e0045fdccc4dd152e7249d966612dc1721384" dependencies = [ - "base64 0.13.0", + "base64 0.21.2", "serde", "serde_json", ] [[package]] name = "bcrypt" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e7c93a3fb23b2fdde989b2c9ec4dd153063ec81f408507f84c090cd91c6641" +checksum = "9df288bec72232f78c1ec5fe4e8f1d108aa0265476e93097593c803c8c02062a" dependencies = [ - "base64 0.13.0", + "base64 0.21.2", "blowfish", - "getrandom 0.2.7", + "getrandom", + "subtle", "zeroize", ] [[package]] name = "bigdecimal" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aaf33151a6429fe9211d1b276eafdf70cdff28b071e76c0b0e1503221ea3744" +checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" dependencies = [ "num-bigint 0.4.3", "num-integer", @@ -531,28 +558,30 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.59.2" +version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", "lazycell", "peeking_take_while", + "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", + "syn 2.0.18", ] [[package]] name = "bit_field" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" [[package]] name = "bitflags" @@ -561,10 +590,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bitvec" -version = "0.22.3" +name = "bitflags" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5237f00a8c86130a0cc317830e558b966dd7850d48a953d998c813f01a41b527" +checksum = "6776fc96284a0bb647b615056fc496d1fe1644a7ab01829818a6d91cae888b84" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", "radium", @@ -574,37 +609,21 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.9.0" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] -[[package]] -name = "block-buffer" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-modes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" -dependencies = [ - "block-padding", - "cipher 0.2.5", -] - [[package]] name = "block-padding" -version = "0.2.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array", +] [[package]] name = "blowfish" @@ -613,7 +632,52 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e412e2cd0f2b2d93e02543ceae7917b3c70331573df19ee046bcbc35e45e87d7" dependencies = [ "byteorder", - "cipher 0.4.3", + "cipher", +] + +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive", + "hashbrown 0.13.2", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -629,9 +693,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.3.2" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ad2d4653bf5ca36ae797b1f4bb4dbddb60ce49ca4aed8a2ce4829f60425b80" +checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -645,15 +709,37 @@ checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" [[package]] name = "bumpalo" -version = "3.11.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" + +[[package]] +name = "bytecheck" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] name = "bytemuck" -version = "1.12.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" [[package]] name = "byteorder" @@ -663,24 +749,24 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.2.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "bytestring" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b6a75fd3048808ef06af5cd79712be8111960adaf89d90250974b38fc3928a" +checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae" dependencies = [ "bytes", ] [[package]] name = "bzip2" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6afcd980b5f3a45017c57e57a2fcccbb351cc43a356ce117ef760ef8052b89b0" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" dependencies = [ "bzip2-sys", "libc", @@ -698,10 +784,19 @@ dependencies = [ ] [[package]] -name = "cc" -version = "1.0.73" +name = "cbc" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" dependencies = [ "jobserver", ] @@ -723,42 +818,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", - "time 0.1.44", + "time 0.1.45", "wasm-bindgen", "winapi", ] [[package]] name = "cipher" -version = "0.2.5" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array", -] - -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array", -] - -[[package]] -name = "cipher" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", @@ -766,9 +843,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.3.3" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", @@ -777,9 +854,9 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.48" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" dependencies = [ "cc", ] @@ -792,18 +869,19 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "compact_jwt" -version = "0.2.4" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9417bb4f581b7a5e08fabb4398b910064363bbfd7b75a10d1da3bfff3ef9b36" +checksum = "51f9032b96a89dd79ffc5f62523d5351ebb40680cbdfc4029393b511b9e971aa" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "base64urlsafedata", + "hex", "openssl", "serde", "serde_json", "tracing", "url", - "uuid 1.1.2", + "uuid", ] [[package]] @@ -834,7 +912,7 @@ dependencies = [ "mysql", "pdf", "percent-encoding", - "rand 0.8.5", + "rand", "regex", "reqwest", "serde", @@ -863,12 +941,12 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cookie" -version = "0.16.0" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" +checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" dependencies = [ "percent-encoding", - "time 0.3.13", + "time 0.3.21", "version_check", ] @@ -884,15 +962,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.4" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc948ebb96241bb40ab73effeb80d9f93afaad49359d159a5e61be51619fe813" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -922,9 +1000,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -932,9 +1010,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -943,23 +1021,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.10" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", "memoffset", - "once_cell", "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" dependencies = [ "cfg-if", "crossbeam-utils", @@ -967,14 +1044,19 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.11" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", - "once_cell", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -996,15 +1078,15 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "socket2", + "socket2 0.4.9", "winapi", ] [[package]] name = "curl-sys" -version = "0.4.56+curl-7.83.1" +version = "0.4.62+curl-8.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093e169dd4de29e468fa649fbae11cdcd5551c81fe5bf1b0677adad7ef3d26f" +checksum = "274ef7ef7c1113c7611af49ce248a700afa1171045a1aaa40137030773f993b8" dependencies = [ "cc", "libc", @@ -1016,30 +1098,112 @@ dependencies = [ ] [[package]] -name = "dashmap" -version = "5.3.4" +name = "darling" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3495912c9c1ccf2e18976439f4443f3fee0fd61f424ff99fde6a66b15ecb448f" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core 0.14.4", + "darling_macro 0.14.4", +] + +[[package]] +name = "darling" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" +dependencies = [ + "darling_core 0.20.1", + "darling_macro 0.20.1", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.18", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core 0.14.4", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" +dependencies = [ + "darling_core 0.20.1", + "quote", + "syn 2.0.18", +] + +[[package]] +name = "dashmap" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.12.3", "lock_api", + "once_cell", "parking_lot_core", ] [[package]] name = "data-encoding" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] -name = "deflate" -version = "0.9.1" +name = "datasize" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f95bf05dffba6e6cce8dfbb30def788154949ccd9aed761b472119c21e01c70" +checksum = "c88ad90721dc8e2ebe1430ac2f59c5bdcd74478baa68da26f30f33b0fe997f11" dependencies = [ - "adler32", + "datasize_derive", +] + +[[package]] +name = "datasize_derive" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b0415ec81945214410892a00d4b5dd4566f6263205184248e018a3fe384a61e" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -1075,49 +1239,40 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.109", ] [[package]] name = "derive_utils" -version = "0.11.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532b4c15dccee12c7044f1fcad956e98410860b22231e44a3b827464797ca7bf" +checksum = "dff8f6a793f528719e1ad4425a52a213ac1214ac7158c5fb97a7f50a64bfc96d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", ] [[package]] name = "digest" -version = "0.9.0" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" -dependencies = [ - "block-buffer 0.10.2", + "block-buffer", "crypto-common", "subtle", ] [[package]] name = "displaydoc" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", ] [[package]] @@ -1134,32 +1289,54 @@ checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "encoding_rs" -version = "0.8.31" +version = "0.8.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" dependencies = [ "cfg-if", ] [[package]] -name = "exr" -version = "1.5.0" +name = "errno" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c26a90d9dd411a3d119d6f55752fb4c134ca243250c32fb9cab7b2561638d2" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "exr" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd2162b720141a91a054640662d3edce3d50a944a50ffca5313cd951abb35b4" dependencies = [ "bit_field", "flume", - "half", + "half 2.2.1", "lebe", - "miniz_oxide", + "miniz_oxide 0.6.2", + "rayon-core", "smallvec", - "threadpool", + "zune-inflate", ] [[package]] @@ -1173,18 +1350,18 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] [[package]] name = "fax" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be28317220fbcf14cead021ae0a973a4433df68fd3c3a022bf8a4fb3bdc3ba8e" +checksum = "b2cec1797683c06c2f3de5edb3fde4d99c70e96f3204f6aaff944078353e5c55" dependencies = [ "fax_derive", ] @@ -1197,24 +1374,27 @@ checksum = "3c1d7ffc9f2dc8316348c75281a99c8fdc60c1ddf4f82a366d117bf1b74d5a39" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] -name = "firestorm" -version = "0.5.1" +name = "fdeflate" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c5f6c2c942da57e2aaaa84b8a521489486f14e75e7fa91dab70aba913975f98" +checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +dependencies = [ + "simd-adler32", +] [[package]] name = "flate2" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide", + "miniz_oxide 0.7.1", ] [[package]] @@ -1227,7 +1407,7 @@ dependencies = [ "futures-sink", "nanorand", "pin-project", - "spin 0.9.4", + "spin 0.9.8", ] [[package]] @@ -1253,19 +1433,18 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" dependencies = [ - "matches", "percent-encoding", ] [[package]] name = "frunk" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cd67cf7d54b7e72d0ea76f3985c3747d74aee43e0218ad993b7903ba7a5395e" +checksum = "a89c703bf50009f383a0873845357cc400a95fc535f836feddfe015d7df6e1e0" dependencies = [ "frunk_core", "frunk_derives", @@ -1274,38 +1453,38 @@ dependencies = [ [[package]] name = "frunk_core" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1246cf43ec80bf8b2505b5c360b8fb999c97dabd17dbb604d85558d5cbc25482" +checksum = "2a446d01a558301dca28ef43222864a9fa2bd9a2e71370f769d5d5d5ec9f3537" [[package]] name = "frunk_derives" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dbc4f084ec5a3f031d24ccedeb87ab2c3189a2f33b8d070889073837d5ea09e" +checksum = "b83164912bb4c97cfe0772913c7af7387ee2e00cb6d4636fb65a35b3d0c8f173" dependencies = [ "frunk_proc_macro_helpers", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "frunk_proc_macro_helpers" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99f11257f106c6753f5ffcb8e601fb39c390a088017aaa55b70c526bff15f63e" +checksum = "015425591bbeb0f5b8a75593340f1789af428e9f887a4f1e36c0c471f067ef50" dependencies = [ "frunk_core", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "frunk_proc_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a078bd8459eccbb85e0b007b8f756585762a72a9efc53f359b371c3b6351dbcc" +checksum = "ea01524f285deab48affffb342b97f186e657b119c3f1821ac531780e0fbfae0" dependencies = [ "frunk_core", "frunk_proc_macros_impl", @@ -1314,22 +1493,22 @@ dependencies = [ [[package]] name = "frunk_proc_macros_impl" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ffba99f0fa4f57e42f57388fbb9a0ca863bc2b4261f3c5570fed579d5df6c32" +checksum = "0a802d974cc18ee7fe1a7868fc9ce31086294fd96ba62f8da64ecb44e92a2653" dependencies = [ "frunk_core", "frunk_proc_macro_helpers", "proc-macro-hack", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "funty" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1847abb9cb65d566acd5942e94aea9c8f547ad02c98e1649326fc0e8910b8b1e" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futf" @@ -1343,9 +1522,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab30e97ab6aacfe635fad58f22c2bb06c8b685f7421eb1e064a729e2a5f481fa" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -1358,9 +1537,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bfc52cbddcfd745bf1740338492bb0bd83d76c67b445f91c5fb29fae29ecaa1" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -1368,15 +1547,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2acedae88d38235936c3922476b10fced7b2b68136f5e3c03c2d5be348a1115" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d11aa21b5b587a64682c0094c2bdd4df0076c5324961a40cc3abd7f37930528" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -1385,38 +1564,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93a66fc6d035a26a3ae255a6d2bca35eda63ae4c5512bef54449113f7a1228e5" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0db9cce532b0eae2ccf2766ab246f114b56b9cf6d445e00c2549fbc100ca045d" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", ] [[package]] name = "futures-sink" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0bae1fe9752cf7fd9b0064c674ae63f97b37bc714d745cbde0afb7ec4e6765" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "842fc63b931f4056a24d59de13fb1272134ce261816e063e634ad0c15cdc5306" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0828a5471e340229c11c77ca80017937ce3c58cb788a17e5f1c2d5c485a9577" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -1443,9 +1622,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -1453,20 +1632,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.16" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "js-sys", @@ -1477,9 +1645,9 @@ dependencies = [ [[package]] name = "gif" -version = "0.11.4" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3edd93c6756b4dfaf2709eafcc345ba2636565295c198a9cfbf75fa5e3e00b06" +checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045" dependencies = [ "color_quant", "weezl", @@ -1487,9 +1655,18 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "globalcache" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469dba5c15b33d67400508ff1f640e8906fa6c8d5ee80540203eb9029ce475df" +dependencies = [ + "async-trait", +] [[package]] name = "gouth" @@ -1507,9 +1684,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.14" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -1530,23 +1707,59 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +[[package]] +name = "half" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" +dependencies = [ + "crunchy", +] + [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", ] [[package]] name = "hermit-abi" -version = "0.1.19" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" @@ -1554,32 +1767,32 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.3", + "digest", ] [[package]] name = "html5ever" -version = "0.25.2" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c13fb08e5d4dfc151ee5e88bae63f7773d61852f3bdc73c9f4b9e1bde03148" +checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" dependencies = [ "log", "mac", "markup5ever", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", - "itoa 1.0.3", + "itoa 1.0.6", ] [[package]] @@ -1601,9 +1814,9 @@ checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" [[package]] name = "httparse" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" @@ -1613,9 +1826,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.20" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -1626,9 +1839,9 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.3", + "itoa 1.0.6", "pin-project-lite", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -1650,55 +1863,70 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.46" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad2bfd338099682614d3ee3fe0cd72e0b6a41ca6a87f6a74a3bd593c91650501" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", + "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] -name = "idna" -version = "0.2.3" +name = "iana-time-zone-haiku" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" dependencies = [ - "matches", "unicode-bidi", "unicode-normalization", ] [[package]] name = "image" -version = "0.24.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964" +checksum = "527909aa81e20ac3a44803521443a765550f09b5130c2c2fa1ea59c2f8f50a3a" dependencies = [ "bytemuck", "byteorder", "color_quant", "exr", "gif", - "jpeg-decoder 0.2.6", + "jpeg-decoder", "num-rational", "num-traits", "png", - "scoped_threadpool", + "qoi", "tiff", ] [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -1716,6 +1944,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ + "block-padding", "generic-array", ] @@ -1730,27 +1959,45 @@ dependencies = [ [[package]] name = "io-enum" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e3306b0f260aad2872563eb0d5d1a59f2420fad270a661dce59a01e92d806b" +checksum = "01c662c349c9c9f542e7bfd9134143beb27da4b20dfbc3b3ef5b2a5b507dafbd" dependencies = [ - "autocfg", "derive_utils", - "quote", - "syn", + "syn 2.0.18", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", ] [[package]] name = "ipnet" -version = "2.5.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" + +[[package]] +name = "istring" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80fa5ca8bf0d6cc95e94ac834a7c27da3daacd089dc6284d85df18db23510664" +dependencies = [ + "datasize", +] [[package]] name = "itertools" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] @@ -1763,39 +2010,33 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jobserver" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] [[package]] name = "jpeg-decoder" -version = "0.1.22" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" - -[[package]] -name = "jpeg-decoder" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9478aa10f73e7528198d75109c8be5cd7d15fb530238040148d5f9a22d4c5b3b" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" dependencies = [ "rayon", ] [[package]] name = "js-sys" -version = "0.3.59" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -1816,9 +2057,9 @@ dependencies = [ [[package]] name = "kamadak-exif" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70494964492bf8e491eb3951c5d70c9627eb7100ede6cc56d748b9a3f302cfb6" +checksum = "ef4fc70d0ab7e5b6bafa30216a6b48705ea964cdfc29c050f2412295eba58077" dependencies = [ "mutate_once", ] @@ -1922,15 +2163,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.132" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libloading" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ "cfg-if", "winapi", @@ -1938,9 +2179,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" dependencies = [ "cc", "libc", @@ -1954,6 +2195,12 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + [[package]] name = "local-channel" version = "0.1.3" @@ -1974,9 +2221,9 @@ checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" [[package]] name = "lock_api" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ "autocfg", "scopeguard", @@ -1984,20 +2231,17 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" [[package]] name = "lru" -version = "0.7.8" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" +checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" dependencies = [ - "hashbrown", + "hashbrown 0.13.2", ] [[package]] @@ -2008,9 +2252,9 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "mailchecker" -version = "5.0.0" +version = "5.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9188ee74b3b27e3a35bdc2764e806445de607a0d0324b0281bd0e5c5b8bad4a3" +checksum = "4c64fa7af9860896bdfe496f323ac278f256006fd248dd7730e37c5faa648b05" dependencies = [ "fast_chemail", "once_cell", @@ -2018,9 +2262,9 @@ dependencies = [ [[package]] name = "markup5ever" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" +checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" dependencies = [ "log", "phf", @@ -2032,9 +2276,9 @@ dependencies = [ [[package]] name = "markup5ever_rcdom" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f015da43bcd8d4f144559a3423f4591d69b8ce0652c905374da7205df336ae2b" +checksum = "b9521dd6750f8e80ee6c53d65e2e4656d7de37064f3a7a5d2d11d05df93839c2" dependencies = [ "html5ever", "markup5ever", @@ -2042,12 +2286,6 @@ dependencies = [ "xml5ever", ] -[[package]] -name = "matches" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" - [[package]] name = "md5" version = "0.7.0" @@ -2062,18 +2300,18 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" -version = "0.6.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" dependencies = [ "autocfg", ] [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" @@ -2093,23 +2331,33 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.5.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] [[package]] -name = "mio" -version = "0.8.4" +name = "miniz_oxide" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2120,9 +2368,9 @@ checksum = "e4eaa3a228dc218005d769b88ce3a0310f49152f2029125289e94c49474c9cc4" [[package]] name = "mp4" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3f2d2c1de60843b72f18e2cc79c3529791e109747737e65d547540482c10e8" +checksum = "509348cba250e7b852a875100a2ddce7a36ee3abf881a681c756670c1774264d" dependencies = [ "byteorder", "bytes", @@ -2140,9 +2388,9 @@ checksum = "16cf681a23b4d0a43fc35024c176437f9dcd818db34e0f42ab456a0ee5ad497b" [[package]] name = "mysql" -version = "22.2.0" +version = "24.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d8136c78f78cda5c1a4eee4ce555281b71e3e6db715817bc50e186e623b36f" +checksum = "cfe2babc5f5b354eab9c0a0e40da3e69c4d77421c8b9b6ee03f97acc75bd7955" dependencies = [ "bufstream", "bytes", @@ -2155,25 +2403,43 @@ dependencies = [ "named_pipe", "native-tls", "once_cell", - "pem 1.1.0", + "pem 2.0.1", "percent-encoding", "serde", "serde_json", - "socket2", + "socket2 0.5.3", "twox-hash", "url", ] [[package]] -name = "mysql_common" -version = "0.28.2" +name = "mysql-common-derive" +version = "0.30.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4140827f2d12750de1e8755442577e4292a835f26ff2f659f0a380d1d71020b0" +checksum = "56b0d8a0db9bf6d2213e11f2c701cb91387b0614361625ab7b9743b41aa4938f" dependencies = [ - "base64 0.13.0", + "darling 0.20.1", + "heck", + "num-bigint 0.4.3", + "proc-macro-crate 1.3.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.18", + "termcolor", + "thiserror", +] + +[[package]] +name = "mysql_common" +version = "0.30.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b8fb568c9537cf4f1ad39e2542aa74a66bf89883e550df2cb30a8f0c0f0355" +dependencies = [ + "base64 0.21.2", "bigdecimal", "bindgen", - "bitflags", + "bitflags 2.3.1", "bitvec", "byteorder", "bytes", @@ -2184,21 +2450,22 @@ dependencies = [ "frunk", "lazy_static", "lexical", + "mysql-common-derive", "num-bigint 0.4.3", "num-traits", - "rand 0.8.5", + "rand", "regex", "rust_decimal", "saturating", "serde", "serde_json", - "sha-1", - "sha2 0.10.2", + "sha1", + "sha2", "smallvec", "subprocess", "thiserror", - "time 0.3.13", - "uuid 0.8.2", + "time 0.3.21", + "uuid", ] [[package]] @@ -2216,14 +2483,14 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" dependencies = [ - "getrandom 0.2.7", + "getrandom", ] [[package]] name = "native-tls" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" dependencies = [ "lazy_static", "libc", @@ -2245,9 +2512,9 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] name = "nom" -version = "7.1.1" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", @@ -2309,20 +2576,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "num_threads" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ + "hermit-abi 0.2.6", "libc", ] @@ -2337,23 +2595,17 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.13.1" +version = "1.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" [[package]] name = "openssl" -version = "0.10.41" +version = "0.10.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0" +checksum = "12df40a956736488b7b44fe79fe12d4f245bb5b3f5a1f6095e499760015be392" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -2364,13 +2616,13 @@ dependencies = [ [[package]] name = "openssl-macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", ] [[package]] @@ -2381,23 +2633,16 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.75" +version = "0.9.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" +checksum = "c2ce0f250f34a308dcfdbb351f511359857d4ed2134ba715a4eadd46e1ffd617" dependencies = [ - "autocfg", "cc", "libc", "pkg-config", "vcpkg", ] -[[package]] -name = "ordermap" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91409674c628d07a6b4b79cc877c6b63ba5ccbfbadddd77ca822f55069ed1bd4" - [[package]] name = "parking_lot" version = "0.12.1" @@ -2410,69 +2655,74 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.3" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] -name = "password-hash" -version = "0.3.2" +name = "parse-size" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8" +checksum = "944553dd59c802559559161f9816429058b869003836120e262e8caec061b7ae" + +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" dependencies = [ "base64ct", - "rand_core 0.6.3", + "rand_core", "subtle", ] [[package]] name = "paste" -version = "1.0.8" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pbkdf2" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest 0.10.3", + "digest", "hmac", "password-hash", - "sha2 0.10.2", + "sha2", ] [[package]] name = "pdf" -version = "0.7.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f48644b2f4e9c3f3468d7c31fa75e9b823dfb167c8581ec15e90a90c34430d9" +checksum = "e375ec076445f61d4dbc4636e9e788f841d279c65d6fea8a3875caddd4f2dd82" dependencies = [ - "aes 0.6.0", - "block-modes", - "byteorder", - "chrono", - "deflate 0.9.1", + "aes", + "bitflags 1.3.2", + "cbc", + "datasize", + "deflate", "fax", - "glob", + "globalcache", "inflate", + "istring", "itertools", - "jpeg-decoder 0.1.22", + "jpeg-decoder", "log", "md5", - "num-traits", "once_cell", - "ordermap", "pdf_derive", - "sha2 0.9.9", + "sha2", "snafu", "stringprep", "weezl", @@ -2486,7 +2736,7 @@ checksum = "7f4007262775d0798de87b15cbc64cf1aed5f7ee87eec847e297b69d8ed4b4f8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2501,53 +2751,44 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd56cbd21fea48d0c440b41cd69c589faacade08c992d9a54e471b79d0fd13eb" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "once_cell", "regex", ] [[package]] name = "pem" -version = "1.1.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c64931a1a212348ec4f3b4362585eca7159d0d09cbdf4a7f74f02173596fd4" +checksum = "6b13fe415cdf3c8e44518e18a7c95a13431d9bdf6d15367d82b23c377fdd441a" dependencies = [ - "base64 0.13.0", + "base64 0.21.2", + "serde", ] [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "phf" -version = "0.8.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" dependencies = [ - "phf_shared 0.8.0", + "phf_shared", ] [[package]] name = "phf_codegen" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" +checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" dependencies = [ - "phf_generator 0.8.0", - "phf_shared 0.8.0", -] - -[[package]] -name = "phf_generator" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" -dependencies = [ - "phf_shared 0.8.0", - "rand 0.7.3", + "phf_generator", + "phf_shared", ] [[package]] @@ -2556,17 +2797,8 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ - "phf_shared 0.10.0", - "rand 0.8.5", -] - -[[package]] -name = "phf_shared" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" -dependencies = [ - "siphasher", + "phf_shared", + "rand", ] [[package]] @@ -2580,22 +2812,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", ] [[package]] @@ -2612,27 +2844,28 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "png" -version = "0.17.5" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba" +checksum = "aaeebc51f9e7d2c150d3f3bfeb667f2aa985db5ef1e3d212847bdedb488beeaa" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", - "deflate 1.0.0", - "miniz_oxide", + "fdeflate", + "flate2", + "miniz_oxide 0.7.1", ] [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "precomputed-hash" @@ -2641,48 +2874,116 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] -name = "proc-macro-hack" -version = "0.5.19" +name = "prettyplease" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" +checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1" +dependencies = [ + "proc-macro2", + "syn 2.0.18", +] + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.43" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" dependencies = [ "unicode-ident", ] [[package]] -name = "quote" -version = "1.0.21" +name = "ptr_meta" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "quote" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] [[package]] name = "radium" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", - "rand_pcg", -] +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] name = "rand" @@ -2691,18 +2992,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -2712,62 +3003,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", + "rand_core", ] [[package]] name = "rand_core" -version = "0.5.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom 0.2.7", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] name = "rayon" -version = "1.5.3" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.3" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -2781,14 +3043,23 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.6.0" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" dependencies = [ "aho-corasick", "memchr", @@ -2797,26 +3068,26 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] -name = "remove_dir_all" -version = "0.5.3" +name = "rend" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" dependencies = [ - "winapi", + "bytecheck", ] [[package]] name = "reqwest" -version = "0.11.11" +version = "0.11.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" dependencies = [ - "base64 0.13.0", + "base64 0.21.2", "bytes", "encoding_rs", "futures-core", @@ -2828,10 +3099,10 @@ dependencies = [ "hyper-tls", "ipnet", "js-sys", - "lazy_static", "log", "mime", "native-tls", + "once_cell", "percent-encoding", "pin-project-lite", "serde", @@ -2863,14 +3134,49 @@ dependencies = [ ] [[package]] -name = "rust_decimal" -version = "1.26.1" +name = "rkyv" +version = "0.7.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee9164faf726e4f3ece4978b25ca877ddc6802fa77f38cdccb32c7f805ecd70c" +checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +dependencies = [ + "bitvec", + "bytecheck", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rust_decimal" +version = "1.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26bd36b60561ee1fb5ec2817f198b6fd09fa571c897a5e86d1487cfc2b096dfc" dependencies = [ "arrayvec", + "borsh", + "bytecheck", + "byteorder", + "bytes", "num-traits", + "rand", + "rkyv", "serde", + "serde_json", ] [[package]] @@ -2897,6 +3203,20 @@ dependencies = [ "nom", ] +[[package]] +name = "rustix" +version = "0.37.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.18.1" @@ -2912,9 +3232,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "saturating" @@ -2924,20 +3244,13 @@ checksum = "ece8e78b2f38ec51c51f5d475df0a7187ba5111b2a28bdc761ee05b075d40a71" [[package]] name = "schannel" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" dependencies = [ - "lazy_static", - "windows-sys", + "windows-sys 0.42.0", ] -[[package]] -name = "scoped_threadpool" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" - [[package]] name = "scopeguard" version = "1.1.0" @@ -2955,12 +3268,18 @@ dependencies = [ ] [[package]] -name = "security-framework" -version = "2.7.0" +name = "seahash" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "security-framework" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -2969,9 +3288,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.6.1" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" dependencies = [ "core-foundation-sys", "libc", @@ -2979,51 +3298,60 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.13" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.144" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] [[package]] -name = "serde_cbor" -version = "0.11.2" +name = "serde_cbor_2" +version = "0.12.0-dev" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +checksum = "b46d75f449e01f1eddbe9b00f432d616fbbd899b809c837d0fbc380496a0dd55" dependencies = [ - "half", + "half 1.8.2", "serde", ] [[package]] name = "serde_derive" -version = "1.0.144" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", ] [[package]] name = "serde_json" -version = "1.0.85" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ - "itoa 1.0.3", + "itoa 1.0.6", "ryu", "serde", ] +[[package]] +name = "serde_plain" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6018081315db179d0ce57b1fe4b62a12a0028c9cf9bbef868c9cf477b3c34ae" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.6.1" @@ -3043,55 +3371,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.3", + "itoa 1.0.6", "ryu", "serde", ] -[[package]] -name = "sha-1" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.3", -] - [[package]] name = "sha1" -version = "0.10.1" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77f4e7f65455545c2153c1253d25056825e77ee2533f0e41deb65a93a34852f" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.3", + "digest", ] [[package]] name = "sha2" -version = "0.9.9" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.3", + "digest", ] [[package]] @@ -3102,13 +3406,25 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] +[[package]] +name = "simd-adler32" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + [[package]] name = "simple_asn1" version = "0.4.1" @@ -3128,24 +3444,24 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] [[package]] name = "smallvec" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "snafu" -version = "0.6.10" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7" +checksum = "cb0656e7e3ffb70f6c39b3c2a86332bb74aa3c679da781642590f3c1118c5045" dependencies = [ "doc-comment", "snafu-derive", @@ -3153,25 +3469,36 @@ dependencies = [ [[package]] name = "snafu-derive" -version = "0.6.10" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b" +checksum = "475b3bbe5245c26f2d8a6f62d67c1f30eb9fffeccee721c45d162c3ebbdf81b2" dependencies = [ + "heck", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "spin" version = "0.5.2" @@ -3180,9 +3507,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "spin" -version = "0.9.4" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" dependencies = [ "lock_api", ] @@ -3195,14 +3522,14 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_cache" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", "parking_lot", - "phf_shared 0.10.0", + "phf_shared", "precomputed-hash", "serde", ] @@ -3213,8 +3540,8 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", + "phf_generator", + "phf_shared", "proc-macro2", "quote", ] @@ -3229,6 +3556,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "subprocess" version = "0.2.9" @@ -3241,15 +3574,26 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "1.0.99" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" dependencies = [ "proc-macro2", "quote", @@ -3264,7 +3608,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "unicode-xid", ] @@ -3276,16 +3620,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.3.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if", "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi", + "redox_syscall 0.3.5", + "rustix", + "windows-sys 0.45.0", ] [[package]] @@ -3300,50 +3643,50 @@ dependencies = [ ] [[package]] -name = "thiserror" -version = "1.0.32" +name = "termcolor" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.32" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", + "syn 2.0.18", ] [[package]] name = "tiff" -version = "0.7.3" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7259662e32d1e219321eb309d5f9d898b779769d81b76e762c07c8e5d38fcb65" +checksum = "7449334f9ff2baf290d55d73983a7d6fa15e01198faef72af07e2a8db851e471" dependencies = [ "flate2", - "jpeg-decoder 0.2.6", + "jpeg-decoder", "weezl", ] [[package]] name = "time" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", @@ -3352,21 +3695,30 @@ dependencies = [ [[package]] name = "time" -version = "0.3.13" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db76ff9fa4b1458b3c7f077f3ff9887394058460d21e634355b273aaf11eea45" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ - "itoa 1.0.3", - "libc", - "num_threads", + "itoa 1.0.6", + "serde", + "time-core", "time-macros", ] [[package]] -name = "time-macros" -version = "0.2.4" +name = "time-core" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "time-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +dependencies = [ + "time-core", +] [[package]] name = "tinyvec" @@ -3379,35 +3731,33 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.20.1" +version = "1.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" +checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" dependencies = [ "autocfg", "bytes", "libc", - "memchr", "mio", "num_cpus", - "once_cell", "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2", - "winapi", + "socket2 0.4.9", + "windows-sys 0.48.0", ] [[package]] name = "tokio-native-tls" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ "native-tls", "tokio", @@ -3415,9 +3765,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.3" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -3427,6 +3777,32 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" + +[[package]] +name = "toml_edit" +version = "0.19.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -3435,9 +3811,9 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.36" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", @@ -3448,39 +3824,29 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.22" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", ] [[package]] name = "tracing-core" -version = "0.1.29" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", ] [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - -[[package]] -name = "twoway" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c57ffb460d7c24cd6eda43694110189030a3d1dfe418416d9468fd1c1d290b47" -dependencies = [ - "memchr", - "unchecked-index", -] +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "twox-hash" @@ -3489,21 +3855,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", - "rand 0.8.5", + "rand", "static_assertions", ] [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" - -[[package]] -name = "unchecked-index" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicase" @@ -3516,30 +3876,30 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.3" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-normalization" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] [[package]] name = "unicode-xid" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "untrusted" @@ -3549,13 +3909,12 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.2.2" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" dependencies = [ "form_urlencoded", "idna", - "matches", "percent-encoding", "serde", ] @@ -3568,17 +3927,11 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "uuid" -version = "0.8.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" - -[[package]] -name = "uuid" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" +checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" dependencies = [ - "getrandom 0.2.7", + "getrandom", "serde", ] @@ -3604,12 +3957,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" @@ -3624,9 +3971,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.82" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3634,24 +3981,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.82" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.18", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.32" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa76fb221a1f8acddf5b54ace85912606980ad661ac7a503b4570ffd3a624dad" +checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" dependencies = [ "cfg-if", "js-sys", @@ -3661,9 +4008,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.82" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3671,28 +4018,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.82" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.82" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "web-sys" -version = "0.3.59" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -3700,47 +4047,47 @@ dependencies = [ [[package]] name = "webauthn-rs" -version = "0.4.3" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08ea37595bdb8d731f39949249e41fb4c66cdad5487693575cc1078c8a67abac" +checksum = "2db00711c712414e93b019c4596315085792215bc2ac2d5872f9e8913b0a6316" dependencies = [ "base64urlsafedata", "serde", "tracing", "url", - "uuid 1.1.2", + "uuid", "webauthn-rs-core", ] [[package]] name = "webauthn-rs-core" -version = "0.4.3" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15a12633855c4094f700cad8e2aad4c7d07d762745c4e26a1684a4351bcdf0d4" +checksum = "294c78c83f12153a51e1cf1e6970b5da1397645dada39033a9c3173a8fc4fc2b" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "base64urlsafedata", "compact_jwt", "der-parser", "nom", "openssl", - "rand 0.8.5", + "rand", "serde", - "serde_cbor", + "serde_cbor_2", "serde_json", "thiserror", "tracing", "url", - "uuid 1.1.2", + "uuid", "webauthn-rs-proto", "x509-parser", ] [[package]] name = "webauthn-rs-proto" -version = "0.4.3" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a72f222f4496b34acfc7809ac8440984665105785f3556b541ab14c515cf357" +checksum = "d24e638361a63ba5c0a0be6a60229490fcdf33740ed63df5bb6bdb627b52a138" dependencies = [ "base64urlsafedata", "serde", @@ -3750,9 +4097,9 @@ dependencies = [ [[package]] name = "webpage" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d03ebca8fe2492fffdb5be0f681a942665c50488348d8abc00efb470e0ea890" +checksum = "8598785beeb5af95abe95e7bb20c7e747d1188347080d6811d5a56d2b9a5f368" dependencies = [ "curl", "html5ever", @@ -3781,9 +4128,9 @@ dependencies = [ [[package]] name = "webrtc-sdp" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99abde0f90c17b56ccc3c105f719d61535003862bdb357465f04181ca667ca16" +checksum = "b27cfe685c697666a76932399d55026bf2a5a205d91d277fd16346f0c65a7c06" dependencies = [ "log", "url", @@ -3817,6 +4164,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -3824,47 +4180,169 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows-sys" -version = "0.36.1" +name = "windows" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows-targets 0.48.0", ] [[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" +name = "windows-sys" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winnow" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +dependencies = [ + "memchr", +] [[package]] name = "winreg" @@ -3877,9 +4355,9 @@ dependencies = [ [[package]] name = "wyz" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "129e027ad65ce1453680623c3fb5163cbf7107bfe1aa32257e7d0e63f9ced188" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", ] @@ -3891,7 +4369,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" dependencies = [ "asn1-rs", - "base64 0.13.0", + "base64 0.13.1", "data-encoding", "der-parser", "lazy_static", @@ -3899,19 +4377,18 @@ dependencies = [ "oid-registry", "rusticata-macros", "thiserror", - "time 0.3.13", + "time 0.3.21", ] [[package]] name = "xml5ever" -version = "0.16.2" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9234163818fd8e2418fcde330655e757900d4236acd8cc70fef345ef91f6d865" +checksum = "4034e1d05af98b51ad7214527730626f019682d797ba38b51689212118d8e650" dependencies = [ "log", "mac", "markup5ever", - "time 0.1.44", ] [[package]] @@ -3925,17 +4402,17 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" [[package]] name = "zip" -version = "0.6.2" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf225bcf73bb52cbb496e70475c7bd7a3f769df699c0020f6c7bd9a96dcf0b8d" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ - "aes 0.7.5", + "aes", "byteorder", "bzip2", "constant_time_eq", @@ -3945,24 +4422,43 @@ dependencies = [ "hmac", "pbkdf2", "sha1", - "time 0.3.13", - "zstd", + "time 0.3.21", + "zstd 0.11.2+zstd.1.5.2", ] [[package]] name = "zstd" -version = "0.10.2+zstd.1.5.2" +version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4a6bd64f22b5e3e94b4e238669ff9f10815c27a5180108b849d24174a83847" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe", + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.12.3+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" +dependencies = [ + "zstd-safe 6.0.5+zstd.1.5.4", ] [[package]] name = "zstd-safe" -version = "4.1.6+zstd.1.5.2" +version = "5.0.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b61c51bb270702d6167b8ce67340d2754b088d0c091b06e593aa772c3ee9bb" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-safe" +version = "6.0.5+zstd.1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" dependencies = [ "libc", "zstd-sys", @@ -3970,10 +4466,20 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.6.3+zstd.1.5.2" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", "libc", + "pkg-config", +] + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", ] diff --git a/Cargo.toml b/Cargo.toml index 24a60e7..ebd1f69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,20 +8,20 @@ edition = "2018" [dependencies] yaml-rust = "0.4.5" -mysql = "22.2.0" +mysql = "24.0.0" actix = "0.13.0" -actix-web = "4.1.0" +actix-web = "4.3.1" actix-files = "0.6.2" -actix-multipart = "0.4.0" -actix-web-actors = "4.1.0" -actix-http = "3.0.4" -serde = { version = "1.0.123", features = ["derive"] } -serde_json = "1.0.82" -futures = "0.3.21" -encoding_rs = "0.8.31" -percent-encoding = "2.1.0" -mailchecker = "5.0.0" -sha1 = "0.10.1" +actix-multipart = "0.6.0" +actix-web-actors = "4.2.0" +actix-http = "3.3.1" +serde = { version = "1.0.163", features = ["derive"] } +serde_json = "1.0.96" +futures = "0.3.28" +encoding_rs = "0.8.32" +percent-encoding = "2.2.0" +mailchecker = "5.0.9" +sha1 = "0.10.5" rand = "0.8.5" chrono = "0.4.19" bytes = "1.2.1" @@ -29,14 +29,14 @@ image = "0.24.3" kamadak-exif = "0.5.4" lazy_static = "1.4.0" mime_guess = "2.0.4" -pdf = "0.7.2" +pdf = "0.8.1" regex = "1.6.0" dashmap = "5.3.4" reqwest = { version = "0.11.11", features = ["json"] } webrtc-sdp = "0.3.9" -bcrypt = "0.13.0" +bcrypt = "0.14.0" mp3-metadata = "0.3.4" -mp4 = "0.12.0" +mp4 = "0.13.0" zip = "0.6.2" webpage = "1.4.0" gouth = "0.2.1" diff --git a/src/api_data/account_export_api.rs b/src/api_data/account_export_api.rs index ba1285e..caee129 100644 --- a/src/api_data/account_export_api.rs +++ b/src/api_data/account_export_api.rs @@ -13,7 +13,7 @@ use crate::api_data::friend_api::FriendAPI; use crate::api_data::group_api::GroupApi; use crate::api_data::post_api::PostAPI; use crate::api_data::survey_response_api::SurveyResponseAPI; -use crate::api_data::user_info::{APIUserInfo, APIAdvancedInfo}; +use crate::api_data::user_info::{APIAdvancedInfo, APIUserInfo}; use crate::api_data::user_like_api::UserLikeAPI; use crate::data::account_export::AccountExport; use crate::data::error::ResultBoxError; @@ -49,32 +49,34 @@ impl AccountExportAPI { comments: CommentAPI::for_list(&export.comments, &curr_user_id.as_option())?, likes: UserLikeAPI::for_list(&export.likes), survey_responses: SurveyResponseAPI::for_list(&export.survey_responses), - all_conversation_messages: ConversationMessageAPI::for_list(&export.all_conversation_messages), + all_conversation_messages: ConversationMessageAPI::for_list( + &export.all_conversation_messages, + ), conversations_list: ConversationAPI::for_list(&export.conversations), - conversations_messages: export.conversation_messages + conversations_messages: export + .conversation_messages .iter() .map(|r| (r.0.id(), ConversationMessageAPI::for_list(r.1))) .collect(), friends_list: FriendAPI::from_list(&export.friends_list), - groups: export.groups + groups: export + .groups .iter() .map(groups_helper::get_info) .collect::, _>>()? .iter() .map(|g| GroupApi::new(g, curr_user_id.as_option())) .collect::, _>>()?, - users_info: export.get_related_users_ids()? + users_info: export + .get_related_users_ids()? .iter() .map(user_helper::find_user_by_id) .collect::, _>>()? .iter() - .map(|u| { - APIUserInfo::new(&curr_user_id.as_option(), u) - .map(|r| (u.id.id(), r)) - }) + .map(|u| APIUserInfo::new(&curr_user_id.as_option(), u).map(|r| (u.id.id(), r))) .collect::, _>>()?, }; Ok(export) } -} \ No newline at end of file +} diff --git a/src/api_data/account_image_settings_api.rs b/src/api_data/account_image_settings_api.rs index 89609d1..37be4f0 100644 --- a/src/api_data/account_image_settings_api.rs +++ b/src/api_data/account_image_settings_api.rs @@ -8,22 +8,22 @@ use crate::utils::user_data_utils::user_data_url; #[derive(Serialize)] #[allow(non_snake_case)] -pub struct AccountImageSettingsAPI -{ +pub struct AccountImageSettingsAPI { has_image: bool, image_url: String, visibility: String, } impl AccountImageSettingsAPI { - pub fn new(user: &User) -> AccountImageSettingsAPI - { - AccountImageSettingsAPI - { + pub fn new(user: &User) -> AccountImageSettingsAPI { + AccountImageSettingsAPI { has_image: user.has_account_image(), - image_url: user_data_url(user.account_image_path - .as_ref().unwrap_or(&DEFAULT_ACCOUNT_IMAGE.to_string())), + image_url: user_data_url( + user.account_image_path + .as_ref() + .unwrap_or(&DEFAULT_ACCOUNT_IMAGE.to_string()), + ), visibility: user.account_image_visibility.to_api(), } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_auth_options.rs b/src/api_data/admin/admin_auth_options.rs index 559a1f4..15e8aad 100644 --- a/src/api_data/admin/admin_auth_options.rs +++ b/src/api_data/admin/admin_auth_options.rs @@ -23,7 +23,14 @@ impl AdminAuthOptions { pub fn new(admin: &Admin, keys: &[AdminKey]) -> Self { Self { reset_token: admin.reset_token.is_some(), - keys: keys.iter().map(|k| AuthKey { id: k.id, name: k.name.to_string(), password: k.password.is_some() }).collect(), + keys: keys + .iter() + .map(|k| AuthKey { + id: k.id, + name: k.name.to_string(), + password: k.password.is_some(), + }) + .collect(), } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_auth_success.rs b/src/api_data/admin/admin_auth_success.rs index 6dcf678..daeb8e3 100644 --- a/src/api_data/admin/admin_auth_success.rs +++ b/src/api_data/admin/admin_auth_success.rs @@ -8,11 +8,11 @@ use serde::Serialize; #[derive(Serialize)] pub struct AdminAuthSuccess { - token: String + token: String, } impl AdminAuthSuccess { pub fn new(t: String) -> Self { Self { token: t } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_create_password_reset_link_api.rs b/src/api_data/admin/admin_create_password_reset_link_api.rs index 751e60f..bfc6caa 100644 --- a/src/api_data/admin/admin_create_password_reset_link_api.rs +++ b/src/api_data/admin/admin_create_password_reset_link_api.rs @@ -11,4 +11,4 @@ impl AdminCreatedPasswordResetLinkApi { pub fn new(url: String) -> Self { Self { url } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_id_api.rs b/src/api_data/admin/admin_id_api.rs index ff74abb..cb8f575 100644 --- a/src/api_data/admin/admin_id_api.rs +++ b/src/api_data/admin/admin_id_api.rs @@ -15,4 +15,4 @@ impl AdminIDAPI { pub fn new(id: AdminID) -> Self { Self { id: id.id() } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_info_api.rs b/src/api_data/admin/admin_info_api.rs index 1101ae3..cc3ad96 100644 --- a/src/api_data/admin/admin_info_api.rs +++ b/src/api_data/admin/admin_info_api.rs @@ -25,4 +25,4 @@ impl AdminInfoAPI { roles: a.roles.iter().map(|r| r.to_id()).collect(), } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_keys_api.rs b/src/api_data/admin/admin_keys_api.rs index a1f6fa1..bd06226 100644 --- a/src/api_data/admin/admin_keys_api.rs +++ b/src/api_data/admin/admin_keys_api.rs @@ -22,4 +22,4 @@ impl AdminKeyAPI { has_password: key.password.is_some(), } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_log_api.rs b/src/api_data/admin/admin_log_api.rs index 3e46106..0eb9dee 100644 --- a/src/api_data/admin/admin_log_api.rs +++ b/src/api_data/admin/admin_log_api.rs @@ -25,4 +25,4 @@ impl AdminLogAPI { format: log.action.format_string(), } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_res_create_account.rs b/src/api_data/admin/admin_res_create_account.rs index 446044c..fc02056 100644 --- a/src/api_data/admin/admin_res_create_account.rs +++ b/src/api_data/admin/admin_res_create_account.rs @@ -8,13 +8,11 @@ use crate::data::admin::AdminID; #[derive(Serialize)] pub struct AdminResCreateAccount { - id: u64 + id: u64, } impl AdminResCreateAccount { pub fn new(id: AdminID) -> Self { - Self { - id: id.id() - } + Self { id: id.id() } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_res_create_reset_token.rs b/src/api_data/admin/admin_res_create_reset_token.rs index 13fba04..e8a2668 100644 --- a/src/api_data/admin/admin_res_create_reset_token.rs +++ b/src/api_data/admin/admin_res_create_reset_token.rs @@ -18,4 +18,4 @@ impl AdminResCreateResetToken { expire: token.expire, } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_role_api.rs b/src/api_data/admin/admin_role_api.rs index 61c2df7..f526b5f 100644 --- a/src/api_data/admin/admin_role_api.rs +++ b/src/api_data/admin/admin_role_api.rs @@ -21,4 +21,4 @@ impl AdminRoleDetailsAPI { description: r.description, } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_search_user_result_api.rs b/src/api_data/admin/admin_search_user_result_api.rs index beddfc3..0c83d2c 100644 --- a/src/api_data/admin/admin_search_user_result_api.rs +++ b/src/api_data/admin/admin_search_user_result_api.rs @@ -10,7 +10,7 @@ pub struct AdminSearchUserResult { first_name: String, last_name: String, email: String, - account_image: Option + account_image: Option, } impl AdminSearchUserResult { @@ -23,4 +23,4 @@ impl AdminSearchUserResult { email: user.email, } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/admin_user_info_api.rs b/src/api_data/admin/admin_user_info_api.rs index c91e127..add3f48 100644 --- a/src/api_data/admin/admin_user_info_api.rs +++ b/src/api_data/admin/admin_user_info_api.rs @@ -53,4 +53,4 @@ impl AdminUserInfoAPI { lang: user.lang, } } -} \ No newline at end of file +} diff --git a/src/api_data/admin/mod.rs b/src/api_data/admin/mod.rs index ad4bb73..b7d88f1 100644 --- a/src/api_data/admin/mod.rs +++ b/src/api_data/admin/mod.rs @@ -4,13 +4,13 @@ pub mod admin_auth_options; pub mod admin_auth_success; +pub mod admin_create_password_reset_link_api; pub mod admin_id_api; pub mod admin_info_api; pub mod admin_keys_api; +pub mod admin_log_api; +pub mod admin_res_create_account; pub mod admin_res_create_reset_token; pub mod admin_role_api; -pub mod admin_res_create_account; -pub mod admin_log_api; pub mod admin_search_user_result_api; pub mod admin_user_info_api; -pub mod admin_create_password_reset_link_api; \ No newline at end of file diff --git a/src/api_data/advanced_group_api.rs b/src/api_data/advanced_group_api.rs index 3149c89..90575ce 100644 --- a/src/api_data/advanced_group_api.rs +++ b/src/api_data/advanced_group_api.rs @@ -9,8 +9,8 @@ use crate::data::config::conf; use crate::data::error::ResultBoxError; use crate::data::group::Group; use crate::data::user::UserID; -use crate::helpers::{conversations_helper, groups_helper, likes_helper}; use crate::helpers::likes_helper::LikeType; +use crate::helpers::{conversations_helper, groups_helper, likes_helper}; #[derive(Serialize)] pub struct AdvancedGroupApi { @@ -44,9 +44,13 @@ impl AdvancedGroupApi { description: g.description.clone().unwrap_or("null".to_string()), url: g.url.clone().unwrap_or("null".to_string()), number_likes: likes_helper::count(g.id.id(), LikeType::GROUP)? as u64, - is_liking: likes_helper::is_liking(&user_id.unwrap_or(UserID::invalid()), g.id.id(), LikeType::GROUP)?, + is_liking: likes_helper::is_liking( + &user_id.unwrap_or(UserID::invalid()), + g.id.id(), + LikeType::GROUP, + )?, conversations: ConversationAPI::for_list(&conversations), is_forez_group: conf().forez_groups.contains(&g.id), }) } -} \ No newline at end of file +} diff --git a/src/api_data/call_member_info.rs b/src/api_data/call_member_info.rs index e1da090..39e1d09 100644 --- a/src/api_data/call_member_info.rs +++ b/src/api_data/call_member_info.rs @@ -20,4 +20,4 @@ impl CallMemberInfo { ready: call.ready, } } -} \ No newline at end of file +} diff --git a/src/api_data/call_peer_interrupted_streaming.rs b/src/api_data/call_peer_interrupted_streaming.rs index 7f69bf8..d88a08a 100644 --- a/src/api_data/call_peer_interrupted_streaming.rs +++ b/src/api_data/call_peer_interrupted_streaming.rs @@ -21,4 +21,4 @@ impl CallPeerInterruptedStreamingAPI { peerID: peer_id.id(), } } -} \ No newline at end of file +} diff --git a/src/api_data/call_peer_ready.rs b/src/api_data/call_peer_ready.rs index ffbddd0..3307dfc 100644 --- a/src/api_data/call_peer_ready.rs +++ b/src/api_data/call_peer_ready.rs @@ -20,4 +20,4 @@ impl CallPeerReadyAPI { peerID: user_id.id(), } } -} \ No newline at end of file +} diff --git a/src/api_data/comment_api.rs b/src/api_data/comment_api.rs index 9c46934..6e49919 100644 --- a/src/api_data/comment_api.rs +++ b/src/api_data/comment_api.rs @@ -49,7 +49,10 @@ impl CommentAPI { Ok(c_api) } - pub fn for_list(l: &[Comment], curr_user_id: &Option) -> ResultBoxError> { + pub fn for_list( + l: &[Comment], + curr_user_id: &Option, + ) -> ResultBoxError> { l.iter().map(|c| Self::new(c, curr_user_id)).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/conversation_api.rs b/src/api_data/conversation_api.rs index 662a2b5..2b9bc1d 100644 --- a/src/api_data/conversation_api.rs +++ b/src/api_data/conversation_api.rs @@ -52,13 +52,19 @@ impl ConversationAPI { id: conv.id.id(), last_activity: conv.last_activity, name: conv.name.clone(), - members: conv.members.iter().map(ConversationMembersAPI::new).collect(), + members: conv + .members + .iter() + .map(ConversationMembersAPI::new) + .collect(), can_everyone_add_members: conv.can_everyone_add_members, color: conv.color.clone(), logo: conv.logo.as_ref().map(|s| user_data_url(s)), group_id: conv.group_id.as_ref().map(|i| i.id()), - group_min_membership_level: conv.min_group_membership_level.as_ref() + group_min_membership_level: conv + .min_group_membership_level + .as_ref() .map(|f| f.to_api()), can_have_call: calls_helper::can_have_call(conv), @@ -70,4 +76,4 @@ impl ConversationAPI { pub fn for_list(l: &Vec) -> Vec { l.iter().map(Self::new).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/conversation_message_api.rs b/src/api_data/conversation_message_api.rs index b914b92..c419f68 100644 --- a/src/api_data/conversation_message_api.rs +++ b/src/api_data/conversation_message_api.rs @@ -39,9 +39,9 @@ impl ConversationMessageAPI { url: user_data_url(&file.path.clone()), size: file.size, name: file.name.clone(), - thumbnail: file.thumbnail.as_ref().map(|u|user_data_url(u)), + thumbnail: file.thumbnail.as_ref().map(|u| user_data_url(u)), r#type: file.r#type.clone(), - }) + }), }; let server_message = match &msg.server_message { @@ -57,7 +57,10 @@ impl ConversationMessageAPI { ConversationServerMessageType::UserAddedAnotherUserToConversation(msg) => { value.insert("type".to_string(), Value::from("user_added_another")); - value.insert("user_who_added".to_string(), Value::from(msg.user_who_added.id())); + value.insert( + "user_who_added".to_string(), + Value::from(msg.user_who_added.id()), + ); value.insert("user_added".to_string(), Value::from(msg.user_added.id())); } @@ -68,8 +71,14 @@ impl ConversationMessageAPI { ConversationServerMessageType::UserRemovedFromConversation(msg) => { value.insert("type".to_string(), Value::from("user_removed_another")); - value.insert("user_who_removed".to_string(), Value::from(msg.user_who_removed.id())); - value.insert("user_removed".to_string(), Value::from(msg.user_removed.id())); + value.insert( + "user_who_removed".to_string(), + Value::from(msg.user_who_removed.id()), + ); + value.insert( + "user_removed".to_string(), + Value::from(msg.user_removed.id()), + ); } } @@ -90,8 +99,6 @@ impl ConversationMessageAPI { /// Turn a list of conversation messages into API entries pub fn for_list(l: &Vec) -> Vec { - l.iter() - .map(|m| ConversationMessageAPI::new(m)) - .collect() + l.iter().map(|m| ConversationMessageAPI::new(m)).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/current_user_id.rs b/src/api_data/current_user_id.rs index 74614a8..e80057e 100644 --- a/src/api_data/current_user_id.rs +++ b/src/api_data/current_user_id.rs @@ -6,13 +6,11 @@ use crate::data::user::UserID; #[derive(Serialize, Deserialize)] #[allow(non_snake_case)] pub struct CurrentUserID { - userID: u64 + userID: u64, } impl CurrentUserID { pub fn new(id: &UserID) -> CurrentUserID { - CurrentUserID { - userID: id.id() - } + CurrentUserID { userID: id.id() } } -} \ No newline at end of file +} diff --git a/src/api_data/custom_emoji.rs b/src/api_data/custom_emoji.rs index 1b4c687..0bd6963 100644 --- a/src/api_data/custom_emoji.rs +++ b/src/api_data/custom_emoji.rs @@ -25,4 +25,4 @@ impl CustomEmojiAPI { url: user_data_url(&custom_emoji.path), } } -} \ No newline at end of file +} diff --git a/src/api_data/data_conservation_settings_api.rs b/src/api_data/data_conservation_settings_api.rs index 5a22c11..1af1f14 100644 --- a/src/api_data/data_conservation_settings_api.rs +++ b/src/api_data/data_conservation_settings_api.rs @@ -1,5 +1,5 @@ //! # Data conservation settings API object -//! +//! //! @author Pierre Hubert use serde::Serialize; @@ -26,4 +26,4 @@ impl DataConservationSettingsAPI { likes_lifetime: user.delete_likes_after, } } -} \ No newline at end of file +} diff --git a/src/api_data/entities_constructor.rs b/src/api_data/entities_constructor.rs index ed99fa9..1b7cd52 100644 --- a/src/api_data/entities_constructor.rs +++ b/src/api_data/entities_constructor.rs @@ -10,7 +10,9 @@ pub trait EntitiesConstructor { /// Parse a list of it fn for_list(l: &[Self::Item]) -> Vec - where Self: std::marker::Sized { + where + Self: std::marker::Sized, + { l.iter().map(Self::new).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/friend_api.rs b/src/api_data/friend_api.rs index b3d41e5..c6f7a07 100644 --- a/src/api_data/friend_api.rs +++ b/src/api_data/friend_api.rs @@ -32,4 +32,4 @@ impl FriendAPI { pub fn from_list(l: &Vec) -> Vec { l.iter().map(Self::new).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/friendship_status_api.rs b/src/api_data/friendship_status_api.rs index 91e81af..04e9151 100644 --- a/src/api_data/friendship_status_api.rs +++ b/src/api_data/friendship_status_api.rs @@ -24,4 +24,4 @@ impl FriendshipStatusAPI { following: status.following, } } -} \ No newline at end of file +} diff --git a/src/api_data/general_settings_api.rs b/src/api_data/general_settings_api.rs index b90d2f6..f567d18 100644 --- a/src/api_data/general_settings_api.rs +++ b/src/api_data/general_settings_api.rs @@ -46,4 +46,4 @@ impl GeneralSettingsAPI { location: user.location.clone(), } } -} \ No newline at end of file +} diff --git a/src/api_data/global_search_result_api.rs b/src/api_data/global_search_result_api.rs index d43982b..af32652 100644 --- a/src/api_data/global_search_result_api.rs +++ b/src/api_data/global_search_result_api.rs @@ -29,8 +29,6 @@ impl GlobalSearchResultAPI { /// Construct a list of results pub fn for_list(l: &Vec) -> Vec { - l.iter() - .map(|f| Self::new(f)) - .collect() + l.iter().map(|f| Self::new(f)).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/group_api.rs b/src/api_data/group_api.rs index a5d68a3..26daf4e 100644 --- a/src/api_data/group_api.rs +++ b/src/api_data/group_api.rs @@ -47,4 +47,4 @@ impl GroupApi { following: membership.following, }) } -} \ No newline at end of file +} diff --git a/src/api_data/group_member_api.rs b/src/api_data/group_member_api.rs index 4ac7045..bce72e5 100644 --- a/src/api_data/group_member_api.rs +++ b/src/api_data/group_member_api.rs @@ -29,4 +29,4 @@ impl GroupMemberAPI { pub fn for_list(l: &Vec) -> Vec { l.iter().map(Self::new).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/http_error.rs b/src/api_data/http_error.rs index b91d35b..3b654a7 100644 --- a/src/api_data/http_error.rs +++ b/src/api_data/http_error.rs @@ -11,7 +11,7 @@ pub struct InnerHTTPError { #[derive(Serialize)] pub struct HttpError { - pub error: InnerHTTPError + pub error: InnerHTTPError, } impl HttpError { @@ -21,7 +21,7 @@ impl HttpError { error: InnerHTTPError { code, message: message.to_string(), - } + }, } } @@ -44,4 +44,4 @@ impl HttpError { pub fn forbidden(message: &str) -> HttpError { HttpError::new(401, message) } -} \ No newline at end of file +} diff --git a/src/api_data/joined_call_message.rs b/src/api_data/joined_call_message.rs index 294b0f2..cb62b84 100644 --- a/src/api_data/joined_call_message.rs +++ b/src/api_data/joined_call_message.rs @@ -22,4 +22,4 @@ impl JoinedCallMessage { userID: user_id.id(), } } -} \ No newline at end of file +} diff --git a/src/api_data/language_settings_api.rs b/src/api_data/language_settings_api.rs index 577bed4..127236a 100644 --- a/src/api_data/language_settings_api.rs +++ b/src/api_data/language_settings_api.rs @@ -15,7 +15,7 @@ pub struct LanguageSettingsAPI { impl LanguageSettingsAPI { pub fn new(user: &User) -> LanguageSettingsAPI { LanguageSettingsAPI { - lang: user.lang.clone() + lang: user.lang.clone(), } } -} \ No newline at end of file +} diff --git a/src/api_data/left_call_message.rs b/src/api_data/left_call_message.rs index 57e0f38..4cd7a36 100644 --- a/src/api_data/left_call_message.rs +++ b/src/api_data/left_call_message.rs @@ -22,4 +22,4 @@ impl LeftCallMessage { userID: user_id.id(), } } -} \ No newline at end of file +} diff --git a/src/api_data/legacy_api_bool.rs b/src/api_data/legacy_api_bool.rs index 57547ca..841a947 100644 --- a/src/api_data/legacy_api_bool.rs +++ b/src/api_data/legacy_api_bool.rs @@ -3,18 +3,19 @@ //! true => 1 //! false => 0 - use serde::{Serialize, Serializer}; /// Special implementation of conversation name (false if none / the name otherwise) pub struct LegacyBool(pub bool); impl Serialize for LegacyBool { - fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> where - S: Serializer { + fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> + where + S: Serializer, + { match &self.0 { true => serializer.serialize_i8(1), false => serializer.serialize_i8(0), } } -} \ No newline at end of file +} diff --git a/src/api_data/list_unread_conversations_api.rs b/src/api_data/list_unread_conversations_api.rs index a7d9054..8b04753 100644 --- a/src/api_data/list_unread_conversations_api.rs +++ b/src/api_data/list_unread_conversations_api.rs @@ -27,8 +27,6 @@ impl UnreadConversationAPI { /// Turn a list of unread conversation into API conversations pub fn for_list(l: &Vec) -> Res> { - l.iter() - .map(|row| Self::new(row.clone())) - .collect() + l.iter().map(|row| Self::new(row.clone())).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/login_success.rs b/src/api_data/login_success.rs index 4fb8342..c9623be 100644 --- a/src/api_data/login_success.rs +++ b/src/api_data/login_success.rs @@ -11,7 +11,7 @@ struct LoginTokens { #[derive(Serialize, Deserialize)] pub struct LoginSuccess { - token: String + token: String, } impl LoginSuccess { @@ -20,4 +20,4 @@ impl LoginSuccess { token: token.to_string(), } } -} \ No newline at end of file +} diff --git a/src/api_data/mod.rs b/src/api_data/mod.rs index 8f20b12..4b741e3 100644 --- a/src/api_data/mod.rs +++ b/src/api_data/mod.rs @@ -9,68 +9,68 @@ pub mod admin; -pub mod server_config; -pub mod http_error; -pub mod login_success; -pub mod current_user_id; -pub mod user_mail_address; -pub mod user_info; -pub mod custom_emoji; -pub mod res_find_user_by_virtual_directory; -pub mod res_find_virtual_directory; -pub mod res_create_conversation; -pub mod conversation_api; -mod legacy_api_bool; -pub mod res_find_private_conversations; -pub mod conversation_message_api; -pub mod res_count_unread_conversations; -pub mod list_unread_conversations_api; -pub mod global_search_result_api; -pub mod res_create_group; -pub mod group_api; +pub mod account_export_api; +pub mod account_image_settings_api; pub mod advanced_group_api; -pub mod res_change_group_logo; -pub mod group_member_api; +pub mod call_member_info; +pub mod call_peer_interrupted_streaming; +pub mod call_peer_ready; +pub mod comment_api; +pub mod conversation_api; +pub mod conversation_message_api; +pub mod current_user_id; +pub mod custom_emoji; +pub mod data_conservation_settings_api; +pub mod entities_constructor; pub mod friend_api; pub mod friendship_status_api; -pub mod post_api; -pub mod survey_choice_api; -pub mod survey_api; -pub mod comment_api; -pub mod res_create_post; -pub mod posts_targets_api; -pub mod res_create_comment; -pub mod res_number_unread_notifications; -pub mod res_count_all_unreads; -pub mod notification_api; -pub mod user_membership_api; -mod type_container_api; -pub mod res_check_email_exists; -pub mod res_check_security_questions_exists; -pub mod res_get_security_questions; -pub mod res_check_security_answers; -pub mod account_export_api; -pub mod user_like_api; -pub mod survey_response_api; -pub mod entities_constructor; pub mod general_settings_api; -pub mod language_settings_api; -pub mod security_settings_api; -pub mod account_image_settings_api; -pub mod data_conservation_settings_api; -pub mod res_create_custom_emoji; -pub mod res_get_ws_token; -pub mod user_calls_config; +pub mod global_search_result_api; +pub mod group_api; +pub mod group_member_api; +pub mod http_error; pub mod joined_call_message; -pub mod call_member_info; +pub mod language_settings_api; pub mod left_call_message; +mod legacy_api_bool; +pub mod list_unread_conversations_api; +pub mod login_success; pub mod new_call_signal; -pub mod call_peer_ready; -pub mod call_peer_interrupted_streaming; -pub mod res_check_password_token; -pub mod removed_user_from_conv_message; -pub mod user_is_writing_message_in_conversation; -pub mod res_create_conversation_for_group; +pub mod notification_api; pub mod notification_settings_api; +pub mod post_api; +pub mod posts_targets_api; pub mod push_notifications_status_api; -pub mod submit_report_result_api; \ No newline at end of file +pub mod removed_user_from_conv_message; +pub mod res_change_group_logo; +pub mod res_check_email_exists; +pub mod res_check_password_token; +pub mod res_check_security_answers; +pub mod res_check_security_questions_exists; +pub mod res_count_all_unreads; +pub mod res_count_unread_conversations; +pub mod res_create_comment; +pub mod res_create_conversation; +pub mod res_create_conversation_for_group; +pub mod res_create_custom_emoji; +pub mod res_create_group; +pub mod res_create_post; +pub mod res_find_private_conversations; +pub mod res_find_user_by_virtual_directory; +pub mod res_find_virtual_directory; +pub mod res_get_security_questions; +pub mod res_get_ws_token; +pub mod res_number_unread_notifications; +pub mod security_settings_api; +pub mod server_config; +pub mod submit_report_result_api; +pub mod survey_api; +pub mod survey_choice_api; +pub mod survey_response_api; +mod type_container_api; +pub mod user_calls_config; +pub mod user_info; +pub mod user_is_writing_message_in_conversation; +pub mod user_like_api; +pub mod user_mail_address; +pub mod user_membership_api; diff --git a/src/api_data/new_call_signal.rs b/src/api_data/new_call_signal.rs index 9ae02ce..dfbf52c 100644 --- a/src/api_data/new_call_signal.rs +++ b/src/api_data/new_call_signal.rs @@ -24,4 +24,4 @@ impl NewCallSignalAPI { data: serde_json::from_str(data)?, }) } -} \ No newline at end of file +} diff --git a/src/api_data/notification_api.rs b/src/api_data/notification_api.rs index 526af64..ef7da96 100644 --- a/src/api_data/notification_api.rs +++ b/src/api_data/notification_api.rs @@ -43,4 +43,4 @@ impl NotificationAPI { pub fn for_list(l: &[Notification]) -> Vec { l.iter().map(Self::new).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/notification_settings_api.rs b/src/api_data/notification_settings_api.rs index e08e6bf..a696efb 100644 --- a/src/api_data/notification_settings_api.rs +++ b/src/api_data/notification_settings_api.rs @@ -19,4 +19,4 @@ impl NotificationSettingsAPI { allow_notifications_sound: user.allow_notif_sound, } } -} \ No newline at end of file +} diff --git a/src/api_data/post_api.rs b/src/api_data/post_api.rs index a0b504b..81368e5 100644 --- a/src/api_data/post_api.rs +++ b/src/api_data/post_api.rs @@ -8,8 +8,8 @@ use crate::api_data::survey_api::SurveyAPI; use crate::data::error::ResultBoxError; use crate::data::post::{Post, PostKind}; use crate::data::user::UserID; -use crate::helpers::{comments_helper, likes_helper, posts_helper, survey_helper}; use crate::helpers::likes_helper::LikeType; +use crate::helpers::{comments_helper, likes_helper, posts_helper, survey_helper}; use crate::utils::user_data_utils::user_data_url; #[derive(Serialize)] @@ -113,8 +113,9 @@ impl PostAPI { PostKind::POST_KIND_COUNTDOWN(time_end) => post.time_end = Some(*time_end), - PostKind::POST_KIND_SURVEY => - post.data_survey = Some(SurveyAPI::new(&survey_helper::get_info(p.id)?, *user)?), + PostKind::POST_KIND_SURVEY => { + post.data_survey = Some(SurveyAPI::new(&survey_helper::get_info(p.id)?, *user)?) + } PostKind::POST_KIND_YOUTUBE(id) => { post.file_path = Some(id.clone()); @@ -133,4 +134,4 @@ impl PostAPI { pub fn for_list(l: &[Post], user_id: Option) -> ResultBoxError> { l.iter().map(|p| Self::new(p, &user_id)).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/posts_targets_api.rs b/src/api_data/posts_targets_api.rs index 0f902d0..fab9c7c 100644 --- a/src/api_data/posts_targets_api.rs +++ b/src/api_data/posts_targets_api.rs @@ -19,4 +19,4 @@ impl PostsTargets { groups: g.iter().map(|f| f.id()).collect(), } } -} \ No newline at end of file +} diff --git a/src/api_data/push_notifications_status_api.rs b/src/api_data/push_notifications_status_api.rs index 38eb194..469930c 100644 --- a/src/api_data/push_notifications_status_api.rs +++ b/src/api_data/push_notifications_status_api.rs @@ -19,13 +19,15 @@ impl PushNotificationsStatusAPI { PushNotificationToken::NONE => "disabled", PushNotificationToken::INDEPENDENT(_) => "independent", PushNotificationToken::FIREBASE(_) => "firebase", - }.to_string(), + } + .to_string(), independent_push_url: match (t, &conf().independent_push_service) { - (PushNotificationToken::INDEPENDENT(i), Some(conf)) => - Some(conf.public_url.replace("{TOKEN_URL}", i)), + (PushNotificationToken::INDEPENDENT(i), Some(conf)) => { + Some(conf.public_url.replace("{TOKEN_URL}", i)) + } _ => None, }, } } -} \ No newline at end of file +} diff --git a/src/api_data/removed_user_from_conv_message.rs b/src/api_data/removed_user_from_conv_message.rs index d7ab901..5f00f08 100644 --- a/src/api_data/removed_user_from_conv_message.rs +++ b/src/api_data/removed_user_from_conv_message.rs @@ -20,4 +20,4 @@ impl RemovedUserFromConversationMessage { conv_id: conv_id.id(), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_change_group_logo.rs b/src/api_data/res_change_group_logo.rs index cec32cf..82eed0a 100644 --- a/src/api_data/res_change_group_logo.rs +++ b/src/api_data/res_change_group_logo.rs @@ -19,4 +19,4 @@ impl ResChangeGroupLogo { url: user_data_url(path), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_check_email_exists.rs b/src/api_data/res_check_email_exists.rs index e2bf613..f7a0030 100644 --- a/src/api_data/res_check_email_exists.rs +++ b/src/api_data/res_check_email_exists.rs @@ -5,11 +5,11 @@ use serde::Serialize; #[derive(Serialize)] pub struct ResCheckEmailExists { - exists: bool + exists: bool, } impl ResCheckEmailExists { pub fn new(exists: bool) -> ResCheckEmailExists { ResCheckEmailExists { exists } } -} \ No newline at end of file +} diff --git a/src/api_data/res_check_password_token.rs b/src/api_data/res_check_password_token.rs index 2320cbc..2e1e8c4 100644 --- a/src/api_data/res_check_password_token.rs +++ b/src/api_data/res_check_password_token.rs @@ -21,4 +21,4 @@ impl ResCheckPasswordToken { mail: user.email.to_string(), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_check_security_answers.rs b/src/api_data/res_check_security_answers.rs index a630b26..92e6d4b 100644 --- a/src/api_data/res_check_security_answers.rs +++ b/src/api_data/res_check_security_answers.rs @@ -7,11 +7,11 @@ use serde::Serialize; #[derive(Serialize)] pub struct ResCheckSecurityAnswers { - reset_token: String + reset_token: String, } impl ResCheckSecurityAnswers { pub fn new(reset_token: String) -> ResCheckSecurityAnswers { ResCheckSecurityAnswers { reset_token } } -} \ No newline at end of file +} diff --git a/src/api_data/res_check_security_questions_exists.rs b/src/api_data/res_check_security_questions_exists.rs index 3ed2aff..0a47442 100644 --- a/src/api_data/res_check_security_questions_exists.rs +++ b/src/api_data/res_check_security_questions_exists.rs @@ -5,11 +5,11 @@ use serde::Serialize; #[derive(Serialize)] pub struct ResCheckSecurityQuestionsExists { - defined: bool + defined: bool, } impl ResCheckSecurityQuestionsExists { pub fn new(defined: bool) -> ResCheckSecurityQuestionsExists { ResCheckSecurityQuestionsExists { defined } } -} \ No newline at end of file +} diff --git a/src/api_data/res_count_all_unreads.rs b/src/api_data/res_count_all_unreads.rs index ae04985..b1cfeee 100644 --- a/src/api_data/res_count_all_unreads.rs +++ b/src/api_data/res_count_all_unreads.rs @@ -20,11 +20,17 @@ pub struct ResCountAllUnread { } impl ResCountAllUnread { - pub fn new(notifications: u64, conversations: u64, friends_requests: Option) -> ResCountAllUnread { + pub fn new( + notifications: u64, + conversations: u64, + friends_requests: Option, + ) -> ResCountAllUnread { ResCountAllUnread { notifications, conversations, - friends: friends_requests.map(|n| CountFriendsRequests { friends_requests: n }), + friends: friends_requests.map(|n| CountFriendsRequests { + friends_requests: n, + }), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_count_unread_conversations.rs b/src/api_data/res_count_unread_conversations.rs index 0829db4..4767d12 100644 --- a/src/api_data/res_count_unread_conversations.rs +++ b/src/api_data/res_count_unread_conversations.rs @@ -5,14 +5,12 @@ use serde::Serialize; #[derive(Serialize)] pub struct ResultCountUnreadConversations { - nb_unread: usize + nb_unread: usize, } impl ResultCountUnreadConversations { /// Generate an new instance pub fn new(count: usize) -> ResultCountUnreadConversations { - ResultCountUnreadConversations { - nb_unread: count - } + ResultCountUnreadConversations { nb_unread: count } } -} \ No newline at end of file +} diff --git a/src/api_data/res_create_comment.rs b/src/api_data/res_create_comment.rs index d4e55f2..b8c5f06 100644 --- a/src/api_data/res_create_comment.rs +++ b/src/api_data/res_create_comment.rs @@ -17,4 +17,4 @@ impl ResCreateComment { commentID: comment_id, } } -} \ No newline at end of file +} diff --git a/src/api_data/res_create_conversation.rs b/src/api_data/res_create_conversation.rs index 358e6c3..e314f16 100644 --- a/src/api_data/res_create_conversation.rs +++ b/src/api_data/res_create_conversation.rs @@ -2,8 +2,8 @@ //! //! @author Pierre Hubert -use serde::{Serialize}; use crate::data::conversation::ConvID; +use serde::Serialize; #[derive(Serialize)] #[allow(non_snake_case)] @@ -20,4 +20,4 @@ impl ResCreateConversation { success: "The conversation was successfully created!".to_string(), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_create_conversation_for_group.rs b/src/api_data/res_create_conversation_for_group.rs index f93a074..e2e813e 100644 --- a/src/api_data/res_create_conversation_for_group.rs +++ b/src/api_data/res_create_conversation_for_group.rs @@ -8,13 +8,13 @@ use crate::data::conversation::ConvID; #[derive(Serialize)] pub struct ResCreateConversationForGroup { - conv_id: u64 + conv_id: u64, } impl ResCreateConversationForGroup { pub fn new(conv_id: ConvID) -> Self { Self { - conv_id: conv_id.id() + conv_id: conv_id.id(), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_create_custom_emoji.rs b/src/api_data/res_create_custom_emoji.rs index 16269ce..84153dd 100644 --- a/src/api_data/res_create_custom_emoji.rs +++ b/src/api_data/res_create_custom_emoji.rs @@ -7,11 +7,11 @@ use serde::Serialize; #[allow(non_snake_case)] #[derive(Serialize)] pub struct ResCreateCustomEmoji { - emojiID: u64 + emojiID: u64, } impl ResCreateCustomEmoji { pub fn new(emoji_id: u64) -> ResCreateCustomEmoji { ResCreateCustomEmoji { emojiID: emoji_id } } -} \ No newline at end of file +} diff --git a/src/api_data/res_create_group.rs b/src/api_data/res_create_group.rs index 5e1d7f4..5c364ed 100644 --- a/src/api_data/res_create_group.rs +++ b/src/api_data/res_create_group.rs @@ -20,4 +20,4 @@ impl GroupCreationResult { id: id.id(), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_find_private_conversations.rs b/src/api_data/res_find_private_conversations.rs index 6439a46..0461507 100644 --- a/src/api_data/res_find_private_conversations.rs +++ b/src/api_data/res_find_private_conversations.rs @@ -9,14 +9,14 @@ use crate::data::conversation::ConvID; #[derive(Serialize)] #[allow(non_snake_case)] pub struct ResFindPrivateConversations { - conversationsID: Vec + conversationsID: Vec, } impl ResFindPrivateConversations { /// Construct a new instance of this structure pub fn new(list: Vec) -> ResFindPrivateConversations { ResFindPrivateConversations { - conversationsID: list.iter().map(|i| i.id()).collect() + conversationsID: list.iter().map(|i| i.id()).collect(), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_find_user_by_virtual_directory.rs b/src/api_data/res_find_user_by_virtual_directory.rs index 935eca8..34005f4 100644 --- a/src/api_data/res_find_user_by_virtual_directory.rs +++ b/src/api_data/res_find_user_by_virtual_directory.rs @@ -5,18 +5,17 @@ use crate::data::user::UserID; use serde::Serialize; - #[derive(Serialize)] #[allow(non_snake_case)] pub struct FindUserByVirtualDirectoryAPIResult { - userID: u64 + userID: u64, } impl FindUserByVirtualDirectoryAPIResult { /// Construct a new `FindUserByVirtualDirectoryAPIResult` instance pub fn new(user_id: UserID) -> FindUserByVirtualDirectoryAPIResult { FindUserByVirtualDirectoryAPIResult { - userID: user_id.id() + userID: user_id.id(), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_find_virtual_directory.rs b/src/api_data/res_find_virtual_directory.rs index f43b683..a46f0b4 100644 --- a/src/api_data/res_find_virtual_directory.rs +++ b/src/api_data/res_find_virtual_directory.rs @@ -2,10 +2,10 @@ //! //! @author Pierre Hubert -use serde::{Serialize}; use crate::data::error::ResultBoxError; -use crate::data::user::User; use crate::data::group_id::GroupID; +use crate::data::user::User; +use serde::Serialize; #[derive(Serialize)] pub struct ResultFindVirtualDirectory { @@ -15,16 +15,24 @@ pub struct ResultFindVirtualDirectory { impl ResultFindVirtualDirectory { /// Construct a new instance - pub fn new(user: ResultBoxError, group: ResultBoxError) -> ResultFindVirtualDirectory { + pub fn new( + user: ResultBoxError, + group: ResultBoxError, + ) -> ResultFindVirtualDirectory { match (user, group) { - // User - (Ok(u), _) => ResultFindVirtualDirectory { kind: "user".to_string(), id: u.id.id() }, + (Ok(u), _) => ResultFindVirtualDirectory { + kind: "user".to_string(), + id: u.id.id(), + }, // Group - (_, Ok(g)) => ResultFindVirtualDirectory { kind: "group".to_string(), id: g.id() }, + (_, Ok(g)) => ResultFindVirtualDirectory { + kind: "group".to_string(), + id: g.id(), + }, - _ => unreachable!() + _ => unreachable!(), } } -} \ No newline at end of file +} diff --git a/src/api_data/res_get_security_questions.rs b/src/api_data/res_get_security_questions.rs index 4452fdf..bc16a1f 100644 --- a/src/api_data/res_get_security_questions.rs +++ b/src/api_data/res_get_security_questions.rs @@ -19,4 +19,4 @@ impl ResGetSecurityQuestions { ResGetSecurityQuestions { questions } } -} \ No newline at end of file +} diff --git a/src/api_data/res_get_ws_token.rs b/src/api_data/res_get_ws_token.rs index 484c1fe..328e503 100644 --- a/src/api_data/res_get_ws_token.rs +++ b/src/api_data/res_get_ws_token.rs @@ -12,4 +12,4 @@ impl ResGetWsToken { pub fn new(token: String) -> Self { ResGetWsToken { token } } -} \ No newline at end of file +} diff --git a/src/api_data/res_number_unread_notifications.rs b/src/api_data/res_number_unread_notifications.rs index 36c3433..5acf4ed 100644 --- a/src/api_data/res_number_unread_notifications.rs +++ b/src/api_data/res_number_unread_notifications.rs @@ -6,11 +6,11 @@ use serde::Serialize; #[derive(Serialize)] pub struct ResNumberUnreadNotifications { - number: u64 + number: u64, } impl ResNumberUnreadNotifications { pub fn new(number: u64) -> ResNumberUnreadNotifications { ResNumberUnreadNotifications { number } } -} \ No newline at end of file +} diff --git a/src/api_data/security_settings_api.rs b/src/api_data/security_settings_api.rs index 85af34e..7ecfaf8 100644 --- a/src/api_data/security_settings_api.rs +++ b/src/api_data/security_settings_api.rs @@ -26,4 +26,4 @@ impl SecuritySettingsAPI { security_answer_2: user.security_answer_2.clone().unwrap_or_default(), } } -} \ No newline at end of file +} diff --git a/src/api_data/server_config.rs b/src/api_data/server_config.rs index 169f50f..749094c 100644 --- a/src/api_data/server_config.rs +++ b/src/api_data/server_config.rs @@ -5,12 +5,23 @@ use std::collections::HashMap; use serde::Serialize; -use crate::constants::{conservation_policy, MIN_SUPPORTED_MOBILE_VERSION, password_policy, reports}; -use crate::constants::accounts_info_policy::{MAX_FIRST_NAME_LENGTH, MAX_LAST_NAME_LENGTH, MAX_LOCATION_LENGTH, MIN_FIRST_NAME_LENGTH, MIN_LAST_NAME_LENGTH}; -use crate::constants::conversations::{ALLOWED_CONVERSATION_FILES_TYPES, CONVERSATION_FILES_MAX_SIZE, CONVERSATION_WRITING_EVENT_INTERVAL, CONVERSATION_WRITING_EVENT_LIFETIME, MAX_CONV_IMAGE_MESSAGE_WIDTH, MAX_CONV_LOGO_HEIGHT, MAX_CONV_LOGO_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT, MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MAX_CONVERSATION_MESSAGE_LENGTH, MAX_CONVERSATION_NAME_LENGTH, MIN_CONVERSATION_MESSAGE_LENGTH}; +use crate::constants::accounts_info_policy::{ + MAX_FIRST_NAME_LENGTH, MAX_LAST_NAME_LENGTH, MAX_LOCATION_LENGTH, MIN_FIRST_NAME_LENGTH, + MIN_LAST_NAME_LENGTH, +}; +use crate::constants::conversations::{ + ALLOWED_CONVERSATION_FILES_TYPES, CONVERSATION_FILES_MAX_SIZE, + CONVERSATION_WRITING_EVENT_INTERVAL, CONVERSATION_WRITING_EVENT_LIFETIME, + MAX_CONVERSATION_MESSAGE_LENGTH, MAX_CONVERSATION_NAME_LENGTH, MAX_CONV_IMAGE_MESSAGE_WIDTH, + MAX_CONV_LOGO_HEIGHT, MAX_CONV_LOGO_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT, + MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MIN_CONVERSATION_MESSAGE_LENGTH, +}; use crate::constants::reports::CAN_USER_REPORT_ITS_OWN_CONTENT; +use crate::constants::{ + conservation_policy, password_policy, reports, MIN_SUPPORTED_MOBILE_VERSION, +}; use crate::data::api_client::APIClient; -use crate::data::config::{Banner, conf}; +use crate::data::config::{conf, Banner}; use crate::data::report::REPORT_CAUSES; #[derive(Serialize)] @@ -108,7 +119,12 @@ impl ServerConfig { play_store_url: &conf().play_store_url, android_direct_download_url: conf().android_direct_download_url.clone(), - banner: match conf().banner.as_ref().map(|b| b.is_visible()).unwrap_or(false) { + banner: match conf() + .banner + .as_ref() + .map(|b| b.is_visible()) + .unwrap_or(false) + { true => conf().banner.as_ref(), false => None, }, @@ -130,11 +146,14 @@ impl ServerConfig { }, data_conservation_policy: DataConservationPolicy { - min_inactive_account_lifetime: conservation_policy::MIN_INACTIVE_ACCOUNT_LIFETIME.as_secs(), - min_notification_lifetime: conservation_policy::MIN_NOTIFICATIONS_LIFETIME.as_secs(), + min_inactive_account_lifetime: conservation_policy::MIN_INACTIVE_ACCOUNT_LIFETIME + .as_secs(), + min_notification_lifetime: conservation_policy::MIN_NOTIFICATIONS_LIFETIME + .as_secs(), min_comments_lifetime: conservation_policy::MIN_COMMENTS_LIFETIME.as_secs(), min_posts_lifetime: conservation_policy::MIN_POSTS_LIFETIME.as_secs(), - min_conversation_messages_lifetime: conservation_policy::MIN_CONVERSATION_MESSAGES_LIFETIME.as_secs(), + min_conversation_messages_lifetime: + conservation_policy::MIN_CONVERSATION_MESSAGES_LIFETIME.as_secs(), min_likes_lifetime: conservation_policy::MIN_LIKES_LIFETIME.as_secs(), }, @@ -164,17 +183,17 @@ impl ServerConfig { report_policy: match conf().allow_reporting { true => Some(ReportPolicy { - causes: REPORT_CAUSES.iter().map(|r| ReportCause { - id: r.id().id(), - label: HashMap::from([ - ("fr", r.label_fr), - ("en", r.label_en) - ]), - }).collect(), + causes: REPORT_CAUSES + .iter() + .map(|r| ReportCause { + id: r.id().id(), + label: HashMap::from([("fr", r.label_fr), ("en", r.label_en)]), + }) + .collect(), max_comment_length: reports::MAX_COMMENT_LENGTH, can_user_report_his_own_content: CAN_USER_REPORT_ITS_OWN_CONTENT, }), - false => None + false => None, }, } } diff --git a/src/api_data/submit_report_result_api.rs b/src/api_data/submit_report_result_api.rs index 0a260b7..fea3351 100644 --- a/src/api_data/submit_report_result_api.rs +++ b/src/api_data/submit_report_result_api.rs @@ -9,4 +9,4 @@ impl SubmitReportResultApi { pub fn new(r: ReportID) -> Self { Self { report_id: r.0 } } -} \ No newline at end of file +} diff --git a/src/api_data/survey_api.rs b/src/api_data/survey_api.rs index d540bab..398c147 100644 --- a/src/api_data/survey_api.rs +++ b/src/api_data/survey_api.rs @@ -44,4 +44,4 @@ impl SurveyAPI { allowNewChoices: s.allow_new_choices, }) } -} \ No newline at end of file +} diff --git a/src/api_data/survey_choice_api.rs b/src/api_data/survey_choice_api.rs index af41d8e..a8d55f0 100644 --- a/src/api_data/survey_choice_api.rs +++ b/src/api_data/survey_choice_api.rs @@ -27,7 +27,9 @@ impl SurveyChoiceAPI { pub fn for_list(c: &[SurveyChoice]) -> HashMap { let mut map = HashMap::with_capacity(c.len()); - c.iter().for_each(|c| { map.insert(c.id, Self::new(c)); }); + c.iter().for_each(|c| { + map.insert(c.id, Self::new(c)); + }); map } -} \ No newline at end of file +} diff --git a/src/api_data/survey_response_api.rs b/src/api_data/survey_response_api.rs index abd1fc6..4ebbb4f 100644 --- a/src/api_data/survey_response_api.rs +++ b/src/api_data/survey_response_api.rs @@ -28,4 +28,4 @@ impl EntitiesConstructor for SurveyResponseAPI { choiceID: r.choice_id, } } -} \ No newline at end of file +} diff --git a/src/api_data/type_container_api.rs b/src/api_data/type_container_api.rs index f3cfe94..551e808 100644 --- a/src/api_data/type_container_api.rs +++ b/src/api_data/type_container_api.rs @@ -1,8 +1,8 @@ //! Use this structure for all structures that needs a "type" field //! //! @author Pierre Hubert -use serde::{Serialize, Serializer}; use serde::ser::SerializeMap; +use serde::{Serialize, Serializer}; pub struct TypeContainerAPI { t: String, @@ -15,10 +15,12 @@ impl TypeContainerAPI { } impl Serialize for TypeContainerAPI { - fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> where - S: Serializer { + fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> + where + S: Serializer, + { let mut map = serializer.serialize_map(Some(1))?; map.serialize_entry("type", &self.t)?; map.end() } -} \ No newline at end of file +} diff --git a/src/api_data/user_calls_config.rs b/src/api_data/user_calls_config.rs index fbeb28b..dc4a7f5 100644 --- a/src/api_data/user_calls_config.rs +++ b/src/api_data/user_calls_config.rs @@ -14,6 +14,8 @@ pub struct UserCallsConfig { impl UserCallsConfig { pub fn new(conf: &RtcRelayConfig) -> Self { - Self { iceServers: conf.ice_servers.clone() } + Self { + iceServers: conf.ice_servers.clone(), + } } -} \ No newline at end of file +} diff --git a/src/api_data/user_info.rs b/src/api_data/user_info.rs index fa4c7cf..40e1275 100644 --- a/src/api_data/user_info.rs +++ b/src/api_data/user_info.rs @@ -5,10 +5,12 @@ use serde::Serialize; use crate::api_data::custom_emoji::CustomEmojiAPI; use crate::data::error::ResultBoxError; -use crate::data::user::{User, UserID, UserPageVisibility}; use crate::data::user::AccountImageVisibility::{COMUNIC_USERS, EVERYONE}; -use crate::helpers::{background_image_helper, custom_emojies_helper, friends_helper, likes_helper, user_helper}; +use crate::data::user::{User, UserID, UserPageVisibility}; use crate::helpers::likes_helper::LikeType; +use crate::helpers::{ + background_image_helper, custom_emojies_helper, friends_helper, likes_helper, user_helper, +}; use crate::utils::user_data_utils::user_data_url; #[derive(Serialize)] @@ -65,7 +67,10 @@ impl APIUserInfo { } /// Get advanced user information - pub fn new_advanced_info(user_id: &Option, info: &User) -> ResultBoxError { + pub fn new_advanced_info( + user_id: &Option, + info: &User, + ) -> ResultBoxError { let user = APIUserInfo::new(&user_id, info)?; let curr_user_id = user_id.clone().unwrap_or(UserID::new(0)); let signed_in = user_id.is_some(); @@ -73,11 +78,15 @@ impl APIUserInfo { // Check if we can return the number of friends of the user let number_friends = if info.public_friends_list || curr_user_id == info.id { friends_helper::count_friends(&info.id)? - } else { 0 }; + } else { + 0 + }; let likes_page = if signed_in { likes_helper::is_liking(&curr_user_id, info.id.id(), LikeType::USER)? - } else { false }; + } else { + false + }; // Set advanced user information Ok(APIAdvancedInfo { @@ -113,16 +122,17 @@ impl APIUserInfo { return user_account_image; } - if user_id.is_none() { // User is not signed in + if user_id.is_none() { + // User is not signed in return Ok(User::error_account_image_url()); } - if user.account_image_visibility == COMUNIC_USERS || - friends_helper::are_friend(&user_id.clone().unwrap(), &user.id)? { + if user.account_image_visibility == COMUNIC_USERS + || friends_helper::are_friend(&user_id.clone().unwrap(), &user.id)? + { return user_account_image; } - Ok(User::error_account_image_url()) } -} \ No newline at end of file +} diff --git a/src/api_data/user_is_writing_message_in_conversation.rs b/src/api_data/user_is_writing_message_in_conversation.rs index 26e907a..e03b3a2 100644 --- a/src/api_data/user_is_writing_message_in_conversation.rs +++ b/src/api_data/user_is_writing_message_in_conversation.rs @@ -19,4 +19,4 @@ impl UserIsWritingMessageInConversation { conv_id: conv_id.id(), } } -} \ No newline at end of file +} diff --git a/src/api_data/user_like_api.rs b/src/api_data/user_like_api.rs index 9a9cb1c..97ef0c6 100644 --- a/src/api_data/user_like_api.rs +++ b/src/api_data/user_like_api.rs @@ -30,4 +30,4 @@ impl UserLikeAPI { pub fn for_list(l: &[UserLike]) -> Vec { l.iter().map(Self::new).collect() } -} \ No newline at end of file +} diff --git a/src/api_data/user_mail_address.rs b/src/api_data/user_mail_address.rs index 29cc002..ea0af0e 100644 --- a/src/api_data/user_mail_address.rs +++ b/src/api_data/user_mail_address.rs @@ -14,7 +14,7 @@ pub struct UserMailAddressAPI { impl UserMailAddressAPI { pub fn new(user: &User) -> Self { Self { - mail: user.email.to_string() + mail: user.email.to_string(), } } -} \ No newline at end of file +} diff --git a/src/api_data/user_membership_api.rs b/src/api_data/user_membership_api.rs index f533aea..ae0ffe7 100644 --- a/src/api_data/user_membership_api.rs +++ b/src/api_data/user_membership_api.rs @@ -44,11 +44,11 @@ impl UserMembershipAPI { friend: None, last_activity: None, conv: Some(ConversationAPI::new(conversation)), - } + }, } } pub fn for_list(l: &[UserMembership]) -> Vec { l.iter().map(Self::new).collect() } -} \ No newline at end of file +} diff --git a/src/cleanup_thread.rs b/src/cleanup_thread.rs index 76a1258..b16534a 100644 --- a/src/cleanup_thread.rs +++ b/src/cleanup_thread.rs @@ -37,13 +37,11 @@ fn clean_up_thread_handler() { /// Do the cleanup async fn do_clean() -> Res { - // Clean old login tokens account_helper::clean_up_old_access_tokens().await?; // Automatic account cleanup for user in user_helper::get_all_users()? { - // Clean old likes likes_helper::clean_old_user_likes(&user)?; @@ -67,4 +65,4 @@ async fn do_clean() -> Res { admin_log_helper::clean_old_logs()?; Ok(()) -} \ No newline at end of file +} diff --git a/src/constants.rs b/src/constants.rs index 7aa7f73..624e502 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -209,25 +209,27 @@ pub mod conversations { /// Allowed files type in conversations pub const ALLOWED_CONVERSATION_FILES_TYPES: [&str; 18] = [ - "image/png", "image/jpeg", "image/gif", "image/bmp", + "image/png", + "image/jpeg", + "image/gif", + "image/bmp", "application/pdf", "audio/mpeg", "video/mp4", "video/quicktime", "application/zip", - // MS Office docs "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - // Open Office docs "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.presentation", "application/vnd.oasis.opendocument.spreadsheet", - // Source code docs (UTF-8 encoded) - "text/x-csrc", "text/plain", "text/x-c++src" + "text/x-csrc", + "text/plain", + "text/x-c++src", ]; /// File maximum size in conversations (10 Mb) @@ -267,7 +269,8 @@ pub mod accounts_info_policy { } /// Url where Firebase push notifications can be sent -pub const FIREBASE_PUSH_MESSAGE_URL: &str = "https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send"; +pub const FIREBASE_PUSH_MESSAGE_URL: &str = + "https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send"; /// Reports constants pub mod reports { @@ -313,6 +316,6 @@ pub mod admin { id: "access_all_admins_logs", name: "Access all admins logs", description: "Allow the admin to access the action history (log) of all admins", - } + }, ]; -} \ No newline at end of file +} diff --git a/src/controllers/account_controller.rs b/src/controllers/account_controller.rs index 64c2cf6..c287121 100644 --- a/src/controllers/account_controller.rs +++ b/src/controllers/account_controller.rs @@ -35,7 +35,10 @@ impl HttpRequestHandler { } /// Get the ID of the user associated with a password reset token - pub fn post_user_id_from_password_reset_token(&mut self, field: &str) -> ResultBoxError { + pub fn post_user_id_from_password_reset_token( + &mut self, + field: &str, + ) -> ResultBoxError { let token = self.post_string_opt(field, PASSWORD_RESET_TOKEN_LENGTH, true)?; let user_id = self.ok_or_forbidden( account_helper::get_user_id_from_password_reset_token(&token), @@ -48,7 +51,6 @@ impl HttpRequestHandler { /// Create a new account pub async fn create(r: &mut HttpRequestHandler) -> RequestResult { - // Get & check email let email = r.post_email("emailAddress")?; if account_helper::exists_mail(&email)? { @@ -77,13 +79,10 @@ pub async fn login_user(request: &mut HttpRequestHandler) -> RequestResult { } // Authenticate user - let token = account_helper::login_user( - &email, &password, request.api_client()); + let token = account_helper::login_user(&email, &password, request.api_client()); match token { - Ok(t) => { - request.set_response(LoginSuccess::new(&t)) - } + Ok(t) => request.set_response(LoginSuccess::new(&t)), Err(e) => { println!("Error on login: {}", e); request.forbidden("Invalid email address / password!".to_string()) @@ -122,14 +121,18 @@ pub async fn get_mail(r: &mut HttpRequestHandler) -> RequestResult { pub async fn exists_mail(r: &mut HttpRequestHandler) -> RequestResult { let email = r.post_email("email")?; - r.set_response(ResCheckEmailExists::new(account_helper::exists_mail(&email)?)) + r.set_response(ResCheckEmailExists::new(account_helper::exists_mail( + &email, + )?)) } /// Check out whether a given user has set security questions or not pub async fn has_security_questions(r: &mut HttpRequestHandler) -> RequestResult { let user = r.post_user_info_from_email("email")?; - r.set_response(ResCheckSecurityQuestionsExists::new(user.has_security_questions())) + r.set_response(ResCheckSecurityQuestionsExists::new( + user.has_security_questions(), + )) } /// Get the security questions of a user @@ -151,17 +154,25 @@ pub async fn check_security_answers(r: &mut HttpRequestHandler) -> RequestResult r.forbidden("Specified user has not setup security questions !".to_string())?; } - let answers: Vec = r.post_string_opt("answers", 3, true)? + let answers: Vec = r + .post_string_opt("answers", 3, true)? .split("&") - .map(|s| percent_decode_str(s).decode_utf8_lossy().to_lowercase().trim().to_string()) + .map(|s| { + percent_decode_str(s) + .decode_utf8_lossy() + .to_lowercase() + .trim() + .to_string() + }) .collect::>(); if answers.len() != 2 { r.forbidden("Please specify two answers!".to_string())?; } - if answers[0] != user.security_answer_1.unwrap().to_lowercase().trim() || - answers[1] != user.security_answer_2.unwrap().to_lowercase().trim() { + if answers[0] != user.security_answer_1.unwrap().to_lowercase().trim() + || answers[1] != user.security_answer_2.unwrap().to_lowercase().trim() + { r.forbidden("Invalid security answers!".to_string())?; } @@ -211,4 +222,4 @@ pub async fn delete_account(r: &mut HttpRequestHandler) -> RequestResult { account_helper::delete(r.user_id_ref()?).await?; r.success("Account deleted.") -} \ No newline at end of file +} diff --git a/src/controllers/admin/admin_account_controller.rs b/src/controllers/admin/admin_account_controller.rs index 5e60182..6e0952a 100644 --- a/src/controllers/admin/admin_account_controller.rs +++ b/src/controllers/admin/admin_account_controller.rs @@ -2,7 +2,6 @@ //! //! @author Pierre Hubert - use crate::api_data::admin::admin_auth_options::AdminAuthOptions; use crate::api_data::admin::admin_auth_success::AdminAuthSuccess; use crate::api_data::admin::admin_id_api::AdminIDAPI; @@ -14,8 +13,8 @@ use crate::data::admin::{NewAdmin, NewAdminGeneralSettings}; use crate::data::admin_action_log::AdminAction; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::http_request_handler::HttpRequestHandler; -use crate::helpers::{admin_access_token_helper, admin_account_helper, admin_account_key_helper}; use crate::helpers::admin_log_helper::log_admin_action; +use crate::helpers::{admin_access_token_helper, admin_account_helper, admin_account_key_helper}; use crate::routes::RequestResult; use crate::utils::date_utils::time; @@ -27,8 +26,15 @@ pub async fn create(r: &mut HttpRequestHandler) -> RequestResult { let new_admin = NewAdmin { name, email }; let admin_id = admin_account_helper::create(&new_admin)?; - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::CreatedAdmin { id: admin_id, name: new_admin.name, email: new_admin.email })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::CreatedAdmin { + id: admin_id, + name: new_admin.name, + email: new_admin.email, + }, + )?; r.set_response(AdminResCreateAccount::new(admin_id)) } @@ -58,8 +64,7 @@ pub async fn auth_with_reset_token(r: &mut HttpRequestHandler) -> RequestResult let token = admin_access_token_helper::create(admin.id)?; - log_admin_action(admin.id, &r.remote_ip(), - AdminAction::AuthWithResetToken)?; + log_admin_action(admin.id, &r.remote_ip(), AdminAction::AuthWithResetToken)?; r.set_response(AdminAuthSuccess::new(token)) } @@ -115,8 +120,15 @@ pub async fn update_general_settings(r: &mut HttpRequestHandler) -> RequestResul email: new_email.to_string(), })?; - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::UpdatedAdminGeneralSettings { target: admin_id, new_name, new_email })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::UpdatedAdminGeneralSettings { + target: admin_id, + new_name, + new_email, + }, + )?; r.ok() } @@ -131,8 +143,11 @@ pub async fn generate_reset_token(r: &mut HttpRequestHandler) -> RequestResult { let token = admin_account_helper::create_new_reset_token(admin_id)?; - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::GeneratedAdminResetToken { target: admin_id })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::GeneratedAdminResetToken { target: admin_id }, + )?; r.set_response(AdminResCreateResetToken::new(token)) -} \ No newline at end of file +} diff --git a/src/controllers/admin/admin_keys_controller.rs b/src/controllers/admin/admin_keys_controller.rs index fff0be4..bd7e131 100644 --- a/src/controllers/admin/admin_keys_controller.rs +++ b/src/controllers/admin/admin_keys_controller.rs @@ -2,7 +2,6 @@ //! //! @author Pierre Hubert - use bcrypt::verify; use webauthn_rs::prelude::Uuid; @@ -15,8 +14,11 @@ use crate::data::base_request_handler::BaseRequestHandler; use crate::data::error::Res; use crate::data::http_request_handler::HttpRequestHandler; use crate::data::webauthn_config::get_wan; -use crate::helpers::{admin_access_token_helper, admin_account_helper, admin_account_key_helper, admin_key_authentication_challenges_helper, admin_key_registration_challenges_helper}; use crate::helpers::admin_log_helper::log_admin_action; +use crate::helpers::{ + admin_access_token_helper, admin_account_helper, admin_account_key_helper, + admin_key_authentication_challenges_helper, admin_key_registration_challenges_helper, +}; use crate::routes::RequestResult; impl HttpRequestHandler { @@ -27,12 +29,13 @@ impl HttpRequestHandler { let admin = admin_account_helper::find_admin_by_email(&mail)?; let keys = admin_account_key_helper::get_admin_keys(admin.id)?; - let key = keys.into_iter() - .find(|k| k.id == key_id); + let key = keys.into_iter().find(|k| k.id == key_id); match key { Some(key) => Ok(key), - None => Err(self.bad_request("The key is not associated with this account!".to_string()).unwrap_err()) + None => Err(self + .bad_request("The key is not associated with this account!".to_string()) + .unwrap_err()), } } } @@ -47,21 +50,21 @@ pub async fn get_keys_list(r: &mut HttpRequestHandler) -> RequestResult { let keys = admin_account_key_helper::get_admin_keys(admin_id)?; - r.set_response(keys.iter().map(AdminKeyAPI::new).collect::>()) + r.set_response( + keys.iter() + .map(AdminKeyAPI::new) + .collect::>(), + ) } - /// Generate a challenge to register a new key pub async fn challenge_register_key(r: &mut HttpRequestHandler) -> RequestResult { let wan = get_wan(); let user_info = admin_account_helper::find_admin_by_id(r.admin_id()?)?; - let (res, state) = wan.start_passkey_registration( - Uuid::new_v4(), - &user_info.name, - &user_info.name, - None)?; + let (res, state) = + wan.start_passkey_registration(Uuid::new_v4(), &user_info.name, &user_info.name, None)?; admin_key_registration_challenges_helper::set(r.admin_id()?, state)?; @@ -84,12 +87,15 @@ pub async fn register_key(r: &mut HttpRequestHandler) -> RequestResult { let key_id = admin_account_key_helper::add_key(r.admin_id()?, &key_name, key, key_password)?; - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::RegisteredAdminKey { - key_id, - key_name, - target: r.admin_id()?, - })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::RegisteredAdminKey { + key_id, + key_name, + target: r.admin_id()?, + }, + )?; r.ok() } @@ -105,12 +111,15 @@ pub async fn delete_auth_key(r: &mut HttpRequestHandler) -> RequestResult { for key in admin_account_key_helper::get_admin_keys(admin_id)? { if key.id == key_id { - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::DeletedAdminKey { - key_id, - key_name: key.name.to_string(), - target: admin_id, - })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::DeletedAdminKey { + key_id, + key_name: key.name.to_string(), + target: admin_id, + }, + )?; admin_account_key_helper::delete_key(key)?; @@ -125,8 +134,7 @@ pub async fn delete_auth_key(r: &mut HttpRequestHandler) -> RequestResult { pub async fn challenge_auth_with_key(r: &mut HttpRequestHandler) -> RequestResult { let key = r.post_admin_auth_key("mail", "key_id")?; - let (challenge_response, auth_state) = - get_wan().start_passkey_authentication(&[key.key])?; + let (challenge_response, auth_state) = get_wan().start_passkey_authentication(&[key.key])?; admin_key_authentication_challenges_helper::set(key.id, auth_state)?; @@ -158,8 +166,14 @@ pub async fn auth_with_key(r: &mut HttpRequestHandler) -> RequestResult { // Generate access token let token = admin_access_token_helper::create(key.admin_id)?; - log_admin_action(key.admin_id, &r.remote_ip(), - AdminAction::AuthWithAccessKey { key: key.name, key_id: key.id })?; + log_admin_action( + key.admin_id, + &r.remote_ip(), + AdminAction::AuthWithAccessKey { + key: key.name, + key_id: key.id, + }, + )?; r.set_response(AdminAuthSuccess::new(token)) -} \ No newline at end of file +} diff --git a/src/controllers/admin/admin_logs_controller.rs b/src/controllers/admin/admin_logs_controller.rs index afae1a8..a1bff2f 100644 --- a/src/controllers/admin/admin_logs_controller.rs +++ b/src/controllers/admin/admin_logs_controller.rs @@ -2,19 +2,20 @@ //! //! @author Pierre Hubert -use crate::routes::RequestResult; -use crate::data::http_request_handler::HttpRequestHandler; -use crate::data::base_request_handler::BaseRequestHandler; -use crate::helpers::{admin_roles_helper, admin_log_helper}; -use crate::constants::admin::AdminRole; use crate::api_data::admin::admin_log_api::AdminLogAPI; +use crate::constants::admin::AdminRole; +use crate::data::base_request_handler::BaseRequestHandler; +use crate::data::http_request_handler::HttpRequestHandler; +use crate::helpers::{admin_log_helper, admin_roles_helper}; +use crate::routes::RequestResult; /// Get the list of logs of the user pub async fn get_list(r: &mut HttpRequestHandler) -> RequestResult { - let logs = match admin_roles_helper::has_role(r.admin_id()?, AdminRole::ACCESS_ALL_ADMINS_LOGS)? { + let logs = match admin_roles_helper::has_role(r.admin_id()?, AdminRole::ACCESS_ALL_ADMINS_LOGS)? + { true => admin_log_helper::get_all_admin_logs(), - false => admin_log_helper::get_admin_logs(r.admin_id()?) + false => admin_log_helper::get_admin_logs(r.admin_id()?), }?; r.set_response(logs.iter().map(AdminLogAPI::new).collect::>()) -} \ No newline at end of file +} diff --git a/src/controllers/admin/admin_roles_controller.rs b/src/controllers/admin/admin_roles_controller.rs index c4bcdeb..775c7aa 100644 --- a/src/controllers/admin/admin_roles_controller.rs +++ b/src/controllers/admin/admin_roles_controller.rs @@ -3,7 +3,7 @@ //! @author Pierre Hubert use crate::api_data::admin::admin_role_api::AdminRoleDetailsAPI; -use crate::constants::admin::{ADMIN_ROLES_LIST, AdminRole}; +use crate::constants::admin::{AdminRole, ADMIN_ROLES_LIST}; use crate::data::admin_action_log::AdminAction; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::http_request_handler::HttpRequestHandler; @@ -13,7 +13,8 @@ use crate::routes::RequestResult; /// Get the list of roles embedded in the code pub async fn get_list(r: &mut HttpRequestHandler) -> RequestResult { - let res = ADMIN_ROLES_LIST.iter() + let res = ADMIN_ROLES_LIST + .iter() .map(AdminRoleDetailsAPI::new) .collect::>(); @@ -32,14 +33,26 @@ pub async fn toggle(r: &mut HttpRequestHandler) -> RequestResult { if !enable { admin_roles_helper::remove_role(admin_id, role)?; - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::RemoveAdminRole { target: admin_id, role: role_str })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::RemoveAdminRole { + target: admin_id, + role: role_str, + }, + )?; } else if !admin_roles_helper::has_role(admin_id, role)? { admin_roles_helper::add_role(admin_id, role)?; - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::AddAdminRole { target: admin_id, role: role_str })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::AddAdminRole { + target: admin_id, + role: role_str, + }, + )?; } r.ok() -} \ No newline at end of file +} diff --git a/src/controllers/admin/admin_users_controller.rs b/src/controllers/admin/admin_users_controller.rs index 3a84d59..c25155d 100644 --- a/src/controllers/admin/admin_users_controller.rs +++ b/src/controllers/admin/admin_users_controller.rs @@ -10,8 +10,8 @@ use crate::data::admin_action_log::AdminAction; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::config::conf; use crate::data::http_request_handler::HttpRequestHandler; -use crate::helpers::{account_helper, user_helper}; use crate::helpers::admin_log_helper::log_admin_action; +use crate::helpers::{account_helper, user_helper}; use crate::routes::RequestResult; /// Search for user @@ -23,7 +23,12 @@ pub async fn search(r: &mut HttpRequestHandler) -> RequestResult { let results = user_helper::search_user_admin(&name, &email, 50)?; - r.set_response(results.into_iter().map(AdminSearchUserResult::new).collect::>()) + r.set_response( + results + .into_iter() + .map(AdminSearchUserResult::new) + .collect::>(), + ) } /// Get information about a single user @@ -33,8 +38,14 @@ pub async fn get_single(r: &mut HttpRequestHandler) -> RequestResult { let user_id = r.post_user_id("user_id")?; let user = user_helper::find_user_by_id(&user_id)?; - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::AccessUserPage { user_id, user_name: user.full_name() })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::AccessUserPage { + user_id, + user_name: user.full_name(), + }, + )?; r.set_response(AdminUserInfoAPI::new(user)) } @@ -49,19 +60,25 @@ pub async fn change_email_address(r: &mut HttpRequestHandler) -> RequestResult { // We check if the email address is already used if user_helper::find_user_by_email(&new_mail).is_ok() { - r.bad_request(format!("The email address {} is already attributed!", new_mail))?; + r.bad_request(format!( + "The email address {} is already attributed!", + new_mail + ))?; } // Do the update account_helper::set_email(user_id, &new_mail)?; - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::ChangedEmailAddress { - user_id, - user_name: user.full_name(), - old_mail: user.email, - new_mail, - })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::ChangedEmailAddress { + user_id, + user_name: user.full_name(), + old_mail: user.email, + new_mail, + }, + )?; r.ok() } @@ -76,8 +93,14 @@ pub async fn create_password_reset_link(r: &mut HttpRequestHandler) -> RequestRe let token = account_helper::generate_password_reset_token(&user_id)?; let reset_link = conf().password_reset_url.replace("{TOKEN}", &token); - log_admin_action(r.admin_id()?, &r.remote_ip(), - AdminAction::CreatePasswordRecoveryLink { user_id, user_name: user.full_name() })?; + log_admin_action( + r.admin_id()?, + &r.remote_ip(), + AdminAction::CreatePasswordRecoveryLink { + user_id, + user_name: user.full_name(), + }, + )?; r.set_response(AdminCreatedPasswordResetLinkApi::new(reset_link)) -} \ No newline at end of file +} diff --git a/src/controllers/admin/mod.rs b/src/controllers/admin/mod.rs index d76edc9..8cb99e4 100644 --- a/src/controllers/admin/mod.rs +++ b/src/controllers/admin/mod.rs @@ -4,6 +4,6 @@ pub mod admin_account_controller; pub mod admin_keys_controller; -pub mod admin_roles_controller; pub mod admin_logs_controller; -pub mod admin_users_controller; \ No newline at end of file +pub mod admin_roles_controller; +pub mod admin_users_controller; diff --git a/src/controllers/calls_controller.rs b/src/controllers/calls_controller.rs index 36a93cd..41e61a0 100644 --- a/src/controllers/calls_controller.rs +++ b/src/controllers/calls_controller.rs @@ -13,7 +13,9 @@ use crate::api_data::new_call_signal::NewCallSignalAPI; use crate::api_data::user_calls_config::UserCallsConfig; use crate::controllers::user_ws_controller; use crate::data::base_request_handler::BaseRequestHandler; -use crate::data::call_signal::{CallSignal, CloseCallStream, IceCandidate, NewUserCallSignal, SdpType, UserCallOfferRequest}; +use crate::data::call_signal::{ + CallSignal, CloseCallStream, IceCandidate, NewUserCallSignal, SdpType, UserCallOfferRequest, +}; use crate::data::config::conf; use crate::data::conversation::ConvID; use crate::data::error::{ExecError, Res}; @@ -21,8 +23,8 @@ use crate::data::user::UserID; use crate::data::user_ws_connection::{ActiveCall, UserWsConnection}; use crate::data::user_ws_message::UserWsMessage; use crate::data::user_ws_request_handler::UserWsRequestHandler; -use crate::helpers::{calls_helper, conversations_helper, events_helper}; use crate::helpers::events_helper::Event; +use crate::helpers::{calls_helper, conversations_helper, events_helper}; use crate::routes::RequestResult; impl UserWsRequestHandler { @@ -63,7 +65,8 @@ impl UserWsRequestHandler { /// Get call information, if available fn call_info(&mut self, call_id: &ConvID) -> Res { - let call = self.get_conn() + let call = self + .get_conn() .active_call .clone() .ok_or(ExecError::new("No call found !"))?; @@ -76,7 +79,10 @@ impl UserWsRequestHandler { } /// Update call information - fn update_call(&mut self, update: F) -> Res where F: FnOnce(&mut ActiveCall) { + fn update_call(&mut self, update: F) -> Res + where + F: FnOnce(&mut ActiveCall), + { self.update_conn(|conn| { if let Some(call) = &mut conn.active_call { update(call); @@ -95,8 +101,7 @@ pub async fn get_config(r: &mut UserWsRequestHandler) -> RequestResult { } if conf().is_rtc_relay_enabled() { - if let Some(conf) = conf().rtc_relay.as_ref() - { + if let Some(conf) = conf().rtc_relay.as_ref() { return r.set_response(UserCallsConfig::new(conf)); } } @@ -117,7 +122,11 @@ pub fn is_conversation_having_call(conv_id: &ConvID) -> bool { }); if let Err(e) = res { - eprintln!("Failed to check if a conversation is having call! Conversation: {} / Error: {:#?}", conv_id.id(), e); + eprintln!( + "Failed to check if a conversation is having call! Conversation: {} / Error: {:#?}", + conv_id.id(), + e + ); } found @@ -149,12 +158,14 @@ pub async fn join_call(r: &mut UserWsRequestHandler) -> RequestResult { make_user_leave_call(&call.conv_id, &conn).await?; } } - }; + } - r.update_conn(|r| r.active_call = Some(ActiveCall { - conv_id, - ready: false, - }))?; + r.update_conn(|r| { + r.active_call = Some(ActiveCall { + conv_id, + ready: false, + }) + })?; // Propagate event events_helper::propagate_event(Event::UserJoinedCall(conv_id, r.user_id()?)).await?; @@ -187,7 +198,10 @@ pub async fn get_members_list(r: &mut UserWsRequestHandler) -> RequestResult { user_ws_controller::foreach_connection(|conn| { if conn.is_having_call_with_conversation(&conv_id) { - list.push(CallMemberInfo::new(conn.user_id(), &conn.active_call.as_ref().unwrap())); + list.push(CallMemberInfo::new( + conn.user_id(), + &conn.active_call.as_ref().unwrap(), + )); } Ok(()) @@ -215,10 +229,11 @@ pub async fn on_client_signal(r: &mut UserWsRequestHandler) -> RequestResult { let signal = match sig_type.as_str() { "SDP" => { // Get SDP type - let sdp_type = SdpType::from_str(data.get("type") - .unwrap_or(&serde_json::Value::Null) - .as_str() - .ok_or(ExecError::boxed_new("Missing SDP type !"))? + let sdp_type = SdpType::from_str( + data.get("type") + .unwrap_or(&serde_json::Value::Null) + .as_str() + .ok_or(ExecError::boxed_new("Missing SDP type !"))?, )?; let sdp = data @@ -237,7 +252,9 @@ pub async fn on_client_signal(r: &mut UserWsRequestHandler) -> RequestResult { .get("candidate") .unwrap_or(&serde_json::Value::Null) .as_str() - .ok_or(ExecError::boxed_new("Failed to get candidate message data!"))? + .ok_or(ExecError::boxed_new( + "Failed to get candidate message data!", + ))? .to_string(); let sdp_m_line_index = data @@ -253,14 +270,16 @@ pub async fn on_client_signal(r: &mut UserWsRequestHandler) -> RequestResult { .ok_or(ExecError::boxed_new("Failed to get sdpMid message data!"))? .to_string(); - let parsed_candidate: SdpAttribute = candidate.trim().parse()?; - CallSignal::Candidate(IceCandidate { - candidate, - sdp_m_line_index, - sdp_mid, - }, parsed_candidate) + CallSignal::Candidate( + IceCandidate { + candidate, + sdp_m_line_index, + sdp_mid, + }, + parsed_candidate, + ) } _ => { @@ -271,10 +290,15 @@ pub async fn on_client_signal(r: &mut UserWsRequestHandler) -> RequestResult { events_helper::propagate_event(Event::NewUserCallSignal(NewUserCallSignal { call_hash: gen_call_hash(&call_id, &peer_id), - user_id: if r.user_id_ref()? == &peer_id { None } else { Some(r.user_id()?) }, + user_id: if r.user_id_ref()? == &peer_id { + None + } else { + Some(r.user_id()?) + }, signal, raw_data: r.post_string("data")?, - })).await?; + })) + .await?; r.success("Signal sent") } @@ -288,7 +312,12 @@ pub async fn mark_user_ready(r: &mut UserWsRequestHandler) -> Res { user_ws_controller::send_message_to_specific_connections( |c| c.user_id() != &user_id && c.is_having_call_with_conversation(&call_id), - |_| UserWsMessage::no_id_message("call_peer_ready", CallPeerReadyAPI::new(&call_id, r.user_id_ref()?)), + |_| { + UserWsMessage::no_id_message( + "call_peer_ready", + CallPeerReadyAPI::new(&call_id, r.user_id_ref()?), + ) + }, )?; r.success("Information propagated.") @@ -308,7 +337,8 @@ pub async fn request_offer(r: &mut UserWsRequestHandler) -> Res { events_helper::propagate_event(Event::UserRequestedCallOffer(UserCallOfferRequest { call_hash: gen_call_hash(&call_id, &peer_id), user_id: r.user_id()?, - })).await?; + })) + .await?; r.success("Request sent") } @@ -325,7 +355,12 @@ pub async fn stop_streaming(r: &mut UserWsRequestHandler) -> Res { // Notify all other users user_ws_controller::send_message_to_specific_connections( |c| c.is_having_call_with_conversation(&call_id) && c.user_id() != &user_id, - |_| UserWsMessage::no_id_message("call_peer_interrupted_streaming", CallPeerInterruptedStreamingAPI::new(&call_id, &user_id)), + |_| { + UserWsMessage::no_id_message( + "call_peer_interrupted_streaming", + CallPeerInterruptedStreamingAPI::new(&call_id, &user_id), + ) + }, )?; } @@ -333,42 +368,50 @@ pub async fn stop_streaming(r: &mut UserWsRequestHandler) -> Res { events_helper::propagate_event(Event::CloseCallStream(CloseCallStream { call_hash: gen_call_hash(&call_id, &user_id), peer_id: None, - })).await?; + })) + .await?; r.success("ok") } - /// Make the user leave the call pub async fn make_user_leave_call(conv_id: &ConvID, connection: &UserWsConnection) -> Res { connection.clone().replace(|c| c.active_call = None); // Notify user (if possible) if connection.session.connected() { - user_ws_controller::send_to_client(connection, &UserWsMessage::no_id_message("call_closed", conv_id.id())?)?; + user_ws_controller::send_to_client( + connection, + &UserWsMessage::no_id_message("call_closed", conv_id.id())?, + )?; } // Close main stream (sender) events_helper::propagate_event(Event::CloseCallStream(CloseCallStream { call_hash: gen_call_hash(&conv_id, connection.user_id()), peer_id: None, - })).await?; + })) + .await?; // Close receiver streams (other users streams) for peer_conn in user_ws_controller::get_all_connections()? { - if peer_conn.is_having_call_with_conversation(conv_id) && peer_conn.user_id() != connection.user_id() { + if peer_conn.is_having_call_with_conversation(conv_id) + && peer_conn.user_id() != connection.user_id() + { events_helper::propagate_event(Event::CloseCallStream(CloseCallStream { call_hash: gen_call_hash(&conv_id, peer_conn.user_id()), peer_id: Some(connection.user_id().clone()), - })).await?; + })) + .await?; } - }; + } // Create a notification events_helper::propagate_event(Event::UserLeftCall( conv_id.clone(), connection.user_id().clone(), - )).await?; + )) + .await?; Ok(()) } @@ -379,14 +422,24 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { Event::UserJoinedCall(conv_id, user_id) => { user_ws_controller::send_message_to_specific_connections( |c| c.is_having_call_with_conversation(conv_id) && c.user_id() != user_id, - |_| UserWsMessage::no_id_message("user_joined_call", JoinedCallMessage::new(conv_id, user_id)), + |_| { + UserWsMessage::no_id_message( + "user_joined_call", + JoinedCallMessage::new(conv_id, user_id), + ) + }, )?; } Event::UserLeftCall(conv_id, user_id) => { user_ws_controller::send_message_to_specific_connections( |c| c.is_having_call_with_conversation(conv_id), - |_| UserWsMessage::no_id_message("user_left_call", LeftCallMessage::new(conv_id, user_id)), + |_| { + UserWsMessage::no_id_message( + "user_left_call", + LeftCallMessage::new(conv_id, user_id), + ) + }, )?; } @@ -409,13 +462,17 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { let target_user = UserID::new(msg.peer_id.parse::()?); let target_user = match target_user.is_valid() { true => target_user, - false => peer_id.clone() + false => peer_id.clone(), }; - user_ws_controller::send_message_to_specific_connections( |c| c.user_id() == target_user && c.is_having_call_with_conversation(&call_id), - |_| UserWsMessage::no_id_message("new_call_signal", NewCallSignalAPI::new(&call_id, &peer_id, &msg.data)?), + |_| { + UserWsMessage::no_id_message( + "new_call_signal", + NewCallSignalAPI::new(&call_id, &peer_id, &msg.data)?, + ) + }, )?; } @@ -426,7 +483,7 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { if let Some(call) = &f.active_call { make_user_leave_call(&call.conv_id, &f).await?; } - }; + } } // Call active call of user (if any) @@ -463,4 +520,4 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { } Ok(()) -} \ No newline at end of file +} diff --git a/src/controllers/comments_controller.rs b/src/controllers/comments_controller.rs index e626dc7..320bc09 100644 --- a/src/controllers/comments_controller.rs +++ b/src/controllers/comments_controller.rs @@ -5,7 +5,6 @@ use crate::api_data::comment_api::CommentAPI; use crate::api_data::res_create_comment::ResCreateComment; use crate::constants::PATH_COMMENTS_IMAGES; -use crate::routes::RequestResult; use crate::controllers::user_ws_controller; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::comment::Comment; @@ -14,8 +13,9 @@ use crate::data::http_request_handler::HttpRequestHandler; use crate::data::notification::NotifEventType; use crate::data::post::PostAccessLevel; use crate::data::user_ws_message::UserWsMessage; -use crate::helpers::{comments_helper, events_helper, notifications_helper, posts_helper}; use crate::helpers::events_helper::Event; +use crate::helpers::{comments_helper, events_helper, notifications_helper, posts_helper}; +use crate::routes::RequestResult; use crate::utils::date_utils::time; use crate::utils::string_utils::remove_html_nodes; @@ -30,16 +30,12 @@ pub async fn create(r: &mut HttpRequestHandler) -> RequestResult { let (content, image) = if r.has_file("image") { ( remove_html_nodes(&r.post_string_opt("content", 0, false)?), - Some(r.save_post_image("image", PATH_COMMENTS_IMAGES, 700, 700)?) + Some(r.save_post_image("image", PATH_COMMENTS_IMAGES, 700, 700)?), ) } else { - ( - r.post_content("content", 2, true)?, - None - ) + (r.post_content("content", 2, true)?, None) }; - let comment = Comment { id: 0, time_sent: time(), @@ -52,10 +48,16 @@ pub async fn create(r: &mut HttpRequestHandler) -> RequestResult { let comment_id = comments_helper::create(&comment).await?; // Create notifications - notifications_helper::create_post_notification(&r.user_id()?, post.id, NotifEventType::COMMENT_CREATED).await?; + notifications_helper::create_post_notification( + &r.user_id()?, + post.id, + NotifEventType::COMMENT_CREATED, + ) + .await?; // Remove notifications targeting current user about the post - notifications_helper::delete_all_post_notifications_targeting_user(r.user_id_ref()?, post.id).await?; + notifications_helper::delete_all_post_notifications_targeting_user(r.user_id_ref()?, post.id) + .await?; r.set_response(ResCreateComment::new(comment_id)) } @@ -92,30 +94,31 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { Event::NewComment(comment) => { user_ws_controller::send_message_to_specific_connections( |c| c.posts.contains(&comment.post_id), - |c| UserWsMessage::no_id_message( - "new_comment", - CommentAPI::new(comment, &Some(c.user_id().clone()))?, - ) + |c| { + UserWsMessage::no_id_message( + "new_comment", + CommentAPI::new(comment, &Some(c.user_id().clone()))?, + ) + }, )?; } Event::UpdatedComment(comment) => { user_ws_controller::send_message_to_specific_connections( |c| c.posts.contains(&comment.post_id), - |c| UserWsMessage::no_id_message( - "comment_updated", - CommentAPI::new(comment, &Some(c.user_id().clone()))?, - ) + |c| { + UserWsMessage::no_id_message( + "comment_updated", + CommentAPI::new(comment, &Some(c.user_id().clone()))?, + ) + }, )?; } Event::DeletedComment(comment) => { user_ws_controller::send_message_to_specific_connections( |c| c.posts.contains(&comment.post_id), - |_| UserWsMessage::no_id_message( - "comment_deleted", - comment.id.clone(), - ), + |_| UserWsMessage::no_id_message("comment_deleted", comment.id.clone()), )?; } @@ -123,4 +126,4 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { } Ok(()) -} \ No newline at end of file +} diff --git a/src/controllers/conversations_controller.rs b/src/controllers/conversations_controller.rs index eed7ecf..3164ba9 100644 --- a/src/controllers/conversations_controller.rs +++ b/src/controllers/conversations_controller.rs @@ -12,7 +12,12 @@ use crate::api_data::res_count_unread_conversations::ResultCountUnreadConversati use crate::api_data::res_create_conversation::ResCreateConversation; use crate::api_data::res_find_private_conversations::ResFindPrivateConversations; use crate::api_data::user_is_writing_message_in_conversation::UserIsWritingMessageInConversation; -use crate::constants::conversations::{ALLOWED_CONVERSATION_FILES_TYPES, CONVERSATION_FILES_MAX_SIZE, MAX_CONV_IMAGE_MESSAGE_HEIGHT, MAX_CONV_IMAGE_MESSAGE_WIDTH, MAX_CONV_LOGO_HEIGHT, MAX_CONV_LOGO_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT, MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MAX_CONVERSATION_MESSAGE_LENGTH, MIN_CONVERSATION_MESSAGE_LENGTH}; +use crate::constants::conversations::{ + ALLOWED_CONVERSATION_FILES_TYPES, CONVERSATION_FILES_MAX_SIZE, MAX_CONVERSATION_MESSAGE_LENGTH, + MAX_CONV_IMAGE_MESSAGE_HEIGHT, MAX_CONV_IMAGE_MESSAGE_WIDTH, MAX_CONV_LOGO_HEIGHT, + MAX_CONV_LOGO_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT, MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, + MIN_CONVERSATION_MESSAGE_LENGTH, +}; use crate::controllers::user_ws_controller; use crate::data::base_request_handler::{BaseRequestHandler, RequestValue}; use crate::data::conversation::NewConversationSettings; @@ -23,8 +28,8 @@ use crate::data::new_conversation::NewConversation; use crate::data::new_conversation_message::NewConversationMessage; use crate::data::user_ws_message::UserWsMessage; use crate::data::user_ws_request_handler::UserWsRequestHandler; -use crate::helpers::{conversations_helper, events_helper}; use crate::helpers::events_helper::Event; +use crate::helpers::{conversations_helper, events_helper}; use crate::routes::RequestResult; use crate::utils::string_utils::remove_html_nodes; use crate::utils::user_data_utils::{delete_user_data_file_if_exists, user_data_path}; @@ -57,7 +62,11 @@ pub async fn create(r: &mut HttpRequestHandler) -> RequestResult { pub async fn get_list(r: &mut HttpRequestHandler) -> RequestResult { let list = conversations_helper::get_list_user(&r.user_id()?)?; - r.set_response(list.iter().map(|c| ConversationAPI::new(c)).collect::>()) + r.set_response( + list.iter() + .map(|c| ConversationAPI::new(c)) + .collect::>(), + ) } /// Get information about a single conversation @@ -84,15 +93,19 @@ pub async fn update_settings(r: &mut HttpRequestHandler) -> RequestResult { // Change moderator settings if r.has_post_parameter("name") && r.has_post_parameter("canEveryoneAddMembers") - && r.has_post_parameter("color") { + && r.has_post_parameter("color") + { if !conv_membership.is_admin { - r.forbidden("You are not allowed to perform changes on this conversation!".to_string())?; + r.forbidden( + "You are not allowed to perform changes on this conversation!".to_string(), + )?; } - let new_settings = NewConversationSettings { conv_id: conv_membership.conv_id, - name: r.post_string_optional("name").map(|s| remove_html_nodes(&s)), + name: r + .post_string_optional("name") + .map(|s| remove_html_nodes(&s)), color: r.post_color_opt("color")?, can_everyone_add_members: r.post_bool("canEveryoneAddMembers")?, }; @@ -108,7 +121,12 @@ pub async fn change_image(r: &mut HttpRequestHandler) -> RequestResult { let conv_membership = r.post_conv_admin("convID")?; let conv = conversations_helper::get_single(conv_membership.conv_id)?; - let new_image = r.save_post_image("file", "conv-image", MAX_CONV_LOGO_WIDTH, MAX_CONV_LOGO_HEIGHT)?; + let new_image = r.save_post_image( + "file", + "conv-image", + MAX_CONV_LOGO_WIDTH, + MAX_CONV_LOGO_HEIGHT, + )?; conversations_helper::remove_conversation_image(&conv)?; @@ -135,7 +153,9 @@ pub async fn add_member(r: &mut HttpRequestHandler) -> RequestResult { let user_to_add = r.post_user_id("userID")?; if conv.is_managed() { - r.bad_request("This conversation is managed, you can not manually change its members!".to_string())?; + r.bad_request( + "This conversation is managed, you can not manually change its members!".to_string(), + )?; } if !conv.can_user_add_members(r.user_id_ref()?) { @@ -146,7 +166,8 @@ pub async fn add_member(r: &mut HttpRequestHandler) -> RequestResult { r.bad_request("This user is already a member of this conversation!".to_string())?; } - conversations_helper::add_member(conv.id, &user_to_add, true, false, Some(r.user_id_ref()?)).await?; + conversations_helper::add_member(conv.id, &user_to_add, true, false, Some(r.user_id_ref()?)) + .await?; r.success("The user was added to the conversation!") } @@ -159,7 +180,9 @@ pub async fn set_admin(r: &mut HttpRequestHandler) -> RequestResult { let set_admin = r.post_bool("setAdmin")?; if conv.is_managed() { - r.bad_request("This conversation is managed, you can not manually change its members!".to_string())?; + r.bad_request( + "This conversation is managed, you can not manually change its members!".to_string(), + )?; } if !conv.can_mark_other_users_admin(r.user_id_ref()?) { @@ -183,7 +206,9 @@ pub async fn remove_member(r: &mut HttpRequestHandler) -> RequestResult { let user_to_remove = r.post_user_id("userID")?; if conv.is_managed() { - r.bad_request("This conversation is managed, you can not manually change its members!".to_string())?; + r.bad_request( + "This conversation is managed, you can not manually change its members!".to_string(), + )?; } if !conv.can_user_remove_members(r.user_id_ref()?) { @@ -254,7 +279,8 @@ pub async fn refresh_single(r: &mut HttpRequestHandler) -> RequestResult { conv.conv_id, r.user_id_ref()?, &messages.last().unwrap(), - ).await?; + ) + .await?; } r.set_response(ConversationMessageAPI::for_list(&messages)) @@ -270,7 +296,7 @@ pub async fn get_older_messages(r: &mut HttpRequestHandler) -> RequestResult { let limit = match limit { 0 => 1, 1..=60 => limit, - _ => 60 + _ => 60, }; let messages = conversations_helper::get_older_messages(conv.conv_id, max_id, limit)?; @@ -285,7 +311,6 @@ pub async fn send_message(r: &mut HttpRequestHandler) -> RequestResult { // Get associated file let file = match r.post_parameter_opt("file") { Some(RequestValue::File(file)) => { - // File name let mut name = file.name.to_string(); @@ -299,7 +324,7 @@ pub async fn send_message(r: &mut HttpRequestHandler) -> RequestResult { // Check for thumbnail let mut thumbnail = match r.has_file("thumbnail") { false => None, - true => Some("thumbnail".to_string()) + true => Some("thumbnail".to_string()), }; let path; @@ -314,56 +339,58 @@ pub async fn send_message(r: &mut HttpRequestHandler) -> RequestResult { thumbnail = Some("file".to_string()); } - path = r.save_post_image("file", "conversation", MAX_CONV_IMAGE_MESSAGE_WIDTH, MAX_CONV_IMAGE_MESSAGE_HEIGHT)?; + path = r.save_post_image( + "file", + "conversation", + MAX_CONV_IMAGE_MESSAGE_WIDTH, + MAX_CONV_IMAGE_MESSAGE_HEIGHT, + )?; mime_type = "image/png".to_string(); name = "picture.png".to_string(); } - // PDF else if mime_type.eq("application/pdf") { path = r.save_post_pdf("file", "conversation")?; } - // MP3 else if mime_type.eq("audio/mpeg") { path = r.save_post_mp3("file", "conversation")?; } - // MP4 else if mime_type.eq("video/mp4") || mime_type.eq("video/quicktime") { path = r.save_post_mp4("file", "conversation")?; } - // ZIP archive else if mime_type.eq("application/zip") { path = r.save_post_zip("file", "conversation")?; } - // Office document else if mime_type.starts_with("application/") { path = r.save_post_office_doc("file", "conversation")?; } - // Text files else { path = r.save_post_txt_doc("file", "conversation")?; } - // Attempt to save thumbnail, if it fails we can not save message let thumbnail = match thumbnail { None => None, - Some(f) => Some(match r.save_post_image(&f, "conversations-thumb", MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT) { + Some(f) => Some(match r.save_post_image( + &f, + "conversations-thumb", + MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, + MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT, + ) { Ok(s) => Ok(s), Err(e) => { eprintln!("Failed to save conversation thumbnail! {:#?}", e); delete_user_data_file_if_exists(&path).unwrap(); Err(e) } - }?) + }?), }; - Some(ConversationMessageFile { path: path.clone(), size: std::fs::metadata(user_data_path(path.as_ref()))?.len(), @@ -394,7 +421,8 @@ pub async fn send_message(r: &mut HttpRequestHandler) -> RequestResult { message, file, server_message: None, - }).await?; + }) + .await?; r.success("Conversation message was successfully sent!") } @@ -419,10 +447,13 @@ pub async fn delete_conversation(r: &mut HttpRequestHandler) -> RequestResult { let conv = conversations_helper::get_single(conv_membership.conv_id)?; if conv.is_managed() { - r.bad_request("This conversation is managed, it can not be deleted by this way!".to_string())?; + r.bad_request( + "This conversation is managed, it can not be deleted by this way!".to_string(), + )?; } - conversations_helper::remove_user_from_conversation(&r.user_id()?, &conv, r.user_id_ref()?).await?; + conversations_helper::remove_user_from_conversation(&r.user_id()?, &conv, r.user_id_ref()?) + .await?; r.success("The conversation has been deleted") } @@ -469,9 +500,11 @@ pub async fn member_is_writing(r: &mut UserWsRequestHandler) -> RequestResult { let conv_id = r.post_registered_conv_id("convID")?; // Propagate event - events_helper::propagate_event( - Event::UserIsWritingMessageInConversation(r.user_id()?, conv_id) - ).await?; + events_helper::propagate_event(Event::UserIsWritingMessageInConversation( + r.user_id()?, + conv_id, + )) + .await?; r.ok() } @@ -496,14 +529,24 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { Event::UserIsWritingMessageInConversation(user_id, conv_id) => { user_ws_controller::send_message_to_specific_connections( |s| s.conversations.contains(conv_id) && s.user_id() != user_id, - |_| UserWsMessage::no_id_message("writing_message_in_conv", UserIsWritingMessageInConversation::new(user_id, *conv_id)), + |_| { + UserWsMessage::no_id_message( + "writing_message_in_conv", + UserIsWritingMessageInConversation::new(user_id, *conv_id), + ) + }, )?; } Event::NewConversationMessage(msg) => { for conn in user_ws_controller::send_message_to_specific_connections( |f| f.conversations.contains(&msg.conv_id), - |_| UserWsMessage::no_id_message("new_conv_message", ConversationMessageAPI::new(msg)), + |_| { + UserWsMessage::no_id_message( + "new_conv_message", + ConversationMessageAPI::new(msg), + ) + }, )? { conversations_helper::mark_user_seen(msg.conv_id, conn.user_id(), msg).await?; } @@ -512,14 +555,24 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { Event::UpdatedConversationMessage(msg) => { user_ws_controller::send_message_to_specific_connections( |f| f.conversations.contains(&msg.conv_id), - |_| UserWsMessage::no_id_message("updated_conv_message", ConversationMessageAPI::new(msg)), + |_| { + UserWsMessage::no_id_message( + "updated_conv_message", + ConversationMessageAPI::new(msg), + ) + }, )?; } Event::DeleteConversationMessage(msg) => { user_ws_controller::send_message_to_specific_connections( |f| f.conversations.contains(&msg.conv_id), - |_| UserWsMessage::no_id_message("deleted_conv_message", ConversationMessageAPI::new(msg)), + |_| { + UserWsMessage::no_id_message( + "deleted_conv_message", + ConversationMessageAPI::new(msg), + ) + }, )?; } @@ -527,7 +580,12 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { // Notify users user_ws_controller::send_message_to_specific_connections( |f| f.conversations.contains(conv_id), - |_| UserWsMessage::no_id_message("removed_user_from_conv", RemovedUserFromConversationMessage::new(user_id, *conv_id)), + |_| { + UserWsMessage::no_id_message( + "removed_user_from_conv", + RemovedUserFromConversationMessage::new(user_id, *conv_id), + ) + }, )?; // Disconnect user from conversation @@ -565,4 +623,4 @@ pub async fn handle_event(e: &events_helper::Event) -> Res { } Ok(()) -} \ No newline at end of file +} diff --git a/src/controllers/forez_controller.rs b/src/controllers/forez_controller.rs index 6925f64..c570508 100644 --- a/src/controllers/forez_controller.rs +++ b/src/controllers/forez_controller.rs @@ -20,7 +20,10 @@ pub async fn get_list_groups(r: &mut HttpRequestHandler) -> RequestResult { let mut list = vec![]; for group in &conf().forez_groups { - list.push(GroupApi::new(&groups_helper::get_info(group)?, r.user_id_opt())?); + list.push(GroupApi::new( + &groups_helper::get_info(group)?, + r.user_id_opt(), + )?); } r.set_response(list) @@ -150,4 +153,4 @@ pub fn del_day(r: &mut H) -> RequestResult { forez_presence_helper::update(&group, &r.user_id()?, list)?; r.success("Updated presences.") -} \ No newline at end of file +} diff --git a/src/controllers/friends_controller.rs b/src/controllers/friends_controller.rs index 016e1a9..d928a26 100644 --- a/src/controllers/friends_controller.rs +++ b/src/controllers/friends_controller.rs @@ -21,13 +21,9 @@ pub async fn get_list(r: &mut HttpRequestHandler) -> RequestResult { pub async fn get_single_friendship_info(r: &mut HttpRequestHandler) -> RequestResult { let friend_id = r.post_user_id("friendID")?; - let info = friends_helper::GetFriendsQuery::new(&r.user_id()?) - .get_single_friend(&friend_id); + let info = friends_helper::GetFriendsQuery::new(&r.user_id()?).get_single_friend(&friend_id); - let info = r.ok_or_not_found( - info, - "The friendship was not found!", - )?; + let info = r.ok_or_not_found(info, "The friendship was not found!")?; r.set_response(FriendAPI::new(&info)) } @@ -48,7 +44,12 @@ pub async fn get_other_user_list(r: &mut HttpRequestHandler) -> RequestResult { .set_only_accepted(true) .exec()?; - r.set_response(friends.iter().map(|f| f.friend_id.id()).collect::>()) + r.set_response( + friends + .iter() + .map(|f| f.friend_id.id()) + .collect::>(), + ) } /// Get the status of a friendship @@ -85,7 +86,9 @@ pub async fn send_request(r: &mut HttpRequestHandler) -> RequestResult { notifications_helper::create_friends_notification( r.user_id_ref()?, &friend_id, - NotifEventType::SENT_FRIEND_REQUEST).await?; + NotifEventType::SENT_FRIEND_REQUEST, + ) + .await?; r.success("The friendship request was successfully sent!") } @@ -101,7 +104,8 @@ pub async fn cancel_request(r: &mut HttpRequestHandler) -> RequestResult { friends_helper::remove_request(&r.user_id()?, &friend_id)?; // Delete related notifications - notifications_helper::delete_all_related_with_friendship_request(r.user_id_ref()?, &friend_id).await?; + notifications_helper::delete_all_related_with_friendship_request(r.user_id_ref()?, &friend_id) + .await?; r.success("Friendship request removed!") } @@ -123,9 +127,10 @@ pub async fn respond_request(r: &mut HttpRequestHandler) -> RequestResult { &friend_id, match accept { true => NotifEventType::ACCEPTED_FRIEND_REQUEST, - false => NotifEventType::REJECTED_FRIEND_REQUEST + false => NotifEventType::REJECTED_FRIEND_REQUEST, }, - ).await?; + ) + .await?; r.set_response("Response to the friendship request successfully saved!") } @@ -137,7 +142,8 @@ pub async fn remove_friend(r: &mut HttpRequestHandler) -> RequestResult { friends_helper::remove_friendship(r.user_id_ref()?, &friend_id)?; // Delete any related notification - notifications_helper::delete_all_related_with_friendship_request(r.user_id_ref()?, &friend_id).await?; + notifications_helper::delete_all_related_with_friendship_request(r.user_id_ref()?, &friend_id) + .await?; r.success("The friend was removed from the list!") } @@ -160,4 +166,4 @@ pub async fn set_can_post_texts(r: &mut HttpRequestHandler) -> RequestResult { friends_helper::set_can_post_texts(r.user_id_ref()?, &friend_id, allow)?; r.success("Updated status!") -} \ No newline at end of file +} diff --git a/src/controllers/groups_controller.rs b/src/controllers/groups_controller.rs index f82ad11..e39327f 100644 --- a/src/controllers/groups_controller.rs +++ b/src/controllers/groups_controller.rs @@ -12,22 +12,29 @@ use crate::api_data::res_create_conversation_for_group::ResCreateConversationFor use crate::api_data::res_create_group::GroupCreationResult; use crate::constants::{DEFAULT_GROUP_LOGO, PATH_GROUPS_LOGOS}; use crate::data::base_request_handler::BaseRequestHandler; +use crate::data::conversation::Conversation; use crate::data::error::Res; -use crate::data::group::{Group, GroupAccessLevel, GroupPostsCreationLevel, GroupRegistrationLevel, GroupVisibilityLevel}; +use crate::data::group::{ + Group, GroupAccessLevel, GroupPostsCreationLevel, GroupRegistrationLevel, GroupVisibilityLevel, +}; use crate::data::group_id::GroupID; use crate::data::group_member::{GroupMember, GroupMembershipLevel}; use crate::data::http_request_handler::HttpRequestHandler; use crate::data::new_group::NewGroup; use crate::data::notification::NotifEventType; -use crate::helpers::{conversations_helper, groups_helper, notifications_helper, virtual_directory_helper}; use crate::helpers::virtual_directory_helper::VirtualDirType; +use crate::helpers::{ + conversations_helper, groups_helper, notifications_helper, virtual_directory_helper, +}; use crate::routes::RequestResult; use crate::utils::date_utils::time; -use crate::data::conversation::Conversation; impl HttpRequestHandler { /// Get membership level for a conversation - pub fn post_group_membership_level_for_conversation(&mut self, name: &str) -> Res { + pub fn post_group_membership_level_for_conversation( + &mut self, + name: &str, + ) -> Res { let level = GroupMembershipLevel::from_api(&self.post_string(name)?); if !level.is_at_least_member() { @@ -43,7 +50,10 @@ impl HttpRequestHandler { let conv = conversations_helper::get_single(conv_membership.conv_id)?; if !conv.is_linked_to_group() { - self.bad_request("This conversation is not linked to a group, it can not be updated this way!".to_string())?; + self.bad_request( + "This conversation is not linked to a group, it can not be updated this way!" + .to_string(), + )?; } Ok(conv) @@ -89,8 +99,10 @@ pub async fn get_info_multiple(r: &mut HttpRequestHandler) -> RequestResult { for id in groups_id { let id = GroupID::new(id as u64); - if !groups_helper::exists(&id)? || - groups_helper::get_access_level(&id, r.user_id_opt())? < GroupAccessLevel::LIMITED_ACCESS { + if !groups_helper::exists(&id)? + || groups_helper::get_access_level(&id, r.user_id_opt())? + < GroupAccessLevel::LIMITED_ACCESS + { r.not_found(format!("Group {} not found!", id.id()))?; } @@ -132,7 +144,11 @@ pub async fn set_settings(r: &mut HttpRequestHandler) -> RequestResult { posts_creation_level: GroupPostsCreationLevel::from_api(&r.post_string("posts_level")?), is_members_list_public: r.post_bool("is_members_list_public")?, logo: None, - virtual_directory: r.post_checked_virtual_directory_opt("virtual_directory", group_id.id(), VirtualDirType::GROUP)?, + virtual_directory: r.post_checked_virtual_directory_opt( + "virtual_directory", + group_id.id(), + VirtualDirType::GROUP, + )?, time_create: 0, description: r.post_string_without_html_opt("description", 0)?, url: r.post_url_opt("url", false)?, @@ -184,10 +200,13 @@ pub async fn delete_logo(r: &mut HttpRequestHandler) -> RequestResult { /// Create a new group's conversation pub async fn create_conversation(r: &mut HttpRequestHandler) -> RequestResult { let group = r.post_group_id_with_access("group_id", GroupAccessLevel::ADMIN_ACCESS)?; - let min_membership_level = r.post_group_membership_level_for_conversation("min_membership_level")?; + let min_membership_level = + r.post_group_membership_level_for_conversation("min_membership_level")?; let name = r.post_string("name")?; - let conv_id = conversations_helper::create_conversation_for_group(group, min_membership_level, &name).await?; + let conv_id = + conversations_helper::create_conversation_for_group(group, min_membership_level, &name) + .await?; r.set_response(ResCreateConversationForGroup::new(conv_id)) } @@ -218,7 +237,9 @@ pub async fn get_members(r: &mut HttpRequestHandler) -> RequestResult { let group = groups_helper::get_info(&group_id)?; if group_access_level < GroupAccessLevel::VIEW_ACCESS - || (!group.is_members_list_public && group_access_level < GroupAccessLevel::MODERATOR_ACCESS) { + || (!group.is_members_list_public + && group_access_level < GroupAccessLevel::MODERATOR_ACCESS) + { r.forbidden("You can not access the list of members of this group!".to_string())?; } @@ -232,14 +253,17 @@ pub async fn cancel_invitation(r: &mut HttpRequestHandler) -> RequestResult { let group_id = r.post_group_id_with_access("groupID", GroupAccessLevel::MODERATOR_ACCESS)?; let user_id = r.post_user_id("userID")?; - if groups_helper::get_membership_level(&group_id, Some(user_id.clone()))? != GroupMembershipLevel::INVITED { + if groups_helper::get_membership_level(&group_id, Some(user_id.clone()))? + != GroupMembershipLevel::INVITED + { r.forbidden("This user has not been invited to join this group!".to_string())?; } groups_helper::delete_member(&group_id, &user_id).await?; // Delete related notifications - notifications_helper::delete_all_related_to_group_membership_notifications(&user_id, &group_id).await?; + notifications_helper::delete_all_related_to_group_membership_notifications(&user_id, &group_id) + .await?; r.success("Membership invitation has been cancelled!") } @@ -249,7 +273,9 @@ pub async fn invite_user(r: &mut HttpRequestHandler) -> RequestResult { let group_id = r.post_group_id_with_access("group_id", GroupAccessLevel::MODERATOR_ACCESS)?; let user_id = r.post_user_id("userID")?; - if groups_helper::get_membership_level(&group_id, Some(user_id.clone()))? != GroupMembershipLevel::VISITOR { + if groups_helper::get_membership_level(&group_id, Some(user_id.clone()))? + != GroupMembershipLevel::VISITOR + { r.bad_request("The user is not a visitor of the group!".to_string())?; } @@ -257,7 +283,12 @@ pub async fn invite_user(r: &mut HttpRequestHandler) -> RequestResult { // Send a notification notifications_helper::create_group_membership_notification( - &user_id, Some(r.user_id_ref()?), &group_id, NotifEventType::SENT_GROUP_MEMBERSHIP_INVITATION).await?; + &user_id, + Some(r.user_id_ref()?), + &group_id, + NotifEventType::SENT_GROUP_MEMBERSHIP_INVITATION, + ) + .await?; r.success("The user has been successfully invited to join the group!") } @@ -278,10 +309,16 @@ pub async fn respond_invitation(r: &mut HttpRequestHandler) -> RequestResult { } // Create a notification - notifications_helper::create_group_membership_notification(r.user_id_ref()?, None, &group_id, match accept { - true => NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_INVITATION, - false => NotifEventType::REJECTED_GROUP_MEMBERSHIP_INVITATION - }).await?; + notifications_helper::create_group_membership_notification( + r.user_id_ref()?, + None, + &group_id, + match accept { + true => NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_INVITATION, + false => NotifEventType::REJECTED_GROUP_MEMBERSHIP_INVITATION, + }, + ) + .await?; r.success("Response to the invitation was successfully saved!") } @@ -290,7 +327,9 @@ pub async fn respond_invitation(r: &mut HttpRequestHandler) -> RequestResult { pub async fn send_request(r: &mut HttpRequestHandler) -> RequestResult { let group_id = r.post_group_id_with_access("id", GroupAccessLevel::LIMITED_ACCESS)?; - if groups_helper::get_membership_level(&group_id, r.user_id_opt())? != GroupMembershipLevel::VISITOR { + if groups_helper::get_membership_level(&group_id, r.user_id_opt())? + != GroupMembershipLevel::VISITOR + { r.forbidden("You are not currently a visitor of the group!".to_string())?; } @@ -300,7 +339,9 @@ pub async fn send_request(r: &mut HttpRequestHandler) -> RequestResult { GroupRegistrationLevel::OPEN_REGISTRATION => GroupMembershipLevel::MEMBER, GroupRegistrationLevel::MODERATED_REGISTRATION => GroupMembershipLevel::PENDING, GroupRegistrationLevel::CLOSED_REGISTRATION => { - r.forbidden("You are not authorized to send a registration request for this group!".to_string())?; + r.forbidden( + "You are not authorized to send a registration request for this group!".to_string(), + )?; unreachable!(); } }; @@ -312,15 +353,23 @@ pub async fn send_request(r: &mut HttpRequestHandler) -> RequestResult { time_create: time(), level, following: true, - }).await?; + }) + .await?; // Send a notification, if required - if matches!(group.registration_level, GroupRegistrationLevel::MODERATED_REGISTRATION) { - notifications_helper::create_group_membership_notification(r.user_id_ref()?, None, - &group_id, NotifEventType::SENT_GROUP_MEMBERSHIP_REQUEST).await?; + if matches!( + group.registration_level, + GroupRegistrationLevel::MODERATED_REGISTRATION + ) { + notifications_helper::create_group_membership_notification( + r.user_id_ref()?, + None, + &group_id, + NotifEventType::SENT_GROUP_MEMBERSHIP_REQUEST, + ) + .await?; } - r.success("The membership has been successfully saved!") } @@ -328,14 +377,20 @@ pub async fn send_request(r: &mut HttpRequestHandler) -> RequestResult { pub async fn cancel_request(r: &mut HttpRequestHandler) -> RequestResult { let group_id = r.post_group_id_with_access("id", GroupAccessLevel::LIMITED_ACCESS)?; - if groups_helper::get_membership_level(&group_id, r.user_id_opt())? != GroupMembershipLevel::PENDING { + if groups_helper::get_membership_level(&group_id, r.user_id_opt())? + != GroupMembershipLevel::PENDING + { r.forbidden("You did not send a membership request to this group!".to_string())?; } groups_helper::delete_member(&group_id, &r.user_id()?).await?; // Delete any related notification - notifications_helper::delete_all_related_to_group_membership_notifications(r.user_id_ref()?, &group_id).await?; + notifications_helper::delete_all_related_to_group_membership_notifications( + r.user_id_ref()?, + &group_id, + ) + .await?; r.success("The request has been successfully cancelled!") } @@ -356,14 +411,17 @@ pub async fn delete_member(r: &mut HttpRequestHandler) -> RequestResult { } // Only administrator can delete members that are more than members (moderators & administrators) - if membership.level < GroupMembershipLevel::MEMBER && curr_user_membership.level != GroupMembershipLevel::ADMINISTRATOR { + if membership.level < GroupMembershipLevel::MEMBER + && curr_user_membership.level != GroupMembershipLevel::ADMINISTRATOR + { r.forbidden("Only administrators can delete this membership!".to_string())?; } groups_helper::delete_member(&group_id, &user_id).await?; // Delete related notifications - notifications_helper::delete_all_related_to_group_membership_notifications(&user_id, &group_id).await?; + notifications_helper::delete_all_related_to_group_membership_notifications(&user_id, &group_id) + .await?; r.success("Membership of the user has been successfully deleted!") } @@ -400,17 +458,25 @@ pub async fn respond_request(r: &mut HttpRequestHandler) -> RequestResult { let user_id = r.post_user_id("userID")?; let accept = r.post_bool("accept")?; - if groups_helper::get_membership_level(&group_id, Some(user_id.clone()))? != GroupMembershipLevel::PENDING { + if groups_helper::get_membership_level(&group_id, Some(user_id.clone()))? + != GroupMembershipLevel::PENDING + { r.forbidden("This user has not requested a membership for this group!".to_string())?; } groups_helper::respond_request(&group_id, &user_id, accept).await?; // Create a notification - notifications_helper::create_group_membership_notification(&user_id, Some(r.user_id_ref()?), &group_id, match accept { - true => NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_REQUEST, - false => NotifEventType::REJECTED_GROUP_MEMBERSHIP_REQUEST - }).await?; + notifications_helper::create_group_membership_notification( + &user_id, + Some(r.user_id_ref()?), + &group_id, + match accept { + true => NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_REQUEST, + false => NotifEventType::REJECTED_GROUP_MEMBERSHIP_REQUEST, + }, + ) + .await?; r.success("The response to the request has been successfully saved!") } @@ -436,7 +502,11 @@ pub async fn remove_membership(r: &mut HttpRequestHandler) -> RequestResult { groups_helper::delete_member(&group_id, &r.user_id()?).await?; // Delete group membership notifications - notifications_helper::delete_all_related_to_group_membership_notifications(r.user_id_ref()?, &group_id).await?; + notifications_helper::delete_all_related_to_group_membership_notifications( + r.user_id_ref()?, + &group_id, + ) + .await?; r.success("Your membership has been successfully deleted!") } @@ -459,4 +529,4 @@ pub async fn delete_group(r: &mut HttpRequestHandler) -> RequestResult { groups_helper::delete(&group_id).await?; r.success("Group deleted.") -} \ No newline at end of file +} diff --git a/src/controllers/likes_controller.rs b/src/controllers/likes_controller.rs index 9b1cbe5..5328612 100644 --- a/src/controllers/likes_controller.rs +++ b/src/controllers/likes_controller.rs @@ -6,8 +6,8 @@ use crate::data::base_request_handler::BaseRequestHandler; use crate::data::error::ExecError; use crate::data::group::GroupAccessLevel; use crate::data::post::PostAccessLevel; -use crate::helpers::{likes_helper, notifications_helper, user_helper}; use crate::helpers::likes_helper::LikeType; +use crate::helpers::{likes_helper, notifications_helper, user_helper}; use crate::routes::RequestResult; struct LikeTarget(u64, LikeType); @@ -18,7 +18,6 @@ pub async fn update(r: &mut H) -> RequestResult { let is_liking = r.post_bool("like")?; let target = match req_type.as_str() { - // In case of user "user" => { let user_id = r.post_user_id("id")?; @@ -30,13 +29,16 @@ pub async fn update(r: &mut H) -> RequestResult { LikeTarget(user_id.id(), LikeType::USER) } - // In case of post "post" => { let post = r.post_post_with_access("id", PostAccessLevel::BASIC_ACCESS)?; // Delete any notification targeting this user about the post - notifications_helper::delete_all_post_notifications_targeting_user(r.user_id_ref()?, post.id).await?; + notifications_helper::delete_all_post_notifications_targeting_user( + r.user_id_ref()?, + post.id, + ) + .await?; LikeTarget(post.id, LikeType::POST) } @@ -46,7 +48,11 @@ pub async fn update(r: &mut H) -> RequestResult { let comment = r.post_comment_with_access("id")?; // Delete any notification targeting this user about the post - notifications_helper::delete_all_post_notifications_targeting_user(r.user_id_ref()?, comment.post_id).await?; + notifications_helper::delete_all_post_notifications_targeting_user( + r.user_id_ref()?, + comment.post_id, + ) + .await?; LikeTarget(comment.id, LikeType::COMMENT) } @@ -66,4 +72,4 @@ pub async fn update(r: &mut H) -> RequestResult { likes_helper::update(r.user_id_ref()?, is_liking, target.0, target.1)?; r.success("") -} \ No newline at end of file +} diff --git a/src/controllers/mod.rs b/src/controllers/mod.rs index 374c35d..6a5a1d4 100644 --- a/src/controllers/mod.rs +++ b/src/controllers/mod.rs @@ -1,24 +1,24 @@ pub mod admin; -pub mod server_controller; -pub mod user_ws_controller; -pub mod rtc_relay_controller; pub mod account_controller; -pub mod user_controller; -pub mod settings_controller; -pub mod friends_controller; -pub mod conversations_controller; -pub mod search_controller; -pub mod groups_controller; -pub mod posts_controller; -pub mod comments_controller; -pub mod likes_controller; -pub mod surveys_controller; -pub mod notifications_controller; -pub mod virtual_directory_controller; -pub mod web_app_controller; pub mod calls_controller; -pub mod user_ws_actions; +pub mod comments_controller; +pub mod conversations_controller; +pub mod forez_controller; +pub mod friends_controller; +pub mod groups_controller; +pub mod likes_controller; +pub mod notifications_controller; +pub mod posts_controller; pub mod push_notifications_controller; pub mod report_controller; -pub mod forez_controller; +pub mod rtc_relay_controller; +pub mod search_controller; +pub mod server_controller; +pub mod settings_controller; +pub mod surveys_controller; +pub mod user_controller; +pub mod user_ws_actions; +pub mod user_ws_controller; +pub mod virtual_directory_controller; +pub mod web_app_controller; diff --git a/src/controllers/notifications_controller.rs b/src/controllers/notifications_controller.rs index 5fb4c9a..5626567 100644 --- a/src/controllers/notifications_controller.rs +++ b/src/controllers/notifications_controller.rs @@ -5,7 +5,6 @@ use crate::api_data::notification_api::NotificationAPI; use crate::api_data::res_count_all_unreads::ResCountAllUnread; use crate::api_data::res_number_unread_notifications::ResNumberUnreadNotifications; -use crate::routes::RequestResult; use crate::controllers::user_ws_controller; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::error::{Res, ResultBoxError}; @@ -13,8 +12,9 @@ use crate::data::http_request_handler::HttpRequestHandler; use crate::data::notification::Notification; use crate::data::user::UserID; use crate::data::user_ws_message::UserWsMessage; -use crate::helpers::{conversations_helper, events_helper, friends_helper, notifications_helper}; use crate::helpers::events_helper::Event; +use crate::helpers::{conversations_helper, events_helper, friends_helper, notifications_helper}; +use crate::routes::RequestResult; impl HttpRequestHandler { /// Get the id of a notification included in the request @@ -46,10 +46,14 @@ pub async fn count_all_news(r: &mut HttpRequestHandler) -> RequestResult { let conversations = conversations_helper::count_unread_for_user(r.user_id_ref()?)?; let friends_requests = match r.post_bool_opt("friends_request", false) { true => Some(friends_helper::count_requests(r.user_id_ref()?)?), - false => None + false => None, }; - r.set_response(ResCountAllUnread::new(notifications, conversations as u64, friends_requests)) + r.set_response(ResCountAllUnread::new( + notifications, + conversations as u64, + friends_requests, + )) } /// Get the list of unread notifications @@ -92,7 +96,10 @@ pub fn send_new_notifications_number(user_id: &UserID) -> Res { } user_ws_controller::send_message_to_user( - &UserWsMessage::no_id_message("number_notifs", notifications_helper::count_unread(user_id)?)?, + &UserWsMessage::no_id_message( + "number_notifs", + notifications_helper::count_unread(user_id)?, + )?, user_id, ) } @@ -109,4 +116,4 @@ pub fn handle_event(e: &events_helper::Event) -> Res { } Ok(()) -} \ No newline at end of file +} diff --git a/src/controllers/posts_controller.rs b/src/controllers/posts_controller.rs index 9ab852d..a5e5f16 100644 --- a/src/controllers/posts_controller.rs +++ b/src/controllers/posts_controller.rs @@ -12,8 +12,12 @@ use crate::data::group::GroupAccessLevel; use crate::data::http_request_handler::HttpRequestHandler; use crate::data::new_survey::NewSurvey; use crate::data::notification::NotifEventType; -use crate::data::post::{Post, PostAccessLevel, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink}; -use crate::helpers::{friends_helper, groups_helper, notifications_helper, posts_helper, survey_helper, user_helper}; +use crate::data::post::{ + Post, PostAccessLevel, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink, +}; +use crate::helpers::{ + friends_helper, groups_helper, notifications_helper, posts_helper, survey_helper, user_helper, +}; use crate::routes::RequestResult; use crate::utils::date_utils::time; use crate::utils::string_utils::{check_string_before_insert, check_youtube_id}; @@ -96,7 +100,8 @@ pub async fn create_post(r: &mut HttpRequestHandler) -> RequestResult { } "group" => { - let group_id = r.post_group_id_with_access("kind-id", GroupAccessLevel::MEMBER_ACCESS)?; + let group_id = + r.post_group_id_with_access("kind-id", GroupAccessLevel::MEMBER_ACCESS)?; if !groups_helper::can_user_create_posts(&group_id, r.user_id_ref()?)? { r.forbidden("You are not allowed to create posts on this group!".to_string())?; @@ -126,7 +131,6 @@ pub async fn create_post(r: &mut HttpRequestHandler) -> RequestResult { // Handle different post types post.kind = match r.post_string("kind")?.as_str() { - // Text posts "text" => { if !check_string_before_insert(post.content.as_ref().unwrap_or(&String::new())) { @@ -136,7 +140,6 @@ pub async fn create_post(r: &mut HttpRequestHandler) -> RequestResult { PostKind::POST_KIND_TEXT } - // Image post "image" => { if !r.has_file("image") { @@ -161,7 +164,8 @@ pub async fn create_post(r: &mut HttpRequestHandler) -> RequestResult { // Weblink posts "weblink" => { - let url = r.post_url_opt("url", true)? + let url = r + .post_url_opt("url", true)? .ok_or(ExecError::new("Missing url!"))?; match get_post_web_link(&url) { @@ -203,7 +207,8 @@ pub async fn create_post(r: &mut HttpRequestHandler) -> RequestResult { post_id: 0, user_id: r.user_id()?, question: r.post_string("question")?, - choices: r.post_string("answers")? + choices: r + .post_string("answers")? .split("<>") .filter(|a| a.len() > 0) .map(|a| a.to_string()) @@ -235,7 +240,12 @@ pub async fn create_post(r: &mut HttpRequestHandler) -> RequestResult { } // Create a notification - notifications_helper::create_post_notification(r.user_id_ref()?, post_id, NotifEventType::ELEM_CREATED).await?; + notifications_helper::create_post_notification( + r.user_id_ref()?, + post_id, + NotifEventType::ELEM_CREATED, + ) + .await?; r.set_response(ResCreatePost::new(post_id)) } @@ -263,7 +273,8 @@ pub async fn update_content(r: &mut HttpRequestHandler) -> RequestResult { posts_helper::set_content(post.id, &new_content)?; // Delete the notifications targeting the current user about this post - notifications_helper::delete_all_post_notifications_targeting_user(r.user_id_ref()?, post.id).await?; + notifications_helper::delete_all_post_notifications_targeting_user(r.user_id_ref()?, post.id) + .await?; r.success("Content updated") } @@ -283,4 +294,4 @@ pub async fn get_targets(r: &mut HttpRequestHandler) -> RequestResult { let groups = groups_helper::get_list_where_user_can_create_posts(r.user_id_ref()?)?; r.set_response(PostsTargets::new(&friends, &groups)) -} \ No newline at end of file +} diff --git a/src/controllers/push_notifications_controller.rs b/src/controllers/push_notifications_controller.rs index 74f7b77..f4b6413 100644 --- a/src/controllers/push_notifications_controller.rs +++ b/src/controllers/push_notifications_controller.rs @@ -12,7 +12,11 @@ use crate::routes::RequestResult; /// Get current push notifications status for a connection pub async fn get_status(r: &mut HttpRequestHandler) -> RequestResult { - let status = &r.user_access_token().unwrap().push_notifications_token.clone(); + let status = &r + .user_access_token() + .unwrap() + .push_notifications_token + .clone(); r.set_response(PushNotificationsStatusAPI::new(status)) } @@ -50,4 +54,4 @@ pub async fn configure(r: &mut HttpRequestHandler) -> RequestResult { account_helper::set_push_notification_token(r.user_access_token().unwrap(), status).await?; r.ok() -} \ No newline at end of file +} diff --git a/src/controllers/report_controller.rs b/src/controllers/report_controller.rs index 7c37f8c..2fac303 100644 --- a/src/controllers/report_controller.rs +++ b/src/controllers/report_controller.rs @@ -6,7 +6,7 @@ use crate::data::config::conf; use crate::data::group::GroupAccessLevel; use crate::data::http_request_handler::HttpRequestHandler; use crate::data::post::PostAccessLevel; -use crate::data::report::{Report, REPORT_CAUSES, ReportID, ReportTarget}; +use crate::data::report::{Report, ReportID, ReportTarget, REPORT_CAUSES}; use crate::helpers::reports_helper; use crate::routes::RequestResult; use crate::utils::date_utils::time; @@ -29,29 +29,23 @@ pub async fn report(r: &mut HttpRequestHandler) -> RequestResult { )?; let target = match r.post_string("target_type")?.as_str() { - "post" => - ReportTarget::Post( - r.post_post_with_access("target_id", PostAccessLevel::BASIC_ACCESS)?.id - ), - - "comment" => ReportTarget::Comment( - r.post_comment_with_access("target_id")?.id + "post" => ReportTarget::Post( + r.post_post_with_access("target_id", PostAccessLevel::BASIC_ACCESS)? + .id, ), - "conversation" => ReportTarget::Conversation( - r.post_conv("target_id")?.conv_id - ), + "comment" => ReportTarget::Comment(r.post_comment_with_access("target_id")?.id), - "conversation_message" => ReportTarget::ConversationMessage( - r.post_conv_message_id("target_id")?.id - ), + "conversation" => ReportTarget::Conversation(r.post_conv("target_id")?.conv_id), - "user" => ReportTarget::User( - r.post_user_id("target_id")? - ), + "conversation_message" => { + ReportTarget::ConversationMessage(r.post_conv_message_id("target_id")?.id) + } + + "user" => ReportTarget::User(r.post_user_id("target_id")?), "group" => ReportTarget::Group( - r.post_group_id_with_access("target_id", GroupAccessLevel::LIMITED_ACCESS)? + r.post_group_id_with_access("target_id", GroupAccessLevel::LIMITED_ACCESS)?, ), _ => { @@ -71,7 +65,10 @@ pub async fn report(r: &mut HttpRequestHandler) -> RequestResult { // Check for duplicate if reports_helper::already_exists(&report)? { - r.set_error(HttpError::new(409, "You have already submitted a report for this resource!")); + r.set_error(HttpError::new( + 409, + "You have already submitted a report for this resource!", + )); return Ok(()); } @@ -79,4 +76,4 @@ pub async fn report(r: &mut HttpRequestHandler) -> RequestResult { let report_id = reports_helper::save_report(report)?; r.set_response(SubmitReportResultApi::new(report_id)) -} \ No newline at end of file +} diff --git a/src/controllers/rtc_relay_controller.rs b/src/controllers/rtc_relay_controller.rs index fbb4b38..20e2fe0 100644 --- a/src/controllers/rtc_relay_controller.rs +++ b/src/controllers/rtc_relay_controller.rs @@ -2,8 +2,8 @@ //! //! @author Pierre Hubert -use actix::{ActorContext, Addr, AsyncContext, Handler, StreamHandler}; use actix::prelude::*; +use actix::{ActorContext, Addr, AsyncContext, Handler, StreamHandler}; use actix_http::ws::Item; use actix_web_actors::ws::{Message, ProtocolError}; use serde::{Deserialize, Serialize}; @@ -90,13 +90,16 @@ impl actix::Actor for RtcRelayActor { println!("Started new WebSocket connection to RTC relay!"); // Send calls configuration to server - ctx.text(serde_json::to_string(&CallsConfigWrapper { - title: "config".to_string(), - data: CallsConfig { - allowVideo: conf().rtc_relay.as_ref().unwrap().allow_video, - iceServers: conf().rtc_relay.as_ref().unwrap().ice_servers.clone(), - }, - }).unwrap()) + ctx.text( + serde_json::to_string(&CallsConfigWrapper { + title: "config".to_string(), + data: CallsConfig { + allowVideo: conf().rtc_relay.as_ref().unwrap().allow_video, + iceServers: conf().rtc_relay.as_ref().unwrap().ice_servers.clone(), + }, + }) + .unwrap(), + ) } fn stopping(&mut self, _: &mut Self::Context) -> Running { @@ -136,14 +139,16 @@ impl RtcRelayActor { } } -impl StreamHandler> for RtcRelayActor { +impl StreamHandler> + for RtcRelayActor +{ fn handle(&mut self, msg: Result, ctx: &mut Self::Context) { let msg = match msg { Err(_) => { ctx.stop(); return; } - Ok(msg) => msg + Ok(msg) => msg, }; if conf().verbose_mode { @@ -201,7 +206,8 @@ async fn process_message_from_relay(msg: &RTCSocketMessage) -> Res { peer_id: msg.peerId.clone().unwrap_or("0".to_string()), data: serde_json::to_string(msg.data.as_ref().unwrap_or(&Value::Null)) .unwrap_or("failed to serialize signal data".to_string()), - })).await?; + })) + .await?; } title => { @@ -217,27 +223,22 @@ impl Handler for RtcRelayActor { fn handle(&mut self, msg: RTCMessages, ctx: &mut Self::Context) -> Self::Result { match msg { - // Close connection - RTCMessages::Close => { - ctx.close(None) - } + RTCMessages::Close => ctx.close(None), // Send message - RTCMessages::SendMessage(msg) => { - match serde_json::to_string(&msg) { - Ok(txt) => { - if conf().verbose_mode { - println!("API => RTC WS : {}", txt); - } + RTCMessages::SendMessage(msg) => match serde_json::to_string(&msg) { + Ok(txt) => { + if conf().verbose_mode { + println!("API => RTC WS : {}", txt); + } - ctx.text(txt) - } - Err(e) => { - eprintln!("Failed to send message to RTC relay ! {:#?}", e); - } + ctx.text(txt) } - } + Err(e) => { + eprintln!("Failed to send message to RTC relay ! {:#?}", e); + } + }, } } } @@ -270,13 +271,18 @@ pub fn is_connected() -> bool { /// ws.onerror = (e) => console.log("WS ERROR !", e); /// ws.onclose = (e) => console.log("WS CLOSED!"); /// ``` -pub async fn open_ws(req: actix_web::HttpRequest, - stream: actix_web::web::Payload) -> Result { +pub async fn open_ws( + req: actix_web::HttpRequest, + stream: actix_web::web::Payload, +) -> Result { let ip = req.peer_addr().unwrap(); // Check if video calls are enabled if !conf().is_rtc_relay_enabled() { - eprintln!("A relay from {} tried to connect to the server but the relay is disabled!", ip); + eprintln!( + "A relay from {} tried to connect to the server but the relay is disabled!", + ip + ); return Ok(actix_web::HttpResponse::BadRequest().body("RTC Relay not configured!")); } @@ -284,13 +290,19 @@ pub async fn open_ws(req: actix_web::HttpRequest, // Check remote IP address if !match_ip(&conf.ip, ip.ip().to_string().as_str()) { - eprintln!("A relay from {} tried to connect to the server but the IP address is not authorized!", ip); + eprintln!( + "A relay from {} tried to connect to the server but the IP address is not authorized!", + ip + ); return Ok(actix_web::HttpResponse::Unauthorized().body("Access denied!")); } // Check the token if !req.query_string().eq(&format!("token={}", &conf.token)) { - eprintln!("A relay from {} tried to connect with an invalid access token!", ip); + eprintln!( + "A relay from {} tried to connect with an invalid access token!", + ip + ); return Ok(actix_web::HttpResponse::Unauthorized().body("Invalid token!")); } @@ -304,9 +316,12 @@ pub async fn open_ws(req: actix_web::HttpRequest, } /// Send a message to the relay -fn send_message_to_relay(e: T) -> Res where T: Serialize { - let conn = get_active_connection() - .ok_or(ExecError::boxed_new("Connection to RTC relay missing!"))?; +fn send_message_to_relay(e: T) -> Res +where + T: Serialize, +{ + let conn = + get_active_connection().ok_or(ExecError::boxed_new("Connection to RTC relay missing!"))?; conn.do_send(RTCMessages::SendMessage(serde_json::to_value(e)?)); @@ -320,12 +335,18 @@ pub fn handle_event(e: &events_helper::Event) -> Res { send_message_to_relay(CallUserSignal { title: "signal".to_string(), callHash: signal.call_hash.to_string(), - peerId: signal.user_id.as_ref().map(|i| i.id()).unwrap_or(0).to_string(), + peerId: signal + .user_id + .as_ref() + .map(|i| i.id()) + .unwrap_or(0) + .to_string(), data: CallUserSignalData { r#type: match signal.signal { CallSignal::SDP(_, _, _) => "SDP", CallSignal::Candidate(_, _) => "CANDIDATE", - }.to_string(), + } + .to_string(), data: serde_json::from_str(&signal.raw_data)?, }, })?; @@ -345,7 +366,7 @@ pub fn handle_event(e: &events_helper::Event) -> Res { callHash: request.call_hash.to_string(), peerId: match &request.peer_id { None => "0".to_string(), - Some(id) => id.id().to_string() + Some(id) => id.id().to_string(), }, })?; } @@ -354,4 +375,4 @@ pub fn handle_event(e: &events_helper::Event) -> Res { } Ok(()) -} \ No newline at end of file +} diff --git a/src/controllers/search_controller.rs b/src/controllers/search_controller.rs index 8c9b877..610efff 100644 --- a/src/controllers/search_controller.rs +++ b/src/controllers/search_controller.rs @@ -3,11 +3,11 @@ //! @author Pierre Hubert use crate::api_data::global_search_result_api::GlobalSearchResultAPI; -use crate::routes::RequestResult; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::global_search_result::GlobalSearchResult; use crate::data::http_request_handler::HttpRequestHandler; use crate::helpers::{groups_helper, user_helper}; +use crate::routes::RequestResult; /// Search for user pub async fn search_user(r: &mut HttpRequestHandler) -> RequestResult { @@ -32,11 +32,12 @@ pub async fn search_global(r: &mut HttpRequestHandler) -> RequestResult { .map(|f| GlobalSearchResult::User(f.clone())) .collect::>(); - list.append(&mut groups_helper::search_group(&query, limit)? - .iter() - .map(|f| GlobalSearchResult::Group(f.clone())) - .collect::>()); - + list.append( + &mut groups_helper::search_group(&query, limit)? + .iter() + .map(|f| GlobalSearchResult::Group(f.clone())) + .collect::>(), + ); r.set_response(GlobalSearchResultAPI::for_list(&list)) -} \ No newline at end of file +} diff --git a/src/controllers/server_controller.rs b/src/controllers/server_controller.rs index 00150b1..c1a94cd 100644 --- a/src/controllers/server_controller.rs +++ b/src/controllers/server_controller.rs @@ -15,4 +15,4 @@ pub async fn main_index(request: &mut HttpRequestHandler) -> RequestResult { /// Get server configuration pub async fn get_config(request: &mut HttpRequestHandler) -> RequestResult { request.set_response(ServerConfig::new(request.api_client())) -} \ No newline at end of file +} diff --git a/src/controllers/settings_controller.rs b/src/controllers/settings_controller.rs index 34488d5..c4e361f 100644 --- a/src/controllers/settings_controller.rs +++ b/src/controllers/settings_controller.rs @@ -9,8 +9,8 @@ use crate::api_data::language_settings_api::LanguageSettingsAPI; use crate::api_data::notification_settings_api::NotificationSettingsAPI; use crate::api_data::res_create_custom_emoji::ResCreateCustomEmoji; use crate::api_data::security_settings_api::SecuritySettingsAPI; -use crate::constants::{conservation_policy, SUPPORTED_LANGUAGES}; use crate::constants::accounts_info_policy::{MIN_FIRST_NAME_LENGTH, MIN_LAST_NAME_LENGTH}; +use crate::constants::{conservation_policy, SUPPORTED_LANGUAGES}; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::general_settings::GeneralSettings; use crate::data::http_request_handler::HttpRequestHandler; @@ -20,8 +20,8 @@ use crate::data::new_data_conservation_policy::NewDataConservationPolicy; use crate::data::new_notifications_settings::NewNotificationsSettings; use crate::data::security_settings::{SecurityQuestion, SecuritySettings}; use crate::data::user::{AccountImageVisibility, UserPageVisibility}; -use crate::helpers::{account_helper, custom_emojies_helper, user_helper}; use crate::helpers::virtual_directory_helper::VirtualDirType; +use crate::helpers::{account_helper, custom_emojies_helper, user_helper}; use crate::routes::RequestResult; use crate::utils::string_utils::remove_html_nodes; @@ -43,7 +43,10 @@ pub async fn set_general(r: &mut HttpRequestHandler) -> RequestResult { let personal_website = r.post_url_opt("personnalWebsite", false)?; let virtual_directory = r.post_checked_virtual_directory_opt( - "virtualDirectory", r.user_id_ref()?.id(), VirtualDirType::USER)?; + "virtualDirectory", + r.user_id_ref()?.id(), + VirtualDirType::USER, + )?; let new_settings = GeneralSettings { id: r.user_id()?, @@ -58,7 +61,9 @@ pub async fn set_general(r: &mut HttpRequestHandler) -> RequestResult { virtual_directory, allow_mails: r.post_bool("allow_comunic_mails")?, public_note: Some(r.post_content("publicNote", 0, false)?), - location: r.post_string_optional("location").map(|s| remove_html_nodes(&s)), + location: r + .post_string_optional("location") + .map(|s| remove_html_nodes(&s)), }; account_helper::set_general(&new_settings)?; @@ -229,33 +234,57 @@ pub async fn set_data_conservation_policy(r: &mut HttpRequestHandler) -> Request delete_notifications_after: r.post_positive_u64_opt("notification_lifetime")?, delete_comments_after: r.post_positive_u64_opt("comments_lifetime")?, delete_posts_after: r.post_positive_u64_opt("posts_lifetime")?, - delete_conversation_messages_after: r.post_positive_u64_opt("conversation_messages_lifetime")?, + delete_conversation_messages_after: r + .post_positive_u64_opt("conversation_messages_lifetime")?, delete_likes_after: r.post_positive_u64_opt("likes_lifetime")?, }; - // Check policy is respected - if policy.delete_account_after.map(|f| f < conservation_policy::MIN_INACTIVE_ACCOUNT_LIFETIME.as_secs()) == Some(true) { + if policy + .delete_account_after + .map(|f| f < conservation_policy::MIN_INACTIVE_ACCOUNT_LIFETIME.as_secs()) + == Some(true) + { r.bad_request("Invalid lifetime for inactive account !".to_string())?; } - if policy.delete_notifications_after.map(|f| f < conservation_policy::MIN_NOTIFICATIONS_LIFETIME.as_secs()) == Some(true) { + if policy + .delete_notifications_after + .map(|f| f < conservation_policy::MIN_NOTIFICATIONS_LIFETIME.as_secs()) + == Some(true) + { r.bad_request("Invalid lifetime for notifications !".to_string())?; } - if policy.delete_comments_after.map(|f| f < conservation_policy::MIN_COMMENTS_LIFETIME.as_secs()) == Some(true) { + if policy + .delete_comments_after + .map(|f| f < conservation_policy::MIN_COMMENTS_LIFETIME.as_secs()) + == Some(true) + { r.bad_request("Invalid lifetime for comments !".to_string())?; } - if policy.delete_posts_after.map(|f| f < conservation_policy::MIN_POSTS_LIFETIME.as_secs()) == Some(true) { + if policy + .delete_posts_after + .map(|f| f < conservation_policy::MIN_POSTS_LIFETIME.as_secs()) + == Some(true) + { r.bad_request("Invalid lifetime for posts !".to_string())?; } - if policy.delete_conversation_messages_after.map(|f| f < conservation_policy::MIN_CONVERSATION_MESSAGES_LIFETIME.as_secs()) == Some(true) { + if policy + .delete_conversation_messages_after + .map(|f| f < conservation_policy::MIN_CONVERSATION_MESSAGES_LIFETIME.as_secs()) + == Some(true) + { r.bad_request("Invalid lifetime for conversation messages !".to_string())?; } - if policy.delete_likes_after.map(|f| f < conservation_policy::MIN_LIKES_LIFETIME.as_secs()) == Some(true) { + if policy + .delete_likes_after + .map(|f| f < conservation_policy::MIN_LIKES_LIFETIME.as_secs()) + == Some(true) + { r.bad_request("Invalid lifetime for likes !".to_string())?; } @@ -280,4 +309,4 @@ pub async fn set_notifications(r: &mut HttpRequestHandler) -> RequestResult { })?; r.ok() -} \ No newline at end of file +} diff --git a/src/controllers/surveys_controller.rs b/src/controllers/surveys_controller.rs index f8c77d5..b63a583 100644 --- a/src/controllers/surveys_controller.rs +++ b/src/controllers/surveys_controller.rs @@ -4,16 +4,20 @@ use crate::api_data::survey_api::SurveyAPI; use crate::constants::MAXIMUM_NUMBER_SURVEY_CHOICES; -use crate::routes::RequestResult; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::error::ResultBoxError; use crate::data::http_request_handler::HttpRequestHandler; use crate::data::post::PostAccessLevel; use crate::helpers::survey_helper; +use crate::routes::RequestResult; impl HttpRequestHandler { /// Get the ID of a survey associated to a post whose ID was specified in the request - fn post_survey_id_from_post_id(&mut self, name: &str, min_level: PostAccessLevel) -> ResultBoxError { + fn post_survey_id_from_post_id( + &mut self, + name: &str, + min_level: PostAccessLevel, + ) -> ResultBoxError { let post = self.post_post_with_access(name, min_level)?; survey_helper::get_id(post.id) } @@ -66,8 +70,12 @@ pub async fn create_new_choice(r: &mut HttpRequestHandler) -> RequestResult { } // Check for similar choices - if survey.choices.iter().find( - |c| c.name.to_lowercase().eq(&new_choice.to_lowercase())).is_some() { + if survey + .choices + .iter() + .find(|c| c.name.to_lowercase().eq(&new_choice.to_lowercase())) + .is_some() + { r.forbidden("This choice already exists!".to_string())?; } @@ -88,4 +96,4 @@ pub async fn block_new_choices_creation(r: &mut HttpRequestHandler) -> RequestRe survey_helper::block_new_choices_creation(survey_id)?; r.success("") -} \ No newline at end of file +} diff --git a/src/controllers/user_controller.rs b/src/controllers/user_controller.rs index b240953..f176af5 100644 --- a/src/controllers/user_controller.rs +++ b/src/controllers/user_controller.rs @@ -7,12 +7,12 @@ use std::collections::HashMap; use crate::api_data::user_info::APIUserInfo; -use crate::routes::RequestResult; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::http_request_handler::HttpRequestHandler; use crate::data::user::UserID; use crate::helpers::user_helper; use crate::helpers::user_helper::find_user_by_id; +use crate::routes::RequestResult; /// Get information about a single user pub async fn get_single(request: &mut HttpRequestHandler) -> RequestResult { @@ -42,7 +42,10 @@ pub async fn get_multiple(request: &mut HttpRequestHandler) -> RequestResult { "At least one user was not found!", )?; - map.insert(user_id.id(), APIUserInfo::new(&request.user_id_opt(), &user)?); + map.insert( + user_id.id(), + APIUserInfo::new(&request.user_id_opt(), &user)?, + ); } request.set_response(map) @@ -52,10 +55,14 @@ pub async fn get_multiple(request: &mut HttpRequestHandler) -> RequestResult { pub async fn get_advanced_info(request: &mut HttpRequestHandler) -> RequestResult { let user_id = request.post_user_id("userID")?; - if !user_helper::can_see_user_page(&request.user_id_opt().unwrap_or(UserID::new(0)), &user_id)? { + if !user_helper::can_see_user_page(&request.user_id_opt().unwrap_or(UserID::new(0)), &user_id)? + { request.forbidden("You are not allowed to see this user page!".to_string())?; } let user = user_helper::find_user_by_id(&user_id)?; - request.set_response(APIUserInfo::new_advanced_info(&request.user_id_opt(), &user)?) -} \ No newline at end of file + request.set_response(APIUserInfo::new_advanced_info( + &request.user_id_opt(), + &user, + )?) +} diff --git a/src/controllers/user_ws_actions.rs b/src/controllers/user_ws_actions.rs index 6b1e488..3cd053b 100644 --- a/src/controllers/user_ws_actions.rs +++ b/src/controllers/user_ws_actions.rs @@ -3,10 +3,10 @@ //! This module contains all the base action that can be executed by the WebSocket use crate::data::base_request_handler::BaseRequestHandler; +use crate::data::conversation::ConvID; use crate::data::error::Res; use crate::data::post::PostAccessLevel; use crate::data::user_ws_request_handler::UserWsRequestHandler; -use crate::data::conversation::ConvID; /// Update incognito status of the connection pub fn set_incognito(r: &mut UserWsRequestHandler) -> Res { @@ -19,27 +19,35 @@ pub fn set_incognito(r: &mut UserWsRequestHandler) -> Res { /// Register a conversation pub fn register_conv(r: &mut UserWsRequestHandler) -> Res { let conv_id = r.post_conv("convID")?.conv_id; - r.update_conn(|c| { c.conversations.insert(conv_id); })?; + r.update_conn(|c| { + c.conversations.insert(conv_id); + })?; r.success("ok") } /// Un-register a conversation pub fn unregister_conv(r: &mut UserWsRequestHandler) -> Res { let conv_id = ConvID::new(r.post_u64("convID")?); - r.update_conn(|c| { c.conversations.remove(&conv_id); })?; + r.update_conn(|c| { + c.conversations.remove(&conv_id); + })?; r.success("ok") } /// Register a post pub fn register_post(r: &mut UserWsRequestHandler) -> Res { let post = r.post_post_with_access("postID", PostAccessLevel::BASIC_ACCESS)?; - r.update_conn(|c| { c.posts.insert(post.id); })?; + r.update_conn(|c| { + c.posts.insert(post.id); + })?; r.success("ok") } /// Un-register a post pub fn unregister_post(r: &mut UserWsRequestHandler) -> Res { let post_id = r.post_u64("postID")?; - r.update_conn(|c| { c.posts.remove(&post_id); })?; + r.update_conn(|c| { + c.posts.remove(&post_id); + })?; r.success("ok") -} \ No newline at end of file +} diff --git a/src/controllers/user_ws_controller.rs b/src/controllers/user_ws_controller.rs index e4bfa6a..8c6a0bd 100644 --- a/src/controllers/user_ws_controller.rs +++ b/src/controllers/user_ws_controller.rs @@ -5,15 +5,17 @@ use std::collections::{HashMap, HashSet}; use std::time::{Duration, Instant}; -use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, Running, StreamHandler}; use actix::prelude::*; +use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, Running, StreamHandler}; use actix_web_actors::ws; use actix_web_actors::ws::ProtocolError; use serde_json::Value; use crate::api_data::res_get_ws_token::ResGetWsToken; use crate::constants::{USER_LAST_ACTIVITY_REFRESH, WS_ACCESS_TOKEN_LENGTH}; -use crate::controllers::user_ws_controller::ws_connections_list::{add_connection, find_connection, get_ws_connections_list, remove_connection}; +use crate::controllers::user_ws_controller::ws_connections_list::{ + add_connection, find_connection, get_ws_connections_list, remove_connection, +}; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::config::conf; use crate::data::error::{ExecError, Res, ResultBoxError}; @@ -23,8 +25,8 @@ use crate::data::user_token::UserAccessToken; use crate::data::user_ws_connection::UserWsConnection; use crate::data::user_ws_message::UserWsMessage; use crate::data::user_ws_request_handler::{UserWsRequestHandler, UserWsResponseType}; -use crate::helpers::{account_helper, events_helper}; use crate::helpers::events_helper::Event; +use crate::helpers::{account_helper, events_helper}; use crate::user_ws_routes::exec_user_ws_route; use crate::utils::crypt_utils::rand_str; use crate::utils::date_utils::time; @@ -54,9 +56,7 @@ mod ws_tokens_list { } lazy_static! { - static ref WS_TOKENS: Arc>> = { - Arc::new(Mutex::new(Vec::new())) - }; + static ref WS_TOKENS: Arc>> = Arc::new(Mutex::new(Vec::new())); } /// Get the list of WebSocket tokens @@ -109,7 +109,10 @@ mod ws_connections_list { impl UserWsConnection { /// Change some of the properties of the connection - pub fn replace(mut self, do_update: H) -> Self where H: FnOnce(&mut Self) { + pub fn replace(mut self, do_update: H) -> Self + where + H: FnOnce(&mut Self), + { let list = get_ws_connections_list(); let mut list = list.lock().unwrap(); @@ -131,9 +134,8 @@ mod ws_connections_list { } lazy_static! { - static ref WS_CONNECTIONS: Arc>> = { - Arc::new(Mutex::new(Vec::new())) - }; + static ref WS_CONNECTIONS: Arc>> = + Arc::new(Mutex::new(Vec::new())); } /// Get the list of WebSocket connections @@ -230,14 +232,23 @@ impl WsSession { /// Helper method that update user last activity at every specified amount of time fn user_activity(&self, ctx: &mut actix_web_actors::ws::WebsocketContext) { - if !self.incognito && account_helper::update_last_activity(&self.user_token.user_id).is_err() { - eprintln!("Failed to do initial refresh of last activity for user {} !", self.user_token.user_id.id()); + if !self.incognito + && account_helper::update_last_activity(&self.user_token.user_id).is_err() + { + eprintln!( + "Failed to do initial refresh of last activity for user {} !", + self.user_token.user_id.id() + ); } ctx.run_interval(USER_LAST_ACTIVITY_REFRESH, |_, ctx| { if let Some(conn) = find_connection(ctx.address()) { - if !conn.incognito && account_helper::update_last_activity(conn.user_id()).is_err() { - eprintln!("Failed to refresh last activity for user {} !", conn.user_id().id()); + if !conn.incognito && account_helper::update_last_activity(conn.user_id()).is_err() + { + eprintln!( + "Failed to refresh last activity for user {} !", + conn.user_id().id() + ); } } }); @@ -247,18 +258,23 @@ impl WsSession { async fn handle_message(addr: Addr, msg: &str) -> Res { let incoming_msg: UserWsMessage = serde_json::from_str(&msg)?; - let data = incoming_msg.data.as_object() + let data = incoming_msg + .data + .as_object() .ok_or(ExecError::boxed_new("Could not parse values!"))?; let mut args = HashMap::new(); for (k, v) in data { - args.insert(k.to_string(), match v { - Value::Null => "null".to_string(), - Value::Bool(b) => b.to_string(), - Value::Number(n) => n.to_string(), - Value::String(s) => s.to_string(), - _ => "invalid".to_string() - }); + args.insert( + k.to_string(), + match v { + Value::Null => "null".to_string(), + Value::Bool(b) => b.to_string(), + Value::Number(n) => n.to_string(), + Value::String(s) => s.to_string(), + _ => "invalid".to_string(), + }, + ); } let mut handler = UserWsRequestHandler::new( @@ -268,7 +284,7 @@ impl WsSession { let result = match exec_user_ws_route(&incoming_msg.title, &mut handler).await { None => handler.not_found("Route not found!".to_string()), - Some(r) => r + Some(r) => r, }; if !handler.has_response() { @@ -343,8 +359,7 @@ impl StreamHandler> for WsSession { Ok(msg) => msg, }; - if conf().verbose_mode - { + if conf().verbose_mode { println!("USER WEBSOCKET MESSAGE: {:?}", msg); } @@ -382,9 +397,7 @@ impl StreamHandler> for WsSession { future.into_actor(self).spawn(ctx); } - ws::Message::Binary(_) => { - ctx.text("WS is text only!") - } + ws::Message::Binary(_) => ctx.text("WS is text only!"), ws::Message::Close(_) => { ctx.stop(); @@ -394,7 +407,7 @@ impl StreamHandler> for WsSession { ctx.stop(); } - ws::Message::Nop => () + ws::Message::Nop => (), } } } @@ -407,7 +420,6 @@ pub struct WsQueuedMessage(String); #[rtype(result = "()")] pub struct WsCloseConnection(); - impl Handler for WsSession { type Result = (); @@ -424,7 +436,6 @@ impl Handler for WsSession { } } - /// Main WebSocket route pub async fn ws_route( req: actix_web::HttpRequest, @@ -501,9 +512,13 @@ pub fn send_to_client(conn: &UserWsConnection, msg: &UserWsMessage) -> Res { } /// Send a message to specific users -pub fn send_message_to_specific_connections(filter: F, msg_generator: M) -> Res> - where F: Fn(&UserWsConnection) -> bool, - M: Fn(&UserWsConnection) -> Res +pub fn send_message_to_specific_connections( + filter: F, + msg_generator: M, +) -> Res> +where + F: Fn(&UserWsConnection) -> bool, + M: Fn(&UserWsConnection) -> Res, { let connections = get_ws_connections_list() .lock() @@ -522,15 +537,22 @@ pub fn send_message_to_specific_connections(filter: F, msg_generator: M) - /// Check out whether user is connected or not pub fn is_user_connected(user_id: &UserID) -> bool { - get_ws_connections_list().lock().unwrap().iter().any(|c| c.user_id() == user_id) + get_ws_connections_list() + .lock() + .unwrap() + .iter() + .any(|c| c.user_id() == user_id) } /// Check out whether user is connected or not and has at list one not incognito connection pub fn is_user_connected_not_incognito(user_id: &UserID) -> bool { - get_ws_connections_list().lock().unwrap().iter().any(|c| c.user_id() == user_id && !c.incognito) + get_ws_connections_list() + .lock() + .unwrap() + .iter() + .any(|c| c.user_id() == user_id && !c.incognito) } - /// Disconnect a user from all the WebSockets of a given access token pub fn disconnect_from_user_token(token: &UserAccessToken) -> Res { let connections = get_ws_connections_list() @@ -567,7 +589,9 @@ pub fn disconnect_user_from_all_sockets(user_id: &UserID) -> Res { /// Do something with all active connections pub fn foreach_connection(mut f: F) -> Res - where F: FnMut(&UserWsConnection) -> Res { +where + F: FnMut(&UserWsConnection) -> Res, +{ let list = get_ws_connections_list().lock().unwrap().clone(); for conn in list.iter() { @@ -592,4 +616,4 @@ pub fn handle_event(e: &events_helper::Event) -> Res { } Ok(()) -} \ No newline at end of file +} diff --git a/src/controllers/virtual_directory_controller.rs b/src/controllers/virtual_directory_controller.rs index 5eda6a3..17d08cc 100644 --- a/src/controllers/virtual_directory_controller.rs +++ b/src/controllers/virtual_directory_controller.rs @@ -4,10 +4,10 @@ use crate::api_data::res_find_user_by_virtual_directory::FindUserByVirtualDirectoryAPIResult; use crate::api_data::res_find_virtual_directory::ResultFindVirtualDirectory; -use crate::routes::RequestResult; use crate::data::base_request_handler::BaseRequestHandler; use crate::data::http_request_handler::HttpRequestHandler; use crate::helpers::{groups_helper, user_helper}; +use crate::routes::RequestResult; /// Find a user by its virtual directory pub async fn find_user(r: &mut HttpRequestHandler) -> RequestResult { @@ -29,10 +29,13 @@ pub async fn find(r: &mut HttpRequestHandler) -> RequestResult { let group = groups_helper::find_by_virtual_directory(&directory); if user.is_err() && group.is_err() { - println!("Find virtual directory errors:\n* User: {}\n* Group: {}", - user.unwrap_err(), group.unwrap_err()); + println!( + "Find virtual directory errors:\n* User: {}\n* Group: {}", + user.unwrap_err(), + group.unwrap_err() + ); r.not_found("Specified user / group virtual directory not found !".to_string()) } else { r.set_response(ResultFindVirtualDirectory::new(user, group)) } -} \ No newline at end of file +} diff --git a/src/controllers/web_app_controller.rs b/src/controllers/web_app_controller.rs index dd7baf0..474b7cd 100644 --- a/src/controllers/web_app_controller.rs +++ b/src/controllers/web_app_controller.rs @@ -13,4 +13,4 @@ pub async fn get_memberships(r: &mut HttpRequestHandler) -> RequestResult { let memberships = webapp_helper::get_user_memberships(r.user_id_ref()?)?; r.set_response(UserMembershipAPI::for_list(&memberships)) -} \ No newline at end of file +} diff --git a/src/data/account_export.rs b/src/data/account_export.rs index ebee07e..dbb8e45 100644 --- a/src/data/account_export.rs +++ b/src/data/account_export.rs @@ -5,7 +5,7 @@ use std::collections::{HashMap, HashSet}; use crate::data::comment::Comment; -use crate::data::conversation::{Conversation, ConvID}; +use crate::data::conversation::{ConvID, Conversation}; use crate::data::conversation_message::ConversationMessage; use crate::data::error::ResultBoxError; use crate::data::friend::Friend; @@ -38,7 +38,9 @@ impl AccountExport { set.insert(self.user.id.clone()); // Friends - self.friends_list.iter().for_each(|f| { set.insert(f.friend_id.clone()); }); + self.friends_list.iter().for_each(|f| { + set.insert(f.friend_id.clone()); + }); // Posts for post in &self.posts { @@ -48,22 +50,30 @@ impl AccountExport { set.insert(id.clone()); } - comments_helper::get(post.id)?.iter().for_each(|f| { set.insert(f.user_id.clone()); }) + comments_helper::get(post.id)?.iter().for_each(|f| { + set.insert(f.user_id.clone()); + }) } // Comments - self.comments.iter().for_each(|f| { set.insert(f.user_id.clone()); }); + self.comments.iter().for_each(|f| { + set.insert(f.user_id.clone()); + }); // Conversation members for conv in &self.conversations { - conv.members_ids().into_iter().for_each(|f| { set.insert(f); }); + conv.members_ids().into_iter().for_each(|f| { + set.insert(f); + }); } // Conversation messages for (_, conv_messages) in &self.conversation_messages { - conv_messages.iter().for_each(|f| { set.extend(f.referenced_users_id()); }) + conv_messages.iter().for_each(|f| { + set.extend(f.referenced_users_id()); + }) } Ok(set) } -} \ No newline at end of file +} diff --git a/src/data/admin.rs b/src/data/admin.rs index 3fd0208..1878033 100644 --- a/src/data/admin.rs +++ b/src/data/admin.rs @@ -6,7 +6,7 @@ use mysql::serde::{Deserializer, Serializer}; use serde::{Deserialize, Serialize}; use webauthn_rs::prelude::Passkey; -use crate::constants::admin::{ADMIN_ROLES_LIST, AdminRole}; +use crate::constants::admin::{AdminRole, ADMIN_ROLES_LIST}; use crate::data::u64_visitor::U64Visitor; #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)] @@ -73,14 +73,16 @@ pub struct NewAdminGeneralSettings { impl AdminRole { pub fn from_id(id: &str) -> Option { - ADMIN_ROLES_LIST.iter() + ADMIN_ROLES_LIST + .iter() .filter(|r| r.id.eq(id)) .map(|r| r.role) .next() } pub fn to_id(&self) -> &'static str { - ADMIN_ROLES_LIST.iter() + ADMIN_ROLES_LIST + .iter() .filter(|r| r.role.eq(self)) .map(|r| r.id) .next() @@ -89,15 +91,21 @@ impl AdminRole { } impl Serialize for AdminID { - fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> where - S: Serializer { + fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> + where + S: Serializer, + { serializer.serialize_u64(self.0) } } impl<'de> Deserialize<'de> for AdminID { - fn deserialize(deserializer: D) -> Result>::Error> where - D: Deserializer<'de> { - deserializer.deserialize_u64(U64Visitor {}).map(AdminID::new) + fn deserialize(deserializer: D) -> Result>::Error> + where + D: Deserializer<'de>, + { + deserializer + .deserialize_u64(U64Visitor {}) + .map(AdminID::new) } -} \ No newline at end of file +} diff --git a/src/data/admin_action_log.rs b/src/data/admin_action_log.rs index 8d08294..bcac6c0 100644 --- a/src/data/admin_action_log.rs +++ b/src/data/admin_action_log.rs @@ -6,18 +6,58 @@ use crate::data::user::UserID; #[derive(serde::Serialize, serde::Deserialize, Clone)] pub enum AdminAction { AuthWithResetToken, - AuthWithAccessKey { key: String, key_id: u64 }, - RegisteredAdminKey { key_id: u64, key_name: String, target: AdminID }, - DeletedAdminKey { key_id: u64, key_name: String, target: AdminID }, - GeneratedAdminResetToken { target: AdminID }, - CreatedAdmin { id: AdminID, name: String, email: String }, - UpdatedAdminGeneralSettings { target: AdminID, new_email: String, new_name: String }, - AddAdminRole { target: AdminID, role: String }, - RemoveAdminRole { target: AdminID, role: String }, - AccessUserPage { user_id: UserID, user_name: String }, - ChangedEmailAddress { user_id: UserID, user_name: String, old_mail: String, new_mail: String }, - CreatePasswordRecoveryLink { user_id: UserID, user_name: String }, - UnsupportedAction { raw_data: String }, + AuthWithAccessKey { + key: String, + key_id: u64, + }, + RegisteredAdminKey { + key_id: u64, + key_name: String, + target: AdminID, + }, + DeletedAdminKey { + key_id: u64, + key_name: String, + target: AdminID, + }, + GeneratedAdminResetToken { + target: AdminID, + }, + CreatedAdmin { + id: AdminID, + name: String, + email: String, + }, + UpdatedAdminGeneralSettings { + target: AdminID, + new_email: String, + new_name: String, + }, + AddAdminRole { + target: AdminID, + role: String, + }, + RemoveAdminRole { + target: AdminID, + role: String, + }, + AccessUserPage { + user_id: UserID, + user_name: String, + }, + ChangedEmailAddress { + user_id: UserID, + user_name: String, + old_mail: String, + new_mail: String, + }, + CreatePasswordRecoveryLink { + user_id: UserID, + user_name: String, + }, + UnsupportedAction { + raw_data: String, + }, } impl AdminAction { @@ -69,4 +109,4 @@ pub struct AdminActionLog { pub ip: String, pub time: u64, pub action: AdminAction, -} \ No newline at end of file +} diff --git a/src/data/api_client.rs b/src/data/api_client.rs index 1ea69c0..60ab57d 100644 --- a/src/data/api_client.rs +++ b/src/data/api_client.rs @@ -14,7 +14,6 @@ pub struct APIClient { impl APIClient { pub fn is_firebase_available(&self) -> bool { - self.firebase_project_name.is_some() && - self.firebase_service_account_file.is_some() + self.firebase_project_name.is_some() && self.firebase_service_account_file.is_some() } -} \ No newline at end of file +} diff --git a/src/data/base_request_handler.rs b/src/data/base_request_handler.rs index 84e4858..2466fce 100644 --- a/src/data/base_request_handler.rs +++ b/src/data/base_request_handler.rs @@ -2,7 +2,6 @@ //! //! Base handling code for all user requests - use std::collections::HashSet; use std::error::Error; use std::str::from_utf8; @@ -17,7 +16,7 @@ use crate::constants::PASSWORD_MIN_LENGTH; use crate::data::admin::AdminID; use crate::data::comment::Comment; use crate::data::config::conf; -use crate::data::conversation::{ConversationMember, ConvID}; +use crate::data::conversation::{ConvID, ConversationMember}; use crate::data::conversation_message::ConversationMessage; use crate::data::custom_emoji::CustomEmoji; use crate::data::error::{ExecError, Res, ResultBoxError}; @@ -26,14 +25,22 @@ use crate::data::group_id::GroupID; use crate::data::post::{Post, PostAccessLevel}; use crate::data::user::UserID; use crate::data::user_token::UserAccessToken; -use crate::helpers::{account_helper, admin_account_helper, admin_roles_helper, comments_helper, conversations_helper, custom_emojies_helper, friends_helper, groups_helper, posts_helper, user_helper, virtual_directory_helper}; use crate::helpers::virtual_directory_helper::VirtualDirType; +use crate::helpers::{ + account_helper, admin_account_helper, admin_roles_helper, comments_helper, + conversations_helper, custom_emojies_helper, friends_helper, groups_helper, posts_helper, + user_helper, virtual_directory_helper, +}; use crate::routes::RequestResult; use crate::utils::mp3_utils::is_valid_mp3; use crate::utils::mp4_utils::is_valid_mp4; use crate::utils::pdf_utils::is_valid_pdf; -use crate::utils::string_utils::{check_emoji_code, check_html_color, check_url, remove_html_nodes}; -use crate::utils::user_data_utils::{generate_new_user_data_file_name, prepare_file_creation, user_data_path}; +use crate::utils::string_utils::{ + check_emoji_code, check_html_color, check_url, remove_html_nodes, +}; +use crate::utils::user_data_utils::{ + generate_new_user_data_file_name, prepare_file_creation, user_data_path, +}; use crate::utils::virtual_directories_utils; use crate::utils::zip_utils::is_valid_zip; @@ -42,7 +49,6 @@ struct SuccessMessage { success: String, } - pub struct PostFile { pub name: String, pub buff: actix_web::web::Bytes, @@ -54,7 +60,6 @@ pub enum RequestValue { File(PostFile), } - pub trait BaseRequestHandler { /// Get a parameter of the request fn post_parameter_opt(&self, name: &str) -> Option<&RequestValue>; @@ -82,14 +87,14 @@ pub trait BaseRequestHandler { /// Success message fn success(&mut self, message: &str) -> RequestResult { self.set_response(SuccessMessage { - success: message.to_string() + success: message.to_string(), }) } /// Success without message fn ok(&mut self) -> RequestResult { self.set_response(SuccessMessage { - success: "OK.".to_string() + success: "OK.".to_string(), }) } @@ -175,7 +180,7 @@ pub trait BaseRequestHandler { self.internal_error(ExecError::boxed_new(msg))?; unreachable!() } - Some(e) => Ok(e) + Some(e) => Ok(e), } } @@ -186,11 +191,10 @@ pub trait BaseRequestHandler { self.bad_request(msg.to_string())?; unreachable!() } - Some(e) => Ok(e) + Some(e) => Ok(e), } } - /// Get a user ID, if available fn user_id_opt(&self) -> Option { self.user_id_opt_ref().map(|u| u.clone()) @@ -212,16 +216,16 @@ pub trait BaseRequestHandler { /// Get user ID as a reference fn user_id_ref(&self) -> ResultBoxError<&UserID> { - self.user_id_opt_ref().ok_or(ExecError::boxed_new("Could not get required user ID!")) + self.user_id_opt_ref() + .ok_or(ExecError::boxed_new("Could not get required user ID!")) } - /// Get current admin ID, returning an error in case of error fn admin_id(&self) -> Res { - self.admin_id_opt().ok_or(ExecError::boxed_new("Could not get required admin ID!")) + self.admin_id_opt() + .ok_or(ExecError::boxed_new("Could not get required admin ID!")) } - /// Check if a POST parameter was present in the request or not fn has_post_parameter(&self, name: &str) -> bool { self.post_parameter_opt(name).is_some() @@ -254,8 +258,12 @@ pub trait BaseRequestHandler { } /// Get a post string, specifying minimum length - fn post_string_opt(&mut self, name: &str, min_length: usize, required: bool) - -> ResultBoxError { + fn post_string_opt( + &mut self, + name: &str, + min_length: usize, + required: bool, + ) -> ResultBoxError { let param = self.post_parameter(name)?; match (¶m, required) { @@ -263,14 +271,17 @@ pub trait BaseRequestHandler { if s.len() >= min_length { Ok(s.to_string()) } else { - Err(self.bad_request(format!("'{}' is too short!", name)).unwrap_err()) + Err(self + .bad_request(format!("'{}' is too short!", name)) + .unwrap_err()) } } (_, false) => Ok(String::new()), - (_, true) => - Err(self.bad_request(format!("'{}' is not a string!", name)).unwrap_err()), + (_, true) => Err(self + .bad_request(format!("'{}' is not a string!", name)) + .unwrap_err()), } } @@ -280,9 +291,11 @@ pub trait BaseRequestHandler { Some(RequestValue::String(s)) => { if s.is_empty() { None - } else { Some(s.to_string()) } + } else { + Some(s.to_string()) + } } - _ => None + _ => None, } } @@ -324,7 +337,8 @@ pub trait BaseRequestHandler { /// Get the extension of a file included in the request fn post_file_ext(&mut self, name: &str, default: &str) -> Res { - let suffix = self.post_file_type(name)? + let suffix = self + .post_file_type(name)? .parse::()? .suffix() .map(|s| s.as_str()) @@ -335,8 +349,13 @@ pub trait BaseRequestHandler { } /// Save an image in user data directory - fn save_post_image(&mut self, name: &str, folder: &str, max_w: u32, max_h: u32) -> ResultBoxError { - + fn save_post_image( + &mut self, + name: &str, + folder: &str, + max_w: u32, + max_h: u32, + ) -> ResultBoxError { // Load image let file = self.post_file(name)?; let mut image = image::load_from_memory(file.buff.as_ref())?; @@ -378,13 +397,12 @@ pub trait BaseRequestHandler { } } - // Determine image destination let target_user_data_folder = prepare_file_creation(&self.user_id()?, folder)?; - let target_file_path = generate_new_user_data_file_name(target_user_data_folder.as_path(), "png")?; + let target_file_path = + generate_new_user_data_file_name(target_user_data_folder.as_path(), "png")?; let target_sys_path = user_data_path(target_file_path.as_path()); - // Save image image.save_with_format(target_sys_path, ImageFormat::Png)?; @@ -400,7 +418,8 @@ pub trait BaseRequestHandler { // Determine pdf file destination let target_user_data_folder = prepare_file_creation(self.user_id_ref()?, folder)?; - let target_file_path = generate_new_user_data_file_name(target_user_data_folder.as_path(), ext)?; + let target_file_path = + generate_new_user_data_file_name(target_user_data_folder.as_path(), ext)?; let target_sys_path = user_data_path(target_file_path.as_path()); std::fs::write(target_sys_path, &copied_buff.as_ref())?; @@ -518,7 +537,7 @@ pub trait BaseRequestHandler { fn post_positive_u64_opt(&mut self, name: &str) -> Res> { match self.post_u64_opt(name, 0)? { 0 => Ok(None), - val => Ok(Some(val)) + val => Ok(Some(val)), } } @@ -532,7 +551,6 @@ pub trait BaseRequestHandler { self.post_bool(name).unwrap_or(default) } - /// Get an email included in the request fn post_email(&mut self, name: &str) -> ResultBoxError { let mail = self.post_string(name)?; @@ -565,14 +583,20 @@ pub trait BaseRequestHandler { } /// Get the response to a key register credential included in the request - fn post_register_public_key_credential(&mut self, name: &str) -> Res { + fn post_register_public_key_credential( + &mut self, + name: &str, + ) -> Res { let str = self.post_string(name)?; Ok(serde_json::from_str(&str)?) } /// Get the response to a key authentication included in the request - fn post_auth_public_key_credential(&mut self, name: &str) -> Res { + fn post_auth_public_key_credential( + &mut self, + name: &str, + ) -> Res { let str = self.post_string(name)?; Ok(serde_json::from_str(&str)?) @@ -619,7 +643,8 @@ pub trait BaseRequestHandler { /// Get a list of users ID included in the request fn post_users_id(&mut self, name: &str) -> ResultBoxError> { - let users = self.post_numbers_list(name, 1)? + let users = self + .post_numbers_list(name, 1)? .iter() .map(|u| UserID::new(u.clone())) .collect::>(); @@ -653,23 +678,39 @@ pub trait BaseRequestHandler { let dir = self.post_string(name)?; if !virtual_directories_utils::check_virtual_directory(&dir) { - self.bad_request(format!("Invalid virtual directory specified in '{}' !", name))?; + self.bad_request(format!( + "Invalid virtual directory specified in '{}' !", + name + ))?; } Ok(dir) } /// Get a string included in the request, with HTML codes removed - fn post_string_without_html(&mut self, name: &str, min_length: usize, required: bool) -> ResultBoxError { - Ok(remove_html_nodes(self.post_string_opt(name, min_length, required)?.as_str())) + fn post_string_without_html( + &mut self, + name: &str, + min_length: usize, + required: bool, + ) -> ResultBoxError { + Ok(remove_html_nodes( + self.post_string_opt(name, min_length, required)?.as_str(), + )) } /// Get an optional string included in the request, with HTML codes removed - fn post_string_without_html_opt(&mut self, name: &str, min_length: usize) -> ResultBoxError> { + fn post_string_without_html_opt( + &mut self, + name: &str, + min_length: usize, + ) -> ResultBoxError> { if !self.has_post_parameter(name) { Ok(None) } else { - Ok(Some(remove_html_nodes(self.post_string_opt(name, min_length, true)?.as_str()))) + Ok(Some(remove_html_nodes( + self.post_string_opt(name, min_length, true)?.as_str(), + ))) } } @@ -706,8 +747,12 @@ pub trait BaseRequestHandler { "Requested conversation message was not found!", )?; - if conversations_helper::get_user_membership(&self.user_id()?, conv_message.conv_id).is_err() { - self.forbidden("You do not belong to the conversation attached to this message!".to_string())?; + if conversations_helper::get_user_membership(&self.user_id()?, conv_message.conv_id) + .is_err() + { + self.forbidden( + "You do not belong to the conversation attached to this message!".to_string(), + )?; } Ok(conv_message) @@ -725,7 +770,11 @@ pub trait BaseRequestHandler { } /// Get the ID of a group included in a request with a check for access level of current user - fn post_group_id_with_access(&mut self, name: &str, min_level: GroupAccessLevel) -> ResultBoxError { + fn post_group_id_with_access( + &mut self, + name: &str, + min_level: GroupAccessLevel, + ) -> ResultBoxError { let group_id = self.post_group_id(name)?; let access_level = groups_helper::get_access_level(&group_id, self.user_id_opt())?; @@ -734,7 +783,10 @@ pub trait BaseRequestHandler { } if access_level < min_level { - self.forbidden("You do not have enough rights to perform what you intend to do on this group!".to_string())?; + self.forbidden( + "You do not have enough rights to perform what you intend to do on this group!" + .to_string(), + )?; } Ok(group_id) @@ -756,7 +808,12 @@ pub trait BaseRequestHandler { } /// Get an optional virtual directory included in the request - fn post_checked_virtual_directory_opt(&mut self, name: &str, target_id: u64, target_type: VirtualDirType) -> ResultBoxError> { + fn post_checked_virtual_directory_opt( + &mut self, + name: &str, + target_id: u64, + target_type: VirtualDirType, + ) -> ResultBoxError> { let dir = self.post_string_opt(name, 0, false)?; if dir.is_empty() { @@ -771,7 +828,11 @@ pub trait BaseRequestHandler { } /// Get information about a post whose ID was specified in the request - fn post_post_with_access(&mut self, name: &str, min_level: PostAccessLevel) -> ResultBoxError { + fn post_post_with_access( + &mut self, + name: &str, + min_level: PostAccessLevel, + ) -> ResultBoxError { let post_id = self.post_u64(name)?; let post = self.ok_or_not_found( posts_helper::get_single(post_id), @@ -795,8 +856,12 @@ pub trait BaseRequestHandler { if comment.user_id != self.user_id_or_invalid() { let post = posts_helper::get_single(comment.post_id)?; - if posts_helper::get_access_level(&post, &self.user_id_opt())? == PostAccessLevel::NO_ACCESS { - self.forbidden("You are not allowed to access this post information !".to_string())?; + if posts_helper::get_access_level(&post, &self.user_id_opt())? + == PostAccessLevel::NO_ACCESS + { + self.forbidden( + "You are not allowed to access this post information !".to_string(), + )?; } } @@ -815,7 +880,12 @@ pub trait BaseRequestHandler { } /// Get a content of a post and sanitize it - fn post_content(&mut self, name: &str, min_len: usize, required: bool) -> ResultBoxError { + fn post_content( + &mut self, + name: &str, + min_len: usize, + required: bool, + ) -> ResultBoxError { let content = self.post_string_opt(name, min_len, required)?; if content.contains("data:image") { @@ -893,4 +963,4 @@ pub trait BaseRequestHandler { Ok(group) } -} \ No newline at end of file +} diff --git a/src/data/call_signal.rs b/src/data/call_signal.rs index aa9da23..26ff451 100644 --- a/src/data/call_signal.rs +++ b/src/data/call_signal.rs @@ -59,7 +59,10 @@ impl SdpType { match val { "offer" => Ok(SdpType::Offer), "answer" => Ok(SdpType::Answer), - _ => Err(ExecError::boxed_new(&format!("SDP type {} is unknown!", val))) + _ => Err(ExecError::boxed_new(&format!( + "SDP type {} is unknown!", + val + ))), } } -} \ No newline at end of file +} diff --git a/src/data/config.rs b/src/data/config.rs index 411ec6d..02d1470 100644 --- a/src/data/config.rs +++ b/src/data/config.rs @@ -37,7 +37,6 @@ pub struct IndependentPushService { pub public_url: String, } - #[derive(Debug, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "lowercase")] pub enum BannerNature { @@ -57,8 +56,7 @@ pub struct Banner { impl Banner { pub fn is_visible(&self) -> bool { - self.enabled && - self.expire.map(|v| v < 1 || v > time()).unwrap_or(true) + self.enabled && self.expire.map(|v| v < 1 || v > time()).unwrap_or(true) } } @@ -110,7 +108,8 @@ impl Config { Yaml::BadValue => { panic!("{} is missing", name); } - }.to_string(); + } + .to_string(); // Check if we have to get an environment variable Self::parse_string_val(val) @@ -126,7 +125,6 @@ impl Config { /// Load the configuration from a given path pub fn load(path: &str) -> Result<(), Box> { - // Read & parse configuration let conf_str = std::fs::read_to_string(path)?; let parsed = YamlLoader::load_from_str(&conf_str)?; @@ -153,12 +151,19 @@ impl Config { enabled: Config::yaml_bool(parsed_rtc, "enabled"), ip: Config::yaml_str(parsed_rtc, "ip"), token: Config::yaml_str(parsed_rtc, "token"), - ice_servers: parsed_rtc["ice-servers"].as_vec().unwrap().iter() - .map(|f| Self::parse_string_val(f.as_str().unwrap().to_string())).collect(), + ice_servers: parsed_rtc["ice-servers"] + .as_vec() + .unwrap() + .iter() + .map(|f| Self::parse_string_val(f.as_str().unwrap().to_string())) + .collect(), max_users_per_calls: Config::yaml_u64(parsed_rtc, "max-users-per-calls"), allow_video: Config::yaml_bool(parsed_rtc, "allow-video"), - max_users_per_video_calls: Config::yaml_u64(parsed_rtc, "max-users-per-video-calls"), - }) + max_users_per_video_calls: Config::yaml_u64( + parsed_rtc, + "max-users-per-video-calls", + ), + }), }; let proxy = Config::yaml_str(parsed, "proxy"); @@ -171,7 +176,7 @@ impl Config { control_url: Config::yaml_str(parsed_independent_push_service, "control-url"), control_token: Config::yaml_str(parsed_independent_push_service, "control-token"), public_url: Config::yaml_str(parsed_independent_push_service, "public-url"), - }) + }), }; let parsed_banner = &parsed["banner"]; @@ -181,38 +186,42 @@ impl Config { enabled: Self::yaml_bool(parsed_banner, "enabled"), expire: match Self::yaml_u64(parsed_banner, "expire") { 0 => None, - v => Some(v) + v => Some(v), }, nature: match Self::yaml_str(parsed_banner, "nature").as_str() { "information" => BannerNature::Information, "warning" => BannerNature::Warning, "success" => BannerNature::Success, - v => panic!("Invalid banner nature: {} !", v) + v => panic!("Invalid banner nature: {} !", v), }, - message: parsed_banner["message"].as_hash().unwrap().iter() - .map(|(k, v)| ( - k.as_str().unwrap().to_string(), - Self::parse_string_val(v.as_str().unwrap().to_string())) - ) + message: parsed_banner["message"] + .as_hash() + .unwrap() + .iter() + .map(|(k, v)| { + ( + k.as_str().unwrap().to_string(), + Self::parse_string_val(v.as_str().unwrap().to_string()), + ) + }) .collect(), - link: parsed_banner["link"].as_str() + link: parsed_banner["link"] + .as_str() .map(str::to_string) .map(Self::parse_string_val) .and_then(|s| match s.is_empty() { true => None, - false => Some(s) + false => Some(s), }), - }) + }), }; let forez_groups = match &parsed["forez_groups"] { Yaml::BadValue => vec![], - _ => { - Self::yaml_str(parsed, "forez_groups") - .split(",") - .map(|f| GroupID::new(f.trim().parse::().unwrap())) - .collect() - } + _ => Self::yaml_str(parsed, "forez_groups") + .split(",") + .map(|f| GroupID::new(f.trim().parse::().unwrap())) + .collect(), }; let conf = Config { @@ -235,7 +244,7 @@ impl Config { proxy: match proxy.as_ref() { "none" => None, - s => Some(s.to_string()) + s => Some(s.to_string()), }, verbose_mode: Config::yaml_bool(parsed, "verbose-mode"), @@ -270,8 +279,7 @@ impl Config { /// Check if rtc relay is enabled pub fn is_rtc_relay_enabled(&self) -> bool { - self.rtc_relay.is_some() - && self.rtc_relay.as_ref().unwrap().enabled + self.rtc_relay.is_some() && self.rtc_relay.as_ref().unwrap().enabled } /// Check if independent push notifications service is enabled @@ -286,4 +294,4 @@ pub fn conf() -> &'static Config { unsafe { return &CONF.as_ref().unwrap(); } -} \ No newline at end of file +} diff --git a/src/data/conversation.rs b/src/data/conversation.rs index c53ed4b..f6b8826 100644 --- a/src/data/conversation.rs +++ b/src/data/conversation.rs @@ -3,8 +3,8 @@ //! @author Pierre Hubert use crate::data::group_id::GroupID; -use crate::data::user::UserID; use crate::data::group_member::GroupMembershipLevel; +use crate::data::user::UserID; #[derive(Copy, Debug, PartialEq, Eq, Clone, Hash)] pub struct ConvID(u64); @@ -71,8 +71,7 @@ impl Conversation { /// Check out whether a given user is an admin of a conversation or not pub fn is_admin(&self, user_id: &UserID) -> bool { - self - .members + self.members .iter() .any(|m| m.user_id == user_id && m.is_admin) } @@ -94,10 +93,7 @@ impl Conversation { /// Check out whether a user is the last administrator of a conversation or not pub fn is_last_admin(&self, user_id: &UserID) -> bool { - let admins: Vec<&ConversationMember> = self.members - .iter() - .filter(|m| m.is_admin) - .collect(); + let admins: Vec<&ConversationMember> = self.members.iter().filter(|m| m.is_admin).collect(); admins.len() == 1 && admins[0].user_id == user_id } @@ -121,4 +117,4 @@ pub struct NewConversationSettings { pub color: Option, pub name: Option, pub can_everyone_add_members: bool, -} \ No newline at end of file +} diff --git a/src/data/conversation_message.rs b/src/data/conversation_message.rs index 716d062..6d8f1ea 100644 --- a/src/data/conversation_message.rs +++ b/src/data/conversation_message.rs @@ -42,10 +42,22 @@ pub enum ConversationServerMessageType { impl ConversationServerMessageType { pub fn to_db(&self) -> String { let info = match self { - ConversationServerMessageType::UserCreatedConversation(u) => ("user_created_conv", Some(u.clone()), None), - ConversationServerMessageType::UserAddedAnotherUserToConversation(msg) => ("user_added_another_user", Some(msg.user_who_added.clone()), Some(msg.user_added.clone())), - ConversationServerMessageType::UserLeftConversation(u) => ("user_left", Some(u.clone()), None), - ConversationServerMessageType::UserRemovedFromConversation(msg) => ("user_removed", Some(msg.user_who_removed.clone()), Some(msg.user_removed.clone())), + ConversationServerMessageType::UserCreatedConversation(u) => { + ("user_created_conv", Some(u.clone()), None) + } + ConversationServerMessageType::UserAddedAnotherUserToConversation(msg) => ( + "user_added_another_user", + Some(msg.user_who_added.clone()), + Some(msg.user_added.clone()), + ), + ConversationServerMessageType::UserLeftConversation(u) => { + ("user_left", Some(u.clone()), None) + } + ConversationServerMessageType::UserRemovedFromConversation(msg) => ( + "user_removed", + Some(msg.user_who_removed.clone()), + Some(msg.user_removed.clone()), + ), }; format!( @@ -69,30 +81,34 @@ impl ConversationServerMessageType { split[0], match id_1 { 0 => None, - id => Some(UserID::new(id)) + id => Some(UserID::new(id)), }, match id_2 { 0 => None, - id => Some(UserID::new(id)) + id => Some(UserID::new(id)), }, ); match info { ("user_created_conv", Some(user_id), _) => Ok(Self::UserCreatedConversation(user_id)), - ("user_added_another_user", Some(user_id), Some(user_2)) => Ok(Self::UserAddedAnotherUserToConversation(UserAddedAnotherUserToConversation { - user_who_added: user_id, - user_added: user_2, - })), + ("user_added_another_user", Some(user_id), Some(user_2)) => Ok( + Self::UserAddedAnotherUserToConversation(UserAddedAnotherUserToConversation { + user_who_added: user_id, + user_added: user_2, + }), + ), ("user_left", Some(user_id), _) => Ok(Self::UserLeftConversation(user_id)), - ("user_removed", Some(user_id), Some(user_2)) => Ok(Self::UserRemovedFromConversation(UserRemovedAnotherUserToConversation { - user_who_removed: user_id, - user_removed: user_2, - })), + ("user_removed", Some(user_id), Some(user_2)) => Ok(Self::UserRemovedFromConversation( + UserRemovedAnotherUserToConversation { + user_who_removed: user_id, + user_removed: user_2, + }, + )), - _ => Err(ExecError::boxed_new("Unknown server message type!")) + _ => Err(ExecError::boxed_new("Unknown server message type!")), } } } @@ -140,4 +156,4 @@ impl ConversationMessage { users } -} \ No newline at end of file +} diff --git a/src/data/custom_emoji.rs b/src/data/custom_emoji.rs index fa8d4d8..5d1bc63 100644 --- a/src/data/custom_emoji.rs +++ b/src/data/custom_emoji.rs @@ -20,4 +20,4 @@ impl CustomEmoji { pub fn sys_path(&self) -> PathBuf { user_data_path(self.path.as_ref()) } -} \ No newline at end of file +} diff --git a/src/data/error.rs b/src/data/error.rs index 4d45e11..15a2e45 100644 --- a/src/data/error.rs +++ b/src/data/error.rs @@ -7,7 +7,6 @@ use std::fmt::{Display, Formatter}; /// /// @author Pierre Hubert - /// Simple result type pub type ResultExecError = Result; pub type ResultBoxError = Result>; @@ -36,5 +35,4 @@ impl fmt::Display for ExecError { } } - -impl error::Error for ExecError {} \ No newline at end of file +impl error::Error for ExecError {} diff --git a/src/data/friend.rs b/src/data/friend.rs index ee1e1af..bbbcee3 100644 --- a/src/data/friend.rs +++ b/src/data/friend.rs @@ -25,4 +25,4 @@ impl Friend { self.last_activity_time } } -} \ No newline at end of file +} diff --git a/src/data/friendship_status.rs b/src/data/friendship_status.rs index 546baa8..a2c8e32 100644 --- a/src/data/friendship_status.rs +++ b/src/data/friendship_status.rs @@ -7,4 +7,4 @@ pub struct FriendshipStatus { pub sent_request: bool, pub received_request: bool, pub following: bool, -} \ No newline at end of file +} diff --git a/src/data/general_settings.rs b/src/data/general_settings.rs index 6f2809e..45163bb 100644 --- a/src/data/general_settings.rs +++ b/src/data/general_settings.rs @@ -18,4 +18,4 @@ pub struct GeneralSettings { pub allow_mails: bool, pub public_note: Option, pub location: Option, -} \ No newline at end of file +} diff --git a/src/data/global_search_result.rs b/src/data/global_search_result.rs index 8e02df1..493fab3 100644 --- a/src/data/global_search_result.rs +++ b/src/data/global_search_result.rs @@ -6,4 +6,4 @@ use crate::data::user::UserID; pub enum GlobalSearchResult { User(UserID), Group(GroupID), -} \ No newline at end of file +} diff --git a/src/data/group.rs b/src/data/group.rs index b5b1f94..962a6c0 100644 --- a/src/data/group.rs +++ b/src/data/group.rs @@ -22,7 +22,8 @@ impl GroupVisibilityLevel { GroupVisibilityLevel::OPEN_GROUP => "open", GroupVisibilityLevel::PRIVATE_GROUP => "private", GroupVisibilityLevel::SECRETE_GROUP => "secrete", - }.to_string() + } + .to_string() } pub fn from_api(level: &str) -> GroupVisibilityLevel { @@ -30,7 +31,7 @@ impl GroupVisibilityLevel { "open" => GroupVisibilityLevel::OPEN_GROUP, "private" => GroupVisibilityLevel::PRIVATE_GROUP, "secrete" => GroupVisibilityLevel::SECRETE_GROUP, - _ => GroupVisibilityLevel::SECRETE_GROUP + _ => GroupVisibilityLevel::SECRETE_GROUP, } } } @@ -49,7 +50,8 @@ impl GroupRegistrationLevel { GroupRegistrationLevel::OPEN_REGISTRATION => "open", GroupRegistrationLevel::MODERATED_REGISTRATION => "moderated", GroupRegistrationLevel::CLOSED_REGISTRATION => "closed", - }.to_string() + } + .to_string() } pub fn from_api(level: &str) -> GroupRegistrationLevel { @@ -77,14 +79,15 @@ impl GroupPostsCreationLevel { match self { GroupPostsCreationLevel::POSTS_LEVEL_MODERATORS => "moderators", GroupPostsCreationLevel::POSTS_LEVEL_ALL_MEMBERS => "members", - }.to_string() + } + .to_string() } pub fn from_api(level: &str) -> GroupPostsCreationLevel { match level { "members" => GroupPostsCreationLevel::POSTS_LEVEL_ALL_MEMBERS, "moderators" => GroupPostsCreationLevel::POSTS_LEVEL_MODERATORS, - _ => GroupPostsCreationLevel::POSTS_LEVEL_MODERATORS + _ => GroupPostsCreationLevel::POSTS_LEVEL_MODERATORS, } } } @@ -168,4 +171,4 @@ mod tests { assert!(GroupAccessLevel::MEMBER_ACCESS < GroupAccessLevel::MODERATOR_ACCESS); assert!(GroupAccessLevel::MODERATOR_ACCESS < GroupAccessLevel::ADMIN_ACCESS); } -} \ No newline at end of file +} diff --git a/src/data/group_id.rs b/src/data/group_id.rs index d387781..39593d9 100644 --- a/src/data/group_id.rs +++ b/src/data/group_id.rs @@ -15,4 +15,4 @@ impl GroupID { pub fn id(&self) -> u64 { self.0 } -} \ No newline at end of file +} diff --git a/src/data/group_member.rs b/src/data/group_member.rs index def15ac..7402e65 100644 --- a/src/data/group_member.rs +++ b/src/data/group_member.rs @@ -23,7 +23,9 @@ impl GroupMembershipLevel { pub fn is_at_least_member(&self) -> bool { matches!( &self, - GroupMembershipLevel::ADMINISTRATOR | GroupMembershipLevel::MODERATOR | GroupMembershipLevel::MEMBER + GroupMembershipLevel::ADMINISTRATOR + | GroupMembershipLevel::MODERATOR + | GroupMembershipLevel::MEMBER ) } @@ -35,7 +37,8 @@ impl GroupMembershipLevel { GroupMembershipLevel::INVITED => "invited", GroupMembershipLevel::PENDING => "pending", GroupMembershipLevel::VISITOR => "visitor", - }.to_string() + } + .to_string() } pub fn from_api(level: &str) -> GroupMembershipLevel { @@ -87,4 +90,4 @@ mod tests { assert!(GroupMembershipLevel::INVITED < GroupMembershipLevel::PENDING); assert!(GroupMembershipLevel::PENDING < GroupMembershipLevel::VISITOR); } -} \ No newline at end of file +} diff --git a/src/data/http_request_handler.rs b/src/data/http_request_handler.rs index 71bfc46..95b9c1a 100644 --- a/src/data/http_request_handler.rs +++ b/src/data/http_request_handler.rs @@ -1,9 +1,9 @@ +use actix_http::header::{HeaderName, HeaderValue}; use std::collections::HashMap; use std::str::FromStr; -use actix_http::header::{HeaderName, HeaderValue}; -use actix_web::{HttpRequest, HttpResponse, HttpResponseBuilder}; use actix_web::http::StatusCode; +use actix_web::{HttpRequest, HttpResponse, HttpResponseBuilder}; use serde::Serialize; use crate::api_data::http_error::HttpError; @@ -61,15 +61,14 @@ impl HttpRequestHandler { // Put additional headers if required for (k, v) in &self.headers { - response.headers_mut().insert(HeaderName::from_str(k)?, - HeaderValue::from_str(v)?, - ); + response + .headers_mut() + .insert(HeaderName::from_str(k)?, HeaderValue::from_str(v)?); } Ok(response) } - /// Get the path of the request pub fn request_path(&self) -> String { self.request.path().to_string() @@ -89,18 +88,22 @@ impl HttpRequestHandler { "Client not recognized!", )?; - if let Some(allowed_origin) = &client.domain { match self.request.headers().get("Referer") { None => self.bad_request("Unknown origin!".to_string())?, Some(s) => { if !s.to_str()?.starts_with(allowed_origin) { - self.bad_request("Use of this client is prohibited from this domain!".to_string())?; + self.bad_request( + "Use of this client is prohibited from this domain!".to_string(), + )?; } } } - self.headers.insert("Access-Control-Allow-Origin".to_string(), allowed_origin.to_string()); + self.headers.insert( + "Access-Control-Allow-Origin".to_string(), + allowed_origin.to_string(), + ); } self.client = Some(client); @@ -126,9 +129,9 @@ impl HttpRequestHandler { Err(e) => { println!("Error marking login tokens as invalid: {}", e); self.response = Some( - actix_web::HttpResponse:: - build(actix_web::http::StatusCode::from_u16(412)?) - .json(HttpError::new(412, "Please check your login tokens!"))); + actix_web::HttpResponse::build(actix_web::http::StatusCode::from_u16(412)?) + .json(HttpError::new(412, "Please check your login tokens!")), + ); Err(e) } } @@ -174,8 +177,9 @@ impl BaseRequestHandler for HttpRequestHandler { /// Set request error fn set_error(&mut self, error: HttpError) { - self.response = Some(HttpResponseBuilder::new(StatusCode::from_u16(error.error.code).unwrap()) - .json(error)); + self.response = Some( + HttpResponseBuilder::new(StatusCode::from_u16(error.error.code).unwrap()).json(error), + ); } /// Get the remote IP address @@ -211,4 +215,4 @@ impl BaseRequestHandler for HttpRequestHandler { fn admin_id_opt(&self) -> Option { self.curr_admin_token.as_ref().map(|p| p.id) } -} \ No newline at end of file +} diff --git a/src/data/lang_settings.rs b/src/data/lang_settings.rs index 8548d64..82d2c55 100644 --- a/src/data/lang_settings.rs +++ b/src/data/lang_settings.rs @@ -7,4 +7,4 @@ use crate::data::user::UserID; pub struct LangSettings { pub id: UserID, pub lang: String, -} \ No newline at end of file +} diff --git a/src/data/mod.rs b/src/data/mod.rs index 283ffe6..4c6d0e0 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -1,48 +1,48 @@ -pub mod error; pub mod config; +pub mod error; +pub mod api_client; pub mod base_request_handler; pub mod http_request_handler; pub mod user_ws_request_handler; -pub mod api_client; -pub mod user; -pub mod user_token; -pub mod custom_emoji; -pub mod new_conversation; +pub mod account_export; +pub mod admin; +pub mod admin_action_log; +pub mod call_signal; +pub mod comment; pub mod conversation; pub mod conversation_message; -pub mod new_conversation_message; -pub mod group_id; -pub mod group; -pub mod new_group; -pub mod group_member; -pub mod global_search_result; +pub mod custom_emoji; pub mod friend; pub mod friendship_status; -pub mod post; -pub mod survey; -pub mod comment; +pub mod general_settings; +pub mod global_search_result; +pub mod group; +pub mod group_id; +pub mod group_member; +pub mod lang_settings; +pub mod new_account; +pub mod new_conversation; +pub mod new_conversation_message; +pub mod new_custom_emoji; +pub mod new_data_conservation_policy; +pub mod new_group; +pub mod new_notifications_settings; pub mod new_survey; pub mod notification; -pub mod user_membership; -pub mod new_account; -pub mod account_export; -pub mod user_like; -pub mod survey_response; -pub mod general_settings; -pub mod lang_settings; -pub mod security_settings; -pub mod new_data_conservation_policy; -pub mod new_custom_emoji; -pub mod user_ws_message; -pub mod user_ws_connection; -pub mod call_signal; -pub mod new_notifications_settings; -pub mod push_notification; +pub mod post; pub mod presence; -pub mod admin; -pub mod webauthn_config; -pub mod admin_action_log; +pub mod push_notification; +pub mod report; +pub mod security_settings; +pub mod survey; +pub mod survey_response; pub mod u64_visitor; -pub mod report; \ No newline at end of file +pub mod user; +pub mod user_like; +pub mod user_membership; +pub mod user_token; +pub mod user_ws_connection; +pub mod user_ws_message; +pub mod webauthn_config; diff --git a/src/data/new_account.rs b/src/data/new_account.rs index 8515cd8..45ad034 100644 --- a/src/data/new_account.rs +++ b/src/data/new_account.rs @@ -7,4 +7,4 @@ pub struct NewAccount { pub last_name: String, pub email: String, pub password: String, -} \ No newline at end of file +} diff --git a/src/data/new_conversation.rs b/src/data/new_conversation.rs index e05797a..ab5b4f0 100644 --- a/src/data/new_conversation.rs +++ b/src/data/new_conversation.rs @@ -19,4 +19,4 @@ pub struct NewConversation { pub owner_following: bool, pub members: HashSet, pub can_everyone_add_members: bool, -} \ No newline at end of file +} diff --git a/src/data/new_conversation_message.rs b/src/data/new_conversation_message.rs index 0f2c2ea..c9ec8f3 100644 --- a/src/data/new_conversation_message.rs +++ b/src/data/new_conversation_message.rs @@ -2,9 +2,9 @@ //! //! @author Pierre Hubert -use crate::data::user::UserID; use crate::data::conversation::ConvID; use crate::data::conversation_message::{ConversationMessageFile, ConversationServerMessageType}; +use crate::data::user::UserID; /// Information about a new conversation message pub struct NewConversationMessage { @@ -26,4 +26,4 @@ impl NewConversationMessage { server_message: Some(message), } } -} \ No newline at end of file +} diff --git a/src/data/new_custom_emoji.rs b/src/data/new_custom_emoji.rs index d1e0203..1ee2276 100644 --- a/src/data/new_custom_emoji.rs +++ b/src/data/new_custom_emoji.rs @@ -8,4 +8,4 @@ pub struct NewCustomEmoji { pub user_id: UserID, pub shortcut: String, pub path: String, -} \ No newline at end of file +} diff --git a/src/data/new_data_conservation_policy.rs b/src/data/new_data_conservation_policy.rs index e3687da..a009733 100644 --- a/src/data/new_data_conservation_policy.rs +++ b/src/data/new_data_conservation_policy.rs @@ -12,4 +12,4 @@ pub struct NewDataConservationPolicy { pub delete_posts_after: Option, pub delete_conversation_messages_after: Option, pub delete_likes_after: Option, -} \ No newline at end of file +} diff --git a/src/data/new_group.rs b/src/data/new_group.rs index b71a212..581f028 100644 --- a/src/data/new_group.rs +++ b/src/data/new_group.rs @@ -7,4 +7,4 @@ use crate::data::user::UserID; pub struct NewGroup { pub name: String, pub owner_id: UserID, -} \ No newline at end of file +} diff --git a/src/data/new_notifications_settings.rs b/src/data/new_notifications_settings.rs index a1cbd9b..521cb19 100644 --- a/src/data/new_notifications_settings.rs +++ b/src/data/new_notifications_settings.rs @@ -8,4 +8,4 @@ pub struct NewNotificationsSettings { pub user_id: UserID, pub allow_notifications_sound: bool, pub allow_conversations: bool, -} \ No newline at end of file +} diff --git a/src/data/new_survey.rs b/src/data/new_survey.rs index edb0e37..afd32fc 100644 --- a/src/data/new_survey.rs +++ b/src/data/new_survey.rs @@ -10,4 +10,4 @@ pub struct NewSurvey { pub question: String, pub choices: Vec, pub allow_new_choices: bool, -} \ No newline at end of file +} diff --git a/src/data/notification.rs b/src/data/notification.rs index 3b2bf36..dcc4f66 100644 --- a/src/data/notification.rs +++ b/src/data/notification.rs @@ -43,7 +43,8 @@ impl NotifElemType { NotifElemType::FRIENDSHIP_REQUEST => "friend_request", NotifElemType::GROUP_MEMBERSHIP => "group_membership", NotifElemType::UNKNOWN => "", - }.to_string() + } + .to_string() } pub fn to_api(&self) -> String { @@ -51,7 +52,6 @@ impl NotifElemType { } } - #[allow(non_camel_case_types)] pub enum NotifEventType { UNKNOWN, @@ -79,11 +79,19 @@ impl NotifEventType { "elem_created" => NotifEventType::ELEM_CREATED, "elem_updated" => NotifEventType::ELEM_UPDATED, "sent_group_membership_invitation" => NotifEventType::SENT_GROUP_MEMBERSHIP_INVITATION, - "accepted_group_membership_invitation" => NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_INVITATION, - "rejected_group_membership_invitation" => NotifEventType::REJECTED_GROUP_MEMBERSHIP_INVITATION, + "accepted_group_membership_invitation" => { + NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_INVITATION + } + "rejected_group_membership_invitation" => { + NotifEventType::REJECTED_GROUP_MEMBERSHIP_INVITATION + } "sent_group_membership_request" => NotifEventType::SENT_GROUP_MEMBERSHIP_REQUEST, - "accepted_group_membership_request" => NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_REQUEST, - "rejected_group_membership_request" => NotifEventType::REJECTED_GROUP_MEMBERSHIP_REQUEST, + "accepted_group_membership_request" => { + NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_REQUEST + } + "rejected_group_membership_request" => { + NotifEventType::REJECTED_GROUP_MEMBERSHIP_REQUEST + } _ => NotifEventType::UNKNOWN, } } @@ -97,13 +105,22 @@ impl NotifEventType { NotifEventType::ELEM_CREATED => "elem_created", NotifEventType::ELEM_UPDATED => "elem_updated", NotifEventType::SENT_GROUP_MEMBERSHIP_INVITATION => "sent_group_membership_invitation", - NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_INVITATION => "accepted_group_membership_invitation", - NotifEventType::REJECTED_GROUP_MEMBERSHIP_INVITATION => "rejected_group_membership_invitation", + NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_INVITATION => { + "accepted_group_membership_invitation" + } + NotifEventType::REJECTED_GROUP_MEMBERSHIP_INVITATION => { + "rejected_group_membership_invitation" + } NotifEventType::SENT_GROUP_MEMBERSHIP_REQUEST => "sent_group_membership_request", - NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_REQUEST => "accepted_group_membership_request", - NotifEventType::REJECTED_GROUP_MEMBERSHIP_REQUEST => "rejected_group_membership_request", - NotifEventType::UNKNOWN => "" - }.to_string() + NotifEventType::ACCEPTED_GROUP_MEMBERSHIP_REQUEST => { + "accepted_group_membership_request" + } + NotifEventType::REJECTED_GROUP_MEMBERSHIP_REQUEST => { + "rejected_group_membership_request" + } + NotifEventType::UNKNOWN => "", + } + .to_string() } pub fn to_api(&self) -> String { @@ -111,7 +128,6 @@ impl NotifEventType { } } - #[allow(non_camel_case_types)] pub enum NotifEventVisibility { EVENT_PRIVATE, @@ -131,7 +147,8 @@ impl NotifEventVisibility { match self { NotifEventVisibility::EVENT_PUBLIC => "event_public", NotifEventVisibility::EVENT_PRIVATE => "event_private", - }.to_string() + } + .to_string() } pub fn to_api(&self) -> String { @@ -240,4 +257,4 @@ impl PartialNotification { self.kind = Some(t); self } -} \ No newline at end of file +} diff --git a/src/data/post.rs b/src/data/post.rs index 3155825..faa9334 100644 --- a/src/data/post.rs +++ b/src/data/post.rs @@ -28,7 +28,8 @@ impl PostVisibilityLevel { PostVisibilityLevel::VISIBILITY_FRIENDS => "friends", PostVisibilityLevel::VISIBILITY_USER => "private", PostVisibilityLevel::VISIBILITY_GROUP_MEMBERS => "members", - }.to_string() + } + .to_string() } pub fn from_api(level: &str) -> PostVisibilityLevel { @@ -66,7 +67,8 @@ impl PostAccessLevel { PostAccessLevel::BASIC_ACCESS => "basic", PostAccessLevel::INTERMEDIATE_ACCESS => "intermediate", PostAccessLevel::FULL_ACCESS => "full", - }.to_string() + } + .to_string() } } @@ -114,7 +116,8 @@ impl PostKind { PostKind::POST_KIND_COUNTDOWN(_) => "countdown", PostKind::POST_KIND_SURVEY => "survey", PostKind::POST_KIND_YOUTUBE(_) => "youtube", - }.to_string() + } + .to_string() } } @@ -171,4 +174,4 @@ mod tests { assert!(PostAccessLevel::BASIC_ACCESS < PostAccessLevel::INTERMEDIATE_ACCESS); assert!(PostAccessLevel::INTERMEDIATE_ACCESS < PostAccessLevel::FULL_ACCESS); } -} \ No newline at end of file +} diff --git a/src/data/presence.rs b/src/data/presence.rs index d72255f..bf0e205 100644 --- a/src/data/presence.rs +++ b/src/data/presence.rs @@ -14,9 +14,9 @@ pub struct Presence { impl PartialEq for Presence { fn eq(&self, other: &Self) -> bool { - self.user_id == other.user_id && - self.year == other.year && - self.month == other.month && - self.day == other.day + self.user_id == other.user_id + && self.year == other.year + && self.month == other.month + && self.day == other.day } -} \ No newline at end of file +} diff --git a/src/data/push_notification.rs b/src/data/push_notification.rs index d68928b..1be662f 100644 --- a/src/data/push_notification.rs +++ b/src/data/push_notification.rs @@ -11,4 +11,4 @@ pub struct PushNotification { pub body: String, pub image: Option, pub timeout: Option, -} \ No newline at end of file +} diff --git a/src/data/report.rs b/src/data/report.rs index 6ad0e9e..27d274e 100644 --- a/src/data/report.rs +++ b/src/data/report.rs @@ -67,7 +67,7 @@ pub const REPORT_CAUSES: [ReportCause; 5] = [ _id: "other", label_fr: "Autre", label_en: "Other", - } + }, ]; impl ReportCause { @@ -86,4 +86,4 @@ pub struct Report { pub time: u64, pub cause: &'static ReportCause, pub comment: Option, -} \ No newline at end of file +} diff --git a/src/data/security_settings.rs b/src/data/security_settings.rs index 4d8e289..56d6446 100644 --- a/src/data/security_settings.rs +++ b/src/data/security_settings.rs @@ -6,27 +6,22 @@ use crate::data::user::UserID; pub struct SecurityQuestion(Option, Option); -impl SecurityQuestion -{ - pub fn new(question: &Option, answer: &Option) -> SecurityQuestion - { +impl SecurityQuestion { + pub fn new(question: &Option, answer: &Option) -> SecurityQuestion { SecurityQuestion(question.clone(), answer.clone()) } - pub fn question(&self) -> Option - { + pub fn question(&self) -> Option { self.0.clone() } - pub fn answer(&self) -> Option - { + pub fn answer(&self) -> Option { self.1.clone() } } -pub struct SecuritySettings -{ +pub struct SecuritySettings { pub id: UserID, pub question1: SecurityQuestion, pub question2: SecurityQuestion, -} \ No newline at end of file +} diff --git a/src/data/survey.rs b/src/data/survey.rs index 08184b6..3f3a574 100644 --- a/src/data/survey.rs +++ b/src/data/survey.rs @@ -20,4 +20,4 @@ pub struct Survey { pub question: String, pub choices: Vec, pub allow_new_choices: bool, -} \ No newline at end of file +} diff --git a/src/data/survey_response.rs b/src/data/survey_response.rs index 93b04fe..51651fc 100644 --- a/src/data/survey_response.rs +++ b/src/data/survey_response.rs @@ -11,5 +11,5 @@ pub struct SurveyResponse { pub time_sent: u64, pub user_id: UserID, pub survey_id: u64, - pub choice_id: u64 -} \ No newline at end of file + pub choice_id: u64, +} diff --git a/src/data/u64_visitor.rs b/src/data/u64_visitor.rs index 2910f0a..80bbe89 100644 --- a/src/data/u64_visitor.rs +++ b/src/data/u64_visitor.rs @@ -13,8 +13,10 @@ impl<'de> Visitor<'de> for U64Visitor { formatter.write_str("An unsigned integer value") } - fn visit_u64(self, v: u64) -> Result where - E: Error, { + fn visit_u64(self, v: u64) -> Result + where + E: Error, + { Ok(v) } -} \ No newline at end of file +} diff --git a/src/data/user.rs b/src/data/user.rs index ac0435f..d292683 100644 --- a/src/data/user.rs +++ b/src/data/user.rs @@ -65,16 +65,22 @@ impl PartialEq for &UserID { } impl Serialize for UserID { - fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> where - S: Serializer { + fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> + where + S: Serializer, + { serializer.serialize_u64(self.0) } } impl<'de> Deserialize<'de> for UserID { - fn deserialize(deserializer: D) -> Result>::Error> where - D: Deserializer<'de> { - deserializer.deserialize_u64(U64Visitor {}).map(|id| UserID::new(id)) + fn deserialize(deserializer: D) -> Result>::Error> + where + D: Deserializer<'de>, + { + deserializer + .deserialize_u64(U64Visitor {}) + .map(|id| UserID::new(id)) } } @@ -90,7 +96,7 @@ impl UserPageVisibility { match self { UserPageVisibility::OPEN => "open", UserPageVisibility::PUBLIC => "public", - UserPageVisibility::PRIVATE => "private" + UserPageVisibility::PRIVATE => "private", } } } @@ -214,9 +220,9 @@ impl User { /// Check out whether security questions have been defined for this user or not pub fn has_security_questions(&self) -> bool { - self.security_question_1.is_some() && - self.security_answer_1.is_some() && - self.security_question_2.is_some() && - self.security_answer_2.is_some() + self.security_question_1.is_some() + && self.security_answer_1.is_some() + && self.security_question_2.is_some() + && self.security_answer_2.is_some() } -} \ No newline at end of file +} diff --git a/src/data/user_like.rs b/src/data/user_like.rs index 13439ea..133fdfe 100644 --- a/src/data/user_like.rs +++ b/src/data/user_like.rs @@ -10,4 +10,4 @@ pub struct UserLike { pub time_sent: u64, pub elem_type: String, pub elem_id: u64, -} \ No newline at end of file +} diff --git a/src/data/user_membership.rs b/src/data/user_membership.rs index 20c389f..be576c8 100644 --- a/src/data/user_membership.rs +++ b/src/data/user_membership.rs @@ -35,4 +35,4 @@ impl Ord for UserMembership { fn cmp(&self, other: &Self) -> Ordering { self.last_active().cmp(&other.last_active()) } -} \ No newline at end of file +} diff --git a/src/data/user_token.rs b/src/data/user_token.rs index 1a74414..0c6c413 100644 --- a/src/data/user_token.rs +++ b/src/data/user_token.rs @@ -1,4 +1,6 @@ -use crate::constants::push_notifications_db_prefix::{FIREBASE_PREFIX, INDEPENDENT_PREFIX, NONE_PREFIX}; +use crate::constants::push_notifications_db_prefix::{ + FIREBASE_PREFIX, INDEPENDENT_PREFIX, NONE_PREFIX, +}; use crate::constants::USER_ACCESS_TOKEN_ACTIVITY_REFRESH; use crate::data::user::UserID; use crate::utils::date_utils::time; @@ -64,4 +66,4 @@ impl PartialEq for UserAccessToken { fn eq(&self, other: &UserAccessToken) -> bool { self.id == other.id } -} \ No newline at end of file +} diff --git a/src/data/user_ws_connection.rs b/src/data/user_ws_connection.rs index cd6274e..8a6a11d 100644 --- a/src/data/user_ws_connection.rs +++ b/src/data/user_ws_connection.rs @@ -29,7 +29,6 @@ impl UserWsConnection { &self.user_token.user_id } - /// Check out whether a connection is being used to make a call in a specific conversation or not pub fn is_having_call_with_conversation(&self, conv_id: &ConvID) -> bool { if let Some(call_info) = &self.active_call { @@ -38,4 +37,4 @@ impl UserWsConnection { false } -} \ No newline at end of file +} diff --git a/src/data/user_ws_message.rs b/src/data/user_ws_message.rs index d84aecd..faf0234 100644 --- a/src/data/user_ws_message.rs +++ b/src/data/user_ws_message.rs @@ -22,4 +22,4 @@ impl UserWsMessage { data: serde_json::to_value(data)?, }) } -} \ No newline at end of file +} diff --git a/src/data/user_ws_request_handler.rs b/src/data/user_ws_request_handler.rs index 18844b6..db7367b 100644 --- a/src/data/user_ws_request_handler.rs +++ b/src/data/user_ws_request_handler.rs @@ -5,13 +5,13 @@ use std::collections::HashMap; use serde::Serialize; use crate::api_data::http_error::HttpError; +use crate::data::admin::AdminID; use crate::data::base_request_handler::{BaseRequestHandler, RequestValue}; use crate::data::conversation::ConvID; use crate::data::error::{Res, ResultBoxError}; use crate::data::user_token::UserAccessToken; use crate::data::user_ws_connection::UserWsConnection; use crate::routes::RequestResult; -use crate::data::admin::AdminID; pub enum UserWsResponseType { SUCCESS, @@ -30,10 +30,16 @@ pub struct UserWsRequestHandler { } impl UserWsRequestHandler { - pub fn new(connection: &UserWsConnection, args: HashMap) -> UserWsRequestHandler { + pub fn new( + connection: &UserWsConnection, + args: HashMap, + ) -> UserWsRequestHandler { UserWsRequestHandler { connection: connection.clone(), - args: args.into_iter().map(|f| (f.0, RequestValue::String(f.1))).collect(), + args: args + .into_iter() + .map(|f| (f.0, RequestValue::String(f.1))) + .collect(), response: None, } } @@ -58,7 +64,10 @@ impl UserWsRequestHandler { } /// Update information about the WebSocket connection - pub fn update_conn(&mut self, do_updates: H) -> ResultBoxError where H: FnOnce(&mut UserWsConnection) { + pub fn update_conn(&mut self, do_updates: H) -> ResultBoxError + where + H: FnOnce(&mut UserWsConnection), + { self.connection = self.connection.clone().replace(do_updates); Ok(()) @@ -108,4 +117,4 @@ impl BaseRequestHandler for UserWsRequestHandler { fn admin_id_opt(&self) -> Option { None } -} \ No newline at end of file +} diff --git a/src/data/webauthn_config.rs b/src/data/webauthn_config.rs index f907c41..add70d8 100644 --- a/src/data/webauthn_config.rs +++ b/src/data/webauthn_config.rs @@ -8,7 +8,8 @@ use crate::data::config::conf; pub fn get_wan() -> Webauthn { WebauthnBuilder::new( - conf().admin_url + conf() + .admin_url .replace("https://", "") .replace("http://", "") .split(':') @@ -19,8 +20,8 @@ pub fn get_wan() -> Webauthn { .unwrap(), &url::Url::parse(&conf().admin_url).unwrap(), ) - .expect("Invalid Webauthn configuration!") - .rp_name("ComunicAdmin") - .build() - .expect("Failed to build Webauthn object") -} \ No newline at end of file + .expect("Invalid Webauthn configuration!") + .rp_name("ComunicAdmin") + .build() + .expect("Failed to build Webauthn object") +} diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index 854e66e..6ee9e73 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -1,7 +1,7 @@ -use bcrypt::{DEFAULT_COST, hash_with_result, verify}; +use bcrypt::{hash_with_result, verify, DEFAULT_COST}; +use crate::constants::database_tables_names::{USERS_TABLE, USER_ACCESS_TOKENS_TABLE}; use crate::constants::{PASSWORD_RESET_TOKEN_LENGTH, PASSWORD_RESET_TOKEN_LIFETIME}; -use crate::constants::database_tables_names::{USER_ACCESS_TOKENS_TABLE, USERS_TABLE}; use crate::controllers::user_ws_controller; use crate::data::account_export::AccountExport; use crate::data::api_client::APIClient; @@ -15,10 +15,14 @@ use crate::data::report::ReportTarget; use crate::data::security_settings::SecuritySettings; use crate::data::user::{AccountImageVisibility, User, UserID, UserPageVisibility}; use crate::data::user_token::{PushNotificationToken, UserAccessToken}; -use crate::helpers::{comments_helper, conversations_helper, custom_emojies_helper, database, events_helper, forez_presence_helper, friends_helper, groups_helper, likes_helper, notifications_helper, posts_helper, push_notifications_helper, reports_helper, survey_helper, user_helper}; use crate::helpers::database::{DeleteQuery, InsertQuery, QueryInfo, RowResult, UpdateInfo}; use crate::helpers::events_helper::Event; use crate::helpers::likes_helper::LikeType; +use crate::helpers::{ + comments_helper, conversations_helper, custom_emojies_helper, database, events_helper, + forez_presence_helper, friends_helper, groups_helper, likes_helper, notifications_helper, + posts_helper, push_notifications_helper, reports_helper, survey_helper, user_helper, +}; use crate::utils::crypt_utils::{legacy_crypt_pass, rand_str}; use crate::utils::date_utils::{mysql_date, time}; use crate::utils::user_data_utils::user_data_path; @@ -68,14 +72,20 @@ pub fn login_user(email: &str, password: &str, client: &APIClient) -> ResultBoxE .add_str("token", &new_token.token) .add_u64("last_refresh", new_token.last_refresh) .add_u64("timeout", new_token.timeout) - .add_opt_str("push_notifications_token", new_token.push_notifications_token.to_db().as_ref()) + .add_opt_str( + "push_notifications_token", + new_token.push_notifications_token.to_db().as_ref(), + ) .insert_drop_result()?; Ok(new_token.token) } /// Find a user ID based on login token -pub fn find_user_by_login_token(token: &str, client: &APIClient) -> ResultBoxError { +pub fn find_user_by_login_token( + token: &str, + client: &APIClient, +) -> ResultBoxError { QueryInfo::new(USER_ACCESS_TOKENS_TABLE) .cond_u64("client_id", client.id) .cond("token", token) @@ -195,11 +205,13 @@ pub fn change_password(user_id: &UserID, new_password: &str) -> ResultBoxError { } /// Check out whether a virtual directory is taken by a user or not -pub fn check_user_directory_availability(dir: &str, user_id: Option) -> ResultBoxError { +pub fn check_user_directory_availability( + dir: &str, + user_id: Option, +) -> ResultBoxError { let found_user = user_helper::find_user_by_virtual_directory(dir); match (found_user, user_id) { - // A user was found, but we did not specify a user (Ok(_), None) => Ok(false), @@ -207,7 +219,7 @@ pub fn check_user_directory_availability(dir: &str, user_id: Option) -> (Ok(user), Some(id)) => Ok(user.id == id), // No user was found, virtual directory is considered as available - (Err(_), _) => Ok(true) + (Err(_), _) => Ok(true), } } @@ -219,15 +231,20 @@ pub fn update_last_activity(user_id: &UserID) -> ResultBoxError { .exec() } - /// Set new general settings of an account pub fn set_general(settings: &GeneralSettings) -> ResultBoxError { database::UpdateInfo::new(USERS_TABLE) .cond_user_id("ID", &settings.id) .set_str("prenom", &settings.first_name) .set_str("nom", &settings.last_name) - .set_legacy_bool("public", settings.page_status != UserPageVisibility::PRIVATE) - .set_legacy_bool("pageouverte", settings.page_status == UserPageVisibility::OPEN) + .set_legacy_bool( + "public", + settings.page_status != UserPageVisibility::PRIVATE, + ) + .set_legacy_bool( + "pageouverte", + settings.page_status == UserPageVisibility::OPEN, + ) .set_legacy_bool("bloquecommentaire", settings.block_comments) .set_legacy_bool("autoriser_post_amis", settings.allow_posts_from_friends) .set_legacy_bool("autorise_mail", settings.allow_mails) @@ -277,8 +294,7 @@ pub fn delete_account_image(user_id: &UserID) -> ResultBoxError { let path = user_data_path(user.account_image_path.unwrap().as_ref()); - if path.exists() - { + if path.exists() { std::fs::remove_file(path)?; } @@ -301,7 +317,10 @@ pub fn set_account_image(user_id: &UserID, uri: &String) -> ResultBoxError { } /// Set account image visibility level -pub fn set_account_image_visibility(user_id: &UserID, level: AccountImageVisibility) -> ResultBoxError { +pub fn set_account_image_visibility( + user_id: &UserID, + level: AccountImageVisibility, +) -> ResultBoxError { database::UpdateInfo::new(USERS_TABLE) .cond_user_id("ID", user_id) .set_str("account_image_visibility", &level.to_db()) @@ -313,10 +332,16 @@ pub fn set_data_conservation_policy(new_policy: NewDataConservationPolicy) -> Re database::UpdateInfo::new(USERS_TABLE) .cond_user_id("ID", &new_policy.user_id) .set_opt_u64_or_zero("delete_account_after", new_policy.delete_account_after) - .set_opt_u64_or_zero("delete_notifications_after", new_policy.delete_notifications_after) + .set_opt_u64_or_zero( + "delete_notifications_after", + new_policy.delete_notifications_after, + ) .set_opt_u64_or_zero("delete_comments_after", new_policy.delete_comments_after) .set_opt_u64_or_zero("delete_posts_after", new_policy.delete_posts_after) - .set_opt_u64_or_zero("delete_conversation_messages_after", new_policy.delete_conversation_messages_after) + .set_opt_u64_or_zero( + "delete_conversation_messages_after", + new_policy.delete_conversation_messages_after, + ) .set_opt_u64_or_zero("delete_likes_after", new_policy.delete_likes_after) .exec() } @@ -331,7 +356,10 @@ pub fn set_notifications_settings(new_settings: NewNotificationsSettings) -> Res } /// Set new push notification token -pub async fn set_push_notification_token(client: &UserAccessToken, new_token: PushNotificationToken) -> Res { +pub async fn set_push_notification_token( + client: &UserAccessToken, + new_token: PushNotificationToken, +) -> Res { // In case of independent push service, remove previous client push_notifications_helper::un_register_from_previous_service(client).await?; @@ -451,7 +479,6 @@ fn hash_password(pass: &str) -> Res { /// If the password is encoded using the legacy method, it is automatically upgraded in case of /// success fn validate_password(user: &User, password: &str) -> Res { - // We check if the password use the new storage mechanism if user.password.starts_with("$") { return Ok(verify(password, &user.password)?); @@ -472,7 +499,8 @@ fn validate_password(user: &User, password: &str) -> Res { } fn db_to_user_access_token(res: &RowResult) -> Res { - let push_notifications_token = PushNotificationToken::from_db(res.get_optional_str("push_notifications_token")?); + let push_notifications_token = + PushNotificationToken::from_db(res.get_optional_str("push_notifications_token")?); Ok(UserAccessToken { id: res.get_u64("id")?, @@ -483,4 +511,4 @@ fn db_to_user_access_token(res: &RowResult) -> Res { timeout: res.get_u64("timeout")?, push_notifications_token, }) -} \ No newline at end of file +} diff --git a/src/helpers/admin_access_token_helper.rs b/src/helpers/admin_access_token_helper.rs index ff1b34c..f60ce13 100644 --- a/src/helpers/admin_access_token_helper.rs +++ b/src/helpers/admin_access_token_helper.rs @@ -23,9 +23,7 @@ pub fn init() { /// Create and return a new access token for an admin pub fn create(id: AdminID) -> Res { - let map = unsafe { - CACHE.as_ref().unwrap().lock() - }; + let map = unsafe { CACHE.as_ref().unwrap().lock() }; let token = AdminAccessToken { token: rand_str(ADMIN_ACCESS_TOKEN_LENGTH), @@ -40,9 +38,7 @@ pub fn create(id: AdminID) -> Res { /// Remove an access token from the list pub fn destroy(id: AdminID) -> Res { - let map = unsafe { - CACHE.as_ref().unwrap().lock() - }; + let map = unsafe { CACHE.as_ref().unwrap().lock() }; map?.remove(&id); @@ -51,22 +47,20 @@ pub fn destroy(id: AdminID) -> Res { /// Find an admin by its access token pub fn find_by_token(t: &str) -> Res { - let map = unsafe { - CACHE.as_ref().unwrap().lock() - }; + let map = unsafe { CACHE.as_ref().unwrap().lock() }; let mut map = map?; - let token = map.iter() - .filter(|p| p.1.token.eq(t)) - .next(); + let token = map.iter().filter(|p| p.1.token.eq(t)).next(); let mut token = match token { None => { - return Err(ExecError::boxed_new("The token was not recognized as an admin token!")); + return Err(ExecError::boxed_new( + "The token was not recognized as an admin token!", + )); } - Some(t) => t.1 - }.clone(); - + Some(t) => t.1, + } + .clone(); if token.last_refresh + ADMIN_ACCESS_TOKEN_LIFETIME < time() { return Err(ExecError::boxed_new("The token has expired!")); @@ -77,4 +71,4 @@ pub fn find_by_token(t: &str) -> Res { map.insert(token.id, token.clone()); Ok(token) -} \ No newline at end of file +} diff --git a/src/helpers/admin_account_helper.rs b/src/helpers/admin_account_helper.rs index 16991c5..86b1b25 100644 --- a/src/helpers/admin_account_helper.rs +++ b/src/helpers/admin_account_helper.rs @@ -2,8 +2,8 @@ //! //! @author Pierre Hubert -use crate::constants::{ADMIN_RESET_TOKEN_LENGTH, ADMIN_RESET_TOKEN_LIFETIME}; use crate::constants::database_tables_names::ADMIN_LIST_TABLE; +use crate::constants::{ADMIN_RESET_TOKEN_LENGTH, ADMIN_RESET_TOKEN_LIFETIME}; use crate::data::admin::{Admin, AdminID, AdminResetToken, NewAdmin, NewAdminGeneralSettings}; use crate::data::error::{ExecError, Res}; use crate::helpers::{admin_roles_helper, database}; @@ -13,7 +13,9 @@ use crate::utils::date_utils::time; /// Create a new admin account pub fn create(new_admin: &NewAdmin) -> Res { if find_admin_by_email(&new_admin.email).is_ok() { - return Err(ExecError::boxed_new("An other admin account already holds the same email address!")); + return Err(ExecError::boxed_new( + "An other admin account already holds the same email address!", + )); } database::InsertQuery::new(ADMIN_LIST_TABLE) @@ -34,8 +36,7 @@ pub fn exists(id: AdminID) -> Res { /// Get the entire list of administrators pub fn get_list() -> Res> { - database::QueryInfo::new(ADMIN_LIST_TABLE) - .exec(db_to_admin) + database::QueryInfo::new(ADMIN_LIST_TABLE).exec(db_to_admin) } /// Get admin information by ID @@ -79,8 +80,7 @@ pub fn set_general_settings(settings: NewAdminGeneralSettings) -> Res { /// Turn a database entry into an admin structure fn db_to_admin(row: &database::RowResult) -> Res { - let reset_token_expire = row.get_optional_u64("reset_token_expire")? - .unwrap_or(0); + let reset_token_expire = row.get_optional_u64("reset_token_expire")?.unwrap_or(0); let reset_token = if reset_token_expire < time() { None @@ -101,4 +101,4 @@ fn db_to_admin(row: &database::RowResult) -> Res { reset_token, roles: admin_roles_helper::get_roles(admin_id)?, }) -} \ No newline at end of file +} diff --git a/src/helpers/admin_account_key_helper.rs b/src/helpers/admin_account_key_helper.rs index 9c741d6..f736f97 100644 --- a/src/helpers/admin_account_key_helper.rs +++ b/src/helpers/admin_account_key_helper.rs @@ -2,7 +2,7 @@ //! //! @author Pierre Hubert -use bcrypt::{DEFAULT_COST, hash_with_result}; +use bcrypt::{hash_with_result, DEFAULT_COST}; use webauthn_rs::prelude::Passkey; use crate::constants::database_tables_names::ADMIN_KEYS_TABLE; @@ -18,7 +18,10 @@ pub fn add_key(id: AdminID, name: &str, key: Passkey, password: String) -> Res Res { key: serde_json::from_str(&row.get_str("credential")?)?, password: row.get_optional_str("password")?, }) -} \ No newline at end of file +} diff --git a/src/helpers/admin_key_authentication_challenges_helper.rs b/src/helpers/admin_key_authentication_challenges_helper.rs index ce47ce4..137d8ce 100644 --- a/src/helpers/admin_key_authentication_challenges_helper.rs +++ b/src/helpers/admin_key_authentication_challenges_helper.rs @@ -23,9 +23,7 @@ pub fn init() { /// Store a new entry in the cache pub fn set(key_id: u64, state: PasskeyAuthentication) -> Res { - let cache = unsafe { - CACHE.as_ref().unwrap().lock() - }; + let cache = unsafe { CACHE.as_ref().unwrap().lock() }; cache?.insert(key_id, state); @@ -33,9 +31,7 @@ pub fn set(key_id: u64, state: PasskeyAuthentication) -> Res { } pub fn get(key_id: u64) -> Res> { - let cache = unsafe { - CACHE.as_ref().unwrap().lock() - }; + let cache = unsafe { CACHE.as_ref().unwrap().lock() }; Ok(cache?.remove(&key_id)) -} \ No newline at end of file +} diff --git a/src/helpers/admin_key_registration_challenges_helper.rs b/src/helpers/admin_key_registration_challenges_helper.rs index c14690c..d812542 100644 --- a/src/helpers/admin_key_registration_challenges_helper.rs +++ b/src/helpers/admin_key_registration_challenges_helper.rs @@ -24,9 +24,7 @@ pub fn init() { /// Store a new entry in the cache pub fn set(admin: AdminID, key: PasskeyRegistration) -> Res { - let cache = unsafe { - CACHE.as_ref().unwrap().lock() - }; + let cache = unsafe { CACHE.as_ref().unwrap().lock() }; cache?.insert(admin, key); @@ -34,9 +32,7 @@ pub fn set(admin: AdminID, key: PasskeyRegistration) -> Res { } pub fn get(admin: AdminID) -> Res> { - let cache = unsafe { - CACHE.as_ref().unwrap().lock() - }; + let cache = unsafe { CACHE.as_ref().unwrap().lock() }; Ok(cache?.remove(&admin)) -} \ No newline at end of file +} diff --git a/src/helpers/admin_log_helper.rs b/src/helpers/admin_log_helper.rs index fa56bff..9eff55f 100644 --- a/src/helpers/admin_log_helper.rs +++ b/src/helpers/admin_log_helper.rs @@ -28,7 +28,6 @@ pub fn clean_old_logs() -> Res { .exec() } - /// Get all administrators action log history pub fn get_all_admin_logs() -> Res> { database::QueryInfo::new(ADMIN_LOGS_TABLE).exec(db_to_log) @@ -47,7 +46,10 @@ fn db_to_log(row: &database::RowResult) -> Res { admin_id: row.get_admin_id("admin_id")?, ip: row.get_str("ip")?, time: row.get_u64("time")?, - action: serde_json::from_str(&row.get_str("action")?) - .unwrap_or(AdminAction::UnsupportedAction { raw_data: row.get_str("action").unwrap() }), + action: serde_json::from_str(&row.get_str("action")?).unwrap_or( + AdminAction::UnsupportedAction { + raw_data: row.get_str("action").unwrap(), + }, + ), }) -} \ No newline at end of file +} diff --git a/src/helpers/admin_roles_helper.rs b/src/helpers/admin_roles_helper.rs index 296171b..4d8510d 100644 --- a/src/helpers/admin_roles_helper.rs +++ b/src/helpers/admin_roles_helper.rs @@ -46,7 +46,10 @@ fn db_to_role(row: &database::RowResult) -> Res { let role = AdminRole::from_id(&role_id); match role { - None => Err(ExecError::boxed_string(format!("Role {} from database not found in the list!", role_id))), - Some(r) => Ok(r) + None => Err(ExecError::boxed_string(format!( + "Role {} from database not found in the list!", + role_id + ))), + Some(r) => Ok(r), } -} \ No newline at end of file +} diff --git a/src/helpers/api_helper.rs b/src/helpers/api_helper.rs index 0d9bc08..296467f 100644 --- a/src/helpers/api_helper.rs +++ b/src/helpers/api_helper.rs @@ -2,7 +2,7 @@ use crate::constants::database_tables_names::CLIENTS_TABLE; use crate::data::api_client::APIClient; use crate::data::error::{Res, ResultBoxError}; use crate::helpers::database; -use crate::helpers::database::{QueryInfo, InsertQuery}; +use crate::helpers::database::{InsertQuery, QueryInfo}; /// API helper /// @@ -10,8 +10,7 @@ use crate::helpers::database::{QueryInfo, InsertQuery}; /// Get the entire list of clients pub fn get_clients() -> Res> { - QueryInfo::new(CLIENTS_TABLE) - .exec(db_to_client) + QueryInfo::new(CLIENTS_TABLE).exec(db_to_client) } /// Register a new client @@ -20,8 +19,14 @@ pub fn register_client(client: &APIClient) -> Res { .add_str("name", &client.name) .add_opt_str("domain", client.domain.as_ref()) .add_opt_str("comment", client.comment.as_ref()) - .add_opt_str("firebase_project_name", client.firebase_project_name.as_ref()) - .add_opt_str("firebase_service_account_file", client.firebase_service_account_file.as_ref()); + .add_opt_str( + "firebase_project_name", + client.firebase_project_name.as_ref(), + ) + .add_opt_str( + "firebase_service_account_file", + client.firebase_service_account_file.as_ref(), + ); if client.default_expiration_time > 0 { query = query.add_u64("default_expiration_time", client.default_expiration_time); @@ -61,4 +66,4 @@ fn db_to_client(res: &database::RowResult) -> Res { firebase_project_name: res.get_optional_str("firebase_project_name")?, firebase_service_account_file: res.get_optional_str("firebase_service_account_file")?, }) -} \ No newline at end of file +} diff --git a/src/helpers/background_image_helper.rs b/src/helpers/background_image_helper.rs index fc956a6..f3fa438 100644 --- a/src/helpers/background_image_helper.rs +++ b/src/helpers/background_image_helper.rs @@ -8,4 +8,4 @@ use crate::utils::user_data_utils::user_data_url; pub fn get_url(_user_id: &UserID) -> String { user_data_url("imgfond/0.jpg") -} \ No newline at end of file +} diff --git a/src/helpers/calls_helper.rs b/src/helpers/calls_helper.rs index 7d36d6e..4b90eb1 100644 --- a/src/helpers/calls_helper.rs +++ b/src/helpers/calls_helper.rs @@ -30,4 +30,4 @@ pub fn can_have_video_calls(conv: &Conversation) -> bool { } false -} \ No newline at end of file +} diff --git a/src/helpers/comments_helper.rs b/src/helpers/comments_helper.rs index 1370f64..dc88a93 100644 --- a/src/helpers/comments_helper.rs +++ b/src/helpers/comments_helper.rs @@ -7,9 +7,9 @@ use crate::data::comment::Comment; use crate::data::error::{ExecError, Res, ResultBoxError}; use crate::data::report::ReportTarget; use crate::data::user::{User, UserID}; -use crate::helpers::{database, events_helper, likes_helper, reports_helper}; use crate::helpers::events_helper::Event; use crate::helpers::likes_helper::LikeType; +use crate::helpers::{database, events_helper, likes_helper, reports_helper}; use crate::utils::date_utils::{mysql_date, time}; use crate::utils::user_data_utils::user_data_path; @@ -53,7 +53,6 @@ pub fn export_all_user(user_id: &UserID) -> ResultBoxError> { .exec(db_to_comment) } - /// Turn a database entry into a comment object fn db_to_comment(row: &database::RowResult) -> ResultBoxError { Ok(Comment { @@ -62,7 +61,8 @@ fn db_to_comment(row: &database::RowResult) -> ResultBoxError { user_id: row.get_user_id("ID_personne")?, post_id: row.get_u64("ID_texte")?, content: row.get_str("commentaire")?, - image_path: row.get_optional_str("image_commentaire")? + image_path: row + .get_optional_str("image_commentaire")? .map(|f| f.replace("file:", "")), }) } @@ -144,4 +144,4 @@ pub async fn clean_old_comments(user: &User) -> Res { } Ok(()) -} \ No newline at end of file +} diff --git a/src/helpers/conversations_helper.rs b/src/helpers/conversations_helper.rs index 7b83ca5..df3a3e8 100644 --- a/src/helpers/conversations_helper.rs +++ b/src/helpers/conversations_helper.rs @@ -2,9 +2,16 @@ //! //! @author Pierre Hubert -use crate::constants::database_tables_names::{CONV_LIST_TABLE, CONV_MEMBERS_TABLE, CONV_MESSAGES_TABLE}; -use crate::data::conversation::{Conversation, ConversationMember, ConvID, NewConversationSettings}; -use crate::data::conversation_message::{ConversationMessage, ConversationMessageFile, ConversationServerMessageType, UserAddedAnotherUserToConversation, UserRemovedAnotherUserToConversation}; +use crate::constants::database_tables_names::{ + CONV_LIST_TABLE, CONV_MEMBERS_TABLE, CONV_MESSAGES_TABLE, +}; +use crate::data::conversation::{ + ConvID, Conversation, ConversationMember, NewConversationSettings, +}; +use crate::data::conversation_message::{ + ConversationMessage, ConversationMessageFile, ConversationServerMessageType, + UserAddedAnotherUserToConversation, UserRemovedAnotherUserToConversation, +}; use crate::data::error::{ExecError, Res, ResultBoxError}; use crate::data::group_id::GroupID; use crate::data::group_member::GroupMembershipLevel; @@ -12,9 +19,9 @@ use crate::data::new_conversation::NewConversation; use crate::data::new_conversation_message::NewConversationMessage; use crate::data::report::ReportTarget; use crate::data::user::{User, UserID}; -use crate::helpers::{database, events_helper, groups_helper, reports_helper}; use crate::helpers::database::{InsertQuery, UpdateInfo}; use crate::helpers::events_helper::Event; +use crate::helpers::{database, events_helper, groups_helper, reports_helper}; use crate::utils::date_utils::time; use crate::utils::user_data_utils::delete_user_data_file_if_exists; @@ -29,8 +36,10 @@ pub async fn create(conv: &NewConversation) -> Res { .add_opt_str("logo", Option::from(&conv.logo)) .add_legacy_bool("can_everyone_add_members", conv.can_everyone_add_members) .add_opt_group_id("group_id", conv.group_id.clone()) - .add_opt_u32("min_group_membership_level", - conv.group_min_membership_level.as_ref().map(|s| s.to_db())) + .add_opt_u32( + "min_group_membership_level", + conv.group_min_membership_level.as_ref().map(|s| s.to_db()), + ) .insert()? .map(|i| ConvID::new(i)) .ok_or(ExecError::new("missing result conv id!"))?; @@ -40,13 +49,19 @@ pub async fn create(conv: &NewConversation) -> Res { update_members_list_for_group_conversation(conv_id).await?; } else { // Add the creator of the conversation - add_member(conv_id, &conv.owner_id, conv.owner_following, true, Some(&conv.owner_id)).await?; + add_member( + conv_id, + &conv.owner_id, + conv.owner_following, + true, + Some(&conv.owner_id), + ) + .await?; // Add other members to the conversation for member in &conv.members { if !member.eq(&conv.owner_id) { - add_member(conv_id, member, true, false, - Some(&conv.owner_id)).await?; + add_member(conv_id, member, true, false, Some(&conv.owner_id)).await?; } } } @@ -55,7 +70,11 @@ pub async fn create(conv: &NewConversation) -> Res { } /// Create a conversation for a group -pub async fn create_conversation_for_group(group_id: GroupID, min_membership_level: GroupMembershipLevel, name: &String) -> Res { +pub async fn create_conversation_for_group( + group_id: GroupID, + min_membership_level: GroupMembershipLevel, + name: &String, +) -> Res { create(&NewConversation { owner_id: UserID::invalid(), name: Some(name.to_string()), @@ -66,11 +85,18 @@ pub async fn create_conversation_for_group(group_id: GroupID, min_membership_lev owner_following: false, members: Default::default(), can_everyone_add_members: false, - }).await + }) + .await } /// Add a member to a conversation -pub async fn add_member(conv_id: ConvID, user_id: &UserID, following: bool, admin: bool, adder: Option<&UserID>) -> Res { +pub async fn add_member( + conv_id: ConvID, + user_id: &UserID, + following: bool, + admin: bool, + adder: Option<&UserID>, +) -> Res { InsertQuery::new(CONV_MEMBERS_TABLE) .add_conv_id("conv_id", conv_id) .add_user_id("user_id", user_id) @@ -82,22 +108,24 @@ pub async fn add_member(conv_id: ConvID, user_id: &UserID, following: bool, admi // Send the messages (if possible, no messages are created for groups conversations) if let Some(adder) = adder { - // Create a message if adder != user_id { - send_message( - &NewConversationMessage::new_server_message( - conv_id, - ConversationServerMessageType::UserAddedAnotherUserToConversation(UserAddedAnotherUserToConversation { + send_message(&NewConversationMessage::new_server_message( + conv_id, + ConversationServerMessageType::UserAddedAnotherUserToConversation( + UserAddedAnotherUserToConversation { user_who_added: adder.clone(), user_added: user_id.clone(), - }), - ) - ).await?; + }, + ), + )) + .await?; } else { send_message(&NewConversationMessage::new_server_message( - conv_id, ConversationServerMessageType::UserCreatedConversation(user_id.clone()), - )).await?; + conv_id, + ConversationServerMessageType::UserCreatedConversation(user_id.clone()), + )) + .await?; } } @@ -117,19 +145,14 @@ pub fn set_admin(conv_id: &ConvID, user_id: &UserID, admin: bool) -> Res { pub fn get_list_user(user_id: &UserID) -> ResultBoxError> { database::QueryInfo::new(CONV_LIST_TABLE) .alias("l") - // Join with conversation members table .join(CONV_MEMBERS_TABLE, "u", "l.id = u.conv_id") - // Specify selected fields .add_field("l.*") - // Filter query .cond_user_id("u.user_id", user_id) - // Sort results .set_order("l.last_activity DESC") - // Execute query .exec(db_to_conversation_info) } @@ -164,7 +187,6 @@ pub fn get_user_membership(user_id: &UserID, conv_id: ConvID) -> Res ResultBoxError { database::QueryInfo::new(CONV_LIST_TABLE) @@ -188,12 +210,18 @@ pub fn set_settings(settings: NewConversationSettings) -> Res { .cond_conv_id("id", settings.conv_id) .set_opt_str("name", settings.name) .set_opt_str("color", settings.color) - .set_legacy_bool("can_everyone_add_members", settings.can_everyone_add_members) + .set_legacy_bool( + "can_everyone_add_members", + settings.can_everyone_add_members, + ) .exec() } /// Change minimal membership level to join a group conversation -pub async fn set_min_group_conversation_membership_level(conv_id: ConvID, level: GroupMembershipLevel) -> Res { +pub async fn set_min_group_conversation_membership_level( + conv_id: ConvID, + level: GroupMembershipLevel, +) -> Res { database::UpdateInfo::new(CONV_LIST_TABLE) .cond_conv_id("id", conv_id) .set_u32("min_group_membership_level", level.to_db()) @@ -206,20 +234,27 @@ pub async fn set_min_group_conversation_membership_level(conv_id: ConvID, level: pub fn find_private(user_1: &UserID, user_2: &UserID) -> ResultBoxError> { database::QueryInfo::new(CONV_MEMBERS_TABLE) .alias("t1") - // Join .join(CONV_MEMBERS_TABLE, "t2", "t1.conv_id = t2.conv_id") - // Conditions .cond_user_id("t1.user_id", user_1) .cond_user_id("t2.user_id", user_2) - .set_custom_where(format!("(SELECT COUNT(*) FROM {} WHERE conv_id = t1.conv_id) = 2", CONV_MEMBERS_TABLE).as_ref()) + .set_custom_where( + format!( + "(SELECT COUNT(*) FROM {} WHERE conv_id = t1.conv_id) = 2", + CONV_MEMBERS_TABLE + ) + .as_ref(), + ) .add_field("t1.conv_id AS conv_id") .exec(|f| f.get_conv_id("conv_id")) } /// Get the last messages posted in a conversation -pub fn get_last_messages(conv_id: ConvID, number_of_messages: u64) -> ResultBoxError> { +pub fn get_last_messages( + conv_id: ConvID, + number_of_messages: u64, +) -> ResultBoxError> { database::QueryInfo::new(CONV_MESSAGES_TABLE) .cond_conv_id("conv_id", conv_id) .set_limit(number_of_messages) @@ -232,7 +267,10 @@ pub fn get_last_messages(conv_id: ConvID, number_of_messages: u64) -> ResultBoxE } /// Get the new messages of a conversation -pub fn get_new_messages(conv_id: ConvID, last_message_id: u64) -> ResultBoxError> { +pub fn get_new_messages( + conv_id: ConvID, + last_message_id: u64, +) -> ResultBoxError> { database::QueryInfo::new(CONV_MESSAGES_TABLE) .cond_conv_id("conv_id", conv_id) .set_custom_where("id > ?") @@ -246,7 +284,11 @@ pub fn get_new_messages(conv_id: ConvID, last_message_id: u64) -> ResultBoxError /// `conv_id` contains the ID of the target conversation /// `start_id` contains the ID from wich the research start /// `limit` Maximum number of messages to get -pub fn get_older_messages(conv_id: ConvID, start_id: u64, limit: u64) -> ResultBoxError> { +pub fn get_older_messages( + conv_id: ConvID, + start_id: u64, + limit: u64, +) -> ResultBoxError> { database::QueryInfo::new(CONV_MESSAGES_TABLE) .cond_conv_id("conv_id", conv_id) .set_custom_where("ID <= ?") @@ -261,7 +303,10 @@ pub fn get_older_messages(conv_id: ConvID, start_id: u64, limit: u64) -> ResultB } /// Get all the messages of a single user for a conversation -pub fn get_user_messages_for_conversations(conv_id: ConvID, user_id: &UserID) -> ResultBoxError> { +pub fn get_user_messages_for_conversations( + conv_id: ConvID, + user_id: &UserID, +) -> ResultBoxError> { database::QueryInfo::new(CONV_MESSAGES_TABLE) .cond_conv_id("conv_id", conv_id) .cond_user_id("user_id", user_id) @@ -353,7 +398,8 @@ pub async fn send_message(msg: &NewConversationMessage) -> ResultBoxError<()> { } if let Some(file) = &msg.file { - msg_request = msg_request.add_str("file_path", &file.path) + msg_request = msg_request + .add_str("file_path", &file.path) .add_u64("file_size", file.size) .add_str("file_name", &file.name) .add_str("file_type", &file.r#type) @@ -400,14 +446,16 @@ pub async fn update_message_content(msg_id: u64, new_content: &str) -> ResultBox .exec()?; // Send an event (conv_message_updated) - events_helper::propagate_event(Event::UpdatedConversationMessage(get_single_message(msg_id)?)).await?; + events_helper::propagate_event(Event::UpdatedConversationMessage(get_single_message( + msg_id, + )?)) + .await?; Ok(()) } /// Remove a message from a conversation pub async fn delete_message(msg: &ConversationMessage) -> ResultBoxError<()> { - // Delete associated reports reports_helper::delete_all_for_target(ReportTarget::ConversationMessage(msg.id))?; @@ -446,19 +494,19 @@ pub fn get_list_unread(user_id: &UserID) -> ResultBoxError> { database::QueryInfo::new(CONV_MEMBERS_TABLE) .alias("mem") .join(CONV_MESSAGES_TABLE, "mess", "mem.conv_id = mess.conv_id") - .cond_user_id("mem.user_id", user_id) .cond_legacy_bool("mem.following", true) - .set_custom_where("mem.last_message_seen < mess.id") - .add_field("distinct mem.conv_id") - .exec(|r| r.get_conv_id("conv_id")) } /// Indicate that a user has seen the last messages of a conversation -pub async fn mark_user_seen(conv_id: ConvID, user_id: &UserID, last_msg: &ConversationMessage) -> Res { +pub async fn mark_user_seen( + conv_id: ConvID, + user_id: &UserID, + last_msg: &ConversationMessage, +) -> Res { database::UpdateInfo::new(CONV_MEMBERS_TABLE) .cond_conv_id("conv_id", conv_id) .cond_user_id("user_id", user_id) @@ -467,16 +515,24 @@ pub async fn mark_user_seen(conv_id: ConvID, user_id: &UserID, last_msg: &Conver .exec()?; // Push an event - events_helper::propagate_event(Event::SeenLastConversationMessage(user_id.clone(), conv_id)).await?; + events_helper::propagate_event(Event::SeenLastConversationMessage(user_id.clone(), conv_id)) + .await?; // Push an event (updated_number_unread_conversations) - events_helper::propagate_event(Event::UpdatedNumberUnreadConversations(vec![user_id.clone()])).await?; + events_helper::propagate_event(Event::UpdatedNumberUnreadConversations(vec![ + user_id.clone() + ])) + .await?; Ok(()) } /// Remove a user from a conversation -pub async fn remove_user_from_conversation(user_id: &UserID, conv: &Conversation, remover: &UserID) -> ResultBoxError<()> { +pub async fn remove_user_from_conversation( + user_id: &UserID, + conv: &Conversation, + remover: &UserID, +) -> ResultBoxError<()> { if conv.is_last_admin(user_id) { delete_conversation(conv).await } else { @@ -498,14 +554,20 @@ pub async fn update_members_list_for_group_conversation(conv_id: ConvID) -> Res let conv = get_single(conv_id)?; if !conv.is_linked_to_group() { - return Err(ExecError::boxed_new("Attempted to update members list for a non-group conversation!")); + return Err(ExecError::boxed_new( + "Attempted to update members list for a non-group conversation!", + )); } let group_members = groups_helper::get_list_members(conv.group_id.as_ref().unwrap())?; // Add missing memberships / Update existing invalid memberships for member in &group_members { - let conv_member = conv.members.iter().filter(|f| f.user_id == member.user_id).next(); + let conv_member = conv + .members + .iter() + .filter(|f| f.user_id == member.user_id) + .next(); if let Some(conv_member) = conv_member { // Update admin status, if required @@ -513,7 +575,6 @@ pub async fn update_members_list_for_group_conversation(conv_id: ConvID) -> Res set_admin(&conv_id, &member.user_id, member.is_admin())?; } } - // Create the member else if conv.min_group_membership_level.as_ref().unwrap() >= &member.level { add_member(conv_id, &member.user_id, true, member.is_admin(), None).await?; @@ -522,10 +583,15 @@ pub async fn update_members_list_for_group_conversation(conv_id: ConvID) -> Res // Remove memberships that have to be removed for conv_member in &conv.members { - let member = group_members.iter().filter(|m| m.user_id == conv_member.user_id).next(); + let member = group_members + .iter() + .filter(|m| m.user_id == conv_member.user_id) + .next(); // Remove the member, if required - if member.is_none() || conv.min_group_membership_level.as_ref().unwrap() < &member.unwrap().level { + if member.is_none() + || conv.min_group_membership_level.as_ref().unwrap() < &member.unwrap().level + { remove_member(&conv_member.user_id, conv_id, None).await?; } } @@ -574,7 +640,11 @@ pub async fn delete_all_group_conversations(group_id: &GroupID) -> Res { } /// Delete a conversation membership -pub async fn remove_member(user_id: &UserID, conv_id: ConvID, remover: Option<&UserID>) -> ResultBoxError<()> { +pub async fn remove_member( + user_id: &UserID, + conv_id: ConvID, + remover: Option<&UserID>, +) -> ResultBoxError<()> { for msg in get_user_messages_for_conversations(conv_id, user_id)? { delete_message(&msg).await?; } @@ -591,20 +661,25 @@ pub async fn remove_member(user_id: &UserID, conv_id: ConvID, remover: Option<&U send_message(&NewConversationMessage::new_server_message( conv_id, ConversationServerMessageType::UserLeftConversation(user_id.clone()), - )).await?; + )) + .await?; } else { send_message(&NewConversationMessage::new_server_message( conv_id, - ConversationServerMessageType::UserRemovedFromConversation(UserRemovedAnotherUserToConversation { - user_who_removed: remover.clone(), - user_removed: user_id.clone(), - }), - )).await?; + ConversationServerMessageType::UserRemovedFromConversation( + UserRemovedAnotherUserToConversation { + user_who_removed: remover.clone(), + user_removed: user_id.clone(), + }, + ), + )) + .await?; } } // Propagate event - events_helper::propagate_event(Event::RemovedUserFromConversation(user_id.clone(), conv_id)).await?; + events_helper::propagate_event(Event::RemovedUserFromConversation(user_id.clone(), conv_id)) + .await?; Ok(()) } @@ -653,7 +728,8 @@ fn db_to_conversation_info(row: &database::RowResult) -> ResultBoxError Res ResultBoxError { let user_id = match row.is_null("user_id")? { true => None, - false => Some(row.get_user_id("user_id")?) + false => Some(row.get_user_id("user_id")?), }; let file = match row.is_null_or_empty("file_path")? { @@ -688,12 +763,14 @@ fn db_to_conversation_message(row: &database::RowResult) -> ResultBoxError None, - None => Some(ConversationServerMessageType::from_db(&row.get_str("message")?)?) + None => Some(ConversationServerMessageType::from_db( + &row.get_str("message")?, + )?), }; let message = match server_message { @@ -710,4 +787,4 @@ fn db_to_conversation_message(row: &database::RowResult) -> ResultBoxError ResultBoxError shortcut: row.get_str("shortcut")?, path: row.get_str("path")?, }) -} \ No newline at end of file +} diff --git a/src/helpers/database.rs b/src/helpers/database.rs index 890ae11..07a3fcf 100644 --- a/src/helpers/database.rs +++ b/src/helpers/database.rs @@ -4,9 +4,9 @@ use std::ops::Add; use std::sync::{Arc, Mutex}; use chrono::{TimeZone, Utc}; +use mysql::prelude::*; use mysql::*; use mysql::{Binary, Pool, ResultSet, Value}; -use mysql::prelude::*; use crate::data::admin::AdminID; use crate::data::config::{conf, DatabaseConfig}; @@ -147,52 +147,61 @@ impl QueryInfo { } pub fn cond(mut self, key: &str, val: &str) -> QueryInfo { - self.conditions.insert(key.to_string(), mysql::Value::from(val)); + self.conditions + .insert(key.to_string(), mysql::Value::from(val)); self } pub fn cond_u32(mut self, key: &str, val: u32) -> QueryInfo { - self.conditions.insert(key.to_string(), mysql::Value::from(val)); + self.conditions + .insert(key.to_string(), mysql::Value::from(val)); self } pub fn cond_u64(mut self, key: &str, val: u64) -> QueryInfo { - self.conditions.insert(key.to_string(), mysql::Value::from(val)); + self.conditions + .insert(key.to_string(), mysql::Value::from(val)); self } pub fn cond_i64(mut self, key: &str, val: i64) -> QueryInfo { - self.conditions.insert(key.to_string(), mysql::Value::from(val)); + self.conditions + .insert(key.to_string(), mysql::Value::from(val)); self } pub fn cond_user_id(mut self, key: &str, val: &UserID) -> QueryInfo { - self.conditions.insert(key.to_string(), mysql::Value::from(val.id())); + self.conditions + .insert(key.to_string(), mysql::Value::from(val.id())); self } pub fn cond_admin_id(mut self, key: &str, val: AdminID) -> QueryInfo { - self.conditions.insert(key.to_string(), mysql::Value::from(val.id())); + self.conditions + .insert(key.to_string(), mysql::Value::from(val.id())); self } pub fn cond_group_id(mut self, key: &str, val: &GroupID) -> QueryInfo { - self.conditions.insert(key.to_string(), mysql::Value::from(val.id())); + self.conditions + .insert(key.to_string(), mysql::Value::from(val.id())); self } pub fn cond_conv_id(mut self, key: &str, val: ConvID) -> QueryInfo { - self.conditions.insert(key.to_string(), mysql::Value::from(val.id())); + self.conditions + .insert(key.to_string(), mysql::Value::from(val.id())); self } pub fn cond_legacy_bool(mut self, key: &str, val: bool) -> QueryInfo { let val = match val { true => 1, - false => 0 + false => 0, }; - self.conditions.insert(key.to_string(), mysql::Value::from(val)); + self.conditions + .insert(key.to_string(), mysql::Value::from(val)); self } @@ -257,14 +266,18 @@ impl QueryInfo { } /// Execute query - pub fn exec ProcessRowResult>(self, process_function: F) - -> Res> { + pub fn exec ProcessRowResult>( + self, + process_function: F, + ) -> Res> { query(self, process_function) } /// Query just a row - pub fn query_row ProcessRowResult>(self, process_function: F) - -> Res { + pub fn query_row ProcessRowResult>( + self, + process_function: F, + ) -> Res { query_row(self, process_function) } @@ -286,9 +299,7 @@ pub struct RowResult<'a> { impl<'a> RowResult<'a> { pub fn new(row: &mysql::Row) -> RowResult { - RowResult { - row - } + RowResult { row } } /// Find a column in result set @@ -303,7 +314,10 @@ impl<'a> RowResult<'a> { index += 1; } - Err(ExecError::boxed_new(format!("Column {} not found in database result set!", name))) + Err(ExecError::boxed_new(format!( + "Column {} not found in database result set!", + name + ))) } /// Find an integer included in the request @@ -311,9 +325,11 @@ impl<'a> RowResult<'a> { let value = self.row.get_opt(self.find_col(name)?); match value { - None => Err(ExecError::boxed_string( - format!("Could not extract integer field {} !", name))), - Some(s) => Ok(s?) + None => Err(ExecError::boxed_string(format!( + "Could not extract integer field {} !", + name + ))), + Some(s) => Ok(s?), } } @@ -322,9 +338,11 @@ impl<'a> RowResult<'a> { let value = self.row.get_opt(self.find_col(name)?); match value { - None => Err(ExecError::boxed_string( - format!("Could not extract integer field {} !", name))), - Some(s) => Ok(s?) + None => Err(ExecError::boxed_string(format!( + "Could not extract integer field {} !", + name + ))), + Some(s) => Ok(s?), } } @@ -332,14 +350,14 @@ impl<'a> RowResult<'a> { pub fn get_optional_u64(&self, name: &str) -> Res> { match self.is_null(name)? { true => Ok(None), - false => Ok(Some(self.get_u64(name)?)) + false => Ok(Some(self.get_u64(name)?)), } } pub fn get_optional_u32(&self, name: &str) -> Res> { match self.is_null(name)? { true => Ok(None), - false => Ok(Some(self.get_u32(name)?)) + false => Ok(Some(self.get_u32(name)?)), } } @@ -347,7 +365,7 @@ impl<'a> RowResult<'a> { pub fn get_optional_positive_u64(&self, name: &str) -> Res> { Ok(match self.get_optional_u64(name)? { None | Some(0) => None, - Some(val) => Some(val) + Some(val) => Some(val), }) } @@ -355,9 +373,11 @@ impl<'a> RowResult<'a> { let value = self.row.get_opt(self.find_col(name)?); match value { - None => Err(ExecError::boxed_string( - format!("Could not extract integer field {} !", name))), - Some(s) => Ok(s?) + None => Err(ExecError::boxed_string(format!( + "Could not extract integer field {} !", + name + ))), + Some(s) => Ok(s?), } } @@ -365,9 +385,11 @@ impl<'a> RowResult<'a> { let value = self.row.get_opt(self.find_col(name)?); match value { - None => Err(ExecError::boxed_string( - format!("Could not extract integer field {} !", name))), - Some(s) => Ok(s?) + None => Err(ExecError::boxed_string(format!( + "Could not extract integer field {} !", + name + ))), + Some(s) => Ok(s?), } } @@ -376,9 +398,11 @@ impl<'a> RowResult<'a> { let value = self.row.get_opt(self.find_col(name)?); match value { - None => Err(ExecError::boxed_string( - format!("Could not extract integer field {} !", name))), - Some(s) => Ok(s?) + None => Err(ExecError::boxed_string(format!( + "Could not extract integer field {} !", + name + ))), + Some(s) => Ok(s?), } } @@ -401,7 +425,7 @@ impl<'a> RowResult<'a> { pub fn get_optional_group_id(&self, name: &str) -> Res> { Ok(match self.get_optional_u64(name)? { None | Some(0) => None, - Some(id) => Some(GroupID::new(id)) + Some(id) => Some(GroupID::new(id)), }) } @@ -415,9 +439,11 @@ impl<'a> RowResult<'a> { let value = self.row.get_opt(self.find_col(name)?); match value { - None => Err(ExecError::boxed_string( - format!("Could not extract string field {} !", name))), - Some(s) => Ok(s?) + None => Err(ExecError::boxed_string(format!( + "Could not extract string field {} !", + name + ))), + Some(s) => Ok(s?), } } @@ -428,7 +454,7 @@ impl<'a> RowResult<'a> { match value { None => Ok(true), Some(Ok(Value::NULL)) => Ok(true), - _ => Ok(false) + _ => Ok(false), } } @@ -445,12 +471,12 @@ impl<'a> RowResult<'a> { pub fn get_optional_str(&self, name: &str) -> Res> { match self.is_null(name)? { true => Ok(None), - false => Ok(Some(self.get_str(name)?).map_or(None, |d| { - match d.is_empty() { + false => Ok( + Some(self.get_str(name)?).map_or(None, |d| match d.is_empty() { true => None, - false => Some(d) - } - })) + false => Some(d), + }), + ), } } @@ -462,44 +488,62 @@ impl<'a> RowResult<'a> { /// Get a MYSQL date as a timestamp pub fn get_date_as_time(&self, name: &str) -> Res { let value = self.row.get_opt(self.find_col(name)?); - let value: Value = value.ok_or(ExecError(format!("Could not find date field {} !", name)))??; + let value: Value = + value.ok_or(ExecError(format!("Could not find date field {} !", name)))??; // Check if it is a date - if let Value::Date(year, month, day, hour, minutes, seconds, mic_secs) = value { - let dt = Utc.ymd(year as i32, month as u32, day as u32) - .and_hms_micro(hour as u32, minutes as u32, seconds as u32, mic_secs); + if let Value::Date(year, month, day, hour, minutes, seconds, _mic_secs) = value { + let dt = Utc + .with_ymd_and_hms( + year as i32, + month as u32, + day as u32, + hour as u32, + minutes as u32, + seconds as u32, + ) + .single() + .expect("invalid time"); return Ok(dt.timestamp() as u64); } - Err(ExecError::boxed_string(format!("Field {} could not be resolved as a date !", name))) + Err(ExecError::boxed_string(format!( + "Field {} could not be resolved as a date !", + name + ))) } } - /// Query a single row of the database -pub fn query_row ProcessRowResult>(mut info: QueryInfo, - process_function: F) -> Res { +pub fn query_row ProcessRowResult>( + mut info: QueryInfo, + process_function: F, +) -> Res { let table = info.table.clone(); info.limit = 1; let mut list = query(info, process_function)?; match list.len() { - 0 => Err(ExecError::boxed_string( - format!("Database query did not return a result: (table: {}) !", table))), - _ => Ok(list.remove(0)) + 0 => Err(ExecError::boxed_string(format!( + "Database query did not return a result: (table: {}) !", + table + ))), + _ => Ok(list.remove(0)), } } /// Make a simple query -pub fn query ProcessRowResult>(info: QueryInfo, process_function: F) - -> Res> { +pub fn query ProcessRowResult>( + info: QueryInfo, + process_function: F, +) -> Res> { let mut params = vec![]; let select_elements = match info.fields.len() { 0 => "*".to_string(), - _ => info.fields.join(", ") + _ => info.fields.join(", "), }; // Build query @@ -516,11 +560,10 @@ pub fn query ProcessRowResult>(info: QueryInfo, proce } for j in info.joins { - query = query.add( - format!(" JOIN {} {} ON {} ", j.table, j.table_alias, j.condition).as_ref()); + query = + query.add(format!(" JOIN {} {} ON {} ", j.table, j.table_alias, j.condition).as_ref()); } - // WHERE clause if !info.conditions.is_empty() { let mut where_args = vec![]; @@ -582,7 +625,6 @@ pub fn query ProcessRowResult>(info: QueryInfo, proce } let result_set: ResultSet = result_set.unwrap(); - // Parse each result of the dataset let mut res: Vec = vec![]; for row in result_set { @@ -593,7 +635,6 @@ pub fn query ProcessRowResult>(info: QueryInfo, proce res.push(parsed); } - Ok(res) } @@ -602,8 +643,11 @@ pub fn count(mut q: QueryInfo) -> Res { q.fields.clear(); q.fields.push("COUNT(*) as count".to_string()); - query(q, |res| res.get_usize("count"))?.pop() - .ok_or(ExecError::boxed_new("database::count did not return a result!")) + query(q, |res| res.get_usize("count"))? + .pop() + .ok_or(ExecError::boxed_new( + "database::count did not return a result!", + )) } /// Structure used to execute a insert query @@ -627,7 +671,6 @@ impl InsertQuery { self } - /// Add a string pub fn add_str(mut self, key: &str, value: &str) -> InsertQuery { self.values.insert(key.to_string(), Value::from(value)); @@ -636,23 +679,28 @@ impl InsertQuery { /// Add an optional string. If None, an empty string will be inserted pub fn add_opt_str(mut self, key: &str, value: Option<&String>) -> InsertQuery { - self.values.insert(key.to_string(), Value::from(value.unwrap_or(&String::new()))); + self.values.insert( + key.to_string(), + Value::from(value.unwrap_or(&String::new())), + ); self } /// Add an optional number. If None, Null will be inserted pub fn add_opt_u64(mut self, key: &str, value: Option) -> InsertQuery { - self.values.insert(key.to_string(), value - .map(|u| Value::UInt(u)) - .unwrap_or(Value::NULL)); + self.values.insert( + key.to_string(), + value.map(|u| Value::UInt(u)).unwrap_or(Value::NULL), + ); self } /// Add an optional number. If None, Null will be inserted pub fn add_opt_u32(mut self, key: &str, value: Option) -> InsertQuery { - self.values.insert(key.to_string(), value - .map(|u| Value::UInt(u as u64)) - .unwrap_or(Value::NULL)); + self.values.insert( + key.to_string(), + value.map(|u| Value::UInt(u as u64)).unwrap_or(Value::NULL), + ); self } @@ -712,12 +760,11 @@ impl InsertQuery { self } - /// Legacy database boolean (1 = true / 0 = false) pub fn add_legacy_bool(mut self, key: &str, value: bool) -> InsertQuery { let num = match value { true => 1, - false => 0 + false => 0, }; self.values.insert(key.to_string(), Value::from(num)); @@ -744,9 +791,9 @@ impl InsertQuery { /// Insert a new entry into the database pub fn insert(query: InsertQuery) -> Res> { - // Collect keys - let keys = query.values + let keys = query + .values .keys() .map(|f| f.to_string()) .collect::>(); @@ -767,7 +814,6 @@ pub fn insert(query: InsertQuery) -> Res> { Ok(res.last_insert_id()) } - /// Structure used to build delete queries pub struct DeleteQuery { table: String, @@ -835,29 +881,33 @@ impl DeleteQuery { pub fn cond_legacy_bool(mut self, key: &str, value: bool) -> DeleteQuery { let value = match value { true => 1, - false => 0 + false => 0, }; self.conditions.insert(key.to_string(), Value::from(value)); self } pub fn cond_user_id(mut self, key: &str, value: &UserID) -> DeleteQuery { - self.conditions.insert(key.to_string(), Value::from(value.id())); + self.conditions + .insert(key.to_string(), Value::from(value.id())); self } pub fn cond_admin_id(mut self, key: &str, value: AdminID) -> DeleteQuery { - self.conditions.insert(key.to_string(), Value::from(value.id())); + self.conditions + .insert(key.to_string(), Value::from(value.id())); self } pub fn cond_group_id(mut self, key: &str, value: &GroupID) -> DeleteQuery { - self.conditions.insert(key.to_string(), Value::from(value.id())); + self.conditions + .insert(key.to_string(), Value::from(value.id())); self } pub fn cond_conv_id(mut self, key: &str, value: ConvID) -> DeleteQuery { - self.conditions.insert(key.to_string(), Value::from(value.id())); + self.conditions + .insert(key.to_string(), Value::from(value.id())); self } @@ -870,13 +920,17 @@ impl DeleteQuery { /// Delete an entry from the database pub fn delete(query: DeleteQuery) -> Res<()> { if query.conditions.is_empty() && query.custom_where.is_none() { - return Err(ExecError::boxed_new("DELETE without WHERE condition blocked for security reasons!")); + return Err(ExecError::boxed_new( + "DELETE without WHERE condition blocked for security reasons!", + )); } let mut query_sql = format!( "DELETE FROM {} WHERE {}", query.table, - query.conditions.keys() + query + .conditions + .keys() .map(|f| format!("{} = ?", f)) .collect::>() .join(" AND ") @@ -947,7 +1001,6 @@ impl UpdateInfo { self } - /// Filter with an unsigned integer pub fn cond_u64(mut self, name: &str, val: u64) -> UpdateInfo { self.cond.insert(name.to_string(), Value::UInt(val)); @@ -958,7 +1011,7 @@ impl UpdateInfo { pub fn cond_legacy_bool(mut self, name: &str, val: bool) -> UpdateInfo { let num = match val { true => 1, - false => 0 + false => 0, }; self.cond.insert(name.to_string(), Value::Int(num)); @@ -988,7 +1041,8 @@ impl UpdateInfo { /// None => Empty string /// Some => The string pub fn set_opt_str(mut self, name: &str, val: Option) -> UpdateInfo { - self.set.insert(name.to_string(), Value::from(val.unwrap_or(String::new()))); + self.set + .insert(name.to_string(), Value::from(val.unwrap_or(String::new()))); self } @@ -997,11 +1051,11 @@ impl UpdateInfo { /// None => 0 /// Some => The value pub fn set_opt_u64_or_zero(mut self, name: &str, val: Option) -> UpdateInfo { - self.set.insert(name.to_string(), Value::from(val.unwrap_or(0))); + self.set + .insert(name.to_string(), Value::from(val.unwrap_or(0))); self } - /// Set a new legacy boolean pub fn set_legacy_bool(mut self, name: &str, val: bool) -> UpdateInfo { let num = match val { @@ -1033,19 +1087,24 @@ impl UpdateInfo { /// Execute an update query pub fn update(u: UpdateInfo) -> Res<()> { if u.cond.is_empty() { - Err(ExecError::boxed_new("Update without conditions blocked for security!"))?; + Err(ExecError::boxed_new( + "Update without conditions blocked for security!", + ))?; } if u.set.is_empty() { - Err(ExecError::boxed_new("Update with no change specified useless!"))?; + Err(ExecError::boxed_new( + "Update with no change specified useless!", + ))?; } - let mut query_sql = format!("UPDATE {} SET ", u.table); let mut values = vec![]; // Prepare updates - let updates = u.set.keys() + let updates = u + .set + .keys() .into_iter() .map(|f| format!("{} = ?", f)) .collect::>() @@ -1053,7 +1112,9 @@ pub fn update(u: UpdateInfo) -> Res<()> { u.set.values().into_iter().for_each(|f| values.push(f)); // Prepare conditions - let mut conditions = u.cond.keys() + let mut conditions = u + .cond + .keys() .into_iter() .map(|f| format!("{} = ?", f)) .collect::>() @@ -1073,18 +1134,15 @@ pub fn update(u: UpdateInfo) -> Res<()> { watcher::ExecDatabaseQuery::new( &query_sql, &values.iter().map(|f| mysql::Value::from(f)).collect(), - ).display(); + ) + .display(); } - get_connection()?.exec_drop( - query_sql, - values, - )?; + get_connection()?.exec_drop(query_sql, values)?; Ok(()) } - /// Private module used to watch what is going on the database mod watcher { /// Database logging & optimisation @@ -1114,4 +1172,4 @@ mod watcher { println!() } } -} \ No newline at end of file +} diff --git a/src/helpers/events_helper.rs b/src/helpers/events_helper.rs index ff67365..ef869c8 100644 --- a/src/helpers/events_helper.rs +++ b/src/helpers/events_helper.rs @@ -4,8 +4,13 @@ use async_recursion::async_recursion; -use crate::controllers::{calls_controller, comments_controller, conversations_controller, notifications_controller, rtc_relay_controller, user_ws_controller}; -use crate::data::call_signal::{CloseCallStream, NewRtcRelayMessage, NewUserCallSignal, UserCallOfferRequest}; +use crate::controllers::{ + calls_controller, comments_controller, conversations_controller, notifications_controller, + rtc_relay_controller, user_ws_controller, +}; +use crate::data::call_signal::{ + CloseCallStream, NewRtcRelayMessage, NewUserCallSignal, UserCallOfferRequest, +}; use crate::data::comment::Comment; use crate::data::conversation::ConvID; use crate::data::conversation_message::ConversationMessage; @@ -96,4 +101,4 @@ pub async fn propagate_event(e: Event) -> Res { rtc_relay_controller::handle_event(&e)?; push_notifications_helper::handle_event(&e).await?; Ok(()) -} \ No newline at end of file +} diff --git a/src/helpers/firebase_notifications_helper.rs b/src/helpers/firebase_notifications_helper.rs index 273fa3e..d38adfe 100644 --- a/src/helpers/firebase_notifications_helper.rs +++ b/src/helpers/firebase_notifications_helper.rs @@ -6,8 +6,8 @@ use std::collections::HashMap; -use reqwest::Client; use reqwest::header::{HeaderMap, HeaderValue}; +use reqwest::Client; use serde::Serialize; use crate::constants::FIREBASE_PUSH_MESSAGE_URL; @@ -29,7 +29,6 @@ struct FirebaseNotification { image: Option, } - #[derive(Serialize)] struct FirebaseAndroidNotification { tag: String, @@ -59,7 +58,10 @@ fn get_credentials(client: &APIClient) -> Res { let service_account_file = match &client.firebase_service_account_file { Some(file) => file, None => { - return Err(ExecError::boxed_string(format!("No service account file for client {}!", client.name))); + return Err(ExecError::boxed_string(format!( + "No service account file for client {}!", + client.name + ))); } }; @@ -74,7 +76,11 @@ fn get_credentials(client: &APIClient) -> Res { } /// Send a single notification through Firebase service -async fn send_notification(n: &PushNotification, client_token: &str, access: &FirebaseClientIdentifier) -> Res { +async fn send_notification( + n: &PushNotification, + client_token: &str, + access: &FirebaseClientIdentifier, +) -> Res { let notif = FirebaseNotificationRequest { validate_only: false, message: FirebaseMessage { @@ -94,13 +100,17 @@ async fn send_notification(n: &PushNotification, client_token: &str, access: &Fi }; let mut headers = HeaderMap::new(); - headers.insert("Authorization", HeaderValue::from_str(&access.authorization_token)?); + headers.insert( + "Authorization", + HeaderValue::from_str(&access.authorization_token)?, + ); let client = Client::builder().default_headers(headers).build()?; client .post(&FIREBASE_PUSH_MESSAGE_URL.replace("{PROJECT_ID}", &access.project_name)) .json(¬if) - .send().await?; + .send() + .await?; Ok(()) } @@ -113,19 +123,22 @@ pub async fn push_notifications(n: &PushNotification, targets: Vec { return Err(ExecError::boxed_new("Should have a Firebase token now!!!")); } - Some(token) => token + Some(token) => token, }; let client_token = match &target.push_notifications_token { @@ -135,11 +148,13 @@ pub async fn push_notifications(n: &PushNotification, targets: Vec Res { month: row.get_u16("month")?, day: row.get_u16("day")?, }) -} \ No newline at end of file +} diff --git a/src/helpers/friends_helper.rs b/src/helpers/friends_helper.rs index 787041b..ca3ea5c 100644 --- a/src/helpers/friends_helper.rs +++ b/src/helpers/friends_helper.rs @@ -2,8 +2,6 @@ //! //! @author Pierre Hubert - - use crate::constants::database_tables_names::{FRIENDS_TABLE, USERS_TABLE}; use crate::data::error::{ExecError, ResultBoxError}; use crate::data::friend::Friend; @@ -182,10 +180,12 @@ pub fn respond_request(user_id: &UserID, friend_id: &UserID, accept: bool) -> Re /// Check out whether two users are friend or not pub fn are_friend(user_one: &UserID, user_two: &UserID) -> ResultBoxError { - Ok(database::count(QueryInfo::new(FRIENDS_TABLE) - .cond_user_id("ID_personne", user_one) - .cond_user_id("ID_amis", user_two) - .cond_i64("actif", 1))? > 0) + Ok(database::count( + QueryInfo::new(FRIENDS_TABLE) + .cond_user_id("ID_personne", user_one) + .cond_user_id("ID_amis", user_two) + .cond_i64("actif", 1), + )? > 0) } /// Delete a friendship @@ -304,4 +304,4 @@ fn db_to_friend(row: &database::RowResult) -> ResultBoxError { last_activity_time: row.get_u64("last_activity")?, can_post_texts: row.get_legacy_bool("autoriser_post_page")?, }) -} \ No newline at end of file +} diff --git a/src/helpers/groups_helper.rs b/src/helpers/groups_helper.rs index c5999fc..48e03c3 100644 --- a/src/helpers/groups_helper.rs +++ b/src/helpers/groups_helper.rs @@ -4,14 +4,19 @@ use crate::constants::database_tables_names::{GROUPS_LIST_TABLE, GROUPS_MEMBERS_TABLE}; use crate::data::error::{ExecError, ResultBoxError}; -use crate::data::group::{Group, GroupAccessLevel, GroupPostsCreationLevel, GroupRegistrationLevel, GroupVisibilityLevel}; +use crate::data::group::{ + Group, GroupAccessLevel, GroupPostsCreationLevel, GroupRegistrationLevel, GroupVisibilityLevel, +}; use crate::data::group_id::GroupID; use crate::data::group_member::{GroupMember, GroupMembershipLevel}; use crate::data::new_group::NewGroup; use crate::data::report::ReportTarget; use crate::data::user::UserID; -use crate::helpers::{conversations_helper, database, forez_presence_helper, likes_helper, notifications_helper, posts_helper, reports_helper}; use crate::helpers::likes_helper::LikeType; +use crate::helpers::{ + conversations_helper, database, forez_presence_helper, likes_helper, notifications_helper, + posts_helper, reports_helper, +}; use crate::utils::date_utils::time; impl GroupVisibilityLevel { @@ -28,7 +33,7 @@ impl GroupVisibilityLevel { 0 => GroupVisibilityLevel::OPEN_GROUP, 1 => GroupVisibilityLevel::PRIVATE_GROUP, 2 => GroupVisibilityLevel::SECRETE_GROUP, - _ => GroupVisibilityLevel::SECRETE_GROUP + _ => GroupVisibilityLevel::SECRETE_GROUP, } } } @@ -53,7 +58,7 @@ impl GroupMembershipLevel { 3 => GroupMembershipLevel::INVITED, 4 => GroupMembershipLevel::PENDING, 5 => GroupMembershipLevel::VISITOR, - _ => GroupMembershipLevel::VISITOR + _ => GroupMembershipLevel::VISITOR, } } } @@ -101,7 +106,8 @@ pub async fn create(group: &NewGroup) -> ResultBoxError { .add_u64("time_create", time()) .add_user_id("userid_create", &group.owner_id) .add_str("name", &group.name) - .insert()?.ok_or(ExecError::new("Could not get group ID!"))?; + .insert()? + .ok_or(ExecError::new("Could not get group ID!"))?; let group_id = GroupID::new(group_id); // Insert first member @@ -112,7 +118,8 @@ pub async fn create(group: &NewGroup) -> ResultBoxError { time_create: time(), level: GroupMembershipLevel::ADMINISTRATOR, following: true, - }).await?; + }) + .await?; Ok(group_id) } @@ -147,7 +154,11 @@ pub async fn delete_member(group_id: &GroupID, user_id: &UserID) -> ResultBoxErr } /// Update a user's membership level -pub async fn update_membership_level(group_id: &GroupID, user_id: &UserID, new_level: GroupMembershipLevel) -> ResultBoxError { +pub async fn update_membership_level( + group_id: &GroupID, + user_id: &UserID, + new_level: GroupMembershipLevel, +) -> ResultBoxError { database::UpdateInfo::new(GROUPS_MEMBERS_TABLE) .cond_user_id("user_id", user_id) .cond_group_id("groups_id", group_id) @@ -182,21 +193,17 @@ pub fn get_list_user(user_id: &UserID, only_followed: bool) -> ResultBoxError ResultBoxError> { database::QueryInfo::new(GROUPS_MEMBERS_TABLE) .alias("m") .join(GROUPS_LIST_TABLE, "g", "m.groups_id = g.id") - .cond_user_id("user_id", user_id) - .set_custom_where("level = ? OR level = ? OR (level = ? AND posts_level = ?)") .add_custom_where_argument_u32(GroupMembershipLevel::ADMINISTRATOR.to_db()) .add_custom_where_argument_u32(GroupMembershipLevel::MODERATOR.to_db()) .add_custom_where_argument_u32(GroupMembershipLevel::MEMBER.to_db()) .add_custom_where_argument_u32(GroupPostsCreationLevel::POSTS_LEVEL_ALL_MEMBERS.to_db()) - .add_field("g.id") .exec(|r| r.get_group_id("id")) } @@ -260,7 +267,10 @@ pub fn get_membership(group_id: &GroupID, user_id: Option) -> ResultBoxE } /// Get the membership level of a user for a group -pub fn get_membership_level(group_id: &GroupID, user_id: Option) -> ResultBoxError { +pub fn get_membership_level( + group_id: &GroupID, + user_id: Option, +) -> ResultBoxError { match user_id { None => Ok(GroupMembershipLevel::VISITOR), Some(user_id) => { @@ -292,7 +302,10 @@ pub fn is_open(group_id: &GroupID) -> ResultBoxError { } /// Get the current access level of a user over a group -pub fn get_access_level(group_id: &GroupID, user_id: Option) -> ResultBoxError { +pub fn get_access_level( + group_id: &GroupID, + user_id: Option, +) -> ResultBoxError { let membership_level = get_membership_level(group_id, user_id)?; // Check if the user is a confirmed member of group @@ -308,15 +321,15 @@ pub fn get_access_level(group_id: &GroupID, user_id: Option) -> ResultBo let visibility_level = get_visibility(group_id)?; - //If the group is open, everyone has view access if visibility_level == GroupVisibilityLevel::OPEN_GROUP { return Ok(GroupAccessLevel::VIEW_ACCESS); } //Else, all pending and invited membership get limited access - if membership_level == GroupMembershipLevel::PENDING || - membership_level == GroupMembershipLevel::INVITED { + if membership_level == GroupMembershipLevel::PENDING + || membership_level == GroupMembershipLevel::INVITED + { return Ok(GroupAccessLevel::LIMITED_ACCESS); } @@ -349,7 +362,10 @@ pub fn count_members(group_id: &GroupID) -> ResultBoxError { } /// Count the number of group's members at a specific level -pub fn count_members_at_level(group_id: &GroupID, level: GroupMembershipLevel) -> ResultBoxError { +pub fn count_members_at_level( + group_id: &GroupID, + level: GroupMembershipLevel, +) -> ResultBoxError { database::QueryInfo::new(GROUPS_MEMBERS_TABLE) .cond_group_id("groups_id", group_id) .cond_u32("level", level.to_db()) @@ -358,8 +374,9 @@ pub fn count_members_at_level(group_id: &GroupID, level: GroupMembershipLevel) - /// Check out whether a user is the last administrator of a group pub fn is_last_admin(group_id: &GroupID, user_id: &UserID) -> ResultBoxError { - Ok(get_membership_level(group_id, Some(user_id.clone()))? == GroupMembershipLevel::ADMINISTRATOR && - count_members_at_level(&group_id, GroupMembershipLevel::ADMINISTRATOR)? == 1) + Ok(get_membership_level(group_id, Some(user_id.clone()))? + == GroupMembershipLevel::ADMINISTRATOR + && count_members_at_level(&group_id, GroupMembershipLevel::ADMINISTRATOR)? == 1) } /// Check the availability of a virtual directory for a group @@ -369,7 +386,7 @@ pub fn check_directory_availability(dir: &str, group_id: Option) -> Res match (group, group_id) { (Ok(_), None) => Ok(false), (Ok(g), Some(g2)) => Ok(g == g2), - (Err(_), _) => Ok(true) + (Err(_), _) => Ok(true), } } @@ -394,7 +411,6 @@ pub fn get_last_activity(user_id: &UserID, group_id: &GroupID) -> ResultBoxError pub fn set_settings(g: &Group) -> ResultBoxError { database::UpdateInfo::new(GROUPS_LIST_TABLE) .cond_group_id("id", &g.id) - // Updates .set_str("name", &g.name) .set_u64("visibility", g.visibility.to_db()) @@ -404,8 +420,6 @@ pub fn set_settings(g: &Group) -> ResultBoxError { .set_opt_str("virtual_directory", g.virtual_directory.clone()) .set_opt_str("description", g.description.clone()) .set_opt_str("url", g.url.clone()) - - .exec() } @@ -449,7 +463,8 @@ pub async fn send_invitation(group_id: &GroupID, user_id: &UserID) -> ResultBoxE time_create: time(), level: GroupMembershipLevel::INVITED, following: true, - }).await + }) + .await } /// Check out whether a user received an invitation to join a group or not @@ -484,7 +499,8 @@ pub fn can_user_create_posts(group_id: &GroupID, user_id: &UserID) -> ResultBoxE match membership_level { GroupMembershipLevel::ADMINISTRATOR | GroupMembershipLevel::MODERATOR => Ok(true), - GroupMembershipLevel::MEMBER => Ok(get_info(group_id)?.posts_creation_level == GroupPostsCreationLevel::POSTS_LEVEL_ALL_MEMBERS), + GroupMembershipLevel::MEMBER => Ok(get_info(group_id)?.posts_creation_level + == GroupPostsCreationLevel::POSTS_LEVEL_ALL_MEMBERS), _ => Ok(false), } } @@ -536,7 +552,6 @@ pub async fn delete_all_user_groups(user_id: &UserID) -> ResultBoxError { Ok(()) } - /// Turn a database entry into a group struct fn db_to_group(row: &database::RowResult) -> ResultBoxError { let group_id = row.get_group_id("id")?; @@ -566,4 +581,4 @@ fn db_to_group_member(row: &database::RowResult) -> ResultBoxError level: GroupMembershipLevel::from_db(row.get_u32("level")?), following: row.get_legacy_bool("following")?, }) -} \ No newline at end of file +} diff --git a/src/helpers/independent_push_notifications_service_helper.rs b/src/helpers/independent_push_notifications_service_helper.rs index 08f1b69..c232b04 100644 --- a/src/helpers/independent_push_notifications_service_helper.rs +++ b/src/helpers/independent_push_notifications_service_helper.rs @@ -2,11 +2,10 @@ //! //! @author Pierre Hubert - use actix_http::header::HeaderValue; use actix_web::http::StatusCode; -use reqwest::Client; use reqwest::header::HeaderMap; +use reqwest::Client; use serde::{Deserialize, Serialize}; use crate::data::config::{conf, IndependentPushService}; @@ -33,7 +32,6 @@ struct PushNotificationRequest { timeout: Option, } - #[derive(Serialize)] struct CancelNotificationRequest { clients: Vec, @@ -49,7 +47,10 @@ fn svc_conf() -> Res<&'static IndependentPushService> { fn create_client() -> Res { let mut headers = HeaderMap::new(); - headers.insert("token", HeaderValue::from_str(&svc_conf()?.control_token.clone())?); + headers.insert( + "token", + HeaderValue::from_str(&svc_conf()?.control_token.clone())?, + ); Ok(Client::builder().default_headers(headers).build()?) } @@ -57,8 +58,8 @@ fn create_client() -> Res { pub async fn create_token() -> Res { let client = create_client()? .get(&format!("{}{}", svc_conf()?.control_url, "create_client")) - .send().await?; - + .send() + .await?; let response: CreateTokenResult = client.json().await?; @@ -69,21 +70,30 @@ pub async fn create_token() -> Res { pub async fn remove_token(t: &str) -> Res { let client = create_client()? .get(&format!("{}{}", svc_conf()?.control_url, "remove_client")) - .json(&RemoveTokenRequest { client: t.to_string() }) - .send().await?; + .json(&RemoveTokenRequest { + client: t.to_string(), + }) + .send() + .await?; if client.status() == StatusCode::OK { return Ok(()); } - Err(ExecError::boxed_string( - format!("Failed to remove client, got a status {} for service!", client.status().as_u16()))) + Err(ExecError::boxed_string(format!( + "Failed to remove client, got a status {} for service!", + client.status().as_u16() + ))) } /// Push notifications pub async fn push_notifications(n: &PushNotification, targets: Vec) -> Res { let client = create_client()? - .get(&format!("{}{}", svc_conf()?.control_url, "push_notification")) + .get(&format!( + "{}{}", + svc_conf()?.control_url, + "push_notification" + )) .json(&PushNotificationRequest { clients: targets, id: n.id.clone(), @@ -92,30 +102,40 @@ pub async fn push_notifications(n: &PushNotification, targets: Vec) -> R image: n.image.clone(), timeout: n.timeout.clone(), }) - .send().await?; + .send() + .await?; if client.status() == StatusCode::OK { return Ok(()); } - Err(ExecError::boxed_string( - format!("Failed to push notification, got a status {} for service!", client.status().as_u16()))) + Err(ExecError::boxed_string(format!( + "Failed to push notification, got a status {} for service!", + client.status().as_u16() + ))) } /// Cancel notifications pub async fn cancel_notifications(id: String, targets: Vec) -> Res { let client = create_client()? - .get(&format!("{}{}", svc_conf()?.control_url, "remove_notification")) + .get(&format!( + "{}{}", + svc_conf()?.control_url, + "remove_notification" + )) .json(&CancelNotificationRequest { clients: targets, id: id.clone(), }) - .send().await?; + .send() + .await?; if client.status() == StatusCode::OK { return Ok(()); } - Err(ExecError::boxed_string( - format!("Failed to remove notification, got a status {} for service!", client.status().as_u16()))) -} \ No newline at end of file + Err(ExecError::boxed_string(format!( + "Failed to remove notification, got a status {} for service!", + client.status().as_u16() + ))) +} diff --git a/src/helpers/likes_helper.rs b/src/helpers/likes_helper.rs index f345e17..b3b59d8 100644 --- a/src/helpers/likes_helper.rs +++ b/src/helpers/likes_helper.rs @@ -48,7 +48,8 @@ pub fn is_liking(user_id: &UserID, id: u64, kind: LikeType) -> ResultBoxError 0) + .exec_count()? + > 0) } /// Update like status @@ -61,7 +62,6 @@ pub fn update(user_id: &UserID, liking: bool, id: u64, kind: LikeType) -> Result .exec(); } - if is_liking(user_id, id, kind)? { return Ok(()); } @@ -98,8 +98,7 @@ pub fn delete_all_user(user_id: &UserID) -> ResultBoxError { /// Delete old user likes pub fn clean_old_user_likes(user: &User) -> Res { - if let Some(lifetime) = user.delete_likes_after - { + if let Some(lifetime) = user.delete_likes_after { database::DeleteQuery::new(LIKES_TABLE) .cond_user_id("ID_personne", &user.id) .set_custom_where("Date_envoi < ?") @@ -119,4 +118,4 @@ fn db_to_user_like(r: &database::RowResult) -> ResultBoxError { elem_type: r.get_str("type")?, elem_id: r.get_u64("ID_type")?, }) -} \ No newline at end of file +} diff --git a/src/helpers/mod.rs b/src/helpers/mod.rs index a985e8d..e7480e5 100644 --- a/src/helpers/mod.rs +++ b/src/helpers/mod.rs @@ -1,33 +1,33 @@ pub mod database; -pub mod api_helper; pub mod account_helper; -pub mod user_helper; -pub mod friends_helper; -pub mod custom_emojies_helper; +pub mod api_helper; pub mod background_image_helper; -pub mod likes_helper; -pub mod groups_helper; -pub mod posts_helper; -pub mod conversations_helper; -pub mod virtual_directory_helper; -pub mod survey_helper; -pub mod comments_helper; -pub mod notifications_helper; -pub mod webapp_helper; -pub mod requests_limit_helper; -pub mod events_helper; pub mod calls_helper; -pub mod push_notifications_helper; -pub mod independent_push_notifications_service_helper; +pub mod comments_helper; +pub mod conversations_helper; +pub mod custom_emojies_helper; +pub mod events_helper; pub mod firebase_notifications_helper; -pub mod reports_helper; pub mod forez_presence_helper; +pub mod friends_helper; +pub mod groups_helper; +pub mod independent_push_notifications_service_helper; +pub mod likes_helper; +pub mod notifications_helper; +pub mod posts_helper; +pub mod push_notifications_helper; +pub mod reports_helper; +pub mod requests_limit_helper; +pub mod survey_helper; +pub mod user_helper; +pub mod virtual_directory_helper; +pub mod webapp_helper; +pub mod admin_access_token_helper; pub mod admin_account_helper; pub mod admin_account_key_helper; -pub mod admin_access_token_helper; -pub mod admin_key_registration_challenges_helper; pub mod admin_key_authentication_challenges_helper; +pub mod admin_key_registration_challenges_helper; +pub mod admin_log_helper; pub mod admin_roles_helper; -pub mod admin_log_helper; \ No newline at end of file diff --git a/src/helpers/notifications_helper.rs b/src/helpers/notifications_helper.rs index 7146fc3..2d814d4 100644 --- a/src/helpers/notifications_helper.rs +++ b/src/helpers/notifications_helper.rs @@ -7,17 +7,23 @@ use std::collections::HashMap; use crate::constants::database_tables_names::NOTIFICATIONS_TABLE; use crate::data::error::{ExecError, Res, ResultBoxError}; use crate::data::group_id::GroupID; -use crate::data::notification::{NotifElemType, NotifEventType, NotifEventVisibility, Notification, PartialNotification}; +use crate::data::notification::{ + NotifElemType, NotifEventType, NotifEventVisibility, Notification, PartialNotification, +}; use crate::data::post::{PostID, PostPageKind, PostVisibilityLevel}; use crate::data::user::{User, UserID}; -use crate::helpers::{database, events_helper, groups_helper, posts_helper}; use crate::helpers::events_helper::Event; use crate::helpers::friends_helper::GetFriendsQuery; +use crate::helpers::{database, events_helper, groups_helper, posts_helper}; use crate::utils::date_utils; use crate::utils::date_utils::time; /// Create post notification -pub async fn create_post_notification(from_user: &UserID, post_id: u64, action: NotifEventType) -> ResultBoxError { +pub async fn create_post_notification( + from_user: &UserID, + post_id: u64, + action: NotifEventType, +) -> ResultBoxError { let mut n = PartialNotification::new() .set_from_user_id(from_user) .set_on_elem_id(post_id) @@ -28,7 +34,11 @@ pub async fn create_post_notification(from_user: &UserID, post_id: u64, action: } /// Create & push friend notification -pub async fn create_friends_notification(from_user: &UserID, dest_user: &UserID, action: NotifEventType) -> ResultBoxError { +pub async fn create_friends_notification( + from_user: &UserID, + dest_user: &UserID, + action: NotifEventType, +) -> ResultBoxError { let mut n = PartialNotification::new() .set_from_user_id(from_user) .set_dest_user_id(dest_user) @@ -40,7 +50,12 @@ pub async fn create_friends_notification(from_user: &UserID, dest_user: &UserID, } /// Create & push a group membership notification -pub async fn create_group_membership_notification(user_id: &UserID, moderator_id: Option<&UserID>, group_id: &GroupID, kind: NotifEventType) -> Res { +pub async fn create_group_membership_notification( + user_id: &UserID, + moderator_id: Option<&UserID>, + group_id: &GroupID, + kind: NotifEventType, +) -> Res { // Delete related group membership notifications delete_all_related_to_group_membership_notifications(user_id, group_id).await?; @@ -50,7 +65,6 @@ pub async fn create_group_membership_notification(user_id: &UserID, moderator_id .set_type(kind); match moderator_id { - // The notification must be sent to all the moderators of the group None => { n = n.set_from_user_id(user_id); @@ -59,8 +73,7 @@ pub async fn create_group_membership_notification(user_id: &UserID, moderator_id // We specify both the source and the destination of the notification // not to broadcast the notification to all the group members Some(moderator_id) => { - n = n.set_from_user_id(moderator_id) - .set_dest_user_id(user_id); + n = n.set_from_user_id(moderator_id).set_dest_user_id(user_id); } } @@ -68,10 +81,8 @@ pub async fn create_group_membership_notification(user_id: &UserID, moderator_id } /// Push a new notification -async fn push(n: &mut PartialNotification) -> ResultBoxError -{ - if n.time_create.is_none() - { +async fn push(n: &mut PartialNotification) -> ResultBoxError { + if n.time_create.is_none() { n.time_create = Some(date_utils::time()); } @@ -104,7 +115,6 @@ async fn push(n: &mut PartialNotification) -> ResultBoxError if post.user_page_id().unwrap() != n.from_user_id.as_ref().unwrap() { n.dest_user_id = Some(post.user_page_id().unwrap().clone()); } - // If the user is the owner of the page, but the post does not belongs to him else { n.dest_user_id = Some(post.user_id); @@ -112,11 +122,10 @@ async fn push(n: &mut PartialNotification) -> ResultBoxError return push_private(n).await; } - // Posts on user page else if post.is_on_user_page() { - let mut friend_req = GetFriendsQuery::new(n.from_user_id.as_ref().unwrap()) - .set_only_followers(true); + let mut friend_req = + GetFriendsQuery::new(n.from_user_id.as_ref().unwrap()).set_only_followers(true); // If the person who created the notification is not on his page if n.from_user_id.as_ref().unwrap() != post.user_page_id().unwrap() { @@ -131,18 +140,15 @@ async fn push(n: &mut PartialNotification) -> ResultBoxError return push_public(n, friends).await; } - // Posts on group pages else if post.is_on_group_page() { return push_group_members(n, post.group_id().unwrap()).await; } - // Unsupported scenario else { unimplemented!(); } } - // Friendship notification else if matches!(n.on_elem_type, Some(NotifElemType::FRIENDSHIP_REQUEST)) { n.container_id = None; @@ -150,19 +156,15 @@ async fn push(n: &mut PartialNotification) -> ResultBoxError return push_private(n).await; } - - // Groups membership notifications else if matches!(n.on_elem_type, Some(NotifElemType::GROUP_MEMBERSHIP)) { - // Complete the notification n.container_type = None; n.container_id = None; // Check whether the notification has to be pushed to a single user // or to all the moderators of the group - return if let Some(_) = n.dest_user_id - { + return if let Some(_) = n.dest_user_id { // Push the notification in private way (if it has a destination, // generally the target user of the membership request) push_private(n).await @@ -177,7 +179,10 @@ async fn push(n: &mut PartialNotification) -> ResultBoxError /// Push a notification to group members async fn push_group_members(n: &mut PartialNotification, group_id: &GroupID) -> ResultBoxError { let mut list = groups_helper::get_list_followers(group_id)?; - list = list.into_iter().filter(|f| f != n.from_user_id.as_ref().unwrap()).collect(); + list = list + .into_iter() + .filter(|f| f != n.from_user_id.as_ref().unwrap()) + .collect(); push_public(n, list).await } @@ -220,9 +225,10 @@ async fn push_private(n: &mut PartialNotification) -> Res { /// Create a new notification async fn create(n: &PartialNotification) -> ResultBoxError { - if n.dest_user_id.is_none() || n.from_user_id.is_none() - { - return Err(ExecError::boxed_new("Trying to send a notification without a source or a destination!")); + if n.dest_user_id.is_none() || n.from_user_id.is_none() { + return Err(ExecError::boxed_new( + "Trying to send a notification without a source or a destination!", + )); } database::InsertQuery::new(NOTIFICATIONS_TABLE) @@ -230,12 +236,15 @@ async fn create(n: &PartialNotification) -> ResultBoxError { .insert_drop_result()?; // Send a notification (updated_number_conversations) - events_helper::propagate_event(Event::UpdatedNotificationsNumber(vec![n.dest_user_id.clone().unwrap()])).await?; + events_helper::propagate_event(Event::UpdatedNotificationsNumber(vec![n + .dest_user_id + .clone() + .unwrap()])) + .await?; Ok(()) } - /// Delete notifications pub async fn delete(notification: &PartialNotification) -> ResultBoxError { let conditions = notif_to_db(notification, false); @@ -289,19 +298,26 @@ pub fn clean_old_user_notifications(user: &User) -> Res { /// Delete all the notifications related with a group pub async fn delete_all_related_with_group(group_id: &GroupID) -> ResultBoxError { - delete(&PartialNotification::new() - .set_on_elem_type(NotifElemType::GROUP_MEMBERSHIP) - .set_on_elem_id(group_id.id()) - ).await?; + delete( + &PartialNotification::new() + .set_on_elem_type(NotifElemType::GROUP_MEMBERSHIP) + .set_on_elem_id(group_id.id()), + ) + .await?; - delete(&PartialNotification::new() - .set_on_elem_type(NotifElemType::GROUP_PAGE) - .set_on_elem_id(group_id.id()) - ).await + delete( + &PartialNotification::new() + .set_on_elem_type(NotifElemType::GROUP_PAGE) + .set_on_elem_id(group_id.id()), + ) + .await } /// Delete all the notifications related to a group membership -pub async fn delete_all_related_to_group_membership_notifications(user_id: &UserID, group_id: &GroupID) -> ResultBoxError { +pub async fn delete_all_related_to_group_membership_notifications( + user_id: &UserID, + group_id: &GroupID, +) -> ResultBoxError { let mut n = PartialNotification::new() .set_on_elem_type(NotifElemType::GROUP_MEMBERSHIP) .set_on_elem_id(group_id.id()); @@ -318,7 +334,10 @@ pub async fn delete_all_related_to_group_membership_notifications(user_id: &User } /// Delete all the notifications about a post targeting a specified user -pub async fn delete_all_post_notifications_targeting_user(user_id: &UserID, post_id: PostID) -> ResultBoxError { +pub async fn delete_all_post_notifications_targeting_user( + user_id: &UserID, + post_id: PostID, +) -> ResultBoxError { let n = PartialNotification::new() .set_dest_user_id(user_id) .set_on_elem_type(NotifElemType::POST) @@ -337,9 +356,11 @@ pub async fn delete_all_related_with_post(post_id: PostID) -> ResultBoxError { } /// Delete all the notifications related with a friendship request -pub async fn delete_all_related_with_friendship_request(user_one: &UserID, user_two: &UserID) -> ResultBoxError { - let mut n = PartialNotification::new() - .set_on_elem_type(NotifElemType::FRIENDSHIP_REQUEST); +pub async fn delete_all_related_with_friendship_request( + user_one: &UserID, + user_two: &UserID, +) -> ResultBoxError { + let mut n = PartialNotification::new().set_on_elem_type(NotifElemType::FRIENDSHIP_REQUEST); n.from_user_id = Some(user_one.clone()); n.dest_user_id = Some(user_two.clone()); @@ -396,13 +417,17 @@ fn db_to_notif(row: &database::RowResult) -> ResultBoxError { kind: NotifEventType::from_db(&row.get_str("type")?), visibility: NotifEventVisibility::from_db(&row.get_str("visibility")?), container_id: row.get_optional_u64("from_container_id")?, - container_type: row.get_optional_str("from_container_type")? + container_type: row + .get_optional_str("from_container_type")? .map(|s| NotifElemType::from_db(&s)), }) } /// Turn a notification into a database entry -fn notif_to_db(n: &PartialNotification, complete_information: bool) -> HashMap { +fn notif_to_db( + n: &PartialNotification, + complete_information: bool, +) -> HashMap { let mut map = HashMap::new(); if let Some(id) = n.id { @@ -410,18 +435,27 @@ fn notif_to_db(n: &PartialNotification, complete_information: bool) -> HashMap 1, - false => 0, - })); + map.insert( + "seen".to_string(), + mysql::Value::Int(match seen { + true => 1, + false => 0, + }), + ); } if let Some(from_user_id) = &n.from_user_id { - map.insert("from_user_id".to_string(), mysql::Value::UInt(from_user_id.id())); + map.insert( + "from_user_id".to_string(), + mysql::Value::UInt(from_user_id.id()), + ); } if let Some(dest_user_id) = &n.dest_user_id { - map.insert("dest_user_id".to_string(), mysql::Value::UInt(dest_user_id.id())); + map.insert( + "dest_user_id".to_string(), + mysql::Value::UInt(dest_user_id.id()), + ); } if let Some(kind) = &n.kind { @@ -433,17 +467,25 @@ fn notif_to_db(n: &PartialNotification, complete_information: bool) -> HashMap HashMap "count_down", POST_KIND_SURVEY => "sondage", POST_KIND_YOUTUBE(_) => "youtube", - }.to_string() + } + .to_string() } } /// Create a new post pub fn create(p: &Post) -> ResultBoxError { - // Determine post target let (user_id, friend_id, group_id) = match &p.target_page { - PostPageKind::PAGE_KIND_USER(user_id) => { - (user_id, Some(&p.user_id), None) - } - PostPageKind::PAGE_KIND_GROUP(group_id) => { - (&p.user_id, None, Some(group_id)) - } + PostPageKind::PAGE_KIND_USER(user_id) => (user_id, Some(&p.user_id), None), + PostPageKind::PAGE_KIND_GROUP(group_id) => (&p.user_id, None, Some(group_id)), }; // Start insert query @@ -81,15 +83,15 @@ pub fn create(p: &Post) -> ResultBoxError { // Posts with associated file POST_KIND_IMAGE(file) | POST_KIND_PDF(file) => { - insert_query = insert_query.add_str("path", &file.path) + insert_query = insert_query + .add_str("path", &file.path) .add_usize("size", file.size) .add_opt_str("file_type", file.file_type.as_ref()); } // YouTube posts POST_KIND_YOUTUBE(id) => { - insert_query = insert_query.add_str("path", id) - .add_str("type", "youtube"); + insert_query = insert_query.add_str("path", id).add_str("type", "youtube"); } // Weblink @@ -111,13 +113,13 @@ pub fn create(p: &Post) -> ResultBoxError { } // Execute insertion - let post_id = insert_query.insert()? + let post_id = insert_query + .insert()? .ok_or(ExecError::new("Insert post query did not return a result!"))?; Ok(post_id) } - pub struct PostsQuery { /// The ID of the user making the request user_id: Option, @@ -199,7 +201,6 @@ fn get_user(query: &PostsQuery, target_id: &UserID) -> ResultBoxError> custom_where.push_str(")"); // ============= /PERMISSION CONDITIONS ================= - // ============== START POINT CONDITION ================= if query.start_from != 0 { custom_where.push_str(" AND ID <= ?"); @@ -207,7 +208,6 @@ fn get_user(query: &PostsQuery, target_id: &UserID) -> ResultBoxError> } // ============== /START POINT CONDITION ================ - // Perform the request db_query .cond_user_id("ID_personne", target_id) @@ -225,7 +225,7 @@ fn get_group(query: &PostsQuery, group_id: &GroupID) -> ResultBoxError let can_see_all_posts = membership <= GroupMembershipLevel::MEMBER; let visibility_level = match can_see_all_posts { true => PostVisibilityLevel::VISIBILITY_GROUP_MEMBERS, - false => PostVisibilityLevel::VISIBILITY_FRIENDS + false => PostVisibilityLevel::VISIBILITY_FRIENDS, }; // Prepare request @@ -254,7 +254,10 @@ fn get_group(query: &PostsQuery, group_id: &GroupID) -> ResultBoxError /// Get the latest posts of a user pub fn get_latest(query: &PostsQuery, include_group_posts: bool) -> ResultBoxError> { - let user_id = query.user_id.as_ref().ok_or(ExecError::new("Can not get latest posts of no user!"))?; + let user_id = query + .user_id + .as_ref() + .ok_or(ExecError::new("Can not get latest posts of no user!"))?; let visibility_level = PostVisibilityLevel::VISIBILITY_FRIENDS; @@ -279,7 +282,7 @@ pub fn get_latest(query: &PostsQuery, include_group_posts: bool) -> ResultBoxErr for f in &friends_list { custom_where.push_str(" OR ID_personne = ?"); db_query = db_query.add_custom_where_argument_user_id(&f.friend_id); - }; + } custom_where.push_str("))"); // ========== /FRIENDS POSTS ========== @@ -290,14 +293,13 @@ pub fn get_latest(query: &PostsQuery, include_group_posts: bool) -> ResultBoxErr for g in &groups { custom_where.push_str(" OR group_id = ?"); db_query = db_query.add_custom_where_argument_group_id(g); - }; + } } // ========== /GROUPS POSTS =========== custom_where.push_str(")"); // ================== /MEMBERSHIP CONDITION ===================== - // ======================= START POINT ========================== if query.start_from > 0 { custom_where.push_str("AND ID <= ?"); @@ -350,7 +352,10 @@ pub fn get_access_level(p: &Post, user_id: &Option) -> ResultBoxError { - if user_helper::can_see_user_page(user_id.as_ref().unwrap_or(&UserID::invalid()), user_page_id)? { + if user_helper::can_see_user_page( + user_id.as_ref().unwrap_or(&UserID::invalid()), + user_page_id, + )? { Ok(PostAccessLevel::BASIC_ACCESS) } else { Ok(PostAccessLevel::NO_ACCESS) @@ -358,7 +363,12 @@ pub fn get_access_level(p: &Post, user_id: &Option) -> ResultBoxError { - if user_id.is_some() && friends_helper::are_friend(user_id.as_ref().unwrap_or(&UserID::invalid()), user_page_id)? { + if user_id.is_some() + && friends_helper::are_friend( + user_id.as_ref().unwrap_or(&UserID::invalid()), + user_page_id, + )? + { Ok(PostAccessLevel::BASIC_ACCESS) } else { Ok(PostAccessLevel::NO_ACCESS) @@ -380,7 +390,9 @@ pub fn get_access_level(p: &Post, user_id: &Option) -> ResultBoxError) -> ResultBoxError ResultBoxError { - Ok( - !p.is_on_user_page() || - user_helper::allow_comments(p.user_page_id().unwrap_or(&UserID::invalid()))?) + Ok(!p.is_on_user_page() + || user_helper::allow_comments(p.user_page_id().unwrap_or(&UserID::invalid()))?) } /// Set a new visibility level to a post @@ -428,7 +439,6 @@ pub async fn delete(p: &Post) -> ResultBoxError { // Delete associated file / resource (if any) match &p.kind { - // Image / PDF PostKind::POST_KIND_IMAGE(file) | PostKind::POST_KIND_PDF(file) => { let path = user_data_path(file.path.as_ref()); @@ -533,12 +543,14 @@ fn db_to_post(res: &database::RowResult) -> ResultBoxError { match res.get_str("type")?.as_str() { "image" => post.kind = POST_KIND_IMAGE(file?), - "webpage_link" => post.kind = POST_KIND_WEBLINK(PostWebLink { - url: res.get_str("url_page")?, - title: res.get_optional_str("titre_page")?, - description: res.get_optional_str("description_page")?, - image: res.get_optional_str("image_page")?, - }), + "webpage_link" => { + post.kind = POST_KIND_WEBLINK(PostWebLink { + url: res.get_str("url_page")?, + title: res.get_optional_str("titre_page")?, + description: res.get_optional_str("description_page")?, + image: res.get_optional_str("image_page")?, + }) + } "pdf" => post.kind = POST_KIND_PDF(file?), @@ -552,4 +564,4 @@ fn db_to_post(res: &database::RowResult) -> ResultBoxError { } Ok(post) -} \ No newline at end of file +} diff --git a/src/helpers/push_notifications_helper.rs b/src/helpers/push_notifications_helper.rs index 001af0c..5b478f4 100644 --- a/src/helpers/push_notifications_helper.rs +++ b/src/helpers/push_notifications_helper.rs @@ -9,16 +9,22 @@ use crate::data::error::Res; use crate::data::push_notification::PushNotification; use crate::data::user::UserID; use crate::data::user_token::{PushNotificationToken, UserAccessToken}; -use crate::helpers::{account_helper, conversations_helper, firebase_notifications_helper, independent_push_notifications_service_helper, user_helper}; use crate::helpers::events_helper::Event; +use crate::helpers::{ + account_helper, conversations_helper, firebase_notifications_helper, + independent_push_notifications_service_helper, user_helper, +}; /// Un-register for previous push notifications service pub async fn un_register_from_previous_service(client: &UserAccessToken) -> Res { - // This method must not fail in case of error if let PushNotificationToken::INDEPENDENT(old_token) = &client.push_notifications_token { - if let Err(e) = independent_push_notifications_service_helper::remove_token(old_token).await { - eprintln!("Failed to un-register from independent push notifications service! {}", e); + if let Err(e) = independent_push_notifications_service_helper::remove_token(old_token).await + { + eprintln!( + "Failed to un-register from independent push notifications service! {}", + e + ); } } @@ -32,9 +38,7 @@ fn split_tokens(targets: Vec) -> (Vec, Vec { - independent.push(token) - } + PushNotificationToken::INDEPENDENT(token) => independent.push(token), PushNotificationToken::FIREBASE(_) => { firebase.push(target); @@ -69,7 +73,8 @@ async fn cancel_notification(id: String, targets: Vec) -> Res { let (independents, _) = split_tokens(targets); if !independents.is_empty() { - independent_push_notifications_service_helper::cancel_notifications(id, independents).await?; + independent_push_notifications_service_helper::cancel_notifications(id, independents) + .await?; } Ok(()) @@ -77,7 +82,8 @@ async fn cancel_notification(id: String, targets: Vec) -> Res { /// Push a notification to specific users, only if they are not connected async fn push_notification_to_users(n: &PushNotification, users: Vec) -> Res { - let dest_users: Vec = users.into_iter() + let dest_users: Vec = users + .into_iter() .filter(|u| !user_ws_controller::is_user_connected(u)) .collect(); @@ -120,12 +126,12 @@ pub async fn create_conversation_notification(msg: &ConversationMessage) -> Res let notif_title = match conv.name { None => user.full_name(), - Some(name) => format!("{} ({})", user.full_name(), name) + Some(name) => format!("{} ({})", user.full_name(), name), }; let notif_message = match &msg.message { None => "Shared file".to_string(), - Some(msg) => msg.to_string() + Some(msg) => msg.to_string(), }; let notif = PushNotification { @@ -160,21 +166,24 @@ pub async fn cancel_conversation_notification(conv_id: ConvID, users: Option users, None => conversations_helper::get_list_members(conv_id)? - .into_iter().map(|m| m.user_id).collect() + .into_iter() + .map(|m| m.user_id) + .collect(), }; cancel_notification_for_users(notif_id, list).await } - /// Handle event. This method NEVER returns Err pub async fn handle_event(e: &Event) -> Res { match e { Event::NewConversationMessage(msg) => { let msg = (*msg).clone(); std::thread::spawn(move || { - if let Err(err) = tokio::runtime::Runtime::new().unwrap().block_on( - create_conversation_notification(&msg)) { + if let Err(err) = tokio::runtime::Runtime::new() + .unwrap() + .block_on(create_conversation_notification(&msg)) + { eprintln!("Failed to create push for conversation! {}", err); } }); @@ -185,7 +194,8 @@ pub async fn handle_event(e: &Event) -> Res { let conv_id = *conv_id; std::thread::spawn(move || { if let Err(e) = tokio::runtime::Runtime::new().unwrap().block_on( - cancel_conversation_notification(conv_id, Some(vec![user_id]))) { + cancel_conversation_notification(conv_id, Some(vec![user_id])), + ) { eprintln!("Failed to cancel push conversation! {}", e); } }); @@ -195,4 +205,4 @@ pub async fn handle_event(e: &Event) -> Res { } Ok(()) -} \ No newline at end of file +} diff --git a/src/helpers/reports_helper.rs b/src/helpers/reports_helper.rs index 28302f7..0773ba9 100644 --- a/src/helpers/reports_helper.rs +++ b/src/helpers/reports_helper.rs @@ -44,4 +44,4 @@ pub fn delete_all_for_target(target: ReportTarget) -> Res { .cond_str("target_type", target_type) .cond_u64("target_id", target_id) .exec() -} \ No newline at end of file +} diff --git a/src/helpers/requests_limit_helper.rs b/src/helpers/requests_limit_helper.rs index e67aa1f..8992513 100644 --- a/src/helpers/requests_limit_helper.rs +++ b/src/helpers/requests_limit_helper.rs @@ -2,7 +2,6 @@ //! //! Handle the limitation of requests, depending on threshold criterias - use std::sync::{Arc, Mutex}; use crate::constants::LIMIT_COUNTER_LIFETIME; @@ -77,12 +76,11 @@ pub fn trigger_before(req: &HttpRequestHandler, route: &Route) -> ResultBoxError let ip = req.remote_ip(); let cache = get_cache()?; - let found = cache.lock().unwrap() + let found = cache + .lock() + .unwrap() .iter() - .find( - |k| k.uri.eq(route.uri) - && k.count >= max_count - && k.ip.eq(&ip)) + .find(|k| k.uri.eq(route.uri) && k.count >= max_count && k.ip.eq(&ip)) .is_some(); if found { @@ -94,8 +92,7 @@ pub fn trigger_before(req: &HttpRequestHandler, route: &Route) -> ResultBoxError /// Trigger limit at the end of the request pub fn trigger_after(is_success: bool, req: &HttpRequestHandler, route: &Route) -> ResultBoxError { - let need_trigger = match (&route.limit_policy, is_success) - { + let need_trigger = match (&route.limit_policy, is_success) { (LimitPolicy::NONE, _) => false, (LimitPolicy::ANY(_), _) => true, (LimitPolicy::SUCCESS(_), res) => res, @@ -129,4 +126,4 @@ pub fn trigger_after(is_success: bool, req: &HttpRequestHandler, route: &Route) }); Ok(()) -} \ No newline at end of file +} diff --git a/src/helpers/survey_helper.rs b/src/helpers/survey_helper.rs index 328a3c6..17bbdfb 100644 --- a/src/helpers/survey_helper.rs +++ b/src/helpers/survey_helper.rs @@ -2,7 +2,9 @@ //! //! @author Pierre Hubert -use crate::constants::database_tables_names::{SURVEY_CHOICES_TABLE, SURVEY_INFO_TABLE, SURVEY_RESPONSE_TABLE}; +use crate::constants::database_tables_names::{ + SURVEY_CHOICES_TABLE, SURVEY_INFO_TABLE, SURVEY_RESPONSE_TABLE, +}; use crate::data::error::{ExecError, ResultBoxError}; use crate::data::new_survey::NewSurvey; use crate::data::survey::{Survey, SurveyChoice}; @@ -183,4 +185,4 @@ fn db_to_survey_response(row: &database::RowResult) -> ResultBoxError ResultBoxError { /// Get the entire list of Comunic users pub fn get_all_users() -> Res> { - database::QueryInfo::new(USERS_TABLE) - .exec(db_to_user) + database::QueryInfo::new(USERS_TABLE).exec(db_to_user) } /// Execute query & return result @@ -87,7 +86,8 @@ fn db_to_user(res: &database::RowResult) -> ResultBoxError { delete_notifications_after: res.get_optional_positive_u64("delete_notifications_after")?, delete_comments_after: res.get_optional_positive_u64("delete_comments_after")?, delete_posts_after: res.get_optional_positive_u64("delete_posts_after")?, - delete_conversation_messages_after: res.get_optional_positive_u64("delete_conversation_messages_after")?, + delete_conversation_messages_after: res + .get_optional_positive_u64("delete_conversation_messages_after")?, delete_likes_after: res.get_optional_positive_u64("delete_likes_after")?, // Conversation settings @@ -100,7 +100,8 @@ fn db_to_user(res: &database::RowResult) -> ResultBoxError { pub fn exists(id: &UserID) -> ResultBoxError { Ok(database::QueryInfo::new(USERS_TABLE) .cond_user_id("ID", id) - .exec_count()? > 0) + .exec_count()? + > 0) } /// Check if a given user can see another user's page @@ -144,7 +145,6 @@ pub fn allow_comments(user_id: &UserID) -> ResultBoxError { Ok(!find_user_by_id(user_id)?.block_comments_on_his_page) } - /// Check out whether the friends list of a user is public or not pub fn is_user_friends_list_public(user_id: &UserID) -> ResultBoxError { Ok(find_user_by_id(user_id)?.public_friends_list) @@ -152,7 +152,6 @@ pub fn is_user_friends_list_public(user_id: &UserID) -> ResultBoxError { /// Check out if a user can create posts on another user page pub fn can_create_posts(user_id: &UserID, target_id: &UserID) -> ResultBoxError { - // Login required if !user_id.is_valid() { return Ok(false); @@ -221,9 +220,8 @@ pub fn search_user_admin(name: &str, email: &str, limit: u64) -> ResultBoxError< query = query.add_custom_where_argument_str(&format!("%{}%", email)) } - query .set_custom_where(&custom_where) .set_limit(limit) .exec(db_to_user) -} \ No newline at end of file +} diff --git a/src/helpers/virtual_directory_helper.rs b/src/helpers/virtual_directory_helper.rs index 370010d..314a21f 100644 --- a/src/helpers/virtual_directory_helper.rs +++ b/src/helpers/virtual_directory_helper.rs @@ -14,22 +14,23 @@ pub enum VirtualDirType { } /// Check the availability of a virtual directory -pub fn check_availability(dir: &str, target_id: u64, target_type: VirtualDirType) -> ResultBoxError { +pub fn check_availability( + dir: &str, + target_id: u64, + target_type: VirtualDirType, +) -> ResultBoxError { if !check_virtual_directory(dir) { return Ok(false); } match target_type { - VirtualDirType::USER => { - Ok( - account_helper::check_user_directory_availability(dir, Some(UserID::new(target_id)))? && - groups_helper::check_directory_availability(dir, None)? - ) - } - VirtualDirType::GROUP => { - Ok( - account_helper::check_user_directory_availability(dir, None)? - && groups_helper::check_directory_availability(dir, Some(GroupID::new(target_id)))?) - } + VirtualDirType::USER => Ok(account_helper::check_user_directory_availability( + dir, + Some(UserID::new(target_id)), + )? && groups_helper::check_directory_availability(dir, None)?), + VirtualDirType::GROUP => Ok( + account_helper::check_user_directory_availability(dir, None)? + && groups_helper::check_directory_availability(dir, Some(GroupID::new(target_id)))?, + ), } -} \ No newline at end of file +} diff --git a/src/helpers/webapp_helper.rs b/src/helpers/webapp_helper.rs index cf98fe4..82b2efb 100644 --- a/src/helpers/webapp_helper.rs +++ b/src/helpers/webapp_helper.rs @@ -11,8 +11,7 @@ use crate::helpers::{conversations_helper, friends_helper, groups_helper}; /// Get all the memberships of a user pub fn get_user_memberships(user_id: &UserID) -> ResultBoxError> { - let friends = friends_helper::GetFriendsQuery::new(user_id) - .exec()?; + let friends = friends_helper::GetFriendsQuery::new(user_id).exec()?; let groups = groups_helper::get_list_user(user_id, false)?; let conversations_list = conversations_helper::get_list_user(user_id)?; @@ -23,7 +22,10 @@ pub fn get_user_memberships(user_id: &UserID) -> ResultBoxError ResultBoxError Vec { arguments: vec![], function: Box::new(serve), }, - // Show help Action { name: "help", @@ -34,7 +35,6 @@ fn get_actions() -> Vec { arguments: vec![], function: Box::new(help), }, - // Get the list of registered clients Action { name: "clients_list", @@ -42,7 +42,6 @@ fn get_actions() -> Vec { arguments: vec![], function: Box::new(list_clients), }, - // Register a new API client Action { name: "register_client", @@ -50,7 +49,6 @@ fn get_actions() -> Vec { arguments: vec!["name", "origin", "comment"], function: Box::new(register_client), }, - // Reset a user password Action { name: "reset_password", @@ -58,7 +56,6 @@ fn get_actions() -> Vec { arguments: vec!["user_id"], function: Box::new(reset_password), }, - // Create a new administrator Action { name: "create_admin", @@ -66,15 +63,14 @@ fn get_actions() -> Vec { arguments: vec!["name", "email"], function: Box::new(create_admin), }, - // Create a reset token for an admin Action { name: "create_admin_reset_token", - description: "Create a new reset token to register a new access key to an admin account", + description: + "Create a new reset token to register a new access key to an admin account", arguments: vec!["email"], function: Box::new(create_admin_reset_token), }, - // Get the list of available admin roles Action { name: "list_admin_roles", @@ -82,7 +78,6 @@ fn get_actions() -> Vec { arguments: vec![], function: Box::new(list_admin_roles), }, - // Attribute a role to an admin Action { name: "grant_admin_role", @@ -93,7 +88,6 @@ fn get_actions() -> Vec { ] } - fn main() { let args: Vec = std::env::args().collect(); let conf_file = match args.get(1) { @@ -119,15 +113,17 @@ fn main() { let actions = get_actions(); - let selected_action = actions - .iter().find(|p| p.name.eq(&action)); + let selected_action = actions.iter().find(|p| p.name.eq(&action)); let selected_action = match selected_action { None => { - eprintln!("Action {} invalid! For more information try 'help'!", action); + eprintln!( + "Action {} invalid! For more information try 'help'!", + action + ); std::process::exit(-1); } - Some(a) => a + Some(a) => a, }; if !selected_action.arguments.is_empty() && selected_action.arguments.len() + 3 != args.len() { @@ -137,7 +133,7 @@ fn main() { let args = match args.len() { 0 | 1 | 2 => vec![], - _ => (&args[3..]).to_vec() + _ => (&args[3..]).to_vec(), }; let res = (selected_action.function)(args.to_vec()); @@ -154,16 +150,27 @@ fn serve(_a: Vec) -> Res { } fn help(_a: Vec) -> Res { - println!("Comunic API v3 Server - (c) Pierre HUBERT 2012 - {}", current_year()); + println!( + "Comunic API v3 Server - (c) Pierre HUBERT 2012 - {}", + current_year() + ); - - println!("Usage: {} [conf-file] [action] [args...]", std::env::args().next().unwrap()); + println!( + "Usage: {} [conf-file] [action] [args...]", + std::env::args().next().unwrap() + ); println!("Available actions:"); for action in get_actions() { - println!("\t{} {}\t- {}", - action.name, - action.arguments.iter().map(|s| format!("[{}]", s)).collect::>().join(" "), - action.description + println!( + "\t{} {}\t- {}", + action.name, + action + .arguments + .iter() + .map(|s| format!("[{}]", s)) + .collect::>() + .join(" "), + action.description ); } @@ -191,11 +198,11 @@ fn register_client(args: Vec) -> Res { name: args[0].to_string(), domain: match args[1].is_empty() { true => None, - false => Some(args[1].to_string()) + false => Some(args[1].to_string()), }, comment: match args[2].is_empty() { true => None, - false => Some(args[2].to_string()) + false => Some(args[2].to_string()), }, default_expiration_time: 0, firebase_project_name: None, @@ -228,8 +235,7 @@ fn create_admin(args: Vec) -> Res { std::process::exit(-1); } - let id = admin_account_helper::create(&new_admin) - .expect("Failed to create account!"); + let id = admin_account_helper::create(&new_admin).expect("Failed to create account!"); println!("* New admin ID: {}", id.id()); @@ -240,7 +246,10 @@ fn create_admin_reset_token(args: Vec) -> Res { let admin = admin_account_helper::find_admin_by_email(&args[0]) .expect("Failed to load admin information!"); - println!("Generate a new reset token for {} ({})", admin.name, admin.email); + println!( + "Generate a new reset token for {} ({})", + admin.name, admin.email + ); let token = admin_account_helper::create_new_reset_token(admin.id) .expect("Failed to create admin reset token!"); @@ -261,8 +270,7 @@ fn list_admin_roles(_a: Vec) -> Res { } fn grant_admin_role(args: Vec) -> Res { - let role = AdminRole::from_id(&args[1]) - .expect("Requested role does not exist!"); + let role = AdminRole::from_id(&args[1]).expect("Requested role does not exist!"); let admin = admin_account_helper::find_admin_by_email(&args[0]) .expect("Failed to load admin information!"); @@ -276,4 +284,4 @@ fn grant_admin_role(args: Vec) -> Res { println!("Success."); Ok(()) -} \ No newline at end of file +} diff --git a/src/routes.rs b/src/routes.rs index 8406cb0..b657245 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -1,8 +1,8 @@ use std::error::Error; use crate::constants::admin::AdminRole; -use crate::controllers::*; use crate::controllers::admin::*; +use crate::controllers::*; use crate::data::http_request_handler::HttpRequestHandler; use crate::routes::Method::{GET, POST}; @@ -174,314 +174,1232 @@ impl Route { } } - macro_rules! route { - ($req_uri: expr, $call: expr, GET_NO_LOGIN, $uri: expr, $func: expr)=>{ - if($uri.eq($req_uri)) - { + ($req_uri: expr, $call: expr, GET_NO_LOGIN, $uri: expr, $func: expr) => { + if ($uri.eq($req_uri)) { if let Some(c) = $call { - return (None, Some($func(c).await)); + return (None, Some($func(c).await)); } - return (Some(Route::get_without_login($uri)), None) + return (Some(Route::get_without_login($uri)), None); } }; - ($req_uri: expr, $call: expr, POST_NO_LOGIN, $uri: expr, $func: expr)=>{ - if($uri.eq($req_uri)) - { + ($req_uri: expr, $call: expr, POST_NO_LOGIN, $uri: expr, $func: expr) => { + if ($uri.eq($req_uri)) { if let Some(c) = $call { - return (None, Some($func(c).await)); + return (None, Some($func(c).await)); } - return (Some(Route::post_without_login($uri)), None) + return (Some(Route::post_without_login($uri)), None); } }; - ($req_uri: expr, $call: expr, POST_LOGIN, $uri: expr, $func: expr)=>{ - if($uri.eq($req_uri)) - { + ($req_uri: expr, $call: expr, POST_LOGIN, $uri: expr, $func: expr) => { + if ($uri.eq($req_uri)) { if let Some(c) = $call { - return (None, Some($func(c).await)); + return (None, Some($func(c).await)); } - return (Some(Route::post($uri)), None) + return (Some(Route::post($uri)), None); } }; - ($req_uri: expr, $call: expr, LTD_POST_NO_LOGIN, $uri: expr, $func: expr, $policy: expr)=>{ - if($uri.eq($req_uri)) - { + ($req_uri: expr, $call: expr, LTD_POST_NO_LOGIN, $uri: expr, $func: expr, $policy: expr) => { + if ($uri.eq($req_uri)) { if let Some(c) = $call { - return (None, Some($func(c).await)); + return (None, Some($func(c).await)); } - return (Some(Route::limited_post_without_login($uri, $policy)), None) + return (Some(Route::limited_post_without_login($uri, $policy)), None); } }; - ($req_uri: expr, $call: expr, LTD_POST_LOGIN, $uri: expr, $func: expr, $policy: expr)=>{ - if($uri.eq($req_uri)) - { + ($req_uri: expr, $call: expr, LTD_POST_LOGIN, $uri: expr, $func: expr, $policy: expr) => { + if ($uri.eq($req_uri)) { if let Some(c) = $call { - return (None, Some($func(c).await)); + return (None, Some($func(c).await)); } - return (Some(Route::limited_post($uri, $policy)), None) + return (Some(Route::limited_post($uri, $policy)), None); } }; - ($req_uri: expr, $call: expr, LTD_ADMIN_POST_NO_LOGIN, $uri: expr, $func: expr, $policy: expr)=>{ - if($uri.eq($req_uri)) - { + ($req_uri: expr, $call: expr, LTD_ADMIN_POST_NO_LOGIN, $uri: expr, $func: expr, $policy: expr) => { + if ($uri.eq($req_uri)) { if let Some(c) = $call { - return (None, Some($func(c).await)); + return (None, Some($func(c).await)); } - return (Some(Route::limited_admin_post_without_login($uri, $policy)), None) + return ( + Some(Route::limited_admin_post_without_login($uri, $policy)), + None, + ); } }; - ($req_uri: expr, $call: expr, ADMIN_POST_LOGIN, $uri: expr, $func: expr)=>{ - if($uri.eq($req_uri)) - { + ($req_uri: expr, $call: expr, ADMIN_POST_LOGIN, $uri: expr, $func: expr) => { + if ($uri.eq($req_uri)) { if let Some(c) = $call { - return (None, Some($func(c).await)); + return (None, Some($func(c).await)); } return (Some(Route::admin_post($uri)), None); } }; - ($req_uri: expr, $call: expr, ADMIN_POST_LOGIN_RESTR, $uri: expr, $func: expr, $role: expr)=>{ - if($uri.eq($req_uri)) - { + ($req_uri: expr, $call: expr, ADMIN_POST_LOGIN_RESTR, $uri: expr, $func: expr, $role: expr) => { + if ($uri.eq($req_uri)) { if let Some(c) = $call { - return (None, Some($func(c).await)); + return (None, Some($func(c).await)); } return (Some(Route::admin_post_restricted($uri, $role)), None); } }; - } -pub async fn find_route(req_uri: &str, call: Option<&mut HttpRequestHandler>) -> (Option, Option) { +pub async fn find_route( + req_uri: &str, + call: Option<&mut HttpRequestHandler>, +) -> (Option, Option) { // Server meta routes - route!(req_uri, call, GET_NO_LOGIN, "/", server_controller::main_index); - route!(req_uri, call, POST_NO_LOGIN, "/server/config", server_controller::get_config); - + route!( + req_uri, + call, + GET_NO_LOGIN, + "/", + server_controller::main_index + ); + route!( + req_uri, + call, + POST_NO_LOGIN, + "/server/config", + server_controller::get_config + ); // Main user WebSocket - route!(req_uri, call, POST_LOGIN, "/ws/token", user_ws_controller::get_token); + route!( + req_uri, + call, + POST_LOGIN, + "/ws/token", + user_ws_controller::get_token + ); // Account controller - route!(req_uri, call, LTD_POST_NO_LOGIN, "/account/create", account_controller::create, LimitPolicy::SUCCESS(10)); - route!(req_uri, call, LTD_POST_NO_LOGIN, "/account/login", account_controller::login_user, LimitPolicy::FAILURE(10)); - route!(req_uri, call, POST_LOGIN, "/account/logout", account_controller::logout_user); - route!(req_uri, call, POST_LOGIN, "/account/disconnect_all_devices", account_controller::disconnect_all_devices); - route!(req_uri, call, POST_LOGIN, "/account/id", account_controller::user_id); - route!(req_uri, call, POST_LOGIN, "/account/mail", account_controller::get_mail); - route!(req_uri, call, LTD_POST_NO_LOGIN, "/account/exists_email", account_controller::exists_mail, LimitPolicy::ANY(30)); - route!(req_uri, call, LTD_POST_NO_LOGIN, "/account/has_security_questions", account_controller::has_security_questions, LimitPolicy::FAILURE(10)); - route!(req_uri, call, LTD_POST_NO_LOGIN, "/account/get_security_questions", account_controller::get_security_questions, LimitPolicy::FAILURE(10)); - route!(req_uri, call, LTD_POST_NO_LOGIN, "/account/check_security_answers", account_controller::check_security_answers, LimitPolicy::FAILURE(10)); - route!(req_uri, call, LTD_POST_NO_LOGIN, "/account/check_password_reset_token", account_controller::check_password_reset_token, LimitPolicy::FAILURE(10)); - route!(req_uri, call, LTD_POST_NO_LOGIN, "/account/reset_user_passwd", account_controller::reset_user_password, LimitPolicy::FAILURE(10)); - route!(req_uri, call, LTD_POST_LOGIN, "/account/export_data", account_controller::export_data, LimitPolicy::ANY(10)); - route!(req_uri, call, POST_LOGIN, "/account/delete", account_controller::delete_account); + route!( + req_uri, + call, + LTD_POST_NO_LOGIN, + "/account/create", + account_controller::create, + LimitPolicy::SUCCESS(10) + ); + route!( + req_uri, + call, + LTD_POST_NO_LOGIN, + "/account/login", + account_controller::login_user, + LimitPolicy::FAILURE(10) + ); + route!( + req_uri, + call, + POST_LOGIN, + "/account/logout", + account_controller::logout_user + ); + route!( + req_uri, + call, + POST_LOGIN, + "/account/disconnect_all_devices", + account_controller::disconnect_all_devices + ); + route!( + req_uri, + call, + POST_LOGIN, + "/account/id", + account_controller::user_id + ); + route!( + req_uri, + call, + POST_LOGIN, + "/account/mail", + account_controller::get_mail + ); + route!( + req_uri, + call, + LTD_POST_NO_LOGIN, + "/account/exists_email", + account_controller::exists_mail, + LimitPolicy::ANY(30) + ); + route!( + req_uri, + call, + LTD_POST_NO_LOGIN, + "/account/has_security_questions", + account_controller::has_security_questions, + LimitPolicy::FAILURE(10) + ); + route!( + req_uri, + call, + LTD_POST_NO_LOGIN, + "/account/get_security_questions", + account_controller::get_security_questions, + LimitPolicy::FAILURE(10) + ); + route!( + req_uri, + call, + LTD_POST_NO_LOGIN, + "/account/check_security_answers", + account_controller::check_security_answers, + LimitPolicy::FAILURE(10) + ); + route!( + req_uri, + call, + LTD_POST_NO_LOGIN, + "/account/check_password_reset_token", + account_controller::check_password_reset_token, + LimitPolicy::FAILURE(10) + ); + route!( + req_uri, + call, + LTD_POST_NO_LOGIN, + "/account/reset_user_passwd", + account_controller::reset_user_password, + LimitPolicy::FAILURE(10) + ); + route!( + req_uri, + call, + LTD_POST_LOGIN, + "/account/export_data", + account_controller::export_data, + LimitPolicy::ANY(10) + ); + route!( + req_uri, + call, + POST_LOGIN, + "/account/delete", + account_controller::delete_account + ); // User controller - route!(req_uri, call, POST_LOGIN, "/user/getInfo", user_controller::get_single); - route!(req_uri, call, POST_LOGIN, "/user/getInfos", user_controller::get_single); - route!(req_uri, call, POST_LOGIN, "/user/getInfoMultiple", user_controller::get_multiple); - route!(req_uri, call, POST_LOGIN, "/user/getInfosMultiple", user_controller::get_multiple); - route!(req_uri, call, POST_LOGIN, "/user/getAdvancedUserInfo", user_controller::get_advanced_info); - route!(req_uri, call, POST_LOGIN, "/user/getAdvancedUserInfos", user_controller::get_advanced_info); + route!( + req_uri, + call, + POST_LOGIN, + "/user/getInfo", + user_controller::get_single + ); + route!( + req_uri, + call, + POST_LOGIN, + "/user/getInfos", + user_controller::get_single + ); + route!( + req_uri, + call, + POST_LOGIN, + "/user/getInfoMultiple", + user_controller::get_multiple + ); + route!( + req_uri, + call, + POST_LOGIN, + "/user/getInfosMultiple", + user_controller::get_multiple + ); + route!( + req_uri, + call, + POST_LOGIN, + "/user/getAdvancedUserInfo", + user_controller::get_advanced_info + ); + route!( + req_uri, + call, + POST_LOGIN, + "/user/getAdvancedUserInfos", + user_controller::get_advanced_info + ); // Settings controller - route!(req_uri, call, POST_LOGIN, "/settings/get_general", settings_controller::get_general); - route!(req_uri, call, POST_LOGIN, "/settings/set_general", settings_controller::set_general); - route!(req_uri, call, POST_LOGIN, "/settings/check_user_directory_availability", settings_controller::check_virtual_directory); - route!(req_uri, call, POST_LOGIN, "/settings/get_language", settings_controller::get_language); - route!(req_uri, call, POST_LOGIN, "/settings/set_language", settings_controller::set_language); - route!(req_uri, call, POST_LOGIN, "/settings/get_security", settings_controller::get_security); - route!(req_uri, call, POST_LOGIN, "/settings/set_security", settings_controller::set_security); - route!(req_uri, call, POST_LOGIN, "/settings/check_password", settings_controller::check_password); - route!(req_uri, call, POST_LOGIN, "/settings/update_password", settings_controller::update_password); - route!(req_uri, call, POST_LOGIN, "/settings/get_account_image", settings_controller::get_account_image_settings); - route!(req_uri, call, POST_LOGIN, "/settings/upload_account_image", settings_controller::upload_account_image); - route!(req_uri, call, POST_LOGIN, "/settings/delete_account_image", settings_controller::delete_account_image); - route!(req_uri, call, POST_LOGIN, "/settings/set_account_image_visibility", settings_controller::set_account_image_visibility); - route!(req_uri, call, POST_LOGIN, "/settings/upload_custom_emoji", settings_controller::upload_custom_emoji); - route!(req_uri, call, POST_LOGIN, "/settings/delete_custom_emoji", settings_controller::delete_custom_emoji); - route!(req_uri, call, POST_LOGIN, "/settings/get_data_conservation_policy", settings_controller::get_data_conservation_policy); - route!(req_uri, call, LTD_POST_LOGIN, "/settings/set_data_conservation_policy", settings_controller::set_data_conservation_policy, LimitPolicy::FAILURE(10)); - route!(req_uri, call, POST_LOGIN, "/settings/get_notifications", settings_controller::get_notifications); - route!(req_uri, call, POST_LOGIN, "/settings/set_notifications", settings_controller::set_notifications); - + route!( + req_uri, + call, + POST_LOGIN, + "/settings/get_general", + settings_controller::get_general + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/set_general", + settings_controller::set_general + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/check_user_directory_availability", + settings_controller::check_virtual_directory + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/get_language", + settings_controller::get_language + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/set_language", + settings_controller::set_language + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/get_security", + settings_controller::get_security + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/set_security", + settings_controller::set_security + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/check_password", + settings_controller::check_password + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/update_password", + settings_controller::update_password + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/get_account_image", + settings_controller::get_account_image_settings + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/upload_account_image", + settings_controller::upload_account_image + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/delete_account_image", + settings_controller::delete_account_image + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/set_account_image_visibility", + settings_controller::set_account_image_visibility + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/upload_custom_emoji", + settings_controller::upload_custom_emoji + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/delete_custom_emoji", + settings_controller::delete_custom_emoji + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/get_data_conservation_policy", + settings_controller::get_data_conservation_policy + ); + route!( + req_uri, + call, + LTD_POST_LOGIN, + "/settings/set_data_conservation_policy", + settings_controller::set_data_conservation_policy, + LimitPolicy::FAILURE(10) + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/get_notifications", + settings_controller::get_notifications + ); + route!( + req_uri, + call, + POST_LOGIN, + "/settings/set_notifications", + settings_controller::set_notifications + ); // Push notifications controller - route!(req_uri, call, POST_LOGIN, "/push_notifications/status", push_notifications_controller::get_status); - route!(req_uri, call, POST_LOGIN, "/push_notifications/configure", push_notifications_controller::configure); + route!( + req_uri, + call, + POST_LOGIN, + "/push_notifications/status", + push_notifications_controller::get_status + ); + route!( + req_uri, + call, + POST_LOGIN, + "/push_notifications/configure", + push_notifications_controller::configure + ); // Friends controller - route!(req_uri, call, POST_LOGIN, "/friends/getList", friends_controller::get_list); - route!(req_uri, call, POST_LOGIN, "/friends/get_single_infos", friends_controller::get_single_friendship_info); - route!(req_uri, call, POST_LOGIN, "/friends/get_user_list", friends_controller::get_other_user_list); - route!(req_uri, call, POST_LOGIN, "/friends/getStatus", friends_controller::get_status); - route!(req_uri, call, POST_LOGIN, "/friends/sendRequest", friends_controller::send_request); - route!(req_uri, call, POST_LOGIN, "/friends/removeRequest", friends_controller::cancel_request); - route!(req_uri, call, POST_LOGIN, "/friends/respondRequest", friends_controller::respond_request); - route!(req_uri, call, POST_LOGIN, "/friends/remove", friends_controller::remove_friend); - route!(req_uri, call, POST_LOGIN, "/friends/setFollowing", friends_controller::set_following); - route!(req_uri, call, POST_LOGIN, "/friends/set_can_post_texts", friends_controller::set_can_post_texts); - + route!( + req_uri, + call, + POST_LOGIN, + "/friends/getList", + friends_controller::get_list + ); + route!( + req_uri, + call, + POST_LOGIN, + "/friends/get_single_infos", + friends_controller::get_single_friendship_info + ); + route!( + req_uri, + call, + POST_LOGIN, + "/friends/get_user_list", + friends_controller::get_other_user_list + ); + route!( + req_uri, + call, + POST_LOGIN, + "/friends/getStatus", + friends_controller::get_status + ); + route!( + req_uri, + call, + POST_LOGIN, + "/friends/sendRequest", + friends_controller::send_request + ); + route!( + req_uri, + call, + POST_LOGIN, + "/friends/removeRequest", + friends_controller::cancel_request + ); + route!( + req_uri, + call, + POST_LOGIN, + "/friends/respondRequest", + friends_controller::respond_request + ); + route!( + req_uri, + call, + POST_LOGIN, + "/friends/remove", + friends_controller::remove_friend + ); + route!( + req_uri, + call, + POST_LOGIN, + "/friends/setFollowing", + friends_controller::set_following + ); + route!( + req_uri, + call, + POST_LOGIN, + "/friends/set_can_post_texts", + friends_controller::set_can_post_texts + ); // Conversations controller - route!(req_uri, call, POST_LOGIN, "/conversations/create", conversations_controller::create); - route!(req_uri, call, POST_LOGIN, "/conversations/getList", conversations_controller::get_list); - route!(req_uri, call, POST_LOGIN, "/conversations/get_single", conversations_controller::get_single); - route!(req_uri, call, POST_LOGIN, "/conversations/updateSettings", conversations_controller::update_settings); - route!(req_uri, call, POST_LOGIN, "/conversations/change_image", conversations_controller::change_image); - route!(req_uri, call, POST_LOGIN, "/conversations/delete_image", conversations_controller::delete_image); - route!(req_uri, call, POST_LOGIN, "/conversations/addMember", conversations_controller::add_member); - route!(req_uri, call, POST_LOGIN, "/conversations/setAdmin", conversations_controller::set_admin); - route!(req_uri, call, POST_LOGIN, "/conversations/removeMember", conversations_controller::remove_member); - route!(req_uri, call, POST_LOGIN, "/conversations/getPrivate", conversations_controller::find_private); - route!(req_uri, call, POST_LOGIN, "/conversations/refresh_single", conversations_controller::refresh_single); - route!(req_uri, call, POST_LOGIN, "/conversations/get_older_messages", conversations_controller::get_older_messages); - route!(req_uri, call, POST_LOGIN, "/conversations/sendMessage", conversations_controller::send_message); - route!(req_uri, call, POST_LOGIN, "/conversations/get_number_unread", conversations_controller::count_unread); - route!(req_uri, call, POST_LOGIN, "/conversations/get_list_unread", conversations_controller::list_unread); - route!(req_uri, call, POST_LOGIN, "/conversations/delete", conversations_controller::delete_conversation); - route!(req_uri, call, POST_LOGIN, "/conversations/updateMessage", conversations_controller::update_message); - route!(req_uri, call, POST_LOGIN, "/conversations/deleteMessage", conversations_controller::delete_message); - + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/create", + conversations_controller::create + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/getList", + conversations_controller::get_list + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/get_single", + conversations_controller::get_single + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/updateSettings", + conversations_controller::update_settings + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/change_image", + conversations_controller::change_image + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/delete_image", + conversations_controller::delete_image + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/addMember", + conversations_controller::add_member + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/setAdmin", + conversations_controller::set_admin + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/removeMember", + conversations_controller::remove_member + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/getPrivate", + conversations_controller::find_private + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/refresh_single", + conversations_controller::refresh_single + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/get_older_messages", + conversations_controller::get_older_messages + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/sendMessage", + conversations_controller::send_message + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/get_number_unread", + conversations_controller::count_unread + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/get_list_unread", + conversations_controller::list_unread + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/delete", + conversations_controller::delete_conversation + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/updateMessage", + conversations_controller::update_message + ); + route!( + req_uri, + call, + POST_LOGIN, + "/conversations/deleteMessage", + conversations_controller::delete_message + ); // Search controller - route!(req_uri, call, POST_LOGIN, "/search/user", search_controller::search_user); - route!(req_uri, call, POST_LOGIN, "/user/search", search_controller::search_user); - route!(req_uri, call, POST_LOGIN, "/search/global", search_controller::search_global); - + route!( + req_uri, + call, + POST_LOGIN, + "/search/user", + search_controller::search_user + ); + route!( + req_uri, + call, + POST_LOGIN, + "/user/search", + search_controller::search_user + ); + route!( + req_uri, + call, + POST_LOGIN, + "/search/global", + search_controller::search_global + ); // Groups controller - route!(req_uri, call, POST_LOGIN, "/groups/create", groups_controller::create); - route!(req_uri, call, POST_LOGIN, "/groups/get_my_list", groups_controller::get_list_user); - route!(req_uri, call, POST_LOGIN, "/groups/get_info", groups_controller::get_info_single); - route!(req_uri, call, POST_LOGIN, "/groups/get_multiple_info", groups_controller::get_info_multiple); - route!(req_uri, call, POST_LOGIN, "/groups/get_advanced_info", groups_controller::get_advanced_info); - route!(req_uri, call, POST_LOGIN, "/groups/get_settings", groups_controller::get_settings); - route!(req_uri, call, POST_LOGIN, "/groups/set_settings", groups_controller::set_settings); - route!(req_uri, call, POST_LOGIN, "/groups/checkVirtualDirectory", groups_controller::check_virtual_dir); - route!(req_uri, call, POST_LOGIN, "/groups/upload_logo", groups_controller::upload_logo); - route!(req_uri, call, POST_LOGIN, "/groups/delete_logo", groups_controller::delete_logo); - route!(req_uri, call, POST_LOGIN, "/groups/create_conversation", groups_controller::create_conversation); - route!(req_uri, call, POST_LOGIN, "/groups/set_conversation_visibility", groups_controller::set_conversation_visibility); - route!(req_uri, call, POST_LOGIN, "/groups/delete_conversation", groups_controller::delete_conversation); - route!(req_uri, call, POST_LOGIN, "/groups/get_members", groups_controller::get_members); - route!(req_uri, call, POST_LOGIN, "/groups/invite", groups_controller::invite_user); - route!(req_uri, call, POST_LOGIN, "/groups/cancel_invitation", groups_controller::cancel_invitation); - route!(req_uri, call, POST_LOGIN, "/groups/respond_invitation", groups_controller::respond_invitation); - route!(req_uri, call, POST_LOGIN, "/groups/send_request", groups_controller::send_request); - route!(req_uri, call, POST_LOGIN, "/groups/cancel_request", groups_controller::cancel_request); - route!(req_uri, call, POST_LOGIN, "/groups/delete_member", groups_controller::delete_member); - route!(req_uri, call, POST_LOGIN, "/groups/update_membership_level", groups_controller::update_membership); - route!(req_uri, call, POST_LOGIN, "/groups/respond_request", groups_controller::respond_request); - route!(req_uri, call, POST_LOGIN, "/groups/get_membership", groups_controller::get_membership); - route!(req_uri, call, POST_LOGIN, "/groups/remove_membership", groups_controller::remove_membership); - route!(req_uri, call, POST_LOGIN, "/groups/set_following", groups_controller::set_following); - route!(req_uri, call, LTD_POST_LOGIN, "/groups/delete", groups_controller::delete_group, LimitPolicy::FAILURE(10)); - + route!( + req_uri, + call, + POST_LOGIN, + "/groups/create", + groups_controller::create + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/get_my_list", + groups_controller::get_list_user + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/get_info", + groups_controller::get_info_single + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/get_multiple_info", + groups_controller::get_info_multiple + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/get_advanced_info", + groups_controller::get_advanced_info + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/get_settings", + groups_controller::get_settings + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/set_settings", + groups_controller::set_settings + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/checkVirtualDirectory", + groups_controller::check_virtual_dir + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/upload_logo", + groups_controller::upload_logo + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/delete_logo", + groups_controller::delete_logo + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/create_conversation", + groups_controller::create_conversation + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/set_conversation_visibility", + groups_controller::set_conversation_visibility + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/delete_conversation", + groups_controller::delete_conversation + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/get_members", + groups_controller::get_members + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/invite", + groups_controller::invite_user + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/cancel_invitation", + groups_controller::cancel_invitation + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/respond_invitation", + groups_controller::respond_invitation + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/send_request", + groups_controller::send_request + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/cancel_request", + groups_controller::cancel_request + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/delete_member", + groups_controller::delete_member + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/update_membership_level", + groups_controller::update_membership + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/respond_request", + groups_controller::respond_request + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/get_membership", + groups_controller::get_membership + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/remove_membership", + groups_controller::remove_membership + ); + route!( + req_uri, + call, + POST_LOGIN, + "/groups/set_following", + groups_controller::set_following + ); + route!( + req_uri, + call, + LTD_POST_LOGIN, + "/groups/delete", + groups_controller::delete_group, + LimitPolicy::FAILURE(10) + ); // Posts controller - route!(req_uri, call, POST_LOGIN, "/posts/get_user", posts_controller::get_list_user); - route!(req_uri, call, POST_LOGIN, "/posts/get_group", posts_controller::get_list_group); - route!(req_uri, call, POST_LOGIN, "/posts/get_latest", posts_controller::get_latest); - route!(req_uri, call, POST_LOGIN, "/posts/get_single", posts_controller::get_single); - route!(req_uri, call, POST_LOGIN, "/posts/create", posts_controller::create_post); - route!(req_uri, call, POST_LOGIN, "/posts/set_visibility_level", posts_controller::set_visibility_level); - route!(req_uri, call, POST_LOGIN, "/posts/update_content", posts_controller::update_content); - route!(req_uri, call, POST_LOGIN, "/posts/delete", posts_controller::delete); - route!(req_uri, call, POST_LOGIN, "/posts/getAvailableTargets", posts_controller::get_targets); - + route!( + req_uri, + call, + POST_LOGIN, + "/posts/get_user", + posts_controller::get_list_user + ); + route!( + req_uri, + call, + POST_LOGIN, + "/posts/get_group", + posts_controller::get_list_group + ); + route!( + req_uri, + call, + POST_LOGIN, + "/posts/get_latest", + posts_controller::get_latest + ); + route!( + req_uri, + call, + POST_LOGIN, + "/posts/get_single", + posts_controller::get_single + ); + route!( + req_uri, + call, + POST_LOGIN, + "/posts/create", + posts_controller::create_post + ); + route!( + req_uri, + call, + POST_LOGIN, + "/posts/set_visibility_level", + posts_controller::set_visibility_level + ); + route!( + req_uri, + call, + POST_LOGIN, + "/posts/update_content", + posts_controller::update_content + ); + route!( + req_uri, + call, + POST_LOGIN, + "/posts/delete", + posts_controller::delete + ); + route!( + req_uri, + call, + POST_LOGIN, + "/posts/getAvailableTargets", + posts_controller::get_targets + ); // Comments controller - route!(req_uri, call, POST_LOGIN, "/comments/create", comments_controller::create); - route!(req_uri, call, POST_LOGIN, "/comments/get_single", comments_controller::get_single); - route!(req_uri, call, POST_LOGIN, "/comments/edit", comments_controller::edit); - route!(req_uri, call, POST_LOGIN, "/comments/delete", comments_controller::delete); - + route!( + req_uri, + call, + POST_LOGIN, + "/comments/create", + comments_controller::create + ); + route!( + req_uri, + call, + POST_LOGIN, + "/comments/get_single", + comments_controller::get_single + ); + route!( + req_uri, + call, + POST_LOGIN, + "/comments/edit", + comments_controller::edit + ); + route!( + req_uri, + call, + POST_LOGIN, + "/comments/delete", + comments_controller::delete + ); // Likes controller - route!(req_uri, call, POST_LOGIN, "/likes/update", likes_controller::update); - + route!( + req_uri, + call, + POST_LOGIN, + "/likes/update", + likes_controller::update + ); // Surveys controller - route!(req_uri, call, POST_LOGIN, "/surveys/get_info", surveys_controller::get_info_single); - route!(req_uri, call, POST_LOGIN, "/surveys/send_response", surveys_controller::send_response); - route!(req_uri, call, POST_LOGIN, "/surveys/cancel_response", surveys_controller::cancel_response); - route!(req_uri, call, POST_LOGIN, "/surveys/create_new_choice", surveys_controller::create_new_choice); - route!(req_uri, call, POST_LOGIN, "/surveys/block_new_choices_creation", surveys_controller::block_new_choices_creation); - + route!( + req_uri, + call, + POST_LOGIN, + "/surveys/get_info", + surveys_controller::get_info_single + ); + route!( + req_uri, + call, + POST_LOGIN, + "/surveys/send_response", + surveys_controller::send_response + ); + route!( + req_uri, + call, + POST_LOGIN, + "/surveys/cancel_response", + surveys_controller::cancel_response + ); + route!( + req_uri, + call, + POST_LOGIN, + "/surveys/create_new_choice", + surveys_controller::create_new_choice + ); + route!( + req_uri, + call, + POST_LOGIN, + "/surveys/block_new_choices_creation", + surveys_controller::block_new_choices_creation + ); // Notifications controller - route!(req_uri, call, POST_LOGIN, "/notifications/count_unread", notifications_controller::count_unread); - route!(req_uri, call, POST_LOGIN, "/notifications/count_all_news", notifications_controller::count_all_news); - route!(req_uri, call, POST_LOGIN, "/notifications/get_list_unread", notifications_controller::get_list_unread); - route!(req_uri, call, POST_LOGIN, "/notifications/mark_seen", notifications_controller::mark_seen); - route!(req_uri, call, POST_LOGIN, "/notifications/delete_all", notifications_controller::delete_all); - + route!( + req_uri, + call, + POST_LOGIN, + "/notifications/count_unread", + notifications_controller::count_unread + ); + route!( + req_uri, + call, + POST_LOGIN, + "/notifications/count_all_news", + notifications_controller::count_all_news + ); + route!( + req_uri, + call, + POST_LOGIN, + "/notifications/get_list_unread", + notifications_controller::get_list_unread + ); + route!( + req_uri, + call, + POST_LOGIN, + "/notifications/mark_seen", + notifications_controller::mark_seen + ); + route!( + req_uri, + call, + POST_LOGIN, + "/notifications/delete_all", + notifications_controller::delete_all + ); // Virtual directory controller - route!(req_uri, call, POST_LOGIN, "/user/findbyfolder", virtual_directory_controller::find_user); - route!(req_uri, call, POST_LOGIN, "/virtualDirectory/find", virtual_directory_controller::find); - + route!( + req_uri, + call, + POST_LOGIN, + "/user/findbyfolder", + virtual_directory_controller::find_user + ); + route!( + req_uri, + call, + POST_LOGIN, + "/virtualDirectory/find", + virtual_directory_controller::find + ); // Web application controller - route!(req_uri, call, POST_LOGIN, "/webApp/getMemberships", web_app_controller::get_memberships); + route!( + req_uri, + call, + POST_LOGIN, + "/webApp/getMemberships", + web_app_controller::get_memberships + ); // Report controller - route!(req_uri, call, LTD_POST_LOGIN, "/reports/create", report_controller::report, LimitPolicy::ANY(10)); + route!( + req_uri, + call, + LTD_POST_LOGIN, + "/reports/create", + report_controller::report, + LimitPolicy::ANY(10) + ); // Forez controller - route!(req_uri, call, POST_LOGIN, "/forez/get_groups", forez_controller::get_list_groups); - route!(req_uri, call, POST_LOGIN, "/forez/get_member_info", forez_controller::get_member_info); - + route!( + req_uri, + call, + POST_LOGIN, + "/forez/get_groups", + forez_controller::get_list_groups + ); + route!( + req_uri, + call, + POST_LOGIN, + "/forez/get_member_info", + forez_controller::get_member_info + ); // === ADMIN ROUTES === - // Admin accounts controller - route!(req_uri, call, LTD_ADMIN_POST_NO_LOGIN, "/admin/accounts/auth_options", admin_account_controller::get_auth_options, LimitPolicy::FAILURE(5)); - route!(req_uri, call, LTD_ADMIN_POST_NO_LOGIN, "/admin/accounts/auth_with_reset_token", admin_account_controller::auth_with_reset_token, LimitPolicy::FAILURE(5)); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/accounts/sign_out", admin_account_controller::sign_out); - route!(req_uri, call, ADMIN_POST_LOGIN_RESTR, "/admin/accounts/create", admin_account_controller::create, AdminRole::MANAGE_ADMINS); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/accounts/id", admin_account_controller::get_admin_id); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/accounts/list", admin_account_controller::get_list); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/accounts/info", admin_account_controller::get_admin_info); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/accounts/update_general_settings", admin_account_controller::update_general_settings); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/accounts/generate_reset_token", admin_account_controller::generate_reset_token); + route!( + req_uri, + call, + LTD_ADMIN_POST_NO_LOGIN, + "/admin/accounts/auth_options", + admin_account_controller::get_auth_options, + LimitPolicy::FAILURE(5) + ); + route!( + req_uri, + call, + LTD_ADMIN_POST_NO_LOGIN, + "/admin/accounts/auth_with_reset_token", + admin_account_controller::auth_with_reset_token, + LimitPolicy::FAILURE(5) + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/accounts/sign_out", + admin_account_controller::sign_out + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN_RESTR, + "/admin/accounts/create", + admin_account_controller::create, + AdminRole::MANAGE_ADMINS + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/accounts/id", + admin_account_controller::get_admin_id + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/accounts/list", + admin_account_controller::get_list + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/accounts/info", + admin_account_controller::get_admin_info + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/accounts/update_general_settings", + admin_account_controller::update_general_settings + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/accounts/generate_reset_token", + admin_account_controller::generate_reset_token + ); // Admin security keys controller - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/keys/list", admin_keys_controller::get_keys_list); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/keys/challenge_register_key", admin_keys_controller::challenge_register_key); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/keys/register_key", admin_keys_controller::register_key); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/keys/delete_auth_key", admin_keys_controller::delete_auth_key); - route!(req_uri, call, LTD_ADMIN_POST_NO_LOGIN, "/admin/keys/challenge_auth_with_key", admin_keys_controller::challenge_auth_with_key, LimitPolicy::ANY(10)); - route!(req_uri, call, LTD_ADMIN_POST_NO_LOGIN, "/admin/keys/auth_with_key", admin_keys_controller::auth_with_key, LimitPolicy::ANY(10)); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/keys/list", + admin_keys_controller::get_keys_list + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/keys/challenge_register_key", + admin_keys_controller::challenge_register_key + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/keys/register_key", + admin_keys_controller::register_key + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/keys/delete_auth_key", + admin_keys_controller::delete_auth_key + ); + route!( + req_uri, + call, + LTD_ADMIN_POST_NO_LOGIN, + "/admin/keys/challenge_auth_with_key", + admin_keys_controller::challenge_auth_with_key, + LimitPolicy::ANY(10) + ); + route!( + req_uri, + call, + LTD_ADMIN_POST_NO_LOGIN, + "/admin/keys/auth_with_key", + admin_keys_controller::auth_with_key, + LimitPolicy::ANY(10) + ); // Admin roles controller - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/roles/list", admin_roles_controller::get_list); - route!(req_uri, call, ADMIN_POST_LOGIN_RESTR, "/admin/roles/toggle", admin_roles_controller::toggle, AdminRole::MANAGE_ADMINS); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/roles/list", + admin_roles_controller::get_list + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN_RESTR, + "/admin/roles/toggle", + admin_roles_controller::toggle, + AdminRole::MANAGE_ADMINS + ); // Admin logs controller - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/logs/list", admin_logs_controller::get_list); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/logs/list", + admin_logs_controller::get_list + ); // Admin users management controller - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/users/search", admin_users_controller::search); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/users/info", admin_users_controller::get_single); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/users/change_email_address", admin_users_controller::change_email_address); - route!(req_uri, call, ADMIN_POST_LOGIN, "/admin/users/create_password_reset_link", admin_users_controller::create_password_reset_link); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/users/search", + admin_users_controller::search + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/users/info", + admin_users_controller::get_single + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/users/change_email_address", + admin_users_controller::change_email_address + ); + route!( + req_uri, + call, + ADMIN_POST_LOGIN, + "/admin/users/create_password_reset_link", + admin_users_controller::create_password_reset_link + ); (None, None) -} \ No newline at end of file +} diff --git a/src/server.rs b/src/server.rs index e92249f..f8e7bc7 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,14 +1,14 @@ use std::collections::HashMap; use std::pin::Pin; -use actix_web::{App, FromRequest, http, HttpMessage, HttpRequest, HttpResponse, HttpServer, web}; use actix_web::dev::{Decompress, Payload}; use actix_web::error::{ErrorBadRequest, ErrorInternalServerError, PayloadError}; use actix_web::web::{BufMut, Bytes, BytesMut}; +use actix_web::{http, web, App, FromRequest, HttpMessage, HttpRequest, HttpResponse, HttpServer}; use encoding_rs::UTF_8; -use futures::{FutureExt, Stream, StreamExt}; use futures::future::LocalBoxFuture; use futures::task::{Context, Poll}; +use futures::{FutureExt, Stream, StreamExt}; use percent_encoding::percent_decode_str; use crate::api_data::http_error::HttpError; @@ -17,9 +17,12 @@ use crate::controllers::{rtc_relay_controller, user_ws_controller}; use crate::data::base_request_handler::{BaseRequestHandler, PostFile, RequestValue}; use crate::data::config::Config; use crate::data::http_request_handler::HttpRequestHandler; -use crate::helpers::{admin_access_token_helper, admin_key_authentication_challenges_helper, admin_key_registration_challenges_helper, api_helper, requests_limit_helper}; -use crate::routes::{find_route, RequestResult, Route, RouteScope}; +use crate::helpers::{ + admin_access_token_helper, admin_key_authentication_challenges_helper, + admin_key_registration_challenges_helper, api_helper, requests_limit_helper, +}; use crate::routes::Method::{GET, POST}; +use crate::routes::{find_route, RequestResult, Route, RouteScope}; use crate::utils::user_data_utils::user_data_path; /// Main server functions @@ -28,13 +31,12 @@ use crate::utils::user_data_utils::user_data_path; /// Custom stream to give a limit to requests size struct LimitedStream { - stream: Box> + Unpin + 'static>, + stream: Box> + Unpin + 'static>, already_read: usize, max_size: usize, } -impl<'a> Stream for LimitedStream -{ +impl<'a> Stream for LimitedStream { type Item = Result; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { @@ -73,7 +75,9 @@ impl FromRequest for CustomRequest { // Check the size, if provided if req.headers().contains_key("Content-Length") { if let Some(v) = req.headers().get("Content-Length") { - content_length_size = String::from_utf8_lossy(v.as_bytes()).parse::().unwrap_or(0); + content_length_size = String::from_utf8_lossy(v.as_bytes()) + .parse::() + .unwrap_or(0); if content_length_size > MAX_REQUEST_SIZE { return Err(actix_web::error::ErrorBadRequest("Request too big!")); } @@ -81,7 +85,9 @@ impl FromRequest for CustomRequest { unreachable!(); } } else { - return Err(actix_web::error::ErrorBadRequest("Content-Length header is required!")); + return Err(actix_web::error::ErrorBadRequest( + "Content-Length header is required!", + )); } let payload = LimitedStream { @@ -90,12 +96,10 @@ impl FromRequest for CustomRequest { max_size: content_length_size, }; - let mut body_args = HashMap::new(); // Process "application/x-www-form-urlencoded" requests if req.content_type().eq("application/x-www-form-urlencoded") { - // Maximum size of the request let limit = 16384; @@ -105,7 +109,6 @@ impl FromRequest for CustomRequest { while let Some(item) = stream.next().await { let chunk = item?; - if body.len() + chunk.len() > limit { return Err(actix_web::error::ErrorBadRequest("Overflow - too long")); } else { @@ -114,7 +117,6 @@ impl FromRequest for CustomRequest { } let body = body.freeze(); - // Decode body as a string let encoding = req.encoding()?; @@ -137,19 +139,22 @@ impl FromRequest for CustomRequest { let args: Vec<&str> = v.split('=').collect(); if args.len() != 2 { - return Err(actix_web::error::ErrorBadRequest(format!("{} is invalid!", args[0]))); + return Err(actix_web::error::ErrorBadRequest(format!( + "{} is invalid!", + args[0] + ))); } // Add the value to the body body_args.insert( percent_decode_str(args[0]).decode_utf8_lossy().to_string(), - RequestValue::String(percent_decode_str(args[1]).decode_utf8_lossy().to_string()), + RequestValue::String( + percent_decode_str(args[1]).decode_utf8_lossy().to_string(), + ), ); } } } - - // Process "multipart/form-data" request else if req.content_type().starts_with("multipart/form-data") { let mut req = actix_multipart::Multipart::new(req.headers(), payload); @@ -159,8 +164,9 @@ impl FromRequest for CustomRequest { let mut field = el?; let content_type = field.content_disposition().clone(); - let name = content_type.get_name(). - ok_or_else(|| ErrorInternalServerError("Missing field name!"))?; + let name = content_type + .get_name() + .ok_or_else(|| ErrorInternalServerError("Missing field name!"))?; // Handle file upload if content_type.get_filename().is_some() { @@ -172,20 +178,22 @@ impl FromRequest for CustomRequest { buf.put(data); } - body_args.insert(name.to_string(), - RequestValue::File(PostFile { - name: filename.to_string(), - buff: buf.freeze(), - })); + body_args.insert( + name.to_string(), + RequestValue::File(PostFile { + name: filename.to_string(), + buff: buf.freeze(), + }), + ); } - // It is a simple field else { let mut content = String::new(); // Get content while let Some(chunk) = field.next().await { - content = format!("{}{}", content, String::from_utf8_lossy(chunk?.as_ref())); + content = + format!("{}{}", content, String::from_utf8_lossy(chunk?.as_ref())); } body_args.insert(name.to_string(), RequestValue::String(content)); @@ -197,7 +205,8 @@ impl FromRequest for CustomRequest { req: req.clone(), body: body_args, }) - }.boxed_local() + } + .boxed_local() } } @@ -209,7 +218,6 @@ async fn process_simple_route(route: &Route, req: &mut HttpRequestHandler) -> Re // Check if the user is allowed to access the route match route.scope { - // "Normal" user route RouteScope::USER => { // Validate client token @@ -235,7 +243,6 @@ async fn process_simple_route(route: &Route, req: &mut HttpRequestHandler) -> Re } } - let (_, res) = find_route(route.uri, Some(req)).await; let res = res.unwrap(); @@ -250,10 +257,14 @@ async fn process_request(custom_req: CustomRequest) -> HttpResponse { let (route, _) = find_route(&req.uri().to_string(), None).await; // Check if a route was found with the right verb - if !route.as_ref().map(|r| - (req.method() == http::Method::GET && r.method == GET) || - (req.method() == http::Method::POST && r.method == POST) - ).unwrap_or(false) { + if !route + .as_ref() + .map(|r| { + (req.method() == http::Method::GET && r.method == GET) + || (req.method() == http::Method::POST && r.method == POST) + }) + .unwrap_or(false) + { return HttpResponse::NotFound().json(HttpError::not_found("Route not found!")); } @@ -266,7 +277,6 @@ async fn process_request(custom_req: CustomRequest) -> HttpResponse { let mut request = HttpRequestHandler::new(custom_req.req, custom_req.body); match process_simple_route(&route, &mut request).await { - // Set default error response if required Err(e) => { let err_msg = e.to_string(); @@ -275,11 +285,12 @@ async fn process_request(custom_req: CustomRequest) -> HttpResponse { request.internal_error(e).unwrap_err(); } - println!("{} - {} - {} - {}", - request.remote_ip(), - request.response_status_code(), - request.request_path(), - err_msg + println!( + "{} - {} - {} - {}", + request.remote_ip(), + request.response_status_code(), + request.request_path(), + err_msg ); } @@ -289,10 +300,11 @@ async fn process_request(custom_req: CustomRequest) -> HttpResponse { request.success("Success").unwrap() } - println!("{} - {} - {}", - request.remote_ip(), - request.response_status_code(), - request.request_path() + println!( + "{} - {} - {}", + request.remote_ip(), + request.response_status_code(), + request.request_path() ); } } @@ -309,7 +321,6 @@ async fn process_request(custom_req: CustomRequest) -> HttpResponse { /// Handle pre-flight requests async fn handle_options_request(r: HttpRequest) -> HttpResponse { - // Extract origin let origin = r.headers().get("Origin"); if origin.is_none() { @@ -331,7 +342,6 @@ async fn handle_options_request(r: HttpRequest) -> HttpResponse { .finish() } - /// Given the configuration, start the server pub fn start_server(conf: &Config) -> std::io::Result<()> { let sys = actix::System::new(); @@ -351,24 +361,29 @@ pub fn start_server(conf: &Config) -> std::io::Result<()> { let mut app = App::new(); if serve_storage_file { - app = app.service(actix_files::Files::new("/user_data", user_data_path("".as_ref()))); + app = app.service(actix_files::Files::new( + "/user_data", + user_data_path("".as_ref()), + )); } // User WebSocket route app.service(actix_web::web::resource("/ws").to(user_ws_controller::ws_route)) - // RTC Relay WebSocket route .service(actix_web::web::resource("/rtc_proxy/ws").to(rtc_relay_controller::open_ws)) - // Option - .route("{tail:.*}", web::method(http::Method::OPTIONS).to(handle_options_request)) - + .route( + "{tail:.*}", + web::method(http::Method::OPTIONS).to(handle_options_request), + ) // API routes .route("{tail:.*}", web::get().to(process_request)) .route("{tail:.*}", web::post().to(process_request)) - }).bind(&addr)?.run(); + }) + .bind(&addr)? + .run(); sys.block_on(server)?; Ok(()) -} \ No newline at end of file +} diff --git a/src/user_ws_routes.rs b/src/user_ws_routes.rs index 640f26f..faeb303 100644 --- a/src/user_ws_routes.rs +++ b/src/user_ws_routes.rs @@ -2,16 +2,20 @@ //! //! @author Pierre Hubert -use crate::controllers::{calls_controller, conversations_controller, forez_controller, likes_controller, user_ws_actions}; +use crate::controllers::{ + calls_controller, conversations_controller, forez_controller, likes_controller, user_ws_actions, +}; use crate::data::error::Res; use crate::data::user_ws_request_handler::UserWsRequestHandler; use crate::routes::RequestResult; pub type WsRequestProcess = Box Res>; - /// Search for a route -pub async fn exec_user_ws_route(uri: &str, handler: &mut UserWsRequestHandler) -> Option { +pub async fn exec_user_ws_route( + uri: &str, + handler: &mut UserWsRequestHandler, +) -> Option { match uri { // Main controller "$main/set_incognito" => Some(user_ws_actions::set_incognito(handler)), @@ -24,7 +28,9 @@ pub async fn exec_user_ws_route(uri: &str, handler: &mut UserWsRequestHandler) - "likes/update" => Some(likes_controller::update(handler).await), // Conversations controller - "conversations/is_writing" => Some(conversations_controller::member_is_writing(handler).await), + "conversations/is_writing" => { + Some(conversations_controller::member_is_writing(handler).await) + } // Calls controller "calls/config" => Some(calls_controller::get_config(handler).await), @@ -43,4 +49,4 @@ pub async fn exec_user_ws_route(uri: &str, handler: &mut UserWsRequestHandler) - _ => None, } -} \ No newline at end of file +} diff --git a/src/utils/crypt_utils.rs b/src/utils/crypt_utils.rs index 55880bf..d512fbb 100644 --- a/src/utils/crypt_utils.rs +++ b/src/utils/crypt_utils.rs @@ -4,8 +4,8 @@ extern crate sha1; -use rand::{Rng, thread_rng}; use rand::distributions::Alphanumeric; +use rand::{thread_rng, Rng}; use sha1::Digest; use crate::data::error::{ExecError, ResultBoxError}; @@ -67,4 +67,4 @@ pub fn rand_str(len: usize) -> String { .map(char::from) .take(len) .collect() -} \ No newline at end of file +} diff --git a/src/utils/date_utils.rs b/src/utils/date_utils.rs index c567127..a801d1e 100644 --- a/src/utils/date_utils.rs +++ b/src/utils/date_utils.rs @@ -4,7 +4,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; -use chrono::{TimeZone, Utc, Datelike}; +use chrono::{Datelike, TimeZone, Utc}; /// Get the current time since epoch /// @@ -14,10 +14,12 @@ use chrono::{TimeZone, Utc, Datelike}; /// let time = time(); /// ``` pub fn time() -> u64 { - SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() + SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs() } - /// Get Mysql formatted date at specific time /// /// ``` @@ -26,7 +28,7 @@ pub fn time() -> u64 { /// assert_eq!(time_to_mysql_date(1594140466), "2020-07-07 16:47:46"); /// ``` pub fn time_to_mysql_date(time: u64) -> String { - let utc = Utc.timestamp(time as i64, 0); + let utc = Utc.timestamp_opt(time as i64, 0).unwrap(); let str = utc.to_rfc3339(); (&str[..19]).replace('T', " ") } @@ -38,6 +40,6 @@ pub fn mysql_date() -> String { /// Get current year pub fn current_year() -> i32 { - let utc = Utc.timestamp(time() as i64, 0); + let utc = Utc.timestamp_opt(time() as i64, 0).unwrap(); utc.year() -} \ No newline at end of file +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 4c35fdd..94d2ac2 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -3,13 +3,13 @@ //! This module contains utilities that can be used anywhere in the code pub mod crypt_utils; -pub mod user_data_utils; -pub mod virtual_directories_utils; pub mod date_utils; -pub mod string_utils; -pub mod pdf_utils; pub mod mp3_utils; pub mod mp4_utils; -pub mod zip_utils; +pub mod network_utils; +pub mod pdf_utils; +pub mod string_utils; +pub mod user_data_utils; +pub mod virtual_directories_utils; pub mod webpage_utils; -pub mod network_utils; \ No newline at end of file +pub mod zip_utils; diff --git a/src/utils/mp3_utils.rs b/src/utils/mp3_utils.rs index e1e9c85..cf715de 100644 --- a/src/utils/mp3_utils.rs +++ b/src/utils/mp3_utils.rs @@ -13,4 +13,4 @@ pub fn is_valid_mp3(file: &[u8]) -> bool { false } } -} \ No newline at end of file +} diff --git a/src/utils/mp4_utils.rs b/src/utils/mp4_utils.rs index 91a28f3..5b4560b 100644 --- a/src/utils/mp4_utils.rs +++ b/src/utils/mp4_utils.rs @@ -14,4 +14,4 @@ pub fn is_valid_mp4(file: &[u8]) -> bool { false } } -} \ No newline at end of file +} diff --git a/src/utils/network_utils.rs b/src/utils/network_utils.rs index 1e6a947..7b4a5b1 100644 --- a/src/utils/network_utils.rs +++ b/src/utils/network_utils.rs @@ -25,4 +25,4 @@ pub fn match_ip(pattern: &str, ip: &str) -> bool { } false -} \ No newline at end of file +} diff --git a/src/utils/pdf_utils.rs b/src/utils/pdf_utils.rs index 1cf0794..3542a65 100644 --- a/src/utils/pdf_utils.rs +++ b/src/utils/pdf_utils.rs @@ -3,6 +3,7 @@ //! @author Pierre Hubert use pdf::backend::Backend; +use pdf::file::FileOptions; use crate::data::error::{ExecError, ResultBoxError}; @@ -10,12 +11,17 @@ use crate::data::error::{ExecError, ResultBoxError}; pub fn is_valid_pdf(file: &actix_web::web::Bytes) -> ResultBoxError { let backend = file.to_vec(); + let mut pdf_file = FileOptions::cached().load(backend.as_slice())?; + let start_offset = backend.locate_start_offset()?; - match backend.read_xref_table_and_trailer(start_offset) { + match backend.read_xref_table_and_trailer(start_offset, &mut pdf_file) { Ok((refs, _)) => { if refs.is_empty() { - Err(ExecError::boxed_string(format!("Detected a PDF with 0 references (file size: {})!", file.len()))) + Err(ExecError::boxed_string(format!( + "Detected a PDF with 0 references (file size: {})!", + file.len() + ))) } else { Ok(true) } @@ -26,4 +32,4 @@ pub fn is_valid_pdf(file: &actix_web::web::Bytes) -> ResultBoxError { Ok(false) } } -} \ No newline at end of file +} diff --git a/src/utils/string_utils.rs b/src/utils/string_utils.rs index 5549dc9..d4837c4 100644 --- a/src/utils/string_utils.rs +++ b/src/utils/string_utils.rs @@ -19,8 +19,7 @@ use regex::Regex; /// assert_eq!(res1, "<b>hello world</b>"); /// ``` pub fn remove_html_nodes(input: &str) -> String { - input.replace('<', "<") - .replace('>', ">") + input.replace('<', "<").replace('>', ">") } /// Check out whether a URL is valid or not @@ -74,7 +73,6 @@ pub fn check_youtube_id(id: &str) -> bool { && !id.contains('\"') } - /// Check the validity of an emoji shortcut /// /// ``` @@ -106,4 +104,4 @@ pub fn check_emoji_code(shortcut: &str) -> bool { pub fn check_html_color(color: &str) -> bool { let r = Regex::new(r"^[A-F0-9]{6}$").unwrap(); r.is_match(color) -} \ No newline at end of file +} diff --git a/src/utils/user_data_utils.rs b/src/utils/user_data_utils.rs index 56bf4dc..f424204 100644 --- a/src/utils/user_data_utils.rs +++ b/src/utils/user_data_utils.rs @@ -30,7 +30,7 @@ pub fn user_data_path(uri: &Path) -> PathBuf { pub fn prepare_file_creation(user_id: &UserID, folder: &str) -> ResultBoxError { let subfolder = match user_id.id() { 0 => Path::new(folder).to_path_buf(), - id => Path::new(folder).join(to_string(&id)?) + id => Path::new(folder).join(to_string(&id)?), }; let full_path = user_data_path(subfolder.as_path()); @@ -51,7 +51,10 @@ pub fn generate_new_user_data_file_name(dir: &Path, ext: &str) -> ResultBoxError let sys_dir = user_data_path(dir); if !sys_dir.exists() { - return Err(ExecError::boxed_string(format!("Directory {:?} does not exists!", dir))); + return Err(ExecError::boxed_string(format!( + "Directory {:?} does not exists!", + dir + ))); } loop { @@ -70,4 +73,4 @@ pub fn delete_user_data_file_if_exists(path: &str) -> Res { std::fs::remove_file(path)?; } Ok(()) -} \ No newline at end of file +} diff --git a/src/utils/virtual_directories_utils.rs b/src/utils/virtual_directories_utils.rs index 6f64113..d60fb7d 100644 --- a/src/utils/virtual_directories_utils.rs +++ b/src/utils/virtual_directories_utils.rs @@ -17,11 +17,13 @@ pub fn check_virtual_directory(dir: &str) -> bool { return false; } - for d in vec![".html", ".txt", ".php", "à", "â", "é", "ê", "@", "/", "\"", "'", "<", ">", "?", "&", "#"] { + for d in vec![ + ".html", ".txt", ".php", "à", "â", "é", "ê", "@", "/", "\"", "'", "<", ">", "?", "&", "#", + ] { if dir.contains(d) { return false; } } true -} \ No newline at end of file +} diff --git a/src/utils/webpage_utils.rs b/src/utils/webpage_utils.rs index ee642c7..2745a47 100644 --- a/src/utils/webpage_utils.rs +++ b/src/utils/webpage_utils.rs @@ -16,15 +16,30 @@ pub fn get_post_web_link(url: &str) -> Res { follow_location: false, max_redirections: 0, timeout: Duration::from_secs(3), - useragent: "OpenGraph Fetcher v1.0".to_string() + useragent: "OpenGraph Fetcher v1.0".to_string(), }; let page = Webpage::from_url(url, options)?; Ok(PostWebLink { url: url.to_string(), - title: page.html.opengraph.properties.get("title").map(String::to_string), - description: page.html.opengraph.properties.get("description").map(String::to_string), - image: page.html.opengraph.images.first().map(|m| m.url.to_string()), + title: page + .html + .opengraph + .properties + .get("title") + .map(String::to_string), + description: page + .html + .opengraph + .properties + .get("description") + .map(String::to_string), + image: page + .html + .opengraph + .images + .first() + .map(|m| m.url.to_string()), }) -} \ No newline at end of file +} diff --git a/src/utils/zip_utils.rs b/src/utils/zip_utils.rs index 6ce5f21..d843218 100644 --- a/src/utils/zip_utils.rs +++ b/src/utils/zip_utils.rs @@ -13,4 +13,4 @@ pub fn is_valid_zip(file: &[u8]) -> bool { false } } -} \ No newline at end of file +}