Compare commits

...

2 Commits

Author SHA1 Message Date
13612062ad Fix
Some checks are pending
Build docker image / Build-Docker-Image (push) Waiting to run
2025-08-09 23:18:10 +02:00
34f0c9feb6 Update deps and refactor 2025-08-09 23:10:40 +02:00
18 changed files with 390 additions and 359 deletions

181
Cargo.lock generated
View File

@@ -46,7 +46,7 @@ dependencies = [
"mime", "mime",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"rand 0.9.1", "rand 0.9.2",
"sha1", "sha1",
"smallvec", "smallvec",
"tokio", "tokio",
@@ -90,7 +90,7 @@ dependencies = [
"futures-core", "futures-core",
"futures-util", "futures-util",
"mio", "mio",
"socket2", "socket2 0.5.10",
"tokio", "tokio",
"tracing", "tracing",
] ]
@@ -148,7 +148,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"smallvec", "smallvec",
"socket2", "socket2 0.5.10",
"time", "time",
"tracing", "tracing",
"url", "url",
@@ -227,9 +227,9 @@ dependencies = [
[[package]] [[package]]
name = "async-lock" name = "async-lock"
version = "3.4.0" version = "3.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc"
dependencies = [ dependencies = [
"event-listener", "event-listener",
"event-listener-strategy", "event-listener-strategy",
@@ -408,9 +408,9 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.23.1" version = "1.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677"
[[package]] [[package]]
name = "bytes" name = "bytes"
@@ -429,9 +429,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.29" version = "1.2.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362" checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e"
dependencies = [ dependencies = [
"shlex", "shlex",
] ]
@@ -702,9 +702,9 @@ dependencies = [
[[package]] [[package]]
name = "dyn-clone" name = "dyn-clone"
version = "1.0.19" version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
[[package]] [[package]]
name = "either" name = "either"
@@ -749,9 +749,9 @@ dependencies = [
[[package]] [[package]]
name = "event-listener" name = "event-listener"
version = "5.4.0" version = "5.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab"
dependencies = [ dependencies = [
"concurrent-queue", "concurrent-queue",
"parking", "parking",
@@ -966,9 +966,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.4.11" version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785" checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386"
dependencies = [ dependencies = [
"atomic-waker", "atomic-waker",
"bytes", "bytes",
@@ -991,9 +991,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.15.4" version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [ dependencies = [
"foldhash", "foldhash",
] ]
@@ -1133,9 +1133,9 @@ dependencies = [
[[package]] [[package]]
name = "hyper-util" name = "hyper-util"
version = "0.1.15" version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f66d5bd4c6f02bf0542fad85d626775bab9258cf795a4256dcaf3161114d1df" checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e"
dependencies = [ dependencies = [
"base64", "base64",
"bytes", "bytes",
@@ -1149,7 +1149,7 @@ dependencies = [
"libc", "libc",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"socket2", "socket2 0.6.0",
"system-configuration", "system-configuration",
"tokio", "tokio",
"tower-service", "tower-service",
@@ -1337,15 +1337,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown 0.15.4", "hashbrown 0.15.5",
"serde", "serde",
] ]
[[package]] [[package]]
name = "io-uring" name = "io-uring"
version = "0.7.8" version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if",
@@ -1522,10 +1522,10 @@ checksum = "b8496cc523d1f94c1385dd8f0f0c2c480b2b8aeccb5b7e4485ad6365523ae376"
dependencies = [ dependencies = [
"crossbeam-epoch", "crossbeam-epoch",
"crossbeam-utils", "crossbeam-utils",
"hashbrown 0.15.4", "hashbrown 0.15.5",
"metrics", "metrics",
"quanta", "quanta",
"rand 0.9.1", "rand 0.9.2",
"rand_xoshiro", "rand_xoshiro",
"sketches-ddsketch", "sketches-ddsketch",
] ]
@@ -1901,9 +1901,9 @@ dependencies = [
[[package]] [[package]]
name = "quick-xml" name = "quick-xml"
version = "0.38.0" version = "0.38.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8927b0664f5c5a98265138b7e3f90aa19a6b21353182469ace36d4ac527b7b1b" checksum = "9845d9dccf565065824e69f9f235fafba1587031eda353c1f1561cd6a6be78f4"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@@ -1936,9 +1936,9 @@ dependencies = [
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.9.1" version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [ dependencies = [
"rand_chacha 0.9.0", "rand_chacha 0.9.0",
"rand_core 0.9.3", "rand_core 0.9.3",
@@ -2011,9 +2011,9 @@ dependencies = [
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.5.13" version = "0.5.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77"
dependencies = [ dependencies = [
"bitflags", "bitflags",
] ]
@@ -2158,9 +2158,9 @@ dependencies = [
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.25" version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
@@ -2173,22 +2173,22 @@ dependencies = [
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "1.0.7" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"errno", "errno",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys",
"windows-sys 0.59.0", "windows-sys 0.60.2",
] ]
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.23.29" version = "0.23.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1" checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"rustls-pki-types", "rustls-pki-types",
@@ -2228,9 +2228,9 @@ dependencies = [
[[package]] [[package]]
name = "rustversion" name = "rustversion"
version = "1.0.21" version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]] [[package]]
name = "ryu" name = "ryu"
@@ -2314,9 +2314,9 @@ checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
[[package]] [[package]]
name = "sentry" name = "sentry"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "507ac2be9bf2da56c831da57faf1dadd81f434bd282935cdb06193d0c94e8811" checksum = "989425268ab5c011e06400187eed6c298272f8ef913e49fcadc3fda788b45030"
dependencies = [ dependencies = [
"httpdate", "httpdate",
"native-tls", "native-tls",
@@ -2334,9 +2334,9 @@ dependencies = [
[[package]] [[package]]
name = "sentry-actix" name = "sentry-actix"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8402c142005ee560ae361c73ebece13a299ec3e9cce5b8654479ea9aac8dc8df" checksum = "a5c675bdf6118764a8e265c3395c311b4d905d12866c92df52870c0223d2ffc1"
dependencies = [ dependencies = [
"actix-http", "actix-http",
"actix-web", "actix-web",
@@ -2347,9 +2347,9 @@ dependencies = [
[[package]] [[package]]
name = "sentry-backtrace" name = "sentry-backtrace"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb4416302fa5325181a120e0fe7d4afd83cd95e52a9b86afa34a8161383fe0dc" checksum = "68e299dd3f7bcf676875eee852c9941e1d08278a743c32ca528e2debf846a653"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"regex", "regex",
@@ -2358,9 +2358,9 @@ dependencies = [
[[package]] [[package]]
name = "sentry-contexts" name = "sentry-contexts"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "936752f42b6f651dcb257da0bfa235ecc79e82011c49ed3383c212cc582263ff" checksum = "fac0c5d6892cd4c414492fc957477b620026fb3411fca9fa12774831da561c88"
dependencies = [ dependencies = [
"hostname", "hostname",
"libc", "libc",
@@ -2372,21 +2372,22 @@ dependencies = [
[[package]] [[package]]
name = "sentry-core" name = "sentry-core"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00e9bd2cadaeda3af41e9fa5d14645127d6f6a4aec73da3ae38e477ecafd3682" checksum = "deaa38b94e70820ff3f1f9db3c8b0aef053b667be130f618e615e0ff2492cbcc"
dependencies = [ dependencies = [
"rand 0.9.1", "rand 0.9.2",
"sentry-types", "sentry-types",
"serde", "serde",
"serde_json", "serde_json",
"url",
] ]
[[package]] [[package]]
name = "sentry-debug-images" name = "sentry-debug-images"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1e074fe9a0970c91999b23ed3195e6e30990d589fba3a68f20a1686af0f5cda" checksum = "00950648aa0d371c7f57057434ad5671bd4c106390df7e7284739330786a01b6"
dependencies = [ dependencies = [
"findshlibs", "findshlibs",
"sentry-core", "sentry-core",
@@ -2394,9 +2395,9 @@ dependencies = [
[[package]] [[package]]
name = "sentry-panic" name = "sentry-panic"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4651d34f3ba649d9e6dc1268443cae6728b8f741c2f0264004f8ecf5b247330d" checksum = "2b7a23b13c004873de3ce7db86eb0f59fe4adfc655a31f7bbc17fd10bacc9bfe"
dependencies = [ dependencies = [
"sentry-backtrace", "sentry-backtrace",
"sentry-core", "sentry-core",
@@ -2404,9 +2405,9 @@ dependencies = [
[[package]] [[package]]
name = "sentry-tracing" name = "sentry-tracing"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c25c47d36bc80c74d26d568ffe970c37b337c061b7234ad6f2d159439c16f000" checksum = "fac841c7050aa73fc2bec8f7d8e9cb1159af0b3095757b99820823f3e54e5080"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"sentry-backtrace", "sentry-backtrace",
@@ -2417,13 +2418,13 @@ dependencies = [
[[package]] [[package]]
name = "sentry-types" name = "sentry-types"
version = "0.41.0" version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a08e7154abe2cd557f26fd70038452810748aefdf39bc973f674421224b147c1" checksum = "e477f4d4db08ddb4ab553717a8d3a511bc9e81dde0c808c680feacbb8105c412"
dependencies = [ dependencies = [
"debugid", "debugid",
"hex", "hex",
"rand 0.9.1", "rand 0.9.2",
"serde", "serde",
"serde_json", "serde_json",
"thiserror 2.0.12", "thiserror 2.0.12",
@@ -2454,9 +2455,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.140" version = "1.0.142"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7"
dependencies = [ dependencies = [
"itoa", "itoa",
"memchr", "memchr",
@@ -2546,9 +2547,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]] [[package]]
name = "signal-hook-registry" name = "signal-hook-registry"
version = "1.4.5" version = "1.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@@ -2561,9 +2562,9 @@ checksum = "c1e9a774a6c28142ac54bb25d25562e6bcf957493a184f15ad4eebccb23e410a"
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.10" version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
@@ -2602,6 +2603,16 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "socket2"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807"
dependencies = [
"libc",
"windows-sys 0.59.0",
]
[[package]] [[package]]
name = "stable_deref_trait" name = "stable_deref_trait"
version = "1.2.0" version = "1.2.0"
@@ -2635,20 +2646,19 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]] [[package]]
name = "strum" name = "strum"
version = "0.27.1" version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf"
[[package]] [[package]]
name = "strum_macros" name = "strum_macros"
version = "0.27.1" version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
"quote", "quote",
"rustversion",
"syn", "syn",
] ]
@@ -2919,9 +2929,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.46.1" version = "1.47.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17" checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@@ -2932,9 +2942,9 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
"slab", "slab",
"socket2", "socket2 0.6.0",
"tokio-macros", "tokio-macros",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@@ -2981,9 +2991,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-util" name = "tokio-util"
version = "0.7.15" version = "0.7.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-core", "futures-core",
@@ -3373,14 +3383,14 @@ version = "0.26.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75c7f0ef91146ebfb530314f5f1d24528d7f0767efbfd31dce919275413e393e" checksum = "75c7f0ef91146ebfb530314f5f1d24528d7f0767efbfd31dce919275413e393e"
dependencies = [ dependencies = [
"webpki-root-certs 1.0.1", "webpki-root-certs 1.0.2",
] ]
[[package]] [[package]]
name = "webpki-root-certs" name = "webpki-root-certs"
version = "1.0.1" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86138b15b2b7d561bc4469e77027b8dd005a43dc502e9031d1f5afc8ce1f280e" checksum = "4e4ffd8df1c57e87c325000a3d6ef93db75279dc3a231125aac571650f22b12a"
dependencies = [ dependencies = [
"rustls-pki-types", "rustls-pki-types",
] ]
@@ -3544,7 +3554,7 @@ version = "0.60.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
dependencies = [ dependencies = [
"windows-targets 0.53.2", "windows-targets 0.53.3",
] ]
[[package]] [[package]]
@@ -3565,10 +3575,11 @@ dependencies = [
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.53.2" version = "0.53.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91"
dependencies = [ dependencies = [
"windows-link",
"windows_aarch64_gnullvm 0.53.0", "windows_aarch64_gnullvm 0.53.0",
"windows_aarch64_msvc 0.53.0", "windows_aarch64_msvc 0.53.0",
"windows_i686_gnu 0.53.0", "windows_i686_gnu 0.53.0",
@@ -3783,9 +3794,9 @@ dependencies = [
[[package]] [[package]]
name = "zerovec" name = "zerovec"
version = "0.11.2" version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b"
dependencies = [ dependencies = [
"yoke", "yoke",
"zerofrom", "zerofrom",

View File

@@ -34,7 +34,7 @@ tower-http = { version = "0.6.2", features = ["trace"] }
tracing = "0.1.41" tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
sentry-tracing = "0.41.0" sentry-tracing = "0.42.0"
reqwest = { version = "0.12.15", features = ["json", "stream"] } reqwest = { version = "0.12.15", features = ["json", "stream"] }
@@ -66,5 +66,5 @@ smartstring = { version = "1.0.1", features = ["serde"] }
moka = { version = "0.12.10", features = ["future"] } moka = { version = "0.12.10", features = ["future"] }
sentry = { version = "0.41.0", features = ["debug-images"] } sentry = { version = "0.42.0", features = ["debug-images"] }
anyhow = "1.0.98" anyhow = "1.0.98"

View File

@@ -41,10 +41,10 @@ async fn _update_activity(me: teloxide::types::Me, user: teloxide::types::User)
if create_or_update_user_settings( if create_or_update_user_settings(
user.id, user.id,
user.last_name.clone().unwrap_or("".to_string()), &user.last_name.unwrap_or("".to_string()),
user.first_name.clone(), &user.first_name,
user.username.clone().unwrap_or("".to_string()), &user.username.unwrap_or("".to_string()),
me.username.clone().unwrap(), &me.username.clone().unwrap_or("".to_string()),
allowed_langs, allowed_langs,
) )
.await .await
@@ -64,21 +64,18 @@ async fn _update_activity(me: teloxide::types::Me, user: teloxide::types::User)
fn update_user_activity_handler() -> BotHandler { fn update_user_activity_handler() -> BotHandler {
dptree::entry() dptree::entry()
.branch( .branch(Update::filter_callback_query().inspect_async(
Update::filter_callback_query().chain(dptree::filter_map_async( |cq: CallbackQuery, bot: CacheMe<Throttle<Bot>>| async move {
|cq: CallbackQuery, bot: CacheMe<Throttle<Bot>>| async move { _update_activity(bot.get_me().await.unwrap(), cq.from).await;
_update_activity(bot.get_me().await.unwrap(), cq.from).await },
}, ))
)), .branch(Update::filter_message().inspect_async(
)
.branch(Update::filter_message().chain(dptree::filter_map_async(
|message: Message, bot: CacheMe<Throttle<Bot>>| async move { |message: Message, bot: CacheMe<Throttle<Bot>>| async move {
match message.from { if let Some(user) = message.from {
Some(user) => _update_activity(bot.get_me().await.unwrap(), user.clone()).await, _update_activity(bot.get_me().await.unwrap(), user).await;
None => None,
} }
}, },
))) ))
} }
pub fn get_approved_handler() -> (BotHandler, BotCommands) { pub fn get_approved_handler() -> (BotHandler, BotCommands) {

View File

@@ -66,7 +66,7 @@ where
let allowed_langs = get_user_or_default_lang_codes(user_id).await; let allowed_langs = get_user_or_default_lang_codes(user_id).await;
let items_page = match books_getter(id, 1, allowed_langs.clone()).await { let items_page = match books_getter(id, 1, allowed_langs).await {
Ok(v) => v, Ok(v) => v,
Err(err) => { Err(err) => {
bot.send_message(chat_id, "Ошибка! Попробуйте позже :(") bot.send_message(chat_id, "Ошибка! Попробуйте позже :(")
@@ -160,7 +160,7 @@ where
}; };
if page > items_page.pages { if page > items_page.pages {
items_page = match books_getter(id, items_page.pages, allowed_langs.clone()).await { items_page = match books_getter(id, items_page.pages, allowed_langs).await {
Ok(v) => v, Ok(v) => v,
Err(err) => { Err(err) => {
bot.send_message(chat_id, "Ошибка! Попробуйте позже :(") bot.send_message(chat_id, "Ошибка! Попробуйте позже :(")

View File

@@ -97,12 +97,12 @@ async fn send_cached_message(
if _send_cached(&message, &bot, cached).await.is_ok() { if _send_cached(&message, &bot, cached).await.is_ok() {
if need_delete_message { if need_delete_message {
if let MaybeInaccessibleMessage::Regular(message) = message.clone() { if let MaybeInaccessibleMessage::Regular(message) = &message {
let _ = bot.delete_message(message.chat.id, message.id).await; let _ = bot.delete_message(message.chat.id, message.id).await;
} }
} }
match send_donation_notification(bot.clone(), message).await { match send_donation_notification(&bot, &message).await {
Ok(_) => (), Ok(_) => (),
Err(err) => log::error!("{err:?}"), Err(err) => log::error!("{err:?}"),
} }
@@ -119,7 +119,7 @@ async fn send_cached_message(
async fn _send_downloaded_file( async fn _send_downloaded_file(
message: &MaybeInaccessibleMessage, message: &MaybeInaccessibleMessage,
bot: CacheMe<Throttle<Bot>>, bot: &CacheMe<Throttle<Bot>>,
downloaded_data: DownloadFile, downloaded_data: DownloadFile,
) -> BotHandlerInternal { ) -> BotHandlerInternal {
let DownloadFile { let DownloadFile {
@@ -134,14 +134,14 @@ async fn _send_downloaded_file(
.into_async_read() .into_async_read()
.compat(); .compat();
let document = InputFile::read(data).file_name(filename.clone()); let document = InputFile::read(data).file_name(filename);
bot.send_document(message.chat().id, document) bot.send_document(message.chat().id, document)
.caption(caption) .caption(caption)
.send() .send()
.await?; .await?;
send_donation_notification(bot, message.clone()).await?; send_donation_notification(bot, message).await?;
Ok(()) Ok(())
} }
@@ -159,7 +159,7 @@ async fn send_with_download_from_channel(
} }
}; };
_send_downloaded_file(&message, bot.clone(), downloaded_file).await?; _send_downloaded_file(&message, &bot, downloaded_file).await?;
if need_delete_message { if need_delete_message {
if let MaybeInaccessibleMessage::Regular(message) = message { if let MaybeInaccessibleMessage::Regular(message) = message {
@@ -240,13 +240,13 @@ async fn get_download_archive_keyboard_handler(
let available_types = match command { let available_types = match command {
DownloadArchiveCommand::Sequence { id } => { DownloadArchiveCommand::Sequence { id } => {
get_sequence_books_available_types(id, allowed_langs).await get_sequence_books_available_types(id, &allowed_langs).await
} }
DownloadArchiveCommand::Author { id } => { DownloadArchiveCommand::Author { id } => {
get_author_books_available_types(id, allowed_langs).await get_author_books_available_types(id, &allowed_langs).await
} }
DownloadArchiveCommand::Translator { id } => { DownloadArchiveCommand::Translator { id } => {
get_translator_books_available_types(id, allowed_langs).await get_translator_books_available_types(id, &allowed_langs).await
} }
}; };
@@ -307,19 +307,20 @@ async fn send_error_message(bot: CacheMe<Throttle<Bot>>, chat_id: ChatId, messag
} }
async fn send_archive_link( async fn send_archive_link(
bot: CacheMe<Throttle<Bot>>, bot: &CacheMe<Throttle<Bot>>,
message: Box<Message>, chat_id: ChatId,
task: Task, message_id: MessageId,
task: &Task,
) -> BotHandlerInternal { ) -> BotHandlerInternal {
let link = format!( let link = format!(
"{}/api/download/{}", "{}/api/download/{}",
config::CONFIG.public_batch_downloader_url.clone(), config::CONFIG.public_batch_downloader_url,
task.id task.id
); );
bot.edit_message_text( bot.edit_message_text(
message.chat.id, chat_id,
message.id, message_id,
format!( format!(
"Файл не может быть загружен в чат! \n \ "Файл не может быть загружен в чат! \n \
Вы можете скачать его <a href=\"{link}\">по ссылке</a> (работает 3 часа)" Вы можете скачать его <a href=\"{link}\">по ссылке</a> (работает 3 часа)"
@@ -352,7 +353,7 @@ async fn wait_archive(
let task = loop { let task = loop {
interval.tick().await; interval.tick().await;
let task = match get_task(task_id.clone()).await { let task = match get_task(&task_id).await {
Ok(v) => v, Ok(v) => v,
Err(err) => { Err(err) => {
send_error_message(bot, message.chat.id, message.id).await; send_error_message(bot, message.chat.id, message.id).await;
@@ -388,18 +389,18 @@ async fn wait_archive(
let content_size = task.content_size.unwrap(); let content_size = task.content_size.unwrap();
if content_size > 1024 * 1024 * 1024 { if content_size > 1024 * 1024 * 1024 {
send_archive_link(bot.clone(), message.clone(), task.clone()).await?; send_archive_link(&bot, message.chat.id, message.id, &task).await?;
return Ok(()); return Ok(());
} }
let link = format!( let link = format!(
"{}/api/download/{}", "{}/api/download/{}",
config::CONFIG.batch_downloader_url.clone(), config::CONFIG.batch_downloader_url,
task.id task.id
); );
let downloaded_data = let downloaded_data =
match download_file_by_link(task.clone().result_filename.unwrap(), link).await { match download_file_by_link(&task.clone().result_filename.unwrap(), link).await {
Ok(v) => match v { Ok(v) => match v {
Some(v) => v, Some(v) => v,
None => { None => {
@@ -416,14 +417,14 @@ async fn wait_archive(
match _send_downloaded_file( match _send_downloaded_file(
&MaybeInaccessibleMessage::Regular(message.clone()), &MaybeInaccessibleMessage::Regular(message.clone()),
bot.clone(), &bot,
downloaded_data, downloaded_data,
) )
.await .await
{ {
Ok(_) => (), Ok(_) => (),
Err(err) => { Err(err) => {
send_archive_link(bot.clone(), message.clone(), task).await?; send_archive_link(&bot, message.chat.id, message.id, &task).await?;
log::error!("{err:?}"); log::error!("{err:?}");
} }
} }

View File

@@ -13,7 +13,7 @@ use self::commands::HelpCommand;
pub async fn help_handler(message: Message, bot: CacheMe<Throttle<Bot>>) -> BotHandlerInternal { pub async fn help_handler(message: Message, bot: CacheMe<Throttle<Bot>>) -> BotHandlerInternal {
let name = message let name = message
.from .from
.map(|user| user.first_name.clone()) .map(|user| user.first_name)
.unwrap_or("пользователь".to_string()); .unwrap_or("пользователь".to_string());
match bot match bot

View File

@@ -93,17 +93,16 @@ where
}; };
if page > items_page.pages { if page > items_page.pages {
items_page = items_page = match items_getter(query, items_page.pages, allowed_langs).await {
match items_getter(query.clone(), items_page.pages, allowed_langs.clone()).await { Ok(v) => v,
Ok(v) => v, Err(err) => {
Err(err) => { bot.send_message(chat_id, "Ошибка! Попробуйте позже :(")
bot.send_message(chat_id, "Ошибка! Попробуйте позже :(") .send()
.send() .await?;
.await?;
return Err(err); return Err(err);
} }
}; };
} }
let formatted_page = items_page.format(page, 4096); let formatted_page = items_page.format(page, 4096);

View File

@@ -118,10 +118,10 @@ async fn settings_callback_handler(
if let Err(err) = create_or_update_user_settings( if let Err(err) = create_or_update_user_settings(
user.id, user.id,
user.last_name.clone().unwrap_or("".to_string()), &user.last_name.unwrap_or("".to_string()),
user.first_name.clone(), &user.first_name,
user.username.clone().unwrap_or("".to_string()), &user.username.unwrap_or("".to_string()),
me.username.clone().unwrap(), &me.username.clone().unwrap(),
allowed_langs_set.clone().into_iter().collect(), allowed_langs_set.clone().into_iter().collect(),
) )
.await .await

View File

@@ -16,20 +16,20 @@ enum SupportCommand {
pub async fn support_command_handler( pub async fn support_command_handler(
message: Message, message: Message,
bot: CacheMe<Throttle<Bot>>, bot: &CacheMe<Throttle<Bot>>,
) -> BotHandlerInternal { ) -> BotHandlerInternal {
let username = match message.clone().from { let username = match message.clone().from {
Some(user) => match user.is_bot { Some(user) => match user.is_bot {
true => match message.reply_to_message() { true => match message.reply_to_message() {
Some(v) => match &v.from { Some(v) => match &v.from {
Some(v) => v.first_name.clone(), Some(v) => &v.first_name,
None => "пользователь".to_string(), None => "пользователь",
}, },
None => "пользователь".to_string(), None => "пользователь",
}, },
false => user.first_name, false => &user.first_name.clone(),
}, },
None => "пользователь".to_string(), None => "пользователь",
}; };
let message_text = format!( let message_text = format!(
@@ -60,5 +60,7 @@ pub async fn support_command_handler(
pub fn get_support_handler() -> crate::bots::BotHandler { pub fn get_support_handler() -> crate::bots::BotHandler {
Update::filter_message() Update::filter_message()
.filter_command::<SupportCommand>() .filter_command::<SupportCommand>()
.endpoint(support_command_handler) .endpoint(|message: Message, bot: CacheMe<Throttle<Bot>>| async move {
support_command_handler(message, &bot).await
})
} }

View File

@@ -56,7 +56,7 @@ pub async fn create_task(data: CreateTaskData) -> anyhow::Result<Task> {
.await?) .await?)
} }
pub async fn get_task(task_id: String) -> anyhow::Result<Task> { pub async fn get_task(task_id: &str) -> anyhow::Result<Task> {
Ok(CLIENT Ok(CLIENT
.get(format!( .get(format!(
"{}/api/check_archive/{task_id}", "{}/api/check_archive/{task_id}",

View File

@@ -91,7 +91,7 @@ pub async fn download_file(
} }
pub async fn download_file_by_link( pub async fn download_file_by_link(
filename: String, filename: &str,
link: String, link: String,
) -> anyhow::Result<Option<DownloadFile>> { ) -> anyhow::Result<Option<DownloadFile>> {
let response = CLIENT.get(link).send().await?; let response = CLIENT.get(link).send().await?;
@@ -102,7 +102,7 @@ pub async fn download_file_by_link(
Ok(Some(DownloadFile { Ok(Some(DownloadFile {
response, response,
filename, filename: filename.to_string(),
caption: "".to_string(), caption: "".to_string(),
})) }))
} }

View File

@@ -115,7 +115,7 @@ impl FormatInline for BookTranslator {
} }
} }
fn format_authors(authors: Vec<BookAuthor>, count: usize) -> String { fn format_authors(authors: &[BookAuthor], count: usize) -> String {
if count == 0 { if count == 0 {
return "".to_string(); return "".to_string();
} }
@@ -139,7 +139,7 @@ fn format_authors(authors: Vec<BookAuthor>, count: usize) -> String {
} }
} }
fn format_translators(translators: Vec<BookTranslator>, count: usize) -> String { fn format_translators(translators: &[BookTranslator], count: usize) -> String {
if count == 0 { if count == 0 {
return "".to_string(); return "".to_string();
} }
@@ -163,7 +163,7 @@ fn format_translators(translators: Vec<BookTranslator>, count: usize) -> String
} }
} }
fn format_sequences(sequences: Vec<Sequence>, count: usize) -> String { fn format_sequences(sequences: &[Sequence], count: usize) -> String {
if count == 0 { if count == 0 {
return "".to_string(); return "".to_string();
} }
@@ -187,7 +187,7 @@ fn format_sequences(sequences: Vec<Sequence>, count: usize) -> String {
} }
} }
fn format_genres(genres: Vec<BookGenre>, count: usize) -> String { fn format_genres(genres: &[BookGenre], count: usize) -> String {
if count == 0 { if count == 0 {
return "".to_string(); return "".to_string();
} }
@@ -395,117 +395,231 @@ impl FormatVectorsResult {
} }
} }
impl Book { fn format_vectors(
fn format_vectors(&self, max_size: usize) -> FormatVectorsResult { authors: &[BookAuthor],
let mut counts = FormatVectorsCounts { translators: &[BookTranslator],
authors: self.authors.len(), sequences: &[Sequence],
translators: self.translators.len(), genres: &[BookGenre],
sequences: self.sequences.len(), max_size: usize,
genres: self.genres.len(), ) -> FormatVectorsResult {
}; let mut counts = FormatVectorsCounts {
authors: authors.len(),
translators: translators.len(),
sequences: sequences.len(),
genres: genres.len(),
};
let mut result = FormatVectorsResult { let mut result = FormatVectorsResult {
authors: format_authors(self.authors.clone(), counts.authors), authors: format_authors(authors, counts.authors),
translators: format_translators(self.translators.clone(), counts.translators), translators: format_translators(translators, counts.translators),
sequences: format_sequences(self.sequences.clone(), counts.sequences), sequences: format_sequences(sequences, counts.sequences),
genres: format_genres(self.genres.clone(), counts.genres), genres: format_genres(genres, counts.genres),
max_result_size: 0,
};
let max_result_size = result.len();
while result.len() > max_size && counts.can_sub() {
counts = counts.sub();
result = FormatVectorsResult {
authors: format_authors(authors, counts.authors),
translators: format_translators(translators, counts.translators),
sequences: format_sequences(sequences, counts.sequences),
genres: format_genres(genres, counts.genres),
max_result_size: 0, max_result_size: 0,
}; };
}
let max_result_size = result.len(); result.with_max_result_size(max_result_size)
}
while result.len() > max_size && counts.can_sub() { struct FormatData<'a> {
counts = counts.sub(); pub id: u32,
pub title: &'a str,
pub lang: &'a str,
pub annotation_exists: bool,
pub authors: &'a [BookAuthor],
pub translators: &'a [BookTranslator],
pub sequences: &'a [Sequence],
pub genres: &'a [BookGenre],
pub year: i32,
pub pages: Option<u32>,
pub position: Option<i32>,
}
result = FormatVectorsResult { fn format_common(data: FormatData, max_size: usize) -> FormatResult {
authors: format_authors(self.authors.clone(), counts.authors), let FormatData {
translators: format_translators(self.translators.clone(), counts.translators), id,
sequences: format_sequences(self.sequences.clone(), counts.sequences), title,
genres: format_genres(self.genres.clone(), counts.genres), lang,
max_result_size: 0, annotation_exists,
}; authors,
translators,
sequences,
genres,
year,
pages,
position,
} = data;
let book_title = {
let year_part = match year {
0 => "".to_string(),
v => format!(" | {v}г."),
};
let pages_count = match pages {
Some(1) | None => "".to_string(),
Some(v) => format!(" | {v}с."),
};
let position_prefix = match position {
Some(0) | None => "".to_string(),
Some(v) => format!("{v} | "),
};
format!("{position_prefix}📖 {title} | {lang}{year_part}{pages_count}\n")
};
let annotations = match annotation_exists {
true => {
format!("📝 Аннотация: /b_an_{id}\n")
} }
false => "".to_string(),
};
result.with_max_result_size(max_result_size) let download_command = (StartDownloadCommand { id }).to_string();
let download_links = format!("Скачать:\n📥{download_command}");
let required_data_len: usize = format!("{book_title}{annotations}{download_links}").len();
let FormatVectorsResult {
authors,
translators,
sequences,
genres,
max_result_size,
} = format_vectors(
authors,
translators,
sequences,
genres,
max_size - required_data_len,
);
let result = format!(
"{book_title}{annotations}{authors}{translators}{sequences}{genres}{download_links}"
);
let result_len = result.len();
FormatResult {
result,
current_size: result_len,
max_size: max_result_size + required_data_len,
} }
} }
impl Format for Book { impl Format for Book {
fn format(&self, max_size: usize) -> FormatResult { fn format(&self, max_size: usize) -> FormatResult {
let book_title = { format_common(
let Book { title, lang, .. } = self; FormatData {
id: self.id,
let year_part = match self.year { title: &self.title,
0 => "".to_string(), lang: &self.lang,
v => format!(" | {v}г."), annotation_exists: self.annotation_exists,
}; authors: &self.authors,
translators: &self.translators,
let pages_count = match self.pages { sequences: &self.sequences,
Some(1) | None => "".to_string(), genres: &self.genres,
Some(v) => format!(" | {v}с."), year: self.year,
}; pages: self.pages,
position: self.position,
let position_prefix = match self.position { },
Some(0) | None => "".to_string(), max_size,
Some(v) => format!("{v} | "), )
};
format!("{position_prefix}📖 {title} | {lang}{year_part}{pages_count}\n")
};
let annotations = match self.annotation_exists {
true => {
let Book { id, .. } = self;
format!("📝 Аннотация: /b_an_{id}\n")
}
false => "".to_string(),
};
let download_command = (StartDownloadCommand { id: self.id }).to_string();
let download_links = format!("Скачать:\n📥{download_command}");
let required_data_len: usize = format!("{book_title}{annotations}{download_links}").len();
let FormatVectorsResult {
authors,
translators,
sequences,
genres,
max_result_size,
} = self.format_vectors(max_size - required_data_len);
let result = format!(
"{book_title}{annotations}{authors}{translators}{sequences}{genres}{download_links}"
);
let result_len = result.len();
FormatResult {
result,
current_size: result_len,
max_size: max_result_size + required_data_len,
}
} }
} }
impl Format for SearchBook { impl Format for SearchBook {
fn format(&self, max_size: usize) -> FormatResult { fn format(&self, max_size: usize) -> FormatResult {
Into::<Book>::into(self.clone()).format(max_size) format_common(
FormatData {
id: self.id,
title: &self.title,
lang: &self.lang,
annotation_exists: self.annotation_exists,
authors: &self.authors,
translators: &self.translators,
sequences: &self.sequences,
genres: &[],
year: self.year,
pages: None,
position: None,
},
max_size,
)
} }
} }
impl Format for AuthorBook { impl Format for AuthorBook {
fn format(&self, max_size: usize) -> FormatResult { fn format(&self, max_size: usize) -> FormatResult {
Into::<Book>::into(self.clone()).format(max_size) format_common(
FormatData {
id: self.id,
title: &self.title,
lang: &self.lang,
annotation_exists: self.annotation_exists,
authors: &[],
translators: &self.translators,
sequences: &self.sequences,
genres: &[],
year: self.year,
pages: None,
position: None,
},
max_size,
)
} }
} }
impl Format for TranslatorBook { impl Format for TranslatorBook {
fn format(&self, max_size: usize) -> FormatResult { fn format(&self, max_size: usize) -> FormatResult {
Into::<Book>::into(self.clone()).format(max_size) format_common(
FormatData {
id: self.id,
title: &self.title,
lang: &self.lang,
annotation_exists: self.annotation_exists,
authors: &self.authors,
translators: &[],
sequences: &self.sequences,
genres: &[],
year: self.year,
pages: None,
position: None,
},
max_size,
)
} }
} }
impl Format for SequenceBook { impl Format for SequenceBook {
fn format(&self, max_size: usize) -> FormatResult { fn format(&self, max_size: usize) -> FormatResult {
Into::<Book>::into(self.clone()).format(max_size) format_common(
FormatData {
id: self.id,
title: &self.title,
lang: &self.lang,
annotation_exists: self.annotation_exists,
authors: &self.authors,
translators: &self.translators,
sequences: &[],
genres: &[],
year: self.year,
pages: None,
position: Some(self.position),
},
max_size,
)
} }
} }

View File

@@ -15,11 +15,11 @@ use self::types::Empty;
pub static CLIENT: Lazy<reqwest::Client> = Lazy::new(reqwest::Client::new); pub static CLIENT: Lazy<reqwest::Client> = Lazy::new(reqwest::Client::new);
fn get_allowed_langs_params( fn get_allowed_langs_params(
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: &SmallVec<[SmartString; 3]>,
) -> Vec<(&'static str, SmartString)> { ) -> Vec<(&'static str, SmartString)> {
allowed_langs allowed_langs
.into_iter() .into_iter()
.map(|lang| ("allowed_langs", lang)) .map(|lang| ("allowed_langs", lang.clone()))
.collect() .collect()
} }
@@ -52,7 +52,7 @@ pub async fn get_random_book_by_genre(
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
genre: Option<u32>, genre: Option<u32>,
) -> anyhow::Result<types::Book> { ) -> anyhow::Result<types::Book> {
let mut params = get_allowed_langs_params(allowed_langs); let mut params = get_allowed_langs_params(&allowed_langs);
if let Some(v) = genre { if let Some(v) = genre {
params.push(("genre", v.to_string().into())); params.push(("genre", v.to_string().into()));
@@ -70,7 +70,7 @@ pub async fn get_random_book(
pub async fn get_random_author( pub async fn get_random_author(
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<types::Author> { ) -> anyhow::Result<types::Author> {
let params = get_allowed_langs_params(allowed_langs); let params = get_allowed_langs_params(&allowed_langs);
_make_request("/api/v1/authors/random", params).await _make_request("/api/v1/authors/random", params).await
} }
@@ -78,7 +78,7 @@ pub async fn get_random_author(
pub async fn get_random_sequence( pub async fn get_random_sequence(
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<types::Sequence> { ) -> anyhow::Result<types::Sequence> {
let params = get_allowed_langs_params(allowed_langs); let params = get_allowed_langs_params(&allowed_langs);
_make_request("/api/v1/sequences/random", params).await _make_request("/api/v1/sequences/random", params).await
} }
@@ -100,7 +100,7 @@ pub async fn search_book(
page: u32, page: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<types::Page<types::SearchBook, Empty>> { ) -> anyhow::Result<types::Page<types::SearchBook, Empty>> {
let mut params = get_allowed_langs_params(allowed_langs); let mut params = get_allowed_langs_params(&allowed_langs);
params.push(("page", page.to_string().into())); params.push(("page", page.to_string().into()));
params.push(("size", PAGE_SIZE.to_string().into())); params.push(("size", PAGE_SIZE.to_string().into()));
@@ -113,7 +113,7 @@ pub async fn search_author(
page: u32, page: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<types::Page<types::Author, Empty>> { ) -> anyhow::Result<types::Page<types::Author, Empty>> {
let mut params = get_allowed_langs_params(allowed_langs); let mut params = get_allowed_langs_params(&allowed_langs);
params.push(("page", page.to_string().into())); params.push(("page", page.to_string().into()));
params.push(("size", PAGE_SIZE.to_string().into())); params.push(("size", PAGE_SIZE.to_string().into()));
@@ -126,7 +126,7 @@ pub async fn search_sequence(
page: u32, page: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<types::Page<types::Sequence, Empty>> { ) -> anyhow::Result<types::Page<types::Sequence, Empty>> {
let mut params = get_allowed_langs_params(allowed_langs); let mut params = get_allowed_langs_params(&allowed_langs);
params.push(("page", page.to_string().into())); params.push(("page", page.to_string().into()));
params.push(("size", PAGE_SIZE.to_string().into())); params.push(("size", PAGE_SIZE.to_string().into()));
@@ -139,7 +139,7 @@ pub async fn search_translator(
page: u32, page: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<types::Page<types::Translator, Empty>> { ) -> anyhow::Result<types::Page<types::Translator, Empty>> {
let mut params = get_allowed_langs_params(allowed_langs); let mut params = get_allowed_langs_params(&allowed_langs);
params.push(("page", page.to_string().into())); params.push(("page", page.to_string().into()));
params.push(("size", PAGE_SIZE.to_string().into())); params.push(("size", PAGE_SIZE.to_string().into()));
@@ -164,7 +164,7 @@ pub async fn get_author_books(
page: u32, page: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<types::Page<types::AuthorBook, types::BookAuthor>> { ) -> anyhow::Result<types::Page<types::AuthorBook, types::BookAuthor>> {
let mut params = get_allowed_langs_params(allowed_langs); let mut params = get_allowed_langs_params(&allowed_langs);
params.push(("page", page.to_string().into())); params.push(("page", page.to_string().into()));
params.push(("size", PAGE_SIZE.to_string().into())); params.push(("size", PAGE_SIZE.to_string().into()));
@@ -177,7 +177,7 @@ pub async fn get_translator_books(
page: u32, page: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<types::Page<types::TranslatorBook, types::BookTranslator>> { ) -> anyhow::Result<types::Page<types::TranslatorBook, types::BookTranslator>> {
let mut params = get_allowed_langs_params(allowed_langs); let mut params = get_allowed_langs_params(&allowed_langs);
params.push(("page", page.to_string().into())); params.push(("page", page.to_string().into()));
params.push(("size", PAGE_SIZE.to_string().into())); params.push(("size", PAGE_SIZE.to_string().into()));
@@ -190,7 +190,7 @@ pub async fn get_sequence_books(
page: u32, page: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<types::Page<types::SequenceBook, types::Sequence>> { ) -> anyhow::Result<types::Page<types::SequenceBook, types::Sequence>> {
let mut params = get_allowed_langs_params(allowed_langs); let mut params = get_allowed_langs_params(&allowed_langs);
params.push(("page", page.to_string().into())); params.push(("page", page.to_string().into()));
params.push(("size", PAGE_SIZE.to_string().into())); params.push(("size", PAGE_SIZE.to_string().into()));
@@ -216,7 +216,7 @@ pub async fn get_uploaded_books(
pub async fn get_author_books_available_types( pub async fn get_author_books_available_types(
id: u32, id: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: &SmallVec<[SmartString; 3]>,
) -> anyhow::Result<Vec<String>> { ) -> anyhow::Result<Vec<String>> {
let params = get_allowed_langs_params(allowed_langs); let params = get_allowed_langs_params(allowed_langs);
@@ -229,7 +229,7 @@ pub async fn get_author_books_available_types(
pub async fn get_translator_books_available_types( pub async fn get_translator_books_available_types(
id: u32, id: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: &SmallVec<[SmartString; 3]>,
) -> anyhow::Result<Vec<String>> { ) -> anyhow::Result<Vec<String>> {
let params = get_allowed_langs_params(allowed_langs); let params = get_allowed_langs_params(allowed_langs);
@@ -242,7 +242,7 @@ pub async fn get_translator_books_available_types(
pub async fn get_sequence_books_available_types( pub async fn get_sequence_books_available_types(
id: u32, id: u32,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: &SmallVec<[SmartString; 3]>,
) -> anyhow::Result<Vec<String>> { ) -> anyhow::Result<Vec<String>> {
let params = get_allowed_langs_params(allowed_langs); let params = get_allowed_langs_params(allowed_langs);

View File

@@ -149,6 +149,8 @@ where
.map(|item| item_size - item.current_size) .map(|item| item_size - item.current_size)
.sum(); .sum();
use std::borrow::Cow;
self.items self.items
.iter() .iter()
.enumerate() .enumerate()
@@ -156,17 +158,17 @@ where
let already_formated_result = &format_result[index]; let already_formated_result = &format_result[index];
if already_formated_result.current_size == already_formated_result.max_size { if already_formated_result.current_size == already_formated_result.max_size {
already_formated_result.result.clone() Cow::Borrowed(already_formated_result.result.as_str())
} else { } else {
let new_item_size = item_size + free_symbols; let new_item_size = item_size + free_symbols;
let new_formated_result = item.format(new_item_size); let new_formated_result = item.format(new_item_size);
free_symbols = new_item_size - new_formated_result.current_size; free_symbols = new_item_size - new_formated_result.current_size;
new_formated_result.result Cow::Owned(new_formated_result.result)
} }
}) })
.collect::<Vec<String>>() .collect::<Vec<Cow<str>>>()
.join(separator) .join(separator)
} }
} }
@@ -192,17 +194,12 @@ pub struct Book {
pub id: u32, pub id: u32,
pub title: String, pub title: String,
pub lang: String, pub lang: String,
// file_type: String,
pub available_types: SmallVec<[String; 4]>, pub available_types: SmallVec<[String; 4]>,
// uploaded: String,
pub annotation_exists: bool, pub annotation_exists: bool,
pub authors: Vec<BookAuthor>, pub authors: Vec<BookAuthor>,
pub translators: Vec<BookTranslator>, pub translators: Vec<BookTranslator>,
pub sequences: Vec<Sequence>, pub sequences: Vec<Sequence>,
pub genres: Vec<BookGenre>, pub genres: Vec<BookGenre>,
// source: Source,
// remote_id: u32,
// id_deleted: bool,
pub year: i32, pub year: i32,
pub pages: Option<u32>, pub pages: Option<u32>,
pub position: Option<i32>, pub position: Option<i32>,
@@ -213,9 +210,6 @@ pub struct SearchBook {
pub id: u32, pub id: u32,
pub title: String, pub title: String,
pub lang: String, pub lang: String,
// file_type: String,
pub available_types: SmallVec<[String; 4]>,
// uploaded: String,
pub annotation_exists: bool, pub annotation_exists: bool,
pub authors: Vec<BookAuthor>, pub authors: Vec<BookAuthor>,
pub translators: Vec<BookTranslator>, pub translators: Vec<BookTranslator>,
@@ -223,121 +217,36 @@ pub struct SearchBook {
pub year: i32, pub year: i32,
} }
impl From<SearchBook> for Book {
fn from(value: SearchBook) -> Self {
Book {
id: value.id,
title: value.title,
lang: value.lang,
available_types: value.available_types,
annotation_exists: value.annotation_exists,
authors: value.authors,
translators: value.translators,
sequences: value.sequences,
genres: vec![],
pages: None,
year: value.year,
position: None,
}
}
}
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
pub struct AuthorBook { pub struct AuthorBook {
pub id: u32, pub id: u32,
pub title: String, pub title: String,
pub lang: String, pub lang: String,
// file_type: String,
pub available_types: SmallVec<[String; 4]>,
// uploaded: String,
pub annotation_exists: bool, pub annotation_exists: bool,
pub translators: Vec<BookTranslator>, pub translators: Vec<BookTranslator>,
pub sequences: Vec<Sequence>, pub sequences: Vec<Sequence>,
pub year: i32, pub year: i32,
} }
impl From<AuthorBook> for Book {
fn from(value: AuthorBook) -> Self {
Book {
id: value.id,
title: value.title,
lang: value.lang,
available_types: value.available_types,
annotation_exists: value.annotation_exists,
authors: vec![],
translators: value.translators,
sequences: value.sequences,
genres: vec![],
pages: None,
year: value.year,
position: None,
}
}
}
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
pub struct TranslatorBook { pub struct TranslatorBook {
pub id: u32, pub id: u32,
pub title: String, pub title: String,
pub lang: String, pub lang: String,
// file_type: String,
pub available_types: SmallVec<[String; 4]>,
// uploaded: String,
pub annotation_exists: bool, pub annotation_exists: bool,
pub authors: Vec<BookAuthor>, pub authors: Vec<BookAuthor>,
pub sequences: Vec<Sequence>, pub sequences: Vec<Sequence>,
pub year: i32, pub year: i32,
} }
impl From<TranslatorBook> for Book {
fn from(value: TranslatorBook) -> Self {
Book {
id: value.id,
title: value.title,
lang: value.lang,
available_types: value.available_types,
annotation_exists: value.annotation_exists,
authors: value.authors,
translators: vec![],
sequences: value.sequences,
genres: vec![],
pages: None,
year: value.year,
position: None,
}
}
}
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
pub struct SequenceBook { pub struct SequenceBook {
pub id: u32, pub id: u32,
pub title: String, pub title: String,
pub lang: String, pub lang: String,
// file_type: String,
pub available_types: SmallVec<[String; 4]>,
// uploaded: String,
pub authors: Vec<BookAuthor>, pub authors: Vec<BookAuthor>,
pub translators: Vec<BookTranslator>, pub translators: Vec<BookTranslator>,
pub annotation_exists: bool, pub annotation_exists: bool,
pub year: i32, pub year: i32,
pub position: i32, pub position: i32,
} }
impl From<SequenceBook> for Book {
fn from(value: SequenceBook) -> Self {
Book {
id: value.id,
title: value.title,
lang: value.lang,
available_types: value.available_types,
annotation_exists: value.annotation_exists,
authors: value.authors,
translators: value.translators,
sequences: vec![],
genres: vec![],
pages: None,
year: value.year,
position: Some(value.position),
}
}
}

View File

@@ -12,8 +12,8 @@ use crate::{
use super::user_settings::{is_need_donate_notifications, mark_donate_notification_sent}; use super::user_settings::{is_need_donate_notifications, mark_donate_notification_sent};
pub async fn send_donation_notification( pub async fn send_donation_notification(
bot: CacheMe<Throttle<Bot>>, bot: &CacheMe<Throttle<Bot>>,
message: MaybeInaccessibleMessage, message: &MaybeInaccessibleMessage,
) -> BotHandlerInternal { ) -> BotHandlerInternal {
if CHAT_DONATION_NOTIFICATIONS_CACHE if CHAT_DONATION_NOTIFICATIONS_CACHE
.get(&message.chat().id) .get(&message.chat().id)
@@ -31,7 +31,7 @@ pub async fn send_donation_notification(
mark_donate_notification_sent(message.chat().id).await?; mark_donate_notification_sent(message.chat().id).await?;
if let MaybeInaccessibleMessage::Regular(message) = message { if let MaybeInaccessibleMessage::Regular(message) = message {
support_command_handler(*message, bot).await?; support_command_handler(*message.clone(), bot).await?;
} }
}; };

View File

@@ -74,10 +74,10 @@ pub async fn get_user_or_default_lang_codes(user_id: UserId) -> SmallVec<[SmartS
pub async fn create_or_update_user_settings( pub async fn create_or_update_user_settings(
user_id: UserId, user_id: UserId,
last_name: String, last_name: &str,
first_name: String, first_name: &str,
username: String, username: &str,
source: String, source: &str,
allowed_langs: SmallVec<[SmartString; 3]>, allowed_langs: SmallVec<[SmartString; 3]>,
) -> anyhow::Result<UserSettings> { ) -> anyhow::Result<UserSettings> {
USER_LANGS_CACHE.invalidate(&user_id).await; USER_LANGS_CACHE.invalidate(&user_id).await;

View File

@@ -42,9 +42,9 @@ async fn make_register_request(
}); });
let result = reqwest::Client::new() let result = reqwest::Client::new()
.post(config::CONFIG.manager_url.clone()) .post(&config::CONFIG.manager_url)
.body(body.to_string()) .body(body.to_string())
.header("Authorization", config::CONFIG.manager_api_key.clone()) .header("Authorization", &config::CONFIG.manager_api_key)
.header("Content-Type", "application/json") .header("Content-Type", "application/json")
.send() .send()
.await?; .await?;

View File

@@ -93,9 +93,7 @@ impl BotsManager {
let bot_data: BotData = bot_data.clone(); let bot_data: BotData = bot_data.clone();
BOTS_DATA BOTS_DATA.insert(bot_data.token.clone(), bot_data).await;
.insert(bot_data.token.clone(), bot_data.clone())
.await;
} }
} }
@@ -110,9 +108,9 @@ impl BotsManager {
let bot_data: BotData = bot_data.clone(); let bot_data: BotData = bot_data.clone();
let semphore = semaphore.clone(); let semaphore = semaphore.clone();
set_webhook_tasks.spawn(async move { set_webhook_tasks.spawn(async move {
let _permit = semphore.acquire().await.unwrap(); let _permit = semaphore.acquire().await.unwrap();
let webhook_status = set_webhook(&bot_data).await; let webhook_status = set_webhook(&bot_data).await;