From: Dessalines Date: Mon, 26 Sep 2022 14:09:32 +0000 (-0400) Subject: Diesel 2.0.0 upgrade (#2452) X-Git-Url: http://these/git/%7B%60https:/%7B%60css/themes/%22https:/nerdica.net/%7BpictrsAvatarThumbnail%28this.props.site.site.icon%29%7D?a=commitdiff_plain;h=c9f140742925d6da20103124b49f2b58a35fc2b8;p=lemmy.git Diesel 2.0.0 upgrade (#2452) * Initial commit to bump diesel to 2.0.0-rc.0 and see what happens * Add chrono feature from diesel * db_schema crate is close to building? * Upgrade diesel-derive-newtype * Mostly modifying references to connections to be mutable ones; also used new way to do migrations as suggested by the migration guide; a lot more compiles now, though I can't figure out this tricky ToSql issue at the moment * Running clippy --fix * Trying to fix drone clippy 1 * Fix clippy * Upgrade clux-musl * Trying to fix drone clippy 2 * Trying to fix drone clippy 3 * Trying to fix drone clippy 5 * Adding diesel table aliases, removing sql view hack. Fixes #2101 Co-authored-by: Steven Chu Co-authored-by: Nutomic --- diff --git a/.drone.yml b/.drone.yml index de4114c6..43057f64 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,7 +10,7 @@ steps: # use minimum supported rust version for most steps - name: prepare repo - image: clux/muslrust:1.57.0 + image: clux/muslrust:1.59.0 user: root commands: - git fetch --tags @@ -27,12 +27,14 @@ steps: - name: cargo clippy image: rust:1.61-buster commands: + - apt-get update + - apt-get -y install protobuf-compiler libprotobuf-dev - rustup component add clippy - cargo clippy --workspace --tests --all-targets --all-features -- -D warnings -D deprecated -D clippy::perf -D clippy::complexity -D clippy::dbg_macro - cargo clippy --workspace --all-features -- -D clippy::unwrap_used - name: cargo test - image: clux/muslrust:1.57.0 + image: clux/muslrust:1.59.0 environment: LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy LEMMY_CONFIG_LOCATION: ../../config/config.hjson @@ -40,24 +42,24 @@ steps: RUST_TEST_THREADS: 1 commands: - apt-get update - - apt-get -y install --no-install-recommends postgresql-client + - apt-get -y install --no-install-recommends postgresql-client protobuf-compiler libprotobuf-dev - cargo test --workspace --no-fail-fast --all-features - name: check defaults.hjson updated - image: clux/muslrust:1.57.0 + image: clux/muslrust:1.59.0 commands: - ./scripts/update_config_defaults.sh config/defaults_current.hjson - diff config/defaults.hjson config/defaults_current.hjson - name: check with different features - image: clux/muslrust:1.57.0 + image: clux/muslrust:1.59.0 commands: - cargo install cargo-workspaces - cargo workspaces exec cargo check --no-default-features - cargo workspaces exec cargo check --all-features - name: cargo build - image: clux/muslrust:1.57.0 + image: clux/muslrust:1.59.0 commands: - cargo build - mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server diff --git a/Cargo.lock b/Cargo.lock index c1bfba5a..fbfb99d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,9 +38,9 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07520b54fc0f22ad30b90399b2a2689c6e5c113df0642ca3fa2f7ee823e54126" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -70,11 +70,11 @@ dependencies = [ "futures-util", "log", "once_cell", - "parking_lot 0.12.0", + "parking_lot", "pin-project-lite", "smallvec", "tokio", - "tokio-util 0.7.1", + "tokio-util 0.7.4", ] [[package]] @@ -91,14 +91,14 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", - "tokio-util 0.7.1", + "tokio-util 0.7.4", ] [[package]] name = "actix-http" -version = "3.0.4" +version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5885cb81a0d4d0d322864bea1bb6c2a8144626b4fdc625d4c51eba197e7797a" +checksum = "0c83abf9903e1f0ad9973cc4f7b9767fd5a03a583f51a5b7a339e07987cd2724" dependencies = [ "actix-codec", "actix-rt", @@ -120,13 +120,13 @@ dependencies = [ "itoa", "language-tags", "local-channel", - "log", "mime", "percent-encoding", "pin-project-lite", "rand 0.8.5", - "sha-1 0.10.0", + "sha1", "smallvec", + "tracing", ] [[package]] @@ -135,22 +135,21 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" dependencies = [ - "quote 1.0.20", - "syn 1.0.98", + "quote 1.0.21", + "syn 1.0.100", ] [[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]] @@ -207,7 +206,7 @@ dependencies = [ "log", "pin-project-lite", "tokio-rustls", - "tokio-util 0.7.1", + "tokio-util 0.7.4", "webpki-roots", ] @@ -223,9 +222,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.0.1" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4e5ebffd51d50df56a3ae0de0e59487340ca456f05dd0b90c0a7a6dd6a74d31" +checksum = "d48f7b6534e06c7bfc72ee91db7917d4af6afe23e7d223b51e68fffbb21e96b9" dependencies = [ "actix-codec", "actix-http", @@ -246,6 +245,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", + "http", "itoa", "language-tags", "log", @@ -258,7 +258,7 @@ dependencies = [ "serde_urlencoded", "smallvec", "socket2", - "time 0.3.9", + "time 0.3.14", "url", ] @@ -281,14 +281,14 @@ dependencies = [ [[package]] name = "actix-web-codegen" -version = "4.0.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7525bedf54704abb1d469e88d7e7e9226df73778798a69cea5022d53b2ae91bc" +checksum = "1fa9362663c8643d67b2d5eafba49e4cb2c8a053a29ed00a0bea121f17c76b13" dependencies = [ "actix-router", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -297,9 +297,9 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -308,32 +308,35 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - [[package]] name = "ahash" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -345,9 +348,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.58" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" +checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" [[package]] name = "arrayvec" @@ -357,9 +360,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "assert-json-diff" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f1c3703dd33532d7f0ca049168930e9099ecac238e23cf932f3a69c42f06da" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" dependencies = [ "serde", "serde_json", @@ -390,20 +393,20 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "async-trait" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" +checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -425,6 +428,51 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e3356844c4d6a6d6467b8da2cffb4a2820be256f50a3a386c9d152bab31043" +dependencies = [ + "async-trait", + "axum-core", + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde", + "sync_wrapper", + "tokio", + "tower", + "tower-http", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f0c0a60006f2a293d82d571f635042a72edf927539b7685bd62d361963839b" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "tower-layer", + "tower-service", +] + [[package]] name = "background-jobs" version = "0.12.0" @@ -453,7 +501,7 @@ dependencies = [ "tokio", "tracing", "tracing-futures", - "uuid", + "uuid 0.8.2", ] [[package]] @@ -469,10 +517,10 @@ dependencies = [ "serde", "serde_json", "thiserror", - "time 0.3.9", + "time 0.3.14", "tracing", "tracing-futures", - "uuid", + "uuid 0.8.2", ] [[package]] @@ -483,21 +531,21 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bcrypt" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe4fef31efb0f76133ae8e3576a88e58edb7cfc5584c81c758c349ba46b43fc" +checksum = "a7e7c93a3fb23b2fdde989b2c9ec4dd153063ec81f408507f84c090cd91c6641" dependencies = [ "base64", "blowfish", - "getrandom 0.2.6", + "getrandom 0.2.7", "zeroize", ] [[package]] name = "bit-set" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" dependencies = [ "bit-vec", ] @@ -528,32 +576,11 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - -[[package]] -name = "block-buffer" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" -dependencies = [ - "generic-array 0.14.5", -] - -[[package]] -name = "block-padding" -version = "0.1.5" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ - "byte-tools", + "generic-array", ] [[package]] @@ -568,21 +595,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" - -[[package]] -name = "byte-tools" -version = "0.3.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" [[package]] name = "bytemuck" -version = "1.8.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e851ca7c24871e7336801608a4797d7376545b6928a10d32d75685687141ead" +checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da" [[package]] name = "byteorder" @@ -592,15 +613,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" [[package]] name = "bytestring" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" +checksum = "86b6a75fd3048808ef06af5cd79712be8111960adaf89d90250974b38fc3928a" dependencies = [ "bytes", ] @@ -639,15 +660,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" dependencies = [ - "libc", + "iana-time-zone", + "js-sys", "num-integer", "num-traits", "serde", "time 0.1.44", + "wasm-bindgen", "winapi", ] @@ -678,9 +701,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "combine" -version = "4.6.3" +version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50b727aacc797f9fc28e355d21f34709ac4fc9adecfe470ad07b8f4464f53062" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" dependencies = [ "bytes", "memchr", @@ -688,17 +711,17 @@ dependencies = [ [[package]] name = "comrak" -version = "0.12.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff3c476e1a33eb4df1212a02db79d0f788bbd760901f34f5897644623e0e4e74" +checksum = "15bf1e432b302dc6236dd0db580d182ce520bb24af82d6462e2d7a5e0a31c50d" dependencies = [ "entities", "lazy_static", + "memchr", "pest", "pest_derive", "regex", "shell-words", - "twoway", "typed-arena", "unicode_categories", "xdg", @@ -706,22 +729,21 @@ dependencies = [ [[package]] name = "console-api" -version = "0.1.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc347c19eb5b940f396ac155822caee6662f850d97306890ac3773ed76c90c5a" +checksum = "e57ff02e8ad8e06ab9731d5dc72dc23bef9200778eae1a89d555d8c42e5d4a86" dependencies = [ - "prost", - "prost-types", - "tonic", - "tonic-build", + "prost 0.11.0", + "prost-types 0.11.1", + "tonic 0.8.1", "tracing-core", ] [[package]] name = "console-subscriber" -version = "0.1.3" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "565a7dfea2d10dd0e5c57cc394d5d441b1910960d8c9211ed14135e0e6ec3a20" +checksum = "22a3a81dfaf6b66bce5d159eddae701e3a002f194d378cbf7be5f053c281d9be" dependencies = [ "console-api", "crossbeam-channel", @@ -729,13 +751,13 @@ dependencies = [ "futures", "hdrhistogram", "humantime", - "prost-types", + "prost-types 0.11.1", "serde", "serde_json", "thread_local", "tokio", "tokio-stream", - "tonic", + "tonic 0.8.1", "tracing", "tracing-core", "tracing-subscriber", @@ -754,7 +776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" dependencies = [ "percent-encoding", - "time 0.3.9", + "time 0.3.14", "version_check", ] @@ -776,9 +798,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ "libc", ] @@ -794,9 +816,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ "cfg-if", "crossbeam-utils", @@ -804,21 +826,21 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" dependencies = [ "cfg-if", - "lazy_static", + "once_cell", ] [[package]] name = "crypto-common" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.5", + "generic-array", "typenum", ] @@ -860,10 +882,10 @@ checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.40", - "quote 1.0.20", + "proc-macro2 1.0.43", + "quote 1.0.21", "strsim", - "syn 1.0.98", + "syn 1.0.100", ] [[package]] @@ -874,10 +896,10 @@ checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.40", - "quote 1.0.20", + "proc-macro2 1.0.43", + "quote 1.0.21", "strsim", - "syn 1.0.98", + "syn 1.0.100", ] [[package]] @@ -888,10 +910,10 @@ checksum = "649c91bc01e8b1eac09fb91e8dbc7d517684ca6be8ebc75bb9cafc894f9fdb6f" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.40", - "quote 1.0.20", + "proc-macro2 1.0.43", + "quote 1.0.21", "strsim", - "syn 1.0.98", + "syn 1.0.100", ] [[package]] @@ -901,8 +923,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a" dependencies = [ "darling_core 0.12.4", - "quote 1.0.20", - "syn 1.0.98", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -912,8 +934,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core 0.13.4", - "quote 1.0.20", - "syn 1.0.98", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -923,17 +945,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc69c5bfcbd2fc09a0f38451d2daf0e372e367986a83906d1b0dbc88134fb5" dependencies = [ "darling_core 0.14.1", - "quote 1.0.20", - "syn 1.0.98", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] -name = "deflate" -version = "1.0.0" +name = "dashmap" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f" +checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" dependencies = [ - "adler32", + "cfg-if", + "hashbrown", + "lock_api", + "once_cell", + "parking_lot_core", ] [[package]] @@ -961,9 +987,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5" dependencies = [ "darling 0.12.4", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -973,9 +999,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" dependencies = [ "darling 0.14.1", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -985,7 +1011,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73" dependencies = [ "derive_builder_core 0.10.2", - "syn 1.0.98", + "syn 1.0.100", ] [[package]] @@ -995,7 +1021,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" dependencies = [ "derive_builder_core 0.11.2", - "syn 1.0.98", + "syn 1.0.100", ] [[package]] @@ -1005,10 +1031,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "convert_case", - "proc-macro2 1.0.40", - "quote 1.0.20", + "proc-macro2 1.0.43", + "quote 1.0.21", "rustc_version", - "syn 1.0.98", + "syn 1.0.100", ] [[package]] @@ -1022,14 +1048,15 @@ dependencies = [ [[package]] name = "diesel" -version = "1.4.8" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b28135ecf6b7d446b43e27e225622a038cc4e2930a1022f51cdb97ada19b8e4d" +checksum = "01e2adfd0a7a81070ed7beec0c62636458926326c16fedb77796d41e447b282d" dependencies = [ "bitflags", "byteorder", "chrono", "diesel_derives", + "itoa", "pq-sys", "r2d2", "serde_json", @@ -1037,11 +1064,10 @@ dependencies = [ [[package]] name = "diesel-derive-newtype" -version = "0.1.2" +version = "2.0.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e844e8e6f65dcf27aa0b97d4234f974d93dfbf56816033d71b5e0c7eb701709f" +checksum = "dd577654b63c049f4eecd2ce1187740a050166372673f6b09c351c53b575c34a" dependencies = [ - "diesel", "proc-macro2 0.4.30", "quote 0.6.13", "syn 0.14.9", @@ -1049,20 +1075,21 @@ dependencies = [ [[package]] name = "diesel_derives" -version = "1.4.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" +checksum = "22a7ab9d7967e6a1a247ea38aedf88ab808b4ac0c159576bc71866ab8f9f9250" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro-error", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "diesel_ltree" -version = "0.2.7" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55a0b2b2e948a2d8ab673ccee9f37b20bdcc8b7acb40a242a0fdf53d4c2678b0" +checksum = "92d9f0b872d6c87b68a71f105802b941a7262788bf69d1bcd05654669cdbd55d" dependencies = [ "byteorder", "diesel", @@ -1070,30 +1097,22 @@ dependencies = [ [[package]] name = "diesel_migrations" -version = "1.4.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf3cde8413353dc7f5d72fa8ce0b99a560a359d2c5ef1e5817ca731cd9008f4c" +checksum = "e9ae22beef5e9d6fab9225ddb073c1c6c1a7a6ded5019d5da11d1e5c5adc34e2" dependencies = [ + "diesel", "migrations_internals", "migrations_macros", ] [[package]] name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - -[[package]] -name = "digest" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" dependencies = [ - "block-buffer 0.10.2", + "block-buffer", "crypto-common", ] @@ -1145,22 +1164,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6430bef5fcbfa22f3c431f05a14254d45f41ab634cabe09fad82e98d4f9fdc8b" dependencies = [ "darling 0.13.4", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "either" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "email-encoding" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "827e1fb86d24d558ab0454ca3fa084f8a6144ade1e3e6982f697c586bf96b41b" +checksum = "34dd14c63662e0206599796cd5e1ad0268ab2b9d19b868d6050d688eba2bbf98" dependencies = [ "base64", "memchr", @@ -1168,9 +1187,9 @@ dependencies = [ [[package]] name = "email_address" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8684b7c9cb4857dfa1e5b9629ef584ba618c9b93bae60f58cb23f4f271d0468e" +checksum = "b1b32a7a2580c4473f10f66b512c34bdd7d33c5e3473227ca833abdb5afe4809" [[package]] name = "encoding" @@ -1238,9 +1257,9 @@ checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" [[package]] name = "encoding_rs" -version = "0.8.30" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" dependencies = [ "cfg-if", ] @@ -1253,56 +1272,42 @@ checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" [[package]] name = "event-listener" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" - -[[package]] -name = "fake-simd" -version = "0.1.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "fallible_collections" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52db5973b6a19247baf19b30f41c23a1bfffc2e9ce0a5db2f60e3cd5dc8895f7" +checksum = "c195cf4b2285d3c993eb887b4dc56b0d5728bbe1d0f9a99c0ac6bec2da3e4d85" dependencies = [ "hashbrown", ] [[package]] name = "fastrand" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" dependencies = [ "instant", ] -[[package]] -name = "firestorm" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3d6188b8804df28032815ea256b6955c9625c24da7525f387a7af02fbb8f01" - [[package]] name = "fixedbitset" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279fb028e20b3c4c320317955b77c5e0c9701f05a1d309905d6fc702cdc5053e" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" dependencies = [ - "cfg-if", "crc32fast", - "libc", - "miniz_oxide 0.4.4", + "miniz_oxide", ] [[package]] @@ -1328,11 +1333,10 @@ 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", ] @@ -1354,9 +1358,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" dependencies = [ "futures-channel", "futures-core", @@ -1369,9 +1373,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" dependencies = [ "futures-core", "futures-sink", @@ -1379,15 +1383,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" [[package]] name = "futures-executor" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" dependencies = [ "futures-core", "futures-task", @@ -1396,38 +1400,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" [[package]] name = "futures-macro" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" dependencies = [ "futures-channel", "futures-core", @@ -1443,18 +1447,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -1473,20 +1468,20 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] name = "h2" -version = "0.3.12" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62eeb471aa3e3c9197aa4bfeabfe02982f6dc96f750486c0bb0009ac58b26d2b" +checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" dependencies = [ "bytes", "fnv", @@ -1497,24 +1492,24 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util 0.6.9", + "tokio-util 0.7.4", "tracing", ] [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash", ] [[package]] name = "hdrhistogram" -version = "7.5.0" +version = "7.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31672b7011be2c4f7456c4ddbcb40e7e9a4a9fad8efe49a6ebaf5f307d0109c0" +checksum = "7f19b9f54f7c7f55e31401bb647626ce0cf0f67b0004982ce815b3ee72a02aa8" dependencies = [ "base64", "byteorder", @@ -1560,9 +1555,9 @@ dependencies = [ [[package]] name = "hound" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a164bb2ceaeff4f42542bdb847c41517c78a60f5649671b2a07312b6e117549" +checksum = "4d13cdbd5dbb29f9c88095bbdc2590c9cba0d0a1269b983fef6b2cdd7e9f4db1" [[package]] name = "html2md" @@ -1570,7 +1565,7 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61f6bf799d9770725ec13d66f4af9344e96285dc14d8e71e0fe02d272690667f" dependencies = [ - "html5ever", + "html5ever 0.25.2", "jni", "lazy_static", "markup5ever_rcdom", @@ -1580,13 +1575,15 @@ dependencies = [ [[package]] name = "html2text" -version = "0.3.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de2444cdc9d7e23756d000d9f49513bed8bb4e3743072fb45c63e6493e277bed" +checksum = "617dbbb43af195e64f03eef3b9e412d8374764d88a554332624d83d782da7267" dependencies = [ - "html5ever", - "markup5ever_rcdom", + "html5ever 0.26.0", + "markup5ever 0.11.0", + "tendril", "unicode-width", + "xml5ever 0.17.0", ] [[package]] @@ -1597,10 +1594,24 @@ checksum = "e5c13fb08e5d4dfc151ee5e88bae63f7773d61852f3bdc73c9f4b9e1bde03148" dependencies = [ "log", "mac", - "markup5ever", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "markup5ever 0.10.1", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", +] + +[[package]] +name = "html5ever" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" +dependencies = [ + "log", + "mac", + "markup5ever 0.11.0", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -1616,15 +1627,21 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", "pin-project-lite", ] +[[package]] +name = "http-range-header" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" + [[package]] name = "http-signature-normalization" version = "0.6.0" @@ -1673,9 +1690,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" @@ -1691,9 +1708,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.18" +version = "0.14.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2" +checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" dependencies = [ "bytes", "futures-channel", @@ -1738,6 +1755,19 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "iana-time-zone" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "js-sys", + "wasm-bindgen", + "winapi", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1755,16 +1785,25 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "image" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28edd9d7bc256be2502e325ac0628bde30b7001b9b52e0abe31a1a9dc2701212" +checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964" dependencies = [ "bytemuck", "byteorder", "color_quant", - "num-iter", "num-rational", "num-traits", "png", @@ -1772,9 +1811,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.8.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", "hashbrown", @@ -1782,11 +1821,11 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1f03d4ab4d5dc9ec2d219f86c15d2a15fc08239d1cd3b2d6a19717c0a2f443" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "generic-array 0.14.5", + "generic-array", ] [[package]] @@ -1800,24 +1839,24 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e70ee094dc02fd9c13fdad4940090f22dbd6ac7c9e7094a46cf0232a50bc7c" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" [[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", ] [[package]] name = "itoa" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] name = "jni" @@ -1841,18 +1880,18 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.56" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ "wasm-bindgen", ] [[package]] name = "jsonwebtoken" -version = "8.0.1" +version = "8.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "012bb02250fdd38faa5feee63235f7a459974440b9b57593822414c31f92839e" +checksum = "1aa4b4af834c6cfd35d8763d359661b90f2e45d8f750a0849156c7f4671af09c" dependencies = [ "base64", "pem", @@ -1898,7 +1937,7 @@ dependencies = [ "serde", "serde_json", "tracing", - "uuid", + "uuid 1.1.2", ] [[package]] @@ -1984,7 +2023,7 @@ dependencies = [ "task-local-extensions", "tracing", "url", - "uuid", + "uuid 1.1.2", ] [[package]] @@ -2091,7 +2130,7 @@ dependencies = [ "lemmy_websocket", "opentelemetry 0.17.0", "opentelemetry-otlp", - "parking_lot 0.12.0", + "parking_lot", "reqwest", "reqwest-middleware", "reqwest-retry", @@ -2101,7 +2140,7 @@ dependencies = [ "tracing-actix-web", "tracing-error", "tracing-log", - "tracing-opentelemetry 0.17.2", + "tracing-opentelemetry 0.17.4", "tracing-subscriber", "url", ] @@ -2125,7 +2164,7 @@ dependencies = [ "lettre", "once_cell", "openssl", - "parking_lot 0.12.0", + "parking_lot", "rand 0.8.5", "regex", "reqwest-middleware", @@ -2139,7 +2178,7 @@ dependencies = [ "tracing", "tracing-error", "url", - "uuid", + "uuid 1.1.2", ] [[package]] @@ -2167,14 +2206,14 @@ dependencies = [ "strum_macros", "tokio", "tracing", - "tracing-opentelemetry 0.17.2", + "tracing-opentelemetry 0.17.4", ] [[package]] name = "lettre" -version = "0.10.0-rc.7" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f7e87d9d44162eea7abd87b1a7540fcb10d5e58e8bb4f173178f3dc6e453944" +checksum = "2eabca5e0b4d0e98e7f2243fb5b7520b6af2b65d8f87bcc86f2c75185a6ff243" dependencies = [ "base64", "email-encoding", @@ -2183,7 +2222,7 @@ dependencies = [ "futures-util", "hostname", "httpdate", - "idna", + "idna 0.2.3", "mime", "native-tls", "nom 7.1.1", @@ -2207,15 +2246,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.121" +version = "0.2.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" +checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" [[package]] name = "local-channel" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6246c68cf195087205a0512559c97e15eaf95198bf0e206d662092cdcb03fe9f" +checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" dependencies = [ "futures-core", "futures-sink", @@ -2225,24 +2264,25 @@ dependencies = [ [[package]] name = "local-waker" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "902eb695eb0591864543cbfbf6d742510642a605a61fc5e97fe6ceb5a30ac4fb" +checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" [[package]] name = "lock_api" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ + "autocfg", "scopeguard", ] [[package]] name = "lodepng" -version = "3.6.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f84e1fdcdbe8b3f0f9caaadb6b86d0e0647786e993f6ea70686f6837b989ec7" +checksum = "ff45534ec797452c044fcd47861059eddb501e30a8fd9fdadea7957cdff3ebc7" dependencies = [ "crc32fast", "fallible_collections", @@ -2253,9 +2293,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] @@ -2267,20 +2307,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] -name = "maplit" -version = "1.0.2" +name = "markup5ever" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" +dependencies = [ + "log", + "phf 0.8.0", + "phf_codegen 0.8.0", + "string_cache", + "string_cache_codegen", + "tendril", +] [[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", - "phf_codegen", + "phf 0.10.1", + "phf_codegen 0.10.0", "string_cache", "string_cache_codegen", "tendril", @@ -2292,10 +2340,10 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f015da43bcd8d4f144559a3423f4591d69b8ce0652c905374da7205df336ae2b" dependencies = [ - "html5ever", - "markup5ever", + "html5ever 0.25.2", + "markup5ever 0.10.1", "tendril", - "xml5ever", + "xml5ever 0.16.2", ] [[package]] @@ -2319,31 +2367,37 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +[[package]] +name = "matchit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" + [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "migrations_internals" -version = "1.4.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b4fc84e4af020b837029e017966f86a1c2d5e83e64b589963d5047525995860" +checksum = "c493c09323068c01e54c685f7da41a9ccf9219735c3766fbfd6099806ea08fbc" dependencies = [ - "diesel", + "serde", + "toml", ] [[package]] name = "migrations_macros" -version = "1.4.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c" +checksum = "8a8ff27a350511de30cdabb77147501c36ef02e0451d957abea2f30caffb2b58" dependencies = [ "migrations_internals", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", ] [[package]] @@ -2370,44 +2424,23 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.5.1" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" dependencies = [ "libc", "log", - "miow", - "ntapi", "wasi 0.11.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", + "windows-sys", ] [[package]] @@ -2469,15 +2502,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "ntapi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" -dependencies = [ - "winapi", -] - [[package]] name = "num-bigint" version = "0.4.3" @@ -2491,30 +2515,19 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.42" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", - "num-integer", "num-traits", ] [[package]] name = "num-rational" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", "num-integer", @@ -2523,9 +2536,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] @@ -2542,30 +2555,24 @@ dependencies = [ [[package]] name = "num_threads" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aba1801fb138d8e85e11d0fc70baf4fe1cdfffda7c6cd34a854905df588e5ed0" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" dependencies = [ "libc", ] [[package]] name = "once_cell" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" - -[[package]] -name = "opaque-debug" -version = "0.2.3" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" [[package]] name = "openssl" -version = "0.10.40" +version = "0.10.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" +checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0" dependencies = [ "bitflags", "cfg-if", @@ -2582,9 +2589,9 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -2595,9 +2602,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.74" +version = "0.9.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1" +checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" dependencies = [ "autocfg", "cc", @@ -2655,53 +2662,28 @@ dependencies = [ "futures-util", "http", "opentelemetry 0.17.0", - "prost", + "prost 0.9.0", "thiserror", "tokio", - "tonic", + "tonic 0.6.2", "tonic-build", ] [[package]] name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.5", -] - -[[package]] -name = "parking_lot" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.1", + "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" -dependencies = [ - "cfg-if", - "instant", - "libc", - "redox_syscall", - "smallvec", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ "cfg-if", "libc", @@ -2712,39 +2694,40 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" [[package]] name = "pem" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9a3b09a20e374558580a4914d3b7d89bd61b954a5a5e1dcbea98753addb1947" +checksum = "03c64931a1a212348ec4f3b4362585eca7159d0d09cbdf4a7f74f02173596fd4" dependencies = [ "base64", ] [[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 = "pest" -version = "2.1.3" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +checksum = "cb779fcf4bb850fbbb0edc96ff6cf34fd90c4b1a112ce042653280d9a7364048" dependencies = [ + "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.1.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +checksum = "502b62a6d0245378b04ffe0a7fb4f4419a4815fce813bd8a0ec89a56e07d67b1" dependencies = [ "pest", "pest_generator", @@ -2752,33 +2735,33 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.1.3" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +checksum = "451e629bf49b750254da26132f1a5a9d11fd8a95a3df51d15c4abd1ba154cb6c" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "pest_meta" -version = "2.1.3" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +checksum = "bcec162c71c45e269dfc3fc2916eaeb97feab22993a21bcce4721d08cd7801a6" dependencies = [ - "maplit", + "once_cell", "pest", - "sha-1 0.8.2", + "sha1", ] [[package]] name = "petgraph" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a13a2fa9d0b63e5f22328828741e523766fff0ee9e779316902290dff3f824f" +checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" dependencies = [ "fixedbitset", "indexmap", @@ -2793,6 +2776,15 @@ dependencies = [ "phf_shared 0.8.0", ] +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +dependencies = [ + "phf_shared 0.10.0", +] + [[package]] name = "phf_codegen" version = "0.8.0" @@ -2803,6 +2795,16 @@ dependencies = [ "phf_shared 0.8.0", ] +[[package]] +name = "phf_codegen" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", +] + [[package]] name = "phf_generator" version = "0.8.0" @@ -2843,29 +2845,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "pin-project-lite" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -2875,20 +2877,20 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "png" -version = "0.17.5" +version = "0.17.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba" +checksum = "8f0e7f4c94ec26ff209cee506314212639d6c91b80afb82984819fafce9df01c" dependencies = [ "bitflags", "crc32fast", - "deflate", - "miniz_oxide 0.5.1", + "flate2", + "miniz_oxide", ] [[package]] @@ -2899,9 +2901,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "pq-sys" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac25eee5a0582f45a67e837e350d784e7003bd29a5f460796772061ca49ffda" +checksum = "3b845d6d8ec554f972a2c5298aad68953fd64e7441e846075450b44656a016d1" dependencies = [ "vcpkg", ] @@ -2919,9 +2921,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", "version_check", ] @@ -2931,8 +2933,8 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", + "proc-macro2 1.0.43", + "quote 1.0.21", "version_check", ] @@ -2947,9 +2949,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" dependencies = [ "unicode-ident", ] @@ -2961,7 +2963,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.9.0", +] + +[[package]] +name = "prost" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "399c3c31cdec40583bb68f0b18403400d01ec4289c383aa047560439952c4dd7" +dependencies = [ + "bytes", + "prost-derive 0.11.0", ] [[package]] @@ -2977,8 +2989,8 @@ dependencies = [ "log", "multimap", "petgraph", - "prost", - "prost-types", + "prost 0.9.0", + "prost-types 0.9.0", "regex", "tempfile", "which", @@ -2992,9 +3004,22 @@ checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" dependencies = [ "anyhow", "itertools", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", +] + +[[package]] +name = "prost-derive" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7345d5f0e08c0536d7ac7229952590239e77abf0a0100a1b1d890add6ea96364" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -3004,26 +3029,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a" dependencies = [ "bytes", - "prost", + "prost 0.9.0", ] [[package]] -name = "quick-xml" -version = "0.22.0" +name = "prost-types" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" +checksum = "4dfaa718ad76a44b3415e6c4d53b17c8f99160dcb3a99b10470fce8ad43f6e3e" dependencies = [ - "encoding_rs", - "memchr", + "bytes", + "prost 0.11.0", ] [[package]] -name = "quickcheck" -version = "1.0.3" +name = "quick-xml" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" +checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" dependencies = [ - "rand 0.8.5", + "encoding_rs", + "memchr", ] [[package]] @@ -3037,11 +3063,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ - "proc-macro2 1.0.40", + "proc-macro2 1.0.43", ] [[package]] @@ -3052,12 +3078,12 @@ checksum = "3fee2dce59f7a43418e3382c766554c614e06a552d53a8f07ef499ea4b332c0f" [[package]] name = "r2d2" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f" +checksum = "51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93" dependencies = [ "log", - "parking_lot 0.11.2", + "parking_lot", "scheduled-thread-pool", ] @@ -3089,7 +3115,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha 0.3.1", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -3109,7 +3135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -3123,11 +3149,11 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", ] [[package]] @@ -3150,29 +3176,29 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.12" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", "redox_syscall", "thiserror", ] [[package]] name = "regex" -version = "1.5.5" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", @@ -3190,9 +3216,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "remove_dir_all" @@ -3205,9 +3231,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.10" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb" +checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" dependencies = [ "base64", "bytes", @@ -3221,11 +3247,11 @@ dependencies = [ "hyper-tls", "ipnet", "js-sys", - "lazy_static", "log", "mime", "mime_guess", "native-tls", + "once_cell", "percent-encoding", "pin-project-lite", "serde", @@ -3233,7 +3259,8 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", - "tokio-util 0.6.9", + "tokio-util 0.7.4", + "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -3279,9 +3306,9 @@ dependencies = [ [[package]] name = "reqwest-tracing" -version = "0.2.1" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03f32bd53de59d66d157bd974bafbb69fbb9e98f665d14218b5b991e7dba8d75" +checksum = "64977f9a47fa7768cc88751e29026e569730ac1667c2eaeaac04b32624849fbe" dependencies = [ "async-trait", "opentelemetry 0.16.0", @@ -3306,9 +3333,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.32" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74fdc210d8f24a7dbfedc13b04ba5764f5232754ccebfdf5fff1bad791ccbc6" +checksum = "3603b7d71ca82644f79b5a06d1220e9a58ede60bd32255f698cb1af8838b8db3" dependencies = [ "bytemuck", ] @@ -3336,8 +3363,8 @@ checksum = "6f697b8b3f19bee20f30dc87213d05ce091c43bc733ab1bfc98b0e5cdd9943f3" dependencies = [ "convert_case", "lazy_static", - "proc-macro2 1.0.40", - "quote 1.0.20", + "proc-macro2 1.0.43", + "quote 1.0.21", "regex", "tinyjson", ] @@ -3350,9 +3377,9 @@ checksum = "c5298de832602aecc9458398f435d9bff0be57da7aac11221b6ff3d4ef9503de" [[package]] name = "rss" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e19e299f301be17927a7c05b8fa1c621e3227e6c3a0da65492701642901ff7" +checksum = "acaf1331b7fc4edc3c2920819fee1766c27e8d40da593155832db3d6dea64e92" dependencies = [ "atom_syndication", "derive_builder 0.10.2", @@ -3371,9 +3398,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.4" +version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921" +checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033" dependencies = [ "log", "ring", @@ -3383,15 +3410,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "same-file" @@ -3404,21 +3431,21 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" dependencies = [ "lazy_static", - "winapi", + "windows-sys", ] [[package]] name = "scheduled-thread-pool" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f74fd1204073fa02d5d5d68bec8021be4c38690b61264b2fdb48083d0e7d7" +checksum = "977a7519bff143a44f842fd07e80ad1329295bd71686457f18e496736f4bf9bf" dependencies = [ - "parking_lot 0.11.2", + "parking_lot", ] [[package]] @@ -3439,9 +3466,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.6.1" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" dependencies = [ "bitflags", "core-foundation", @@ -3467,41 +3494,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ee061f90afcc8678bef7a78d0d121683f0ba753f740ff7005f833ec445876b7" dependencies = [ "bit-set", - "html5ever", + "html5ever 0.25.2", "markup5ever_rcdom", ] [[package]] name = "semver" -version = "1.0.7" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4" +checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" [[package]] name = "serde" -version = "1.0.137" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" dependencies = [ "indexmap", "itoa", @@ -3538,67 +3565,57 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" dependencies = [ "darling 0.13.4", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "serial_test" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bcc41d18f7a1d50525d080fd3e953be87c4f9f1a974f3c21798ca00d54ec15" +checksum = "92761393ee4dc3ff8f4af487bd58f4307c9329bbedea02cac0089ad9c411e153" dependencies = [ + "dashmap", + "futures", "lazy_static", - "parking_lot 0.11.2", + "log", + "parking_lot", "serial_test_derive", ] [[package]] name = "serial_test_derive" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2881bccd7d60fb32dfa3d7b3136385312f8ad75e2674aab2852867a09790cae8" +checksum = "4b6f5d1c3087fb119617cff2966fe3808a80e5eb59a8c1601d5994d66f4346a5" dependencies = [ "proc-macro-error", - "proc-macro2 1.0.40", - "quote 1.0.20", - "rustversion", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] -name = "sha-1" -version = "0.8.2" +name = "sha1" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "sha-1" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.3", + "digest", ] [[package]] name = "sha2" -version = "0.10.2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.3", + "digest", ] [[package]] @@ -3627,14 +3644,14 @@ dependencies = [ [[package]] name = "simple_asn1" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a762b1c38b9b990c694b9c2f8abe3372ce6a9ceaae6bca39cfc46e054f45745" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" dependencies = [ "num-bigint", "num-traits", "thiserror", - "time 0.3.9", + "time 0.3.14", ] [[package]] @@ -3645,15 +3662,18 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "smallvec" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "smart-default" @@ -3661,16 +3681,16 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", "winapi", @@ -3696,7 +3716,7 @@ checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" dependencies = [ "new_debug_unreachable", "once_cell", - "parking_lot 0.12.0", + "parking_lot", "phf_shared 0.10.0", "precomputed-hash", "serde", @@ -3710,8 +3730,8 @@ checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" dependencies = [ "phf_generator 0.10.0", "phf_shared 0.10.0", - "proc-macro2 1.0.40", - "quote 1.0.20", + "proc-macro2 1.0.43", + "quote 1.0.21", ] [[package]] @@ -3722,21 +3742,21 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96acfc1b70604b8b2f1ffa4c57e59176c7dbb05d556c71ecd2f5498a1dee7f8" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" [[package]] name = "strum_macros" -version = "0.24.0" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck 0.4.0", - "proc-macro2 1.0.40", - "quote 1.0.20", + "proc-macro2 1.0.43", + "quote 1.0.21", "rustversion", - "syn 1.0.98", + "syn 1.0.100", ] [[package]] @@ -3752,15 +3772,21 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.98" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", + "proc-macro2 1.0.43", + "quote 1.0.21", "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8" + [[package]] name = "tap" version = "1.0.1" @@ -3769,9 +3795,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "task-local-extensions" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36794203e10c86e5998179e260869d156e0674f02d5451b4a3fb9fd86d02aaab" +checksum = "4167afbec18ae012de40f8cf1b9bf48420abb390678c34821caa07d924941cc4" dependencies = [ "tokio", ] @@ -3803,22 +3829,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.31" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -3843,14 +3869,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.9" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" +checksum = "3c3f9a28b618c3a6b9251b6908e9c99e04b9e5c02e6581ccbb67d59c34ef7f9b" dependencies = [ "itoa", "libc", "num_threads", - "quickcheck", "serde", "time-macros", ] @@ -3863,15 +3888,15 @@ checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" [[package]] name = "tinyjson" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a8304da9f9370f6a6f9020b7903b044aa9ce3470f300a1fba5bc77c78145a16" +checksum = "b4b2f023483085707f4f0c1238a8a7baf8b502a1d427b9ed2a243884d3d687bb" [[package]] name = "tinyvec" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] @@ -3884,17 +3909,18 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.17.0" +version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" +checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95" dependencies = [ + "autocfg", "bytes", "libc", "memchr", "mio", "num_cpus", "once_cell", - "parking_lot 0.12.0", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -3915,13 +3941,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -3936,9 +3962,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4151fda0cf2798550ad0b34bcfc9b9dcc2a9d2471c895c68f3a8818e54f2389e" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ "rustls", "tokio", @@ -3947,9 +3973,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3" +checksum = "f6edf2d6bc038a43d31353570e27270603f4648d18f5ed10c0e179abe43255af" dependencies = [ "futures-core", "pin-project-lite", @@ -3958,9 +3984,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" +checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" dependencies = [ "bytes", "futures-core", @@ -3972,9 +3998,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0edfdeb067411dba2044da6d1cb2df793dd35add7888d73c16e3381ded401764" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" dependencies = [ "bytes", "futures-core", @@ -3984,6 +4010,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + [[package]] name = "tonic" version = "0.6.2" @@ -4003,11 +4038,43 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost", - "prost-derive", + "prost 0.9.0", + "prost-derive 0.9.0", "tokio", "tokio-stream", - "tokio-util 0.6.9", + "tokio-util 0.6.10", + "tower", + "tower-layer", + "tower-service", + "tracing", + "tracing-futures", +] + +[[package]] +name = "tonic" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11cd56bdb54ef93935a6a79dbd1d91f1ebd4c64150fd61654031fd6b8b775c91" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64", + "bytes", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost 0.11.0", + "prost-derive 0.11.0", + "tokio", + "tokio-stream", + "tokio-util 0.7.4", "tower", "tower-layer", "tower-service", @@ -4021,17 +4088,17 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757" dependencies = [ - "proc-macro2 1.0.40", + "proc-macro2 1.0.43", "prost-build", - "quote 1.0.20", - "syn 1.0.98", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "tower" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a89fd63ad6adf737582df5db40d286574513c69a11dac5214dc3b5603d6713e" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ "futures-core", "futures-util", @@ -4041,12 +4108,31 @@ dependencies = [ "rand 0.8.5", "slab", "tokio", - "tokio-util 0.7.1", + "tokio-util 0.7.4", "tower-layer", "tower-service", "tracing", ] +[[package]] +name = "tower-http" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.1" @@ -4055,15 +4141,15 @@ checksum = "343bc9466d3fe6b0f960ef45960509f84480bf4fd96f92901afe7ff3df9d3a62" [[package]] name = "tower-service" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.35" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" dependencies = [ "cfg-if", "log", @@ -4074,33 +4160,32 @@ dependencies = [ [[package]] name = "tracing-actix-web" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99bcebac55fba44eadf75a424ee403e756f9165596a613d125876388e5fb4c34" +checksum = "ee7247a77b494ee07bda43bce40a33e76f885662f11b3dda9894ecfdbe31fa06" dependencies = [ "actix-web", "pin-project", "tracing", - "tracing-futures", - "uuid", + "uuid 1.1.2", ] [[package]] name = "tracing-attributes" -version = "0.1.20" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b" +checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] name = "tracing-core" -version = "0.1.27" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709595b8878a4965ce5e87ebf880a7d39c9afc6837721b21a5a816a8117d921" +checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" dependencies = [ "once_cell", "valuable", @@ -4128,9 +4213,9 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" dependencies = [ "lazy_static", "log", @@ -4152,10 +4237,11 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.17.2" +version = "0.17.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f9378e96a9361190ae297e7f3a8ff644aacd2897f244b1ff81f381669196fa6" +checksum = "fbbe89715c1dbbb790059e2565353978564924ee85017b5fff365c872ff6721f" dependencies = [ + "once_cell", "opentelemetry 0.17.0", "tracing", "tracing-core", @@ -4165,13 +4251,13 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.9" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e0ab7bdc962035a87fba73f3acca9b8a8d0034c2e6f60b84aeaaddddc155dce" +checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b" dependencies = [ "ansi_term", - "lazy_static", "matchers", + "once_cell", "regex", "sharded-slab", "smallvec", @@ -4187,16 +4273,6 @@ version = "0.2.3" 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", -] - [[package]] name = "typed-arena" version = "1.7.0" @@ -4209,9 +4285,9 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89851716b67b937e393b3daa8423e67ddfc4bbbf1654bcf05488e95e0828db0c" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", ] [[package]] @@ -4222,15 +4298,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - -[[package]] -name = "unchecked-index" -version = "0.2.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "unicase" @@ -4243,36 +4313,36 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" +checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "unicode-xid" @@ -4294,13 +4364,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", + "idna 0.3.0", "percent-encoding", "serde", ] @@ -4317,7 +4386,17 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", + "serde", +] + +[[package]] +name = "uuid" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" +dependencies = [ + "getrandom 0.2.7", "serde", ] @@ -4380,9 +4459,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.79" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -4390,24 +4469,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.79" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" dependencies = [ "bumpalo", - "lazy_static", "log", - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "once_cell", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.29" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" dependencies = [ "cfg-if", "js-sys", @@ -4417,38 +4496,38 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.79" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ - "quote 1.0.20", + "quote 1.0.21", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.79" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ - "proc-macro2 1.0.40", - "quote 1.0.20", - "syn 1.0.98", + "proc-macro2 1.0.43", + "quote 1.0.21", + "syn 1.0.100", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.79" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "web-sys" -version = "0.3.56" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" dependencies = [ "js-sys", "wasm-bindgen", @@ -4475,7 +4554,7 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d03ebca8fe2492fffdb5be0f681a942665c50488348d8abc00efb470e0ea890" dependencies = [ - "html5ever", + "html5ever 0.25.2", "markup5ever_rcdom", "serde", "serde_json", @@ -4493,22 +4572,22 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.2" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" +checksum = "f1c760f0d366a6c24a02ed7816e23e691f5d92291f94d15e836006fd11b04daf" dependencies = [ "webpki", ] [[package]] name = "which" -version = "4.2.5" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" dependencies = [ "either", - "lazy_static", "libc", + "once_cell", ] [[package]] @@ -4544,9 +4623,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.32.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ "windows_aarch64_msvc", "windows_i686_gnu", @@ -4557,33 +4636,33 @@ dependencies = [ [[package]] name = "windows_aarch64_msvc" -version = "0.32.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_i686_gnu" -version = "0.32.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_msvc" -version = "0.32.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_x86_64_gnu" -version = "0.32.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_msvc" -version = "0.32.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "winreg" @@ -4617,12 +4696,23 @@ checksum = "9234163818fd8e2418fcde330655e757900d4236acd8cc70fef345ef91f6d865" dependencies = [ "log", "mac", - "markup5ever", + "markup5ever 0.10.1", "time 0.1.44", ] +[[package]] +name = "xml5ever" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4034e1d05af98b51ad7214527730626f019682d797ba38b51689212118d8e650" +dependencies = [ + "log", + "mac", + "markup5ever 0.11.0", +] + [[package]] name = "zeroize" -version = "1.5.4" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/Cargo.toml b/Cargo.toml index c53d248f..18cf4eb3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,25 +44,25 @@ lemmy_api_common = { version = "=0.16.5", path = "crates/api_common" } lemmy_websocket = { version = "=0.16.5", path = "./crates/websocket" } lemmy_routes = { version = "=0.16.5", path = "./crates/routes" } activitypub_federation = "0.2.0" -diesel = "1.4.8" -diesel_migrations = "1.4.0" -serde = { version = "1.0.136", features = ["derive"] } +diesel = "2.0.0" +diesel_migrations = "2.0.0" +serde = { version = "1.0.145", features = ["derive"] } actix = "0.13.0" -actix-web = { version = "4.0.1", default-features = false, features = ["macros", "rustls"] } -tracing = "0.1.32" -tracing-actix-web = { version = "0.5.1", default-features = false } +actix-web = { version = "4.2.1", default-features = false, features = ["macros", "rustls"] } +tracing = "0.1.36" +tracing-actix-web = { version = "0.6.1", default-features = false } tracing-error = "0.2.0" -tracing-log = "0.1.2" -tracing-subscriber = { version = "0.3.9", features = ["env-filter"] } -url = { version = "2.2.2", features = ["serde"] } -reqwest = { version = "0.11.10", features = ["json"] } -reqwest-middleware = "0.1.5" -reqwest-tracing = "0.2.1" +tracing-log = "0.1.3" +tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } +url = { version = "2.3.1", features = ["serde"] } +reqwest = { version = "0.11.12", features = ["json"] } +reqwest-middleware = "0.1.6" +reqwest-tracing = "0.3.1" clokwerk = "0.3.5" doku = { version = "0.12.0", features = ["url-2"] } -parking_lot = "0.12.0" +parking_lot = "0.12.1" reqwest-retry = "0.1.5" -console-subscriber = { version = "0.1.3", optional = true } +console-subscriber = { version = "0.1.8", optional = true } opentelemetry = { version = "0.17.0", features = ["rt-tokio"], optional = true } opentelemetry-otlp = { version = "0.10.0", optional = true } tracing-opentelemetry = { version = "0.17.2", optional = true } diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index 2b80f16e..737fa7cc 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -23,15 +23,15 @@ lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", featur lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] } lemmy_websocket = { version = "=0.16.5", path = "../websocket" } activitypub_federation = "0.2.0" -diesel = "1.4.8" -bcrypt = "0.12.1" -chrono = { version = "0.4.19", features = ["serde"], default-features = false } -serde_json = { version = "1.0.79", features = ["preserve_order"] } -serde = { version = "1.0.136", features = ["derive"] } -actix-web = { version = "4.0.1", default-features = false } +diesel = "2.0.0" +bcrypt = "0.13.0" +chrono = { version = "0.4.22", features = ["serde"], default-features = false } +serde_json = { version = "1.0.85", features = ["preserve_order"] } +serde = { version = "1.0.145", features = ["derive"] } +actix-web = { version = "4.2.1", default-features = false } base64 = "0.13.0" -uuid = { version = "0.8.2", features = ["serde", "v4"] } -async-trait = "0.1.53" +uuid = { version = "1.1.2", features = ["serde", "v4"] } +async-trait = "0.1.57" captcha = "0.0.9" -anyhow = "1.0.56" -tracing = "0.1.32" +anyhow = "1.0.65" +tracing = "0.1.36" diff --git a/crates/api/src/comment/like.rs b/crates/api/src/comment/like.rs index 144de4bf..4e527dd0 100644 --- a/crates/api/src/comment/like.rs +++ b/crates/api/src/comment/like.rs @@ -92,7 +92,7 @@ impl Perform for CreateCommentLike { let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1); if do_add { let like_form2 = like_form.clone(); - let like = move |conn: &'_ _| CommentLike::like(conn, &like_form2); + let like = move |conn: &mut _| CommentLike::like(conn, &like_form2); blocking(context.pool(), like) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_comment"))?; diff --git a/crates/api/src/comment/save.rs b/crates/api/src/comment/save.rs index 4d599739..e1a26d57 100644 --- a/crates/api/src/comment/save.rs +++ b/crates/api/src/comment/save.rs @@ -32,12 +32,12 @@ impl Perform for SaveComment { }; if data.save { - let save_comment = move |conn: &'_ _| CommentSaved::save(conn, &comment_saved_form); + let save_comment = move |conn: &mut _| CommentSaved::save(conn, &comment_saved_form); blocking(context.pool(), save_comment) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_save_comment"))?; } else { - let unsave_comment = move |conn: &'_ _| CommentSaved::unsave(conn, &comment_saved_form); + let unsave_comment = move |conn: &mut _| CommentSaved::unsave(conn, &comment_saved_form); blocking(context.pool(), unsave_comment) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_save_comment"))?; diff --git a/crates/api/src/comment_report/resolve.rs b/crates/api/src/comment_report/resolve.rs index 2c016b95..c0b8a400 100644 --- a/crates/api/src/comment_report/resolve.rs +++ b/crates/api/src/comment_report/resolve.rs @@ -35,7 +35,7 @@ impl Perform for ResolveCommentReport { is_mod_or_admin(context.pool(), person_id, report.community.id).await?; let resolved = data.resolved; - let resolve_fun = move |conn: &'_ _| { + let resolve_fun = move |conn: &mut _| { if resolved { CommentReport::resolve(conn, report_id, person_id) } else { diff --git a/crates/api/src/community/add_mod.rs b/crates/api/src/community/add_mod.rs index b8999e4b..f0c5ed17 100644 --- a/crates/api/src/community/add_mod.rs +++ b/crates/api/src/community/add_mod.rs @@ -52,12 +52,12 @@ impl Perform for AddModToCommunity { person_id: data.person_id, }; if data.added { - let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form); + let join = move |conn: &mut _| CommunityModerator::join(conn, &community_moderator_form); blocking(context.pool(), join) .await? .map_err(|e| LemmyError::from_error_message(e, "community_moderator_already_exists"))?; } else { - let leave = move |conn: &'_ _| CommunityModerator::leave(conn, &community_moderator_form); + let leave = move |conn: &mut _| CommunityModerator::leave(conn, &community_moderator_form); blocking(context.pool(), leave) .await? .map_err(|e| LemmyError::from_error_message(e, "community_moderator_already_exists"))?; diff --git a/crates/api/src/community/ban.rs b/crates/api/src/community/ban.rs index 07e28783..9ea0c5c9 100644 --- a/crates/api/src/community/ban.rs +++ b/crates/api/src/community/ban.rs @@ -55,19 +55,19 @@ impl Perform for BanFromCommunity { expires: Some(expires), }; - let community: ApubCommunity = blocking(context.pool(), move |conn: &'_ _| { + let community: ApubCommunity = blocking(context.pool(), move |conn: &mut _| { Community::read(conn, community_id) }) .await?? .into(); - let banned_person: ApubPerson = blocking(context.pool(), move |conn: &'_ _| { + let banned_person: ApubPerson = blocking(context.pool(), move |conn: &mut _| { Person::read(conn, banned_person_id) }) .await?? .into(); if data.ban { - let ban = move |conn: &'_ _| CommunityPersonBan::ban(conn, &community_user_ban_form); + let ban = move |conn: &mut _| CommunityPersonBan::ban(conn, &community_user_ban_form); blocking(context.pool(), ban) .await? .map_err(|e| LemmyError::from_error_message(e, "community_user_already_banned"))?; @@ -78,7 +78,7 @@ impl Perform for BanFromCommunity { person_id: banned_person_id, pending: false, }; - blocking(context.pool(), move |conn: &'_ _| { + blocking(context.pool(), move |conn: &mut _| { CommunityFollower::unfollow(conn, &community_follower_form) }) .await? @@ -95,7 +95,7 @@ impl Perform for BanFromCommunity { ) .await?; } else { - let unban = move |conn: &'_ _| CommunityPersonBan::unban(conn, &community_user_ban_form); + let unban = move |conn: &mut _| CommunityPersonBan::unban(conn, &community_user_ban_form); blocking(context.pool(), unban) .await? .map_err(|e| LemmyError::from_error_message(e, "community_user_already_banned"))?; diff --git a/crates/api/src/community/block.rs b/crates/api/src/community/block.rs index 2f5f5f90..5f01ac3d 100644 --- a/crates/api/src/community/block.rs +++ b/crates/api/src/community/block.rs @@ -38,7 +38,7 @@ impl Perform for BlockCommunity { }; if data.block { - let block = move |conn: &'_ _| CommunityBlock::block(conn, &community_block_form); + let block = move |conn: &mut _| CommunityBlock::block(conn, &community_block_form); blocking(context.pool(), block) .await? .map_err(|e| LemmyError::from_error_message(e, "community_block_already_exists"))?; @@ -49,7 +49,7 @@ impl Perform for BlockCommunity { person_id, pending: false, }; - blocking(context.pool(), move |conn: &'_ _| { + blocking(context.pool(), move |conn: &mut _| { CommunityFollower::unfollow(conn, &community_follower_form) }) .await? @@ -60,7 +60,7 @@ impl Perform for BlockCommunity { .await??; UndoFollowCommunity::send(&local_user_view.person.into(), &community.into(), context).await?; } else { - let unblock = move |conn: &'_ _| CommunityBlock::unblock(conn, &community_block_form); + let unblock = move |conn: &mut _| CommunityBlock::unblock(conn, &community_block_form); blocking(context.pool(), unblock) .await? .map_err(|e| LemmyError::from_error_message(e, "community_block_already_exists"))?; diff --git a/crates/api/src/community/follow.rs b/crates/api/src/community/follow.rs index 66689204..7a5e3198 100644 --- a/crates/api/src/community/follow.rs +++ b/crates/api/src/community/follow.rs @@ -55,13 +55,13 @@ impl Perform for FollowCommunity { check_community_ban(local_user_view.person.id, community_id, context.pool()).await?; check_community_deleted_or_removed(community_id, context.pool()).await?; - let follow = move |conn: &'_ _| CommunityFollower::follow(conn, &community_follower_form); + let follow = move |conn: &mut _| CommunityFollower::follow(conn, &community_follower_form); blocking(context.pool(), follow) .await? .map_err(|e| LemmyError::from_error_message(e, "community_follower_already_exists"))?; } else { let unfollow = - move |conn: &'_ _| CommunityFollower::unfollow(conn, &community_follower_form); + move |conn: &mut _| CommunityFollower::unfollow(conn, &community_follower_form); blocking(context.pool(), unfollow) .await? .map_err(|e| LemmyError::from_error_message(e, "community_follower_already_exists"))?; @@ -74,7 +74,8 @@ impl Perform for FollowCommunity { } else { UndoFollowCommunity::send(&local_user_view.person.clone().into(), &community, context) .await?; - let unfollow = move |conn: &'_ _| CommunityFollower::unfollow(conn, &community_follower_form); + let unfollow = + move |conn: &mut _| CommunityFollower::unfollow(conn, &community_follower_form); blocking(context.pool(), unfollow) .await? .map_err(|e| LemmyError::from_error_message(e, "community_follower_already_exists"))?; diff --git a/crates/api/src/community/transfer.rs b/crates/api/src/community/transfer.rs index fe34bbfa..1b6abb21 100644 --- a/crates/api/src/community/transfer.rs +++ b/crates/api/src/community/transfer.rs @@ -75,7 +75,7 @@ impl Perform for TransferCommunity { person_id: cmod.moderator.id, }; - let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form); + let join = move |conn: &mut _| CommunityModerator::join(conn, &community_moderator_form); blocking(context.pool(), join) .await? .map_err(|e| LemmyError::from_error_message(e, "community_moderator_already_exists"))?; diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 2659535a..e3419f38 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -254,8 +254,8 @@ mod tests { #[test] fn test_should_not_validate_user_token_after_password_change() { - let conn = establish_unpooled_connection(); - let secret = Secret::init(&conn).unwrap(); + let conn = &mut establish_unpooled_connection(); + let secret = Secret::init(conn).unwrap(); let settings = &SETTINGS.to_owned(); let new_person = PersonForm { @@ -264,7 +264,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let local_user_form = LocalUserForm { person_id: Some(inserted_person.id), @@ -272,7 +272,7 @@ mod tests { ..LocalUserForm::default() }; - let inserted_local_user = LocalUser::create(&conn, &local_user_form).unwrap(); + let inserted_local_user = LocalUser::create(conn, &local_user_form).unwrap(); let jwt = Claims::jwt( inserted_local_user.id.0, @@ -286,11 +286,11 @@ mod tests { // The check should fail, since the validator time is now newer than the jwt issue time let updated_local_user = - LocalUser::update_password(&conn, inserted_local_user.id, "password111").unwrap(); + LocalUser::update_password(conn, inserted_local_user.id, "password111").unwrap(); let check_after = check_validator_time(&updated_local_user.validator_time, &claims); assert!(check_after.is_err()); - let num_deleted = Person::delete(&conn, inserted_person.id).unwrap(); + let num_deleted = Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(1, num_deleted); } } diff --git a/crates/api/src/local_user/ban_person.rs b/crates/api/src/local_user/ban_person.rs index cc239cac..c2f09da7 100644 --- a/crates/api/src/local_user/ban_person.rs +++ b/crates/api/src/local_user/ban_person.rs @@ -41,7 +41,7 @@ impl Perform for BanPerson { let banned_person_id = data.person_id; let expires = data.expires.map(naive_from_unix); - let ban_person = move |conn: &'_ _| Person::ban_person(conn, banned_person_id, ban, expires); + let ban_person = move |conn: &mut _| Person::ban_person(conn, banned_person_id, ban, expires); let person = blocking(context.pool(), ban_person) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_user"))?; diff --git a/crates/api/src/local_user/block.rs b/crates/api/src/local_user/block.rs index da21dcdd..3f1b36f2 100644 --- a/crates/api/src/local_user/block.rs +++ b/crates/api/src/local_user/block.rs @@ -49,12 +49,12 @@ impl Perform for BlockPerson { } if data.block { - let block = move |conn: &'_ _| PersonBlock::block(conn, &person_block_form); + let block = move |conn: &mut _| PersonBlock::block(conn, &person_block_form); blocking(context.pool(), block) .await? .map_err(|e| LemmyError::from_error_message(e, "person_block_already_exists"))?; } else { - let unblock = move |conn: &'_ _| PersonBlock::unblock(conn, &person_block_form); + let unblock = move |conn: &mut _| PersonBlock::unblock(conn, &person_block_form); blocking(context.pool(), unblock) .await? .map_err(|e| LemmyError::from_error_message(e, "person_block_already_exists"))?; diff --git a/crates/api/src/local_user/notifications/mark_mention_read.rs b/crates/api/src/local_user/notifications/mark_mention_read.rs index b097ddc4..2179ada0 100644 --- a/crates/api/src/local_user/notifications/mark_mention_read.rs +++ b/crates/api/src/local_user/notifications/mark_mention_read.rs @@ -36,7 +36,7 @@ impl Perform for MarkPersonMentionAsRead { let person_mention_id = read_person_mention.id; let read = data.read; let update_mention = - move |conn: &'_ _| PersonMention::update_read(conn, person_mention_id, read); + move |conn: &mut _| PersonMention::update_read(conn, person_mention_id, read); blocking(context.pool(), update_mention) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_comment"))?; diff --git a/crates/api/src/local_user/notifications/mark_reply_read.rs b/crates/api/src/local_user/notifications/mark_reply_read.rs index 46d15886..3e502f39 100644 --- a/crates/api/src/local_user/notifications/mark_reply_read.rs +++ b/crates/api/src/local_user/notifications/mark_reply_read.rs @@ -35,7 +35,7 @@ impl Perform for MarkCommentReplyAsRead { let comment_reply_id = read_comment_reply.id; let read = data.read; - let update_reply = move |conn: &'_ _| CommentReply::update_read(conn, comment_reply_id, read); + let update_reply = move |conn: &mut _| CommentReply::update_read(conn, comment_reply_id, read); blocking(context.pool(), update_reply) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_comment"))?; diff --git a/crates/api/src/post/like.rs b/crates/api/src/post/like.rs index 51972256..ef954675 100644 --- a/crates/api/src/post/like.rs +++ b/crates/api/src/post/like.rs @@ -72,7 +72,7 @@ impl Perform for CreatePostLike { let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1); if do_add { let like_form2 = like_form.clone(); - let like = move |conn: &'_ _| PostLike::like(conn, &like_form2); + let like = move |conn: &mut _| PostLike::like(conn, &like_form2); blocking(context.pool(), like) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_post"))?; diff --git a/crates/api/src/post/save.rs b/crates/api/src/post/save.rs index 25bb6c3c..ff41581c 100644 --- a/crates/api/src/post/save.rs +++ b/crates/api/src/post/save.rs @@ -32,12 +32,12 @@ impl Perform for SavePost { }; if data.save { - let save = move |conn: &'_ _| PostSaved::save(conn, &post_saved_form); + let save = move |conn: &mut _| PostSaved::save(conn, &post_saved_form); blocking(context.pool(), save) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_save_post"))?; } else { - let unsave = move |conn: &'_ _| PostSaved::unsave(conn, &post_saved_form); + let unsave = move |conn: &mut _| PostSaved::unsave(conn, &post_saved_form); blocking(context.pool(), unsave) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_save_post"))?; diff --git a/crates/api/src/post_report/resolve.rs b/crates/api/src/post_report/resolve.rs index 469f96b3..120a76f1 100644 --- a/crates/api/src/post_report/resolve.rs +++ b/crates/api/src/post_report/resolve.rs @@ -35,7 +35,7 @@ impl Perform for ResolvePostReport { is_mod_or_admin(context.pool(), person_id, report.community.id).await?; let resolved = data.resolved; - let resolve_fun = move |conn: &'_ _| { + let resolve_fun = move |conn: &mut _| { if resolved { PostReport::resolve(conn, report_id, person_id) } else { diff --git a/crates/api/src/private_message_report/resolve.rs b/crates/api/src/private_message_report/resolve.rs index 7b3500b4..03aab70b 100644 --- a/crates/api/src/private_message_report/resolve.rs +++ b/crates/api/src/private_message_report/resolve.rs @@ -31,7 +31,7 @@ impl Perform for ResolvePrivateMessageReport { let resolved = self.resolved; let report_id = self.report_id; let person_id = local_user_view.person.id; - let resolve_fn = move |conn: &'_ _| { + let resolve_fn = move |conn: &mut _| { if resolved { PrivateMessageReport::resolve(conn, report_id, person_id) } else { diff --git a/crates/api_common/Cargo.toml b/crates/api_common/Cargo.toml index 65cac308..e7f6c07c 100644 --- a/crates/api_common/Cargo.toml +++ b/crates/api_common/Cargo.toml @@ -24,18 +24,18 @@ lemmy_db_views_moderator = { version = "=0.16.5", path = "../db_views_moderator" lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor" } lemmy_db_schema = { version = "=0.16.5", path = "../db_schema", default-features = false } lemmy_utils = { version = "=0.16.5", path = "../utils", optional = true } -serde = { version = "1.0.136", features = ["derive"] } -url = "2.2.2" -actix-web = { version = "4.0.1", default-features = false, features = ["cookies"], optional = true } -chrono = { version = "0.4.19", features = ["serde"], optional = true } -diesel = { version = "1.4.8", optional = true } -tracing = { version = "0.1.32", optional = true } +serde = { version = "1.0.145", features = ["derive"] } +url = "2.3.1" +actix-web = { version = "4.2.1", default-features = false, features = ["cookies"], optional = true } +chrono = { version = "0.4.22", features = ["serde"], optional = true } +diesel = { version = "2.0.0", optional = true } +tracing = { version = "0.1.36", optional = true } rosetta-i18n = { version = "0.1.2", optional = true } -percent-encoding = { version = "2.1.0", optional = true } +percent-encoding = { version = "2.2.0", optional = true } encoding = { version = "0.2.33", optional = true } -reqwest-middleware = { version = "0.1.5", optional = true } +reqwest-middleware = { version = "0.1.6", optional = true } webpage = { version = "1.4.0", default-features = false, features = ["serde"], optional = true } [dev-dependencies] actix-rt = { version = "2.7.0", default-features = false } -reqwest = { version = "0.11.10", features = ["json"] } +reqwest = { version = "0.11.12", features = ["json"] } diff --git a/crates/api_common/src/post.rs b/crates/api_common/src/post.rs index c9d92380..4f486e05 100644 --- a/crates/api_common/src/post.rs +++ b/crates/api_common/src/post.rs @@ -164,7 +164,7 @@ pub struct GetSiteMetadataResponse { pub metadata: SiteMetadata, } -#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)] pub struct SiteMetadata { pub title: Option, pub description: Option, diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index d2a00978..ce6831e3 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -42,15 +42,15 @@ use tracing::warn; pub async fn blocking(pool: &DbPool, f: F) -> Result where - F: FnOnce(&diesel::PgConnection) -> T + Send + 'static, + F: FnOnce(&mut diesel::PgConnection) -> T + Send + 'static, T: Send + 'static, { let pool = pool.clone(); let blocking_span = tracing::info_span!("blocking operation"); actix_web::web::block(move || { let entered = blocking_span.enter(); - let conn = pool.get()?; - let res = (f)(&conn); + let mut conn = pool.get()?; + let res = (f)(&mut conn); drop(entered); Ok(res) as Result }) @@ -219,7 +219,7 @@ pub async fn check_community_ban( pool: &DbPool, ) -> Result<(), LemmyError> { let is_banned = - move |conn: &'_ _| CommunityPersonBanView::get(conn, person_id, community_id).is_ok(); + move |conn: &mut _| CommunityPersonBanView::get(conn, person_id, community_id).is_ok(); if blocking(pool, is_banned).await? { Err(LemmyError::from_message("community_ban")) } else { @@ -256,7 +256,7 @@ pub async fn check_person_block( potential_blocker_id: PersonId, pool: &DbPool, ) -> Result<(), LemmyError> { - let is_blocked = move |conn: &'_ _| PersonBlock::read(conn, potential_blocker_id, my_id).is_ok(); + let is_blocked = move |conn: &mut _| PersonBlock::read(conn, potential_blocker_id, my_id).is_ok(); if blocking(pool, is_blocked).await? { Err(LemmyError::from_message("person_block")) } else { @@ -519,7 +519,7 @@ pub async fn purge_image_posts_for_person( settings: &Settings, client: &ClientWithMiddleware, ) -> Result<(), LemmyError> { - let posts = blocking(pool, move |conn: &'_ _| { + let posts = blocking(pool, move |conn: &mut _| { Post::fetch_pictrs_posts_for_creator(conn, banned_person_id) }) .await??; @@ -548,7 +548,7 @@ pub async fn purge_image_posts_for_community( settings: &Settings, client: &ClientWithMiddleware, ) -> Result<(), LemmyError> { - let posts = blocking(pool, move |conn: &'_ _| { + let posts = blocking(pool, move |conn: &mut _| { Post::fetch_pictrs_posts_for_community(conn, banned_community_id) }) .await??; @@ -597,7 +597,7 @@ pub async fn remove_user_data( .await??; // Posts - blocking(pool, move |conn: &'_ _| { + blocking(pool, move |conn: &mut _| { Post::update_removed_for_creator(conn, banned_person_id, None, true) }) .await??; @@ -608,7 +608,7 @@ pub async fn remove_user_data( // Communities // Remove all communities where they're the top mod // for now, remove the communities manually - let first_mod_communities = blocking(pool, move |conn: &'_ _| { + let first_mod_communities = blocking(pool, move |conn: &mut _| { CommunityModeratorView::get_community_first_mods(conn) }) .await??; @@ -621,7 +621,7 @@ pub async fn remove_user_data( for first_mod_community in banned_user_first_communities { let community_id = first_mod_community.community.id; - blocking(pool, move |conn: &'_ _| { + blocking(pool, move |conn: &mut _| { Community::update_removed(conn, community_id, true) }) .await??; @@ -643,7 +643,7 @@ pub async fn remove_user_data( } // Comments - blocking(pool, move |conn: &'_ _| { + blocking(pool, move |conn: &mut _| { Comment::update_removed_for_creator(conn, banned_person_id, true) }) .await??; @@ -707,13 +707,13 @@ pub async fn delete_user_account( // No need to update avatar and banner, those are handled in Person::delete_account // Comments - let permadelete = move |conn: &'_ _| Comment::permadelete_for_creator(conn, person_id); + let permadelete = move |conn: &mut _| Comment::permadelete_for_creator(conn, person_id); blocking(pool, permadelete) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_comment"))?; // Posts - let permadelete = move |conn: &'_ _| Post::permadelete_for_creator(conn, person_id); + let permadelete = move |conn: &mut _| Post::permadelete_for_creator(conn, person_id); blocking(pool, permadelete) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_post"))?; diff --git a/crates/api_crud/Cargo.toml b/crates/api_crud/Cargo.toml index 0d709aa2..301015ad 100644 --- a/crates/api_crud/Cargo.toml +++ b/crates/api_crud/Cargo.toml @@ -17,11 +17,11 @@ lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", featur lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] } lemmy_websocket = { version = "=0.16.5", path = "../websocket" } activitypub_federation = "0.2.0" -bcrypt = "0.12.1" -serde_json = { version = "1.0.79", features = ["preserve_order"] } -serde = { version = "1.0.136", features = ["derive"] } -actix-web = { version = "4.0.1", default-features = false } -tracing = "0.1.32" -url = { version = "2.2.2", features = ["serde"] } -async-trait = "0.1.53" +bcrypt = "0.13.0" +serde_json = { version = "1.0.85", features = ["preserve_order"] } +serde = { version = "1.0.145", features = ["derive"] } +actix-web = { version = "4.2.1", default-features = false } +tracing = "0.1.36" +url = { version = "2.3.1", features = ["serde"] } +async-trait = "0.1.57" webmention = "0.4.0" diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index 73408fa9..7ab0f20b 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -145,7 +145,7 @@ impl PerformCrud for CreateComment { score: 1, }; - let like = move |conn: &'_ _| CommentLike::like(conn, &like_form); + let like = move |conn: &mut _| CommentLike::like(conn, &like_form); blocking(context.pool(), like) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_comment"))?; diff --git a/crates/api_crud/src/community/create.rs b/crates/api_crud/src/community/create.rs index e12e3965..a0c40457 100644 --- a/crates/api_crud/src/community/create.rs +++ b/crates/api_crud/src/community/create.rs @@ -114,7 +114,7 @@ impl PerformCrud for CreateCommunity { person_id: local_user_view.person.id, }; - let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form); + let join = move |conn: &mut _| CommunityModerator::join(conn, &community_moderator_form); blocking(context.pool(), join) .await? .map_err(|e| LemmyError::from_error_message(e, "community_moderator_already_exists"))?; @@ -126,7 +126,7 @@ impl PerformCrud for CreateCommunity { pending: false, }; - let follow = move |conn: &'_ _| CommunityFollower::follow(conn, &community_follower_form); + let follow = move |conn: &mut _| CommunityFollower::follow(conn, &community_follower_form); blocking(context.pool(), follow) .await? .map_err(|e| LemmyError::from_error_message(e, "community_follower_already_exists"))?; diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 64a23827..0d4271a8 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -150,7 +150,7 @@ impl PerformCrud for CreatePost { score: 1, }; - let like = move |conn: &'_ _| PostLike::like(conn, &like_form); + let like = move |conn: &mut _| PostLike::like(conn, &like_form); blocking(context.pool(), like) .await? .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_post"))?; diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index c61e3fea..d74117f4 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -80,7 +80,7 @@ impl PerformCrud for CreateSite { ..SiteForm::default() }; - let create_site = move |conn: &'_ _| Site::create(conn, &site_form); + let create_site = move |conn: &mut _| Site::create(conn, &site_form); blocking(context.pool(), create_site) .await? .map_err(|e| LemmyError::from_error_message(e, "site_already_exists"))?; diff --git a/crates/api_crud/src/user/read.rs b/crates/api_crud/src/user/read.rs index d47bc533..d9d26f0c 100644 --- a/crates/api_crud/src/user/read.rs +++ b/crates/api_crud/src/user/read.rs @@ -62,20 +62,36 @@ impl PerformCrud for GetPersonDetails { let saved_only = data.saved_only; let show_deleted_and_removed = data.show_deleted_and_removed; let community_id = data.community_id; + let local_user = local_user_view.map(|l| l.local_user); + let local_user_clone = local_user.to_owned(); - let (posts, comments) = blocking(context.pool(), move |conn| { + let posts = blocking(context.pool(), move |conn| { let posts_query = PostQuery::builder() .conn(conn) + .local_user(local_user.as_ref()) .sort(sort) .saved_only(saved_only) .community_id(community_id) .page(page) .limit(limit); - let local_user = local_user_view.map(|l| l.local_user); + // If its saved only, you don't care what creator it was + // Or, if its not saved, then you only want it for that specific creator + if !saved_only.unwrap_or(false) { + posts_query + .creator_id(Some(person_details_id)) + .build() + .list() + } else { + posts_query.build().list() + } + }) + .await??; + + let comments = blocking(context.pool(), move |conn| { let comments_query = CommentQuery::builder() .conn(conn) - .local_user(local_user.as_ref()) + .local_user(local_user_clone.as_ref()) .sort(sort.map(post_to_comment_sort_type)) .saved_only(saved_only) .show_deleted_and_removed(show_deleted_and_removed) @@ -85,22 +101,14 @@ impl PerformCrud for GetPersonDetails { // If its saved only, you don't care what creator it was // Or, if its not saved, then you only want it for that specific creator - let (posts, comments) = if !saved_only.unwrap_or(false) { - ( - posts_query - .creator_id(Some(person_details_id)) - .build() - .list()?, - comments_query - .creator_id(Some(person_details_id)) - .build() - .list()?, - ) + if !saved_only.unwrap_or(false) { + comments_query + .creator_id(Some(person_details_id)) + .build() + .list() } else { - (posts_query.build().list()?, comments_query.build().list()?) - }; - - Ok((posts, comments)) as Result<_, LemmyError> + comments_query.build().list() + } }) .await??; diff --git a/crates/apub/Cargo.toml b/crates/apub/Cargo.toml index 2714eb8b..31b7dcbe 100644 --- a/crates/apub/Cargo.toml +++ b/crates/apub/Cargo.toml @@ -21,32 +21,32 @@ lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", featur lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] } lemmy_websocket = { version = "=0.16.5", path = "../websocket" } activitypub_federation = "0.2.0" -diesel = "1.4.8" +diesel = "2.0.0" activitystreams-kinds = "0.2.1" -chrono = { version = "0.4.19", features = ["serde"], default-features = false } -serde_json = { version = "1.0.79", features = ["preserve_order"] } -serde = { version = "1.0.136", features = ["derive"] } -serde_with = "1.12.0" +chrono = { version = "0.4.22", features = ["serde"], default-features = false } +serde_json = { version = "1.0.85", features = ["preserve_order"] } +serde = { version = "1.0.145", features = ["derive"] } +serde_with = "1.14.0" actix = "0.13.0" -actix-web = { version = "4.0.1", default-features = false } +actix-web = { version = "4.2.1", default-features = false } actix-rt = { version = "2.7.0", default-features = false } -tracing = "0.1.32" -strum_macros = "0.24.0" -url = { version = "2.2.2", features = ["serde"] } -http = "0.2.6" +tracing = "0.1.36" +strum_macros = "0.24.3" +url = { version = "2.3.1", features = ["serde"] } +http = "0.2.8" http-signature-normalization-actix = { version = "0.6.1", default-features = false, features = ["server", "sha-2"] } -futures = "0.3.21" -itertools = "0.10.3" -uuid = { version = "0.8.2", features = ["serde", "v4"] } -sha2 = "0.10.2" -async-trait = "0.1.53" -anyhow = "1.0.56" -reqwest = { version = "0.11.10", features = ["json"] } +futures = "0.3.24" +itertools = "0.10.5" +uuid = { version = "1.1.2", features = ["serde", "v4"] } +sha2 = "0.10.6" +async-trait = "0.1.57" +anyhow = "1.0.65" +reqwest = { version = "0.11.12", features = ["json"] } html2md = "0.2.13" -once_cell = "1.10.0" +once_cell = "1.15.0" [dev-dependencies] -serial_test = "0.6.0" -assert-json-diff = "2.0.1" -reqwest-middleware = "0.1.5" -task-local-extensions = "0.1.1" +serial_test = "0.9.0" +assert-json-diff = "2.0.2" +reqwest-middleware = "0.1.6" +task-local-extensions = "0.1.3" diff --git a/crates/apub/src/activities/block/block_user.rs b/crates/apub/src/activities/block/block_user.rs index a18002f1..5297cda7 100644 --- a/crates/apub/src/activities/block/block_user.rs +++ b/crates/apub/src/activities/block/block_user.rs @@ -217,7 +217,7 @@ impl ActivityHandler for BlockUser { person_id: blocked_person.id, pending: false, }; - blocking(context.pool(), move |conn: &'_ _| { + blocking(context.pool(), move |conn: &mut _| { CommunityFollower::unfollow(conn, &community_follower_form) }) .await? diff --git a/crates/apub/src/activities/block/undo_block_user.rs b/crates/apub/src/activities/block/undo_block_user.rs index 97ac3482..ee6f631a 100644 --- a/crates/apub/src/activities/block/undo_block_user.rs +++ b/crates/apub/src/activities/block/undo_block_user.rs @@ -141,7 +141,7 @@ impl ActivityHandler for UndoBlockUser { person_id: blocked_person.id, expires: None, }; - blocking(context.pool(), move |conn: &'_ _| { + blocking(context.pool(), move |conn: &mut _| { CommunityPersonBan::unban(conn, &community_user_ban_form) }) .await??; diff --git a/crates/apub/src/activities/create_or_update/comment.rs b/crates/apub/src/activities/create_or_update/comment.rs index e3b01feb..dad6ada9 100644 --- a/crates/apub/src/activities/create_or_update/comment.rs +++ b/crates/apub/src/activities/create_or_update/comment.rs @@ -143,7 +143,7 @@ impl ActivityHandler for CreateOrUpdateComment { person_id: comment.creator_id, score: 1, }; - blocking(context.pool(), move |conn: &'_ _| { + blocking(context.pool(), move |conn: &mut _| { CommentLike::like(conn, &like_form) }) .await??; diff --git a/crates/apub/src/activities/create_or_update/post.rs b/crates/apub/src/activities/create_or_update/post.rs index 5d6f9954..5ac57fb0 100644 --- a/crates/apub/src/activities/create_or_update/post.rs +++ b/crates/apub/src/activities/create_or_update/post.rs @@ -149,7 +149,7 @@ impl ActivityHandler for CreateOrUpdatePost { person_id: post.creator_id, score: 1, }; - blocking(context.pool(), move |conn: &'_ _| { + blocking(context.pool(), move |conn: &mut _| { PostLike::like(conn, &like_form) }) .await??; diff --git a/crates/apub/src/activities/mod.rs b/crates/apub/src/activities/mod.rs index 4b884e4f..bd928e72 100644 --- a/crates/apub/src/activities/mod.rs +++ b/crates/apub/src/activities/mod.rs @@ -67,7 +67,7 @@ pub(crate) async fn verify_person_in_community( let person_id = person.id; let community_id = community.id; let is_banned = - move |conn: &'_ _| CommunityPersonBanView::get(conn, person_id, community_id).is_ok(); + move |conn: &mut _| CommunityPersonBanView::get(conn, person_id, community_id).is_ok(); if blocking(context.pool(), is_banned).await? { return Err(LemmyError::from_message("Person is banned from community")); } diff --git a/crates/apub/src/collections/community_moderators.rs b/crates/apub/src/collections/community_moderators.rs index 2c0c4cd9..9f4374db 100644 --- a/crates/apub/src/collections/community_moderators.rs +++ b/crates/apub/src/collections/community_moderators.rs @@ -163,6 +163,7 @@ mod tests { #[serial] async fn test_parse_lemmy_community_moderators() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); let (new_mod, site) = parse_lemmy_person(&context).await; let community = parse_lemmy_community(&context).await; let community_id = community.id; @@ -172,13 +173,13 @@ mod tests { public_key: Some("pubkey".to_string()), ..PersonForm::default() }; - let old_mod = Person::create(&context.pool().get().unwrap(), &old_mod).unwrap(); + let old_mod = Person::create(conn, &old_mod).unwrap(); let community_moderator_form = CommunityModeratorForm { community_id: community.id, person_id: old_mod.id, }; - CommunityModerator::join(&context.pool().get().unwrap(), &community_moderator_form).unwrap(); + CommunityModerator::join(conn, &community_moderator_form).unwrap(); assert_eq!(site.actor_id.to_string(), "https://enterprise.lemmy.ml/"); @@ -205,13 +206,9 @@ mod tests { assert_eq!(current_moderators.len(), 1); assert_eq!(current_moderators[0].moderator.id, new_mod.id); - Person::delete(&*community_context.1.pool().get().unwrap(), old_mod.id).unwrap(); - Person::delete(&*community_context.1.pool().get().unwrap(), new_mod.id).unwrap(); - Community::delete( - &*community_context.1.pool().get().unwrap(), - community_context.0.id, - ) - .unwrap(); - Site::delete(&*community_context.1.pool().get().unwrap(), site.id).unwrap(); + Person::delete(conn, old_mod.id).unwrap(); + Person::delete(conn, new_mod.id).unwrap(); + Community::delete(conn, community_context.0.id).unwrap(); + Site::delete(conn, site.id).unwrap(); } } diff --git a/crates/apub/src/fetcher/user_or_community.rs b/crates/apub/src/fetcher/user_or_community.rs index 1ed9bb0f..da23ad59 100644 --- a/crates/apub/src/fetcher/user_or_community.rs +++ b/crates/apub/src/fetcher/user_or_community.rs @@ -22,7 +22,7 @@ pub enum PersonOrGroup { Group(Group), } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub enum PersonOrGroupType { Person, Group, diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 840d3a51..41d7f19d 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -249,16 +249,18 @@ pub(crate) mod tests { } fn cleanup(data: (ApubPerson, ApubCommunity, ApubPost, ApubSite), context: &LemmyContext) { - Post::delete(&*context.pool().get().unwrap(), data.2.id).unwrap(); - Community::delete(&*context.pool().get().unwrap(), data.1.id).unwrap(); - Person::delete(&*context.pool().get().unwrap(), data.0.id).unwrap(); - Site::delete(&*context.pool().get().unwrap(), data.3.id).unwrap(); + let conn = &mut context.pool().get().unwrap(); + Post::delete(conn, data.2.id).unwrap(); + Community::delete(conn, data.1.id).unwrap(); + Person::delete(conn, data.0.id).unwrap(); + Site::delete(conn, data.3.id).unwrap(); } #[actix_rt::test] #[serial] pub(crate) async fn test_parse_lemmy_comment() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); let url = Url::parse("https://enterprise.lemmy.ml/comment/38741").unwrap(); let data = prepare_comment_test(&url, &context).await; @@ -280,7 +282,7 @@ pub(crate) mod tests { let to_apub = comment.into_apub(&context).await.unwrap(); assert_json_include!(actual: json, expected: to_apub); - Comment::delete(&*context.pool().get().unwrap(), comment_id).unwrap(); + Comment::delete(conn, comment_id).unwrap(); cleanup(data, &context); } @@ -288,6 +290,7 @@ pub(crate) mod tests { #[serial] async fn test_parse_pleroma_comment() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); let url = Url::parse("https://enterprise.lemmy.ml/comment/38741").unwrap(); let data = prepare_comment_test(&url, &context).await; @@ -315,7 +318,7 @@ pub(crate) mod tests { assert!(!comment.local); assert_eq!(request_counter, 0); - Comment::delete(&*context.pool().get().unwrap(), comment.id).unwrap(); + Comment::delete(conn, comment.id).unwrap(); cleanup(data, &context); } diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index 6e2f409a..cf2dab94 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -247,6 +247,7 @@ pub(crate) mod tests { #[serial] async fn test_parse_lemmy_community() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); let site = parse_lemmy_instance(&context).await; let community = parse_lemmy_community(&context).await; @@ -254,7 +255,7 @@ pub(crate) mod tests { assert!(!community.local); assert_eq!(community.description.as_ref().unwrap().len(), 132); - Community::delete(&*context.pool().get().unwrap(), community.id).unwrap(); - Site::delete(&*context.pool().get().unwrap(), site.id).unwrap(); + Community::delete(conn, community.id).unwrap(); + Site::delete(conn, site.id).unwrap(); } } diff --git a/crates/apub/src/objects/instance.rs b/crates/apub/src/objects/instance.rs index 5e804221..dbf2f9f3 100644 --- a/crates/apub/src/objects/instance.rs +++ b/crates/apub/src/objects/instance.rs @@ -219,11 +219,12 @@ pub(crate) mod tests { #[serial] async fn test_parse_lemmy_instance() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); let site = parse_lemmy_instance(&context).await; assert_eq!(site.name, "Enterprise"); assert_eq!(site.description.as_ref().unwrap().len(), 15); - Site::delete(&*context.pool().get().unwrap(), site.id).unwrap(); + Site::delete(conn, site.id).unwrap(); } } diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index 0b1dd84d..b1a892a3 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -32,7 +32,7 @@ use lemmy_websocket::LemmyContext; use std::ops::Deref; use url::Url; -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct ApubPerson(DbPerson); impl Deref for ApubPerson { @@ -230,20 +230,22 @@ pub(crate) mod tests { #[serial] async fn test_parse_lemmy_person() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); let (person, site) = parse_lemmy_person(&context).await; assert_eq!(person.display_name, Some("Jean-Luc Picard".to_string())); assert!(!person.local); assert_eq!(person.bio.as_ref().unwrap().len(), 39); - DbPerson::delete(&*context.pool().get().unwrap(), person.id).unwrap(); - Site::delete(&*context.pool().get().unwrap(), site.id).unwrap(); + DbPerson::delete(conn, person.id).unwrap(); + Site::delete(conn, site.id).unwrap(); } #[actix_rt::test] #[serial] async fn test_parse_pleroma_person() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); // create and parse a fake pleroma instance actor, to avoid network request during test let mut json: Instance = file_to_json_object("assets/lemmy/objects/instance.json").unwrap(); @@ -270,7 +272,7 @@ pub(crate) mod tests { assert_eq!(request_counter, 0); assert_eq!(person.bio.as_ref().unwrap().len(), 873); - DbPerson::delete(&*context.pool().get().unwrap(), person.id).unwrap(); - Site::delete(&*context.pool().get().unwrap(), site.id).unwrap(); + DbPerson::delete(conn, person.id).unwrap(); + Site::delete(conn, site.id).unwrap(); } } diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 93273466..4789bdc1 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -283,6 +283,7 @@ mod tests { #[serial] async fn test_parse_lemmy_post() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); let (person, site) = parse_lemmy_person(&context).await; let community = parse_lemmy_community(&context).await; @@ -304,9 +305,9 @@ mod tests { assert!(post.stickied); assert_eq!(request_counter, 0); - Post::delete(&*context.pool().get().unwrap(), post.id).unwrap(); - Person::delete(&*context.pool().get().unwrap(), person.id).unwrap(); - Community::delete(&*context.pool().get().unwrap(), community.id).unwrap(); - Site::delete(&*context.pool().get().unwrap(), site.id).unwrap(); + Post::delete(conn, post.id).unwrap(); + Person::delete(conn, person.id).unwrap(); + Community::delete(conn, community.id).unwrap(); + Site::delete(conn, site.id).unwrap(); } } diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index 8a8f9b4a..3aef60c6 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -192,15 +192,17 @@ mod tests { } fn cleanup(data: (ApubPerson, ApubPerson, ApubSite), context: &LemmyContext) { - Person::delete(&*context.pool().get().unwrap(), data.0.id).unwrap(); - Person::delete(&*context.pool().get().unwrap(), data.1.id).unwrap(); - Site::delete(&*context.pool().get().unwrap(), data.2.id).unwrap(); + let conn = &mut context.pool().get().unwrap(); + Person::delete(conn, data.0.id).unwrap(); + Person::delete(conn, data.1.id).unwrap(); + Site::delete(conn, data.2.id).unwrap(); } #[actix_rt::test] #[serial] async fn test_parse_lemmy_pm() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); let url = Url::parse("https://enterprise.lemmy.ml/private_message/1621").unwrap(); let data = prepare_comment_test(&url, &context).await; let json: ChatMessage = file_to_json_object("assets/lemmy/objects/chat_message.json").unwrap(); @@ -220,7 +222,7 @@ mod tests { let to_apub = pm.into_apub(&context).await.unwrap(); assert_json_include!(actual: json, expected: to_apub); - PrivateMessage::delete(&*context.pool().get().unwrap(), pm_id).unwrap(); + PrivateMessage::delete(conn, pm_id).unwrap(); cleanup(data, &context); } @@ -228,6 +230,7 @@ mod tests { #[serial] async fn test_parse_pleroma_pm() { let context = init_context(); + let conn = &mut context.pool().get().unwrap(); let url = Url::parse("https://enterprise.lemmy.ml/private_message/1621").unwrap(); let data = prepare_comment_test(&url, &context).await; let pleroma_url = Url::parse("https://queer.hacktivis.me/objects/2").unwrap(); @@ -244,7 +247,7 @@ mod tests { assert_eq!(pm.content.len(), 3); assert_eq!(request_counter, 0); - PrivateMessage::delete(&*context.pool().get().unwrap(), pm.id).unwrap(); + PrivateMessage::delete(conn, pm.id).unwrap(); cleanup(data, &context); } } diff --git a/crates/apub/src/protocol/activities/mod.rs b/crates/apub/src/protocol/activities/mod.rs index 3b8c9e20..324c8b68 100644 --- a/crates/apub/src/protocol/activities/mod.rs +++ b/crates/apub/src/protocol/activities/mod.rs @@ -8,7 +8,7 @@ pub mod deletion; pub mod following; pub mod voting; -#[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq)] +#[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)] pub enum CreateOrUpdateType { Create, Update, diff --git a/crates/apub/src/protocol/activities/voting/vote.rs b/crates/apub/src/protocol/activities/voting/vote.rs index 2bc674f1..8541b136 100644 --- a/crates/apub/src/protocol/activities/voting/vote.rs +++ b/crates/apub/src/protocol/activities/voting/vote.rs @@ -25,7 +25,7 @@ pub struct Vote { pub(crate) unparsed: Unparsed, } -#[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq)] +#[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)] pub enum VoteType { Like, Dislike, diff --git a/crates/apub/src/protocol/objects/instance.rs b/crates/apub/src/protocol/objects/instance.rs index b921ad20..d8b997b4 100644 --- a/crates/apub/src/protocol/objects/instance.rs +++ b/crates/apub/src/protocol/objects/instance.rs @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; -#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)] +#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum InstanceType { Application, Service, diff --git a/crates/apub/src/protocol/objects/page.rs b/crates/apub/src/protocol/objects/page.rs index 555a9899..1cf55aca 100644 --- a/crates/apub/src/protocol/objects/page.rs +++ b/crates/apub/src/protocol/objects/page.rs @@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; -#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum PageType { Page, Article, diff --git a/crates/apub/src/protocol/objects/person.rs b/crates/apub/src/protocol/objects/person.rs index ac52e46a..eb473250 100644 --- a/crates/apub/src/protocol/objects/person.rs +++ b/crates/apub/src/protocol/objects/person.rs @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; -#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)] +#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum UserTypes { Person, Service, diff --git a/crates/apub_lib/Cargo.toml b/crates/apub_lib/Cargo.toml new file mode 100644 index 00000000..3aaebd41 --- /dev/null +++ b/crates/apub_lib/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "lemmy_apub_lib" +version = "0.16.3" +edition = "2021" +description = "A link aggregator for the fediverse" +license = "AGPL-3.0" +homepage = "https://join-lemmy.org/" +documentation = "https://join-lemmy.org/docs/en/index.html" + +[dependencies] +lemmy_utils = { version = "=0.16.3", path = "../utils" } +lemmy_apub_lib_derive = { version = "=0.16.3", path = "../apub_lib_derive" } +chrono = { version = "0.4.19", default-features = false } +serde = { version = "1.0.136", features = ["derive"] } +async-trait = "0.1.53" +url = { version = "2.2.2", features = ["serde"] } +serde_json = { version = "1.0.79", features = ["preserve_order"] } +anyhow = "1.0.56" +reqwest = { version = "0.11.10", features = ["json"] } +reqwest-middleware = "0.1.5" +tracing = "0.1.32" +base64 = "0.13.0" +openssl = "0.10.38" +once_cell = "1.10.0" +http = "0.2.6" +sha2 = "0.10.2" +actix-web = { version = "4.0.1", default-features = false } +http-signature-normalization-actix = { version = "0.6.1", default-features = false, features = ["server", "sha-2"] } +http-signature-normalization-reqwest = { version = "0.5.0", default-features = false, features = ["sha-2", "middleware"] } +background-jobs = "0.12.0" +diesel = { version = "2.0.0-rc.0", features = ["chrono"] } diff --git a/crates/db_schema/Cargo.toml b/crates/db_schema/Cargo.toml index 7d0a3817..fc5e91b8 100644 --- a/crates/db_schema/Cargo.toml +++ b/crates/db_schema/Cargo.toml @@ -18,22 +18,22 @@ full = ["diesel", "diesel-derive-newtype", "diesel_migrations", "bcrypt", "lemmy "activitypub_federation", "sha2", "regex", "once_cell", "serde_json"] [dependencies] -chrono = { version = "0.4.19", features = ["serde"], default-features = false } -serde = { version = "1.0.136", features = ["derive"] } -url = { version = "2.2.2", features = ["serde"] } -strum = "0.24.0" -strum_macros = "0.24.0" -serde_json = { version = "1.0.79", features = ["preserve_order"], optional = true } +chrono = { version = "0.4.22", features = ["serde"], default-features = false } +serde = { version = "1.0.145", features = ["derive"] } +url = { version = "2.3.1", features = ["serde"] } +strum = "0.24.1" +strum_macros = "0.24.3" +serde_json = { version = "1.0.85", features = ["preserve_order"], optional = true } activitypub_federation = { version = "0.2.0", optional = true } lemmy_utils = { version = "=0.16.5", path = "../utils", optional = true } -bcrypt = { version = "0.12.1", optional = true } -diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"], optional = true } -diesel-derive-newtype = { version = "0.1.2", optional = true } -diesel_migrations = { version = "1.4.0", optional = true } -sha2 = { version = "0.10.2", optional = true } -regex = { version = "1.5.5", optional = true } -once_cell = { version = "1.10.0", optional = true } -diesel_ltree = "0.2.7" +bcrypt = { version = "0.13.0", optional = true } +diesel = { version = "2.0.0", features = ["postgres","chrono","r2d2","serde_json"], optional = true } +diesel-derive-newtype = { version = "2.0.0-rc.0", optional = true } +diesel_migrations = { version = "2.0.0", optional = true } +sha2 = { version = "0.10.6", optional = true } +regex = { version = "1.6.0", optional = true } +once_cell = { version = "1.15.0", optional = true } +diesel_ltree = "0.3.0" [dev-dependencies] -serial_test = "0.6.0" +serial_test = "0.9.0" diff --git a/crates/db_schema/src/aggregates/comment_aggregates.rs b/crates/db_schema/src/aggregates/comment_aggregates.rs index 679efeac..c24e0b94 100644 --- a/crates/db_schema/src/aggregates/comment_aggregates.rs +++ b/crates/db_schema/src/aggregates/comment_aggregates.rs @@ -6,7 +6,7 @@ use crate::{ use diesel::{result::Error, *}; impl CommentAggregates { - pub fn read(conn: &PgConnection, comment_id: CommentId) -> Result { + pub fn read(conn: &mut PgConnection, comment_id: CommentId) -> Result { comment_aggregates::table .filter(comment_aggregates::comment_id.eq(comment_id)) .first::(conn) @@ -31,7 +31,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "thommy_comment_agg".into(), @@ -39,7 +39,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let another_person = PersonForm { name: "jerry_comment_agg".into(), @@ -47,7 +47,7 @@ mod tests { ..PersonForm::default() }; - let another_inserted_person = Person::create(&conn, &another_person).unwrap(); + let another_inserted_person = Person::create(conn, &another_person).unwrap(); let new_community = CommunityForm { name: "TIL_comment_agg".into(), @@ -56,7 +56,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let new_post = PostForm { name: "A test post".into(), @@ -65,7 +65,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let comment_form = CommentForm { content: "A test comment".into(), @@ -74,7 +74,7 @@ mod tests { ..CommentForm::default() }; - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); let child_comment_form = CommentForm { content: "A test comment".into(), @@ -84,7 +84,7 @@ mod tests { }; let _inserted_child_comment = - Comment::create(&conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); + Comment::create(conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); let comment_like = CommentLikeForm { comment_id: inserted_comment.id, @@ -93,9 +93,9 @@ mod tests { score: 1, }; - CommentLike::like(&conn, &comment_like).unwrap(); + CommentLike::like(conn, &comment_like).unwrap(); - let comment_aggs_before_delete = CommentAggregates::read(&conn, inserted_comment.id).unwrap(); + let comment_aggs_before_delete = CommentAggregates::read(conn, inserted_comment.id).unwrap(); assert_eq!(1, comment_aggs_before_delete.score); assert_eq!(1, comment_aggs_before_delete.upvotes); @@ -109,35 +109,35 @@ mod tests { score: -1, }; - CommentLike::like(&conn, &comment_dislike).unwrap(); + CommentLike::like(conn, &comment_dislike).unwrap(); - let comment_aggs_after_dislike = CommentAggregates::read(&conn, inserted_comment.id).unwrap(); + let comment_aggs_after_dislike = CommentAggregates::read(conn, inserted_comment.id).unwrap(); assert_eq!(0, comment_aggs_after_dislike.score); assert_eq!(1, comment_aggs_after_dislike.upvotes); assert_eq!(1, comment_aggs_after_dislike.downvotes); // Remove the first comment like - CommentLike::remove(&conn, inserted_person.id, inserted_comment.id).unwrap(); - let after_like_remove = CommentAggregates::read(&conn, inserted_comment.id).unwrap(); + CommentLike::remove(conn, inserted_person.id, inserted_comment.id).unwrap(); + let after_like_remove = CommentAggregates::read(conn, inserted_comment.id).unwrap(); assert_eq!(-1, after_like_remove.score); assert_eq!(0, after_like_remove.upvotes); assert_eq!(1, after_like_remove.downvotes); // Remove the parent post - Post::delete(&conn, inserted_post.id).unwrap(); + Post::delete(conn, inserted_post.id).unwrap(); // Should be none found, since the post was deleted - let after_delete = CommentAggregates::read(&conn, inserted_comment.id); + let after_delete = CommentAggregates::read(conn, inserted_comment.id); assert!(after_delete.is_err()); // This should delete all the associated rows, and fire triggers - Person::delete(&conn, another_inserted_person.id).unwrap(); - let person_num_deleted = Person::delete(&conn, inserted_person.id).unwrap(); + Person::delete(conn, another_inserted_person.id).unwrap(); + let person_num_deleted = Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(1, person_num_deleted); // Delete the community - let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap(); + let community_num_deleted = Community::delete(conn, inserted_community.id).unwrap(); assert_eq!(1, community_num_deleted); } } diff --git a/crates/db_schema/src/aggregates/community_aggregates.rs b/crates/db_schema/src/aggregates/community_aggregates.rs index 1643fead..9dfa710f 100644 --- a/crates/db_schema/src/aggregates/community_aggregates.rs +++ b/crates/db_schema/src/aggregates/community_aggregates.rs @@ -6,7 +6,7 @@ use crate::{ use diesel::{result::Error, *}; impl CommunityAggregates { - pub fn read(conn: &PgConnection, community_id: CommunityId) -> Result { + pub fn read(conn: &mut PgConnection, community_id: CommunityId) -> Result { community_aggregates::table .filter(community_aggregates::community_id.eq(community_id)) .first::(conn) @@ -31,7 +31,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "thommy_community_agg".into(), @@ -39,7 +39,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let another_person = PersonForm { name: "jerry_community_agg".into(), @@ -47,7 +47,7 @@ mod tests { ..PersonForm::default() }; - let another_inserted_person = Person::create(&conn, &another_person).unwrap(); + let another_inserted_person = Person::create(conn, &another_person).unwrap(); let new_community = CommunityForm { name: "TIL_community_agg".into(), @@ -56,7 +56,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let another_community = CommunityForm { name: "TIL_community_agg_2".into(), @@ -65,7 +65,7 @@ mod tests { ..CommunityForm::default() }; - let another_inserted_community = Community::create(&conn, &another_community).unwrap(); + let another_inserted_community = Community::create(conn, &another_community).unwrap(); let first_person_follow = CommunityFollowerForm { community_id: inserted_community.id, @@ -73,7 +73,7 @@ mod tests { pending: false, }; - CommunityFollower::follow(&conn, &first_person_follow).unwrap(); + CommunityFollower::follow(conn, &first_person_follow).unwrap(); let second_person_follow = CommunityFollowerForm { community_id: inserted_community.id, @@ -81,7 +81,7 @@ mod tests { pending: false, }; - CommunityFollower::follow(&conn, &second_person_follow).unwrap(); + CommunityFollower::follow(conn, &second_person_follow).unwrap(); let another_community_follow = CommunityFollowerForm { community_id: another_inserted_community.id, @@ -89,7 +89,7 @@ mod tests { pending: false, }; - CommunityFollower::follow(&conn, &another_community_follow).unwrap(); + CommunityFollower::follow(conn, &another_community_follow).unwrap(); let new_post = PostForm { name: "A test post".into(), @@ -98,7 +98,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let comment_form = CommentForm { content: "A test comment".into(), @@ -107,7 +107,7 @@ mod tests { ..CommentForm::default() }; - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); let child_comment_form = CommentForm { content: "A test comment".into(), @@ -117,10 +117,10 @@ mod tests { }; let _inserted_child_comment = - Comment::create(&conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); + Comment::create(conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); let community_aggregates_before_delete = - CommunityAggregates::read(&conn, inserted_community.id).unwrap(); + CommunityAggregates::read(conn, inserted_community.id).unwrap(); assert_eq!(2, community_aggregates_before_delete.subscribers); assert_eq!(1, community_aggregates_before_delete.posts); @@ -128,46 +128,46 @@ mod tests { // Test the other community let another_community_aggs = - CommunityAggregates::read(&conn, another_inserted_community.id).unwrap(); + CommunityAggregates::read(conn, another_inserted_community.id).unwrap(); assert_eq!(1, another_community_aggs.subscribers); assert_eq!(0, another_community_aggs.posts); assert_eq!(0, another_community_aggs.comments); // Unfollow test - CommunityFollower::unfollow(&conn, &second_person_follow).unwrap(); - let after_unfollow = CommunityAggregates::read(&conn, inserted_community.id).unwrap(); + CommunityFollower::unfollow(conn, &second_person_follow).unwrap(); + let after_unfollow = CommunityAggregates::read(conn, inserted_community.id).unwrap(); assert_eq!(1, after_unfollow.subscribers); // Follow again just for the later tests - CommunityFollower::follow(&conn, &second_person_follow).unwrap(); - let after_follow_again = CommunityAggregates::read(&conn, inserted_community.id).unwrap(); + CommunityFollower::follow(conn, &second_person_follow).unwrap(); + let after_follow_again = CommunityAggregates::read(conn, inserted_community.id).unwrap(); assert_eq!(2, after_follow_again.subscribers); // Remove a parent comment (the comment count should also be 0) - Post::delete(&conn, inserted_post.id).unwrap(); - let after_parent_post_delete = CommunityAggregates::read(&conn, inserted_community.id).unwrap(); + Post::delete(conn, inserted_post.id).unwrap(); + let after_parent_post_delete = CommunityAggregates::read(conn, inserted_community.id).unwrap(); assert_eq!(0, after_parent_post_delete.comments); assert_eq!(0, after_parent_post_delete.posts); // Remove the 2nd person - Person::delete(&conn, another_inserted_person.id).unwrap(); - let after_person_delete = CommunityAggregates::read(&conn, inserted_community.id).unwrap(); + Person::delete(conn, another_inserted_person.id).unwrap(); + let after_person_delete = CommunityAggregates::read(conn, inserted_community.id).unwrap(); assert_eq!(1, after_person_delete.subscribers); // This should delete all the associated rows, and fire triggers - let person_num_deleted = Person::delete(&conn, inserted_person.id).unwrap(); + let person_num_deleted = Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(1, person_num_deleted); // Delete the community - let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap(); + let community_num_deleted = Community::delete(conn, inserted_community.id).unwrap(); assert_eq!(1, community_num_deleted); let another_community_num_deleted = - Community::delete(&conn, another_inserted_community.id).unwrap(); + Community::delete(conn, another_inserted_community.id).unwrap(); assert_eq!(1, another_community_num_deleted); // Should be none found, since the creator was deleted - let after_delete = CommunityAggregates::read(&conn, inserted_community.id); + let after_delete = CommunityAggregates::read(conn, inserted_community.id); assert!(after_delete.is_err()); } } diff --git a/crates/db_schema/src/aggregates/person_aggregates.rs b/crates/db_schema/src/aggregates/person_aggregates.rs index 29ece732..ff0cb843 100644 --- a/crates/db_schema/src/aggregates/person_aggregates.rs +++ b/crates/db_schema/src/aggregates/person_aggregates.rs @@ -2,7 +2,7 @@ use crate::{aggregates::structs::PersonAggregates, newtypes::PersonId, schema::p use diesel::{result::Error, *}; impl PersonAggregates { - pub fn read(conn: &PgConnection, person_id: PersonId) -> Result { + pub fn read(conn: &mut PgConnection, person_id: PersonId) -> Result { person_aggregates::table .filter(person_aggregates::person_id.eq(person_id)) .first::(conn) @@ -27,7 +27,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "thommy_user_agg".into(), @@ -35,7 +35,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let another_person = PersonForm { name: "jerry_user_agg".into(), @@ -43,7 +43,7 @@ mod tests { ..PersonForm::default() }; - let another_inserted_person = Person::create(&conn, &another_person).unwrap(); + let another_inserted_person = Person::create(conn, &another_person).unwrap(); let new_community = CommunityForm { name: "TIL_site_agg".into(), @@ -52,7 +52,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let new_post = PostForm { name: "A test post".into(), @@ -61,7 +61,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let post_like = PostLikeForm { post_id: inserted_post.id, @@ -69,7 +69,7 @@ mod tests { score: 1, }; - let _inserted_post_like = PostLike::like(&conn, &post_like).unwrap(); + let _inserted_post_like = PostLike::like(conn, &post_like).unwrap(); let comment_form = CommentForm { content: "A test comment".into(), @@ -78,7 +78,7 @@ mod tests { ..CommentForm::default() }; - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); let mut comment_like = CommentLikeForm { comment_id: inserted_comment.id, @@ -87,7 +87,7 @@ mod tests { score: 1, }; - let _inserted_comment_like = CommentLike::like(&conn, &comment_like).unwrap(); + let _inserted_comment_like = CommentLike::like(conn, &comment_like).unwrap(); let child_comment_form = CommentForm { content: "A test comment".into(), @@ -97,7 +97,7 @@ mod tests { }; let inserted_child_comment = - Comment::create(&conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); + Comment::create(conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); let child_comment_like = CommentLikeForm { comment_id: inserted_child_comment.id, @@ -106,10 +106,9 @@ mod tests { score: 1, }; - let _inserted_child_comment_like = CommentLike::like(&conn, &child_comment_like).unwrap(); + let _inserted_child_comment_like = CommentLike::like(conn, &child_comment_like).unwrap(); - let person_aggregates_before_delete = - PersonAggregates::read(&conn, inserted_person.id).unwrap(); + let person_aggregates_before_delete = PersonAggregates::read(conn, inserted_person.id).unwrap(); assert_eq!(1, person_aggregates_before_delete.post_count); assert_eq!(1, person_aggregates_before_delete.post_score); @@ -117,45 +116,45 @@ mod tests { assert_eq!(2, person_aggregates_before_delete.comment_score); // Remove a post like - PostLike::remove(&conn, inserted_person.id, inserted_post.id).unwrap(); - let after_post_like_remove = PersonAggregates::read(&conn, inserted_person.id).unwrap(); + PostLike::remove(conn, inserted_person.id, inserted_post.id).unwrap(); + let after_post_like_remove = PersonAggregates::read(conn, inserted_person.id).unwrap(); assert_eq!(0, after_post_like_remove.post_score); // Remove a parent comment (the scores should also be removed) - Comment::delete(&conn, inserted_comment.id).unwrap(); - Comment::delete(&conn, inserted_child_comment.id).unwrap(); - let after_parent_comment_delete = PersonAggregates::read(&conn, inserted_person.id).unwrap(); + Comment::delete(conn, inserted_comment.id).unwrap(); + Comment::delete(conn, inserted_child_comment.id).unwrap(); + let after_parent_comment_delete = PersonAggregates::read(conn, inserted_person.id).unwrap(); assert_eq!(0, after_parent_comment_delete.comment_count); assert_eq!(0, after_parent_comment_delete.comment_score); // Add in the two comments again, then delete the post. - let new_parent_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let new_parent_comment = Comment::create(conn, &comment_form, None).unwrap(); let _new_child_comment = - Comment::create(&conn, &child_comment_form, Some(&new_parent_comment.path)).unwrap(); + Comment::create(conn, &child_comment_form, Some(&new_parent_comment.path)).unwrap(); comment_like.comment_id = new_parent_comment.id; - CommentLike::like(&conn, &comment_like).unwrap(); - let after_comment_add = PersonAggregates::read(&conn, inserted_person.id).unwrap(); + CommentLike::like(conn, &comment_like).unwrap(); + let after_comment_add = PersonAggregates::read(conn, inserted_person.id).unwrap(); assert_eq!(2, after_comment_add.comment_count); assert_eq!(1, after_comment_add.comment_score); - Post::delete(&conn, inserted_post.id).unwrap(); - let after_post_delete = PersonAggregates::read(&conn, inserted_person.id).unwrap(); + Post::delete(conn, inserted_post.id).unwrap(); + let after_post_delete = PersonAggregates::read(conn, inserted_person.id).unwrap(); assert_eq!(0, after_post_delete.comment_score); assert_eq!(0, after_post_delete.comment_count); assert_eq!(0, after_post_delete.post_score); assert_eq!(0, after_post_delete.post_count); // This should delete all the associated rows, and fire triggers - let person_num_deleted = Person::delete(&conn, inserted_person.id).unwrap(); + let person_num_deleted = Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(1, person_num_deleted); - Person::delete(&conn, another_inserted_person.id).unwrap(); + Person::delete(conn, another_inserted_person.id).unwrap(); // Delete the community - let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap(); + let community_num_deleted = Community::delete(conn, inserted_community.id).unwrap(); assert_eq!(1, community_num_deleted); // Should be none found - let after_delete = PersonAggregates::read(&conn, inserted_person.id); + let after_delete = PersonAggregates::read(conn, inserted_person.id); assert!(after_delete.is_err()); } } diff --git a/crates/db_schema/src/aggregates/post_aggregates.rs b/crates/db_schema/src/aggregates/post_aggregates.rs index 0ef20773..1782d4d6 100644 --- a/crates/db_schema/src/aggregates/post_aggregates.rs +++ b/crates/db_schema/src/aggregates/post_aggregates.rs @@ -2,7 +2,7 @@ use crate::{aggregates::structs::PostAggregates, newtypes::PostId, schema::post_ use diesel::{result::Error, *}; impl PostAggregates { - pub fn read(conn: &PgConnection, post_id: PostId) -> Result { + pub fn read(conn: &mut PgConnection, post_id: PostId) -> Result { post_aggregates::table .filter(post_aggregates::post_id.eq(post_id)) .first::(conn) @@ -27,7 +27,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "thommy_community_agg".into(), @@ -35,7 +35,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let another_person = PersonForm { name: "jerry_community_agg".into(), @@ -43,7 +43,7 @@ mod tests { ..PersonForm::default() }; - let another_inserted_person = Person::create(&conn, &another_person).unwrap(); + let another_inserted_person = Person::create(conn, &another_person).unwrap(); let new_community = CommunityForm { name: "TIL_community_agg".into(), @@ -52,7 +52,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let new_post = PostForm { name: "A test post".into(), @@ -61,7 +61,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let comment_form = CommentForm { content: "A test comment".into(), @@ -70,7 +70,7 @@ mod tests { ..CommentForm::default() }; - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); let child_comment_form = CommentForm { content: "A test comment".into(), @@ -80,7 +80,7 @@ mod tests { }; let inserted_child_comment = - Comment::create(&conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); + Comment::create(conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); let post_like = PostLikeForm { post_id: inserted_post.id, @@ -88,9 +88,9 @@ mod tests { score: 1, }; - PostLike::like(&conn, &post_like).unwrap(); + PostLike::like(conn, &post_like).unwrap(); - let post_aggs_before_delete = PostAggregates::read(&conn, inserted_post.id).unwrap(); + let post_aggs_before_delete = PostAggregates::read(conn, inserted_post.id).unwrap(); assert_eq!(2, post_aggs_before_delete.comments); assert_eq!(1, post_aggs_before_delete.score); @@ -104,9 +104,9 @@ mod tests { score: -1, }; - PostLike::like(&conn, &post_dislike).unwrap(); + PostLike::like(conn, &post_dislike).unwrap(); - let post_aggs_after_dislike = PostAggregates::read(&conn, inserted_post.id).unwrap(); + let post_aggs_after_dislike = PostAggregates::read(conn, inserted_post.id).unwrap(); assert_eq!(2, post_aggs_after_dislike.comments); assert_eq!(0, post_aggs_after_dislike.score); @@ -114,33 +114,33 @@ mod tests { assert_eq!(1, post_aggs_after_dislike.downvotes); // Remove the comments - Comment::delete(&conn, inserted_comment.id).unwrap(); - Comment::delete(&conn, inserted_child_comment.id).unwrap(); - let after_comment_delete = PostAggregates::read(&conn, inserted_post.id).unwrap(); + Comment::delete(conn, inserted_comment.id).unwrap(); + Comment::delete(conn, inserted_child_comment.id).unwrap(); + let after_comment_delete = PostAggregates::read(conn, inserted_post.id).unwrap(); assert_eq!(0, after_comment_delete.comments); assert_eq!(0, after_comment_delete.score); assert_eq!(1, after_comment_delete.upvotes); assert_eq!(1, after_comment_delete.downvotes); // Remove the first post like - PostLike::remove(&conn, inserted_person.id, inserted_post.id).unwrap(); - let after_like_remove = PostAggregates::read(&conn, inserted_post.id).unwrap(); + PostLike::remove(conn, inserted_person.id, inserted_post.id).unwrap(); + let after_like_remove = PostAggregates::read(conn, inserted_post.id).unwrap(); assert_eq!(0, after_like_remove.comments); assert_eq!(-1, after_like_remove.score); assert_eq!(0, after_like_remove.upvotes); assert_eq!(1, after_like_remove.downvotes); // This should delete all the associated rows, and fire triggers - Person::delete(&conn, another_inserted_person.id).unwrap(); - let person_num_deleted = Person::delete(&conn, inserted_person.id).unwrap(); + Person::delete(conn, another_inserted_person.id).unwrap(); + let person_num_deleted = Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(1, person_num_deleted); // Delete the community - let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap(); + let community_num_deleted = Community::delete(conn, inserted_community.id).unwrap(); assert_eq!(1, community_num_deleted); // Should be none found, since the creator was deleted - let after_delete = PostAggregates::read(&conn, inserted_post.id); + let after_delete = PostAggregates::read(conn, inserted_post.id); assert!(after_delete.is_err()); } } diff --git a/crates/db_schema/src/aggregates/site_aggregates.rs b/crates/db_schema/src/aggregates/site_aggregates.rs index 86a46e83..fa60b15d 100644 --- a/crates/db_schema/src/aggregates/site_aggregates.rs +++ b/crates/db_schema/src/aggregates/site_aggregates.rs @@ -2,7 +2,7 @@ use crate::{aggregates::structs::SiteAggregates, schema::site_aggregates}; use diesel::{result::Error, *}; impl SiteAggregates { - pub fn read(conn: &PgConnection) -> Result { + pub fn read(conn: &mut PgConnection) -> Result { site_aggregates::table.first::(conn) } } @@ -26,7 +26,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "thommy_site_agg".into(), @@ -34,7 +34,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let site_form = SiteForm { name: "test_site".into(), @@ -42,7 +42,7 @@ mod tests { ..Default::default() }; - let inserted_site = Site::create(&conn, &site_form).unwrap(); + let inserted_site = Site::create(conn, &site_form).unwrap(); let new_community = CommunityForm { name: "TIL_site_agg".into(), @@ -51,7 +51,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let new_post = PostForm { name: "A test post".into(), @@ -61,8 +61,8 @@ mod tests { }; // Insert two of those posts - let inserted_post = Post::create(&conn, &new_post).unwrap(); - let _inserted_post_again = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); + let _inserted_post_again = Post::create(conn, &new_post).unwrap(); let comment_form = CommentForm { content: "A test comment".into(), @@ -72,7 +72,7 @@ mod tests { }; // Insert two of those comments - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); let child_comment_form = CommentForm { content: "A test comment".into(), @@ -82,9 +82,9 @@ mod tests { }; let _inserted_child_comment = - Comment::create(&conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); + Comment::create(conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); - let site_aggregates_before_delete = SiteAggregates::read(&conn).unwrap(); + let site_aggregates_before_delete = SiteAggregates::read(conn).unwrap(); assert_eq!(1, site_aggregates_before_delete.users); assert_eq!(1, site_aggregates_before_delete.communities); @@ -92,25 +92,25 @@ mod tests { assert_eq!(2, site_aggregates_before_delete.comments); // Try a post delete - Post::delete(&conn, inserted_post.id).unwrap(); - let site_aggregates_after_post_delete = SiteAggregates::read(&conn).unwrap(); + Post::delete(conn, inserted_post.id).unwrap(); + let site_aggregates_after_post_delete = SiteAggregates::read(conn).unwrap(); assert_eq!(1, site_aggregates_after_post_delete.posts); assert_eq!(0, site_aggregates_after_post_delete.comments); // This shouuld delete all the associated rows, and fire triggers - let person_num_deleted = Person::delete(&conn, inserted_person.id).unwrap(); + let person_num_deleted = Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(1, person_num_deleted); // Delete the community - let community_num_deleted = Community::delete(&conn, inserted_community.id).unwrap(); + let community_num_deleted = Community::delete(conn, inserted_community.id).unwrap(); assert_eq!(1, community_num_deleted); // Site should still exist, it can without a site creator. - let after_delete_creator = SiteAggregates::read(&conn); + let after_delete_creator = SiteAggregates::read(conn); assert!(after_delete_creator.is_ok()); - Site::delete(&conn, inserted_site.id).unwrap(); - let after_delete_site = SiteAggregates::read(&conn); + Site::delete(conn, inserted_site.id).unwrap(); + let after_delete_site = SiteAggregates::read(conn); assert!(after_delete_site.is_err()); } } diff --git a/crates/db_schema/src/aggregates/structs.rs b/crates/db_schema/src/aggregates/structs.rs index 328c38a8..15fce13b 100644 --- a/crates/db_schema/src/aggregates/structs.rs +++ b/crates/db_schema/src/aggregates/structs.rs @@ -10,9 +10,10 @@ use crate::schema::{ site_aggregates, }; -#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)] +#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", table_name = "comment_aggregates")] +#[cfg_attr(feature = "full", diesel(table_name = comment_aggregates))] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))] pub struct CommentAggregates { pub id: i32, pub comment_id: CommentId, @@ -23,9 +24,13 @@ pub struct CommentAggregates { pub child_count: i32, } -#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)] +#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", table_name = "community_aggregates")] +#[cfg_attr(feature = "full", diesel(table_name = community_aggregates))] +#[cfg_attr( + feature = "full", + diesel(belongs_to(crate::source::community::Community)) +)] pub struct CommunityAggregates { pub id: i32, pub community_id: CommunityId, @@ -39,9 +44,10 @@ pub struct CommunityAggregates { pub users_active_half_year: i64, } -#[derive(PartialEq, Debug, Serialize, Deserialize, Clone, Default)] +#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", table_name = "person_aggregates")] +#[cfg_attr(feature = "full", diesel(table_name = person_aggregates))] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))] pub struct PersonAggregates { pub id: i32, pub person_id: PersonId, @@ -51,9 +57,10 @@ pub struct PersonAggregates { pub comment_score: i64, } -#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)] +#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", table_name = "post_aggregates")] +#[cfg_attr(feature = "full", diesel(table_name = post_aggregates))] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))] pub struct PostAggregates { pub id: i32, pub post_id: PostId, @@ -67,9 +74,10 @@ pub struct PostAggregates { pub newest_comment_time: chrono::NaiveDateTime, } -#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)] +#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", table_name = "site_aggregates")] +#[cfg_attr(feature = "full", diesel(table_name = site_aggregates))] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))] pub struct SiteAggregates { pub id: i32, pub site_id: i32, diff --git a/crates/db_schema/src/impls/activity.rs b/crates/db_schema/src/impls/activity.rs index b22550a4..87b78a1d 100644 --- a/crates/db_schema/src/impls/activity.rs +++ b/crates/db_schema/src/impls/activity.rs @@ -9,12 +9,12 @@ use serde_json::Value; impl Crud for Activity { type Form = ActivityForm; type IdType = i32; - fn read(conn: &PgConnection, activity_id: i32) -> Result { + fn read(conn: &mut PgConnection, activity_id: i32) -> Result { use crate::schema::activity::dsl::*; activity.find(activity_id).first::(conn) } - fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result { + fn create(conn: &mut PgConnection, new_activity: &ActivityForm) -> Result { use crate::schema::activity::dsl::*; insert_into(activity) .values(new_activity) @@ -22,7 +22,7 @@ impl Crud for Activity { } fn update( - conn: &PgConnection, + conn: &mut PgConnection, activity_id: i32, new_activity: &ActivityForm, ) -> Result { @@ -31,7 +31,7 @@ impl Crud for Activity { .set(new_activity) .get_result::(conn) } - fn delete(conn: &PgConnection, activity_id: i32) -> Result { + fn delete(conn: &mut PgConnection, activity_id: i32) -> Result { use crate::schema::activity::dsl::*; diesel::delete(activity.find(activity_id)).execute(conn) } @@ -40,7 +40,7 @@ impl Crud for Activity { impl Activity { /// Returns true if the insert was successful pub fn insert( - conn: &PgConnection, + conn: &mut PgConnection, ap_id: DbUrl, data: Value, local: bool, @@ -64,12 +64,12 @@ impl Activity { } } - pub fn read_from_apub_id(conn: &PgConnection, object_id: &DbUrl) -> Result { + pub fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result { use crate::schema::activity::dsl::*; activity.filter(ap_id.eq(object_id)).first::(conn) } - pub fn delete_olds(conn: &PgConnection) -> Result { + pub fn delete_olds(conn: &mut PgConnection) -> Result { use crate::schema::activity::dsl::*; diesel::delete(activity.filter(published.lt(now - 6.months()))).execute(conn) } @@ -93,7 +93,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let creator_form = PersonForm { name: "activity_creator_pm".into(), @@ -101,7 +101,7 @@ mod tests { ..PersonForm::default() }; - let inserted_creator = Person::create(&conn, &creator_form).unwrap(); + let inserted_creator = Person::create(conn, &creator_form).unwrap(); let ap_id: DbUrl = Url::parse( "https://enterprise.lemmy.ml/activities/delete/f1b5d57c-80f8-4e03-a615-688d552e946c", @@ -130,7 +130,7 @@ mod tests { updated: None, }; - let inserted_activity = Activity::create(&conn, &activity_form).unwrap(); + let inserted_activity = Activity::create(conn, &activity_form).unwrap(); let expected_activity = Activity { ap_id: ap_id.clone(), @@ -142,10 +142,10 @@ mod tests { updated: None, }; - let read_activity = Activity::read(&conn, inserted_activity.id).unwrap(); - let read_activity_by_apub_id = Activity::read_from_apub_id(&conn, &ap_id).unwrap(); - Person::delete(&conn, inserted_creator.id).unwrap(); - Activity::delete(&conn, inserted_activity.id).unwrap(); + let read_activity = Activity::read(conn, inserted_activity.id).unwrap(); + let read_activity_by_apub_id = Activity::read_from_apub_id(conn, &ap_id).unwrap(); + Person::delete(conn, inserted_creator.id).unwrap(); + Activity::delete(conn, inserted_activity.id).unwrap(); assert_eq!(expected_activity, read_activity); assert_eq!(expected_activity, read_activity_by_apub_id); diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index 5eaedcb9..eca5328d 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -17,7 +17,7 @@ use url::Url; impl Comment { pub fn update_ap_id( - conn: &PgConnection, + conn: &mut PgConnection, comment_id: CommentId, apub_id: DbUrl, ) -> Result { @@ -29,7 +29,7 @@ impl Comment { } pub fn permadelete_for_creator( - conn: &PgConnection, + conn: &mut PgConnection, for_creator_id: PersonId, ) -> Result, Error> { use crate::schema::comment::dsl::*; @@ -43,7 +43,7 @@ impl Comment { } pub fn update_deleted( - conn: &PgConnection, + conn: &mut PgConnection, comment_id: CommentId, new_deleted: bool, ) -> Result { @@ -54,7 +54,7 @@ impl Comment { } pub fn update_removed( - conn: &PgConnection, + conn: &mut PgConnection, comment_id: CommentId, new_removed: bool, ) -> Result { @@ -65,7 +65,7 @@ impl Comment { } pub fn update_removed_for_creator( - conn: &PgConnection, + conn: &mut PgConnection, for_creator_id: PersonId, new_removed: bool, ) -> Result, Error> { @@ -76,7 +76,7 @@ impl Comment { } pub fn create( - conn: &PgConnection, + conn: &mut PgConnection, comment_form: &CommentForm, parent_path: Option<&Ltree>, ) -> Result { @@ -141,7 +141,7 @@ where ca.comment_id = c.id", inserted_comment } } - pub fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result, Error> { + pub fn read_from_apub_id(conn: &mut PgConnection, object_id: Url) -> Result, Error> { use crate::schema::comment::dsl::*; let object_id: DbUrl = object_id.into(); Ok( @@ -170,23 +170,23 @@ where ca.comment_id = c.id", impl Crud for Comment { type Form = CommentForm; type IdType = CommentId; - fn read(conn: &PgConnection, comment_id: CommentId) -> Result { + fn read(conn: &mut PgConnection, comment_id: CommentId) -> Result { use crate::schema::comment::dsl::*; comment.find(comment_id).first::(conn) } - fn delete(conn: &PgConnection, comment_id: CommentId) -> Result { + fn delete(conn: &mut PgConnection, comment_id: CommentId) -> Result { use crate::schema::comment::dsl::*; diesel::delete(comment.find(comment_id)).execute(conn) } /// This is unimplemented, use [[Comment::create]] - fn create(_conn: &PgConnection, _comment_form: &CommentForm) -> Result { + fn create(_conn: &mut PgConnection, _comment_form: &CommentForm) -> Result { unimplemented!(); } fn update( - conn: &PgConnection, + conn: &mut PgConnection, comment_id: CommentId, comment_form: &CommentForm, ) -> Result { @@ -200,7 +200,7 @@ impl Crud for Comment { impl Likeable for CommentLike { type Form = CommentLikeForm; type IdType = CommentId; - fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result { + fn like(conn: &mut PgConnection, comment_like_form: &CommentLikeForm) -> Result { use crate::schema::comment_like::dsl::*; insert_into(comment_like) .values(comment_like_form) @@ -210,7 +210,7 @@ impl Likeable for CommentLike { .get_result::(conn) } fn remove( - conn: &PgConnection, + conn: &mut PgConnection, person_id: PersonId, comment_id: CommentId, ) -> Result { @@ -226,7 +226,7 @@ impl Likeable for CommentLike { impl Saveable for CommentSaved { type Form = CommentSavedForm; - fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result { + fn save(conn: &mut PgConnection, comment_saved_form: &CommentSavedForm) -> Result { use crate::schema::comment_saved::dsl::*; insert_into(comment_saved) .values(comment_saved_form) @@ -235,7 +235,10 @@ impl Saveable for CommentSaved { .set(comment_saved_form) .get_result::(conn) } - fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result { + fn unsave( + conn: &mut PgConnection, + comment_saved_form: &CommentSavedForm, + ) -> Result { use crate::schema::comment_saved::dsl::*; diesel::delete( comment_saved @@ -272,7 +275,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "terry".into(), @@ -280,7 +283,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let new_community = CommunityForm { name: "test community".to_string(), @@ -289,7 +292,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let new_post = PostForm { name: "A test post".into(), @@ -298,7 +301,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let comment_form = CommentForm { content: "A test comment".into(), @@ -307,7 +310,7 @@ mod tests { ..CommentForm::default() }; - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); let expected_comment = Comment { id: inserted_comment.id, @@ -334,7 +337,7 @@ mod tests { }; let inserted_child_comment = - Comment::create(&conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); + Comment::create(conn, &child_comment_form, Some(&inserted_comment.path)).unwrap(); // Comment Like let comment_like_form = CommentLikeForm { @@ -344,7 +347,7 @@ mod tests { score: 1, }; - let inserted_comment_like = CommentLike::like(&conn, &comment_like_form).unwrap(); + let inserted_comment_like = CommentLike::like(conn, &comment_like_form).unwrap(); let expected_comment_like = CommentLike { id: inserted_comment_like.id, @@ -361,7 +364,7 @@ mod tests { person_id: inserted_person.id, }; - let inserted_comment_saved = CommentSaved::save(&conn, &comment_saved_form).unwrap(); + let inserted_comment_saved = CommentSaved::save(conn, &comment_saved_form).unwrap(); let expected_comment_saved = CommentSaved { id: inserted_comment_saved.id, @@ -370,15 +373,15 @@ mod tests { published: inserted_comment_saved.published, }; - let read_comment = Comment::read(&conn, inserted_comment.id).unwrap(); - let updated_comment = Comment::update(&conn, inserted_comment.id, &comment_form).unwrap(); - let like_removed = CommentLike::remove(&conn, inserted_person.id, inserted_comment.id).unwrap(); - let saved_removed = CommentSaved::unsave(&conn, &comment_saved_form).unwrap(); - let num_deleted = Comment::delete(&conn, inserted_comment.id).unwrap(); - Comment::delete(&conn, inserted_child_comment.id).unwrap(); - Post::delete(&conn, inserted_post.id).unwrap(); - Community::delete(&conn, inserted_community.id).unwrap(); - Person::delete(&conn, inserted_person.id).unwrap(); + let read_comment = Comment::read(conn, inserted_comment.id).unwrap(); + let updated_comment = Comment::update(conn, inserted_comment.id, &comment_form).unwrap(); + let like_removed = CommentLike::remove(conn, inserted_person.id, inserted_comment.id).unwrap(); + let saved_removed = CommentSaved::unsave(conn, &comment_saved_form).unwrap(); + let num_deleted = Comment::delete(conn, inserted_comment.id).unwrap(); + Comment::delete(conn, inserted_child_comment.id).unwrap(); + Post::delete(conn, inserted_post.id).unwrap(); + Community::delete(conn, inserted_community.id).unwrap(); + Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(expected_comment, read_comment); assert_eq!(expected_comment, inserted_comment); diff --git a/crates/db_schema/src/impls/comment_reply.rs b/crates/db_schema/src/impls/comment_reply.rs index 271e5e71..8fed2ce4 100644 --- a/crates/db_schema/src/impls/comment_reply.rs +++ b/crates/db_schema/src/impls/comment_reply.rs @@ -8,12 +8,12 @@ use diesel::{dsl::*, result::Error, *}; impl Crud for CommentReply { type Form = CommentReplyForm; type IdType = CommentReplyId; - fn read(conn: &PgConnection, comment_reply_id: CommentReplyId) -> Result { + fn read(conn: &mut PgConnection, comment_reply_id: CommentReplyId) -> Result { use crate::schema::comment_reply::dsl::*; comment_reply.find(comment_reply_id).first::(conn) } - fn create(conn: &PgConnection, comment_reply_form: &CommentReplyForm) -> Result { + fn create(conn: &mut PgConnection, comment_reply_form: &CommentReplyForm) -> Result { use crate::schema::comment_reply::dsl::*; // since the return here isnt utilized, we dont need to do an update // but get_result doesnt return the existing row here @@ -26,7 +26,7 @@ impl Crud for CommentReply { } fn update( - conn: &PgConnection, + conn: &mut PgConnection, comment_reply_id: CommentReplyId, comment_reply_form: &CommentReplyForm, ) -> Result { @@ -39,7 +39,7 @@ impl Crud for CommentReply { impl CommentReply { pub fn update_read( - conn: &PgConnection, + conn: &mut PgConnection, comment_reply_id: CommentReplyId, new_read: bool, ) -> Result { @@ -50,7 +50,7 @@ impl CommentReply { } pub fn mark_all_as_read( - conn: &PgConnection, + conn: &mut PgConnection, for_recipient_id: PersonId, ) -> Result, Error> { use crate::schema::comment_reply::dsl::*; @@ -63,7 +63,10 @@ impl CommentReply { .get_results::(conn) } - pub fn read_by_comment(conn: &PgConnection, for_comment_id: CommentId) -> Result { + pub fn read_by_comment( + conn: &mut PgConnection, + for_comment_id: CommentId, + ) -> Result { use crate::schema::comment_reply::dsl::*; comment_reply .filter(comment_id.eq(for_comment_id)) @@ -89,7 +92,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "terrylake".into(), @@ -97,7 +100,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let recipient_form = PersonForm { name: "terrylakes recipient".into(), @@ -105,7 +108,7 @@ mod tests { ..PersonForm::default() }; - let inserted_recipient = Person::create(&conn, &recipient_form).unwrap(); + let inserted_recipient = Person::create(conn, &recipient_form).unwrap(); let new_community = CommunityForm { name: "test community lake".to_string(), @@ -114,7 +117,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let new_post = PostForm { name: "A test post".into(), @@ -123,7 +126,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let comment_form = CommentForm { content: "A test comment".into(), @@ -132,7 +135,7 @@ mod tests { ..CommentForm::default() }; - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); let comment_reply_form = CommentReplyForm { recipient_id: inserted_recipient.id, @@ -140,7 +143,7 @@ mod tests { read: None, }; - let inserted_reply = CommentReply::create(&conn, &comment_reply_form).unwrap(); + let inserted_reply = CommentReply::create(conn, &comment_reply_form).unwrap(); let expected_reply = CommentReply { id: inserted_reply.id, @@ -150,14 +153,13 @@ mod tests { published: inserted_reply.published, }; - let read_reply = CommentReply::read(&conn, inserted_reply.id).unwrap(); - let updated_reply = - CommentReply::update(&conn, inserted_reply.id, &comment_reply_form).unwrap(); - Comment::delete(&conn, inserted_comment.id).unwrap(); - Post::delete(&conn, inserted_post.id).unwrap(); - Community::delete(&conn, inserted_community.id).unwrap(); - Person::delete(&conn, inserted_person.id).unwrap(); - Person::delete(&conn, inserted_recipient.id).unwrap(); + let read_reply = CommentReply::read(conn, inserted_reply.id).unwrap(); + let updated_reply = CommentReply::update(conn, inserted_reply.id, &comment_reply_form).unwrap(); + Comment::delete(conn, inserted_comment.id).unwrap(); + Post::delete(conn, inserted_post.id).unwrap(); + Community::delete(conn, inserted_community.id).unwrap(); + Person::delete(conn, inserted_person.id).unwrap(); + Person::delete(conn, inserted_recipient.id).unwrap(); assert_eq!(expected_reply, read_reply); assert_eq!(expected_reply, inserted_reply); diff --git a/crates/db_schema/src/impls/comment_report.rs b/crates/db_schema/src/impls/comment_report.rs index 56e917e0..ebafddab 100644 --- a/crates/db_schema/src/impls/comment_report.rs +++ b/crates/db_schema/src/impls/comment_report.rs @@ -13,7 +13,10 @@ impl Reportable for CommentReport { /// /// * `conn` - the postgres connection /// * `comment_report_form` - the filled CommentReportForm to insert - fn report(conn: &PgConnection, comment_report_form: &CommentReportForm) -> Result { + fn report( + conn: &mut PgConnection, + comment_report_form: &CommentReportForm, + ) -> Result { use crate::schema::comment_report::dsl::*; insert_into(comment_report) .values(comment_report_form) @@ -26,7 +29,7 @@ impl Reportable for CommentReport { /// * `report_id` - the id of the report to resolve /// * `by_resolver_id` - the id of the user resolving the report fn resolve( - conn: &PgConnection, + conn: &mut PgConnection, report_id: Self::IdType, by_resolver_id: PersonId, ) -> Result { @@ -46,7 +49,7 @@ impl Reportable for CommentReport { /// * `report_id` - the id of the report to unresolve /// * `by_resolver_id` - the id of the user unresolving the report fn unresolve( - conn: &PgConnection, + conn: &mut PgConnection, report_id: Self::IdType, by_resolver_id: PersonId, ) -> Result { diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index eb92d7a0..574c0ee2 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -73,17 +73,17 @@ mod safe_type { impl Crud for Community { type Form = CommunityForm; type IdType = CommunityId; - fn read(conn: &PgConnection, community_id: CommunityId) -> Result { + fn read(conn: &mut PgConnection, community_id: CommunityId) -> Result { use crate::schema::community::dsl::*; community.find(community_id).first::(conn) } - fn delete(conn: &PgConnection, community_id: CommunityId) -> Result { + fn delete(conn: &mut PgConnection, community_id: CommunityId) -> Result { use crate::schema::community::dsl::*; diesel::delete(community.find(community_id)).execute(conn) } - fn create(conn: &PgConnection, new_community: &CommunityForm) -> Result { + fn create(conn: &mut PgConnection, new_community: &CommunityForm) -> Result { use crate::schema::community::dsl::*; insert_into(community) .values(new_community) @@ -91,7 +91,7 @@ impl Crud for Community { } fn update( - conn: &PgConnection, + conn: &mut PgConnection, community_id: CommunityId, new_community: &CommunityForm, ) -> Result { @@ -104,7 +104,7 @@ impl Crud for Community { impl Community { pub fn update_deleted( - conn: &PgConnection, + conn: &mut PgConnection, community_id: CommunityId, new_deleted: bool, ) -> Result { @@ -115,7 +115,7 @@ impl Community { } pub fn update_removed( - conn: &PgConnection, + conn: &mut PgConnection, community_id: CommunityId, new_removed: bool, ) -> Result { @@ -125,12 +125,15 @@ impl Community { .get_result::(conn) } - pub fn distinct_federated_communities(conn: &PgConnection) -> Result, Error> { + pub fn distinct_federated_communities(conn: &mut PgConnection) -> Result, Error> { use crate::schema::community::dsl::*; community.select(actor_id).distinct().load::(conn) } - pub fn upsert(conn: &PgConnection, community_form: &CommunityForm) -> Result { + pub fn upsert( + conn: &mut PgConnection, + community_form: &CommunityForm, + ) -> Result { use crate::schema::community::dsl::*; insert_into(community) .values(community_form) @@ -141,7 +144,7 @@ impl Community { } pub fn remove_avatar_and_banner( - conn: &PgConnection, + conn: &mut PgConnection, community_id: CommunityId, ) -> Result { use crate::schema::community::dsl::*; @@ -157,7 +160,7 @@ impl Community { impl Joinable for CommunityModerator { type Form = CommunityModeratorForm; fn join( - conn: &PgConnection, + conn: &mut PgConnection, community_moderator_form: &CommunityModeratorForm, ) -> Result { use crate::schema::community_moderator::dsl::*; @@ -167,7 +170,7 @@ impl Joinable for CommunityModerator { } fn leave( - conn: &PgConnection, + conn: &mut PgConnection, community_moderator_form: &CommunityModeratorForm, ) -> Result { use crate::schema::community_moderator::dsl::*; @@ -202,7 +205,7 @@ impl DeleteableOrRemoveable for Community { impl CommunityModerator { pub fn delete_for_community( - conn: &PgConnection, + conn: &mut PgConnection, for_community_id: CommunityId, ) -> Result { use crate::schema::community_moderator::dsl::*; @@ -210,7 +213,7 @@ impl CommunityModerator { } pub fn get_person_moderated_communities( - conn: &PgConnection, + conn: &mut PgConnection, for_person_id: PersonId, ) -> Result, Error> { use crate::schema::community_moderator::dsl::*; @@ -224,7 +227,7 @@ impl CommunityModerator { impl Bannable for CommunityPersonBan { type Form = CommunityPersonBanForm; fn ban( - conn: &PgConnection, + conn: &mut PgConnection, community_person_ban_form: &CommunityPersonBanForm, ) -> Result { use crate::schema::community_person_ban::dsl::*; @@ -237,7 +240,7 @@ impl Bannable for CommunityPersonBan { } fn unban( - conn: &PgConnection, + conn: &mut PgConnection, community_person_ban_form: &CommunityPersonBanForm, ) -> Result { use crate::schema::community_person_ban::dsl::*; @@ -269,7 +272,7 @@ impl CommunityFollower { impl Followable for CommunityFollower { type Form = CommunityFollowerForm; fn follow( - conn: &PgConnection, + conn: &mut PgConnection, community_follower_form: &CommunityFollowerForm, ) -> Result { use crate::schema::community_follower::dsl::*; @@ -281,7 +284,7 @@ impl Followable for CommunityFollower { .get_result::(conn) } fn follow_accepted( - conn: &PgConnection, + conn: &mut PgConnection, community_id_: CommunityId, person_id_: PersonId, ) -> Result @@ -298,7 +301,7 @@ impl Followable for CommunityFollower { .get_result::(conn) } fn unfollow( - conn: &PgConnection, + conn: &mut PgConnection, community_follower_form: &CommunityFollowerForm, ) -> Result { use crate::schema::community_follower::dsl::*; @@ -311,7 +314,10 @@ impl Followable for CommunityFollower { } // TODO: this function name only makes sense if you call it with a remote community. for a local // community, it will also return true if only remote followers exist - fn has_local_followers(conn: &PgConnection, community_id_: CommunityId) -> Result { + fn has_local_followers( + conn: &mut PgConnection, + community_id_: CommunityId, + ) -> Result { use crate::schema::community_follower::dsl::*; diesel::select(exists( community_follower.filter(community_id.eq(community_id_)), @@ -321,7 +327,7 @@ impl Followable for CommunityFollower { } impl ApubActor for Community { - fn read_from_apub_id(conn: &PgConnection, object_id: &DbUrl) -> Result, Error> { + fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result, Error> { use crate::schema::community::dsl::*; Ok( community @@ -333,7 +339,7 @@ impl ApubActor for Community { } fn read_from_name( - conn: &PgConnection, + conn: &mut PgConnection, community_name: &str, include_deleted: bool, ) -> Result { @@ -349,7 +355,7 @@ impl ApubActor for Community { } fn read_from_name_and_domain( - conn: &PgConnection, + conn: &mut PgConnection, community_name: &str, protocol_domain: &str, ) -> Result { @@ -373,7 +379,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "bobbee".into(), @@ -381,7 +387,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let new_community = CommunityForm { name: "TIL".into(), @@ -390,7 +396,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let expected_community = Community { id: inserted_community.id, @@ -423,7 +429,7 @@ mod tests { }; let inserted_community_follower = - CommunityFollower::follow(&conn, &community_follower_form).unwrap(); + CommunityFollower::follow(conn, &community_follower_form).unwrap(); let expected_community_follower = CommunityFollower { id: inserted_community_follower.id, @@ -439,7 +445,7 @@ mod tests { }; let inserted_community_moderator = - CommunityModerator::join(&conn, &community_moderator_form).unwrap(); + CommunityModerator::join(conn, &community_moderator_form).unwrap(); let expected_community_moderator = CommunityModerator { id: inserted_community_moderator.id, @@ -455,7 +461,7 @@ mod tests { }; let inserted_community_person_ban = - CommunityPersonBan::ban(&conn, &community_person_ban_form).unwrap(); + CommunityPersonBan::ban(conn, &community_person_ban_form).unwrap(); let expected_community_person_ban = CommunityPersonBan { id: inserted_community_person_ban.id, @@ -465,14 +471,13 @@ mod tests { expires: None, }; - let read_community = Community::read(&conn, inserted_community.id).unwrap(); - let updated_community = - Community::update(&conn, inserted_community.id, &new_community).unwrap(); - let ignored_community = CommunityFollower::unfollow(&conn, &community_follower_form).unwrap(); - let left_community = CommunityModerator::leave(&conn, &community_moderator_form).unwrap(); - let unban = CommunityPersonBan::unban(&conn, &community_person_ban_form).unwrap(); - let num_deleted = Community::delete(&conn, inserted_community.id).unwrap(); - Person::delete(&conn, inserted_person.id).unwrap(); + let read_community = Community::read(conn, inserted_community.id).unwrap(); + let updated_community = Community::update(conn, inserted_community.id, &new_community).unwrap(); + let ignored_community = CommunityFollower::unfollow(conn, &community_follower_form).unwrap(); + let left_community = CommunityModerator::leave(conn, &community_moderator_form).unwrap(); + let unban = CommunityPersonBan::unban(conn, &community_person_ban_form).unwrap(); + let num_deleted = Community::delete(conn, inserted_community.id).unwrap(); + Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(expected_community, read_community); assert_eq!(expected_community, inserted_community); diff --git a/crates/db_schema/src/impls/community_block.rs b/crates/db_schema/src/impls/community_block.rs index bbad2f12..49a86173 100644 --- a/crates/db_schema/src/impls/community_block.rs +++ b/crates/db_schema/src/impls/community_block.rs @@ -6,7 +6,7 @@ use diesel::{dsl::*, result::Error, *}; impl Blockable for CommunityBlock { type Form = CommunityBlockForm; - fn block(conn: &PgConnection, community_block_form: &Self::Form) -> Result { + fn block(conn: &mut PgConnection, community_block_form: &Self::Form) -> Result { use crate::schema::community_block::dsl::*; insert_into(community_block) .values(community_block_form) @@ -15,7 +15,7 @@ impl Blockable for CommunityBlock { .set(community_block_form) .get_result::(conn) } - fn unblock(conn: &PgConnection, community_block_form: &Self::Form) -> Result { + fn unblock(conn: &mut PgConnection, community_block_form: &Self::Form) -> Result { use crate::schema::community_block::dsl::*; diesel::delete( community_block diff --git a/crates/db_schema/src/impls/email_verification.rs b/crates/db_schema/src/impls/email_verification.rs index c2703739..33415cf0 100644 --- a/crates/db_schema/src/impls/email_verification.rs +++ b/crates/db_schema/src/impls/email_verification.rs @@ -12,33 +12,37 @@ use diesel::{ impl Crud for EmailVerification { type Form = EmailVerificationForm; type IdType = i32; - fn create(conn: &PgConnection, form: &EmailVerificationForm) -> Result { + fn create(conn: &mut PgConnection, form: &EmailVerificationForm) -> Result { use crate::schema::email_verification::dsl::*; insert_into(email_verification) .values(form) .get_result::(conn) } - fn read(conn: &PgConnection, id_: i32) -> Result { + fn read(conn: &mut PgConnection, id_: i32) -> Result { use crate::schema::email_verification::dsl::*; email_verification.find(id_).first::(conn) } - fn update(conn: &PgConnection, id_: i32, form: &EmailVerificationForm) -> Result { + fn update( + conn: &mut PgConnection, + id_: i32, + form: &EmailVerificationForm, + ) -> Result { use crate::schema::email_verification::dsl::*; diesel::update(email_verification.find(id_)) .set(form) .get_result::(conn) } - fn delete(conn: &PgConnection, id_: i32) -> Result { + fn delete(conn: &mut PgConnection, id_: i32) -> Result { use crate::schema::email_verification::dsl::*; diesel::delete(email_verification.find(id_)).execute(conn) } } impl EmailVerification { - pub fn read_for_token(conn: &PgConnection, token: &str) -> Result { + pub fn read_for_token(conn: &mut PgConnection, token: &str) -> Result { use crate::schema::email_verification::dsl::*; email_verification .filter(verification_token.eq(token)) @@ -46,7 +50,7 @@ impl EmailVerification { .first::(conn) } pub fn delete_old_tokens_for_local_user( - conn: &PgConnection, + conn: &mut PgConnection, local_user_id_: LocalUserId, ) -> Result { use crate::schema::email_verification::dsl::*; diff --git a/crates/db_schema/src/impls/language.rs b/crates/db_schema/src/impls/language.rs index f2895e80..0aef28f2 100644 --- a/crates/db_schema/src/impls/language.rs +++ b/crates/db_schema/src/impls/language.rs @@ -2,23 +2,23 @@ use crate::{newtypes::LanguageId, source::language::Language}; use diesel::{result::Error, PgConnection, RunQueryDsl, *}; impl Language { - pub fn read_all(conn: &PgConnection) -> Result, Error> { + pub fn read_all(conn: &mut PgConnection) -> Result, Error> { use crate::schema::language::dsl::*; language.load::(conn) } - pub fn read_from_id(conn: &PgConnection, id_: LanguageId) -> Result { + pub fn read_from_id(conn: &mut PgConnection, id_: LanguageId) -> Result { use crate::schema::language::dsl::*; language.filter(id.eq(id_)).first::(conn) } - pub fn read_id_from_code(conn: &PgConnection, code_: &str) -> Result { + pub fn read_id_from_code(conn: &mut PgConnection, code_: &str) -> Result { use crate::schema::language::dsl::*; Ok(language.filter(code.eq(code_)).first::(conn)?.id) } pub fn read_id_from_code_opt( - conn: &PgConnection, + conn: &mut PgConnection, code_: Option<&str>, ) -> Result, Error> { if let Some(code_) = code_ { @@ -28,7 +28,7 @@ impl Language { } } - pub fn read_undetermined(conn: &PgConnection) -> Result { + pub fn read_undetermined(conn: &mut PgConnection) -> Result { use crate::schema::language::dsl::*; Ok(language.filter(code.eq("und")).first::(conn)?.id) } @@ -42,9 +42,9 @@ mod tests { #[test] #[serial] fn test_languages() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); - let all = Language::read_all(&conn).unwrap(); + let all = Language::read_all(conn).unwrap(); assert_eq!(184, all.len()); assert_eq!("ak", all[5].code); diff --git a/crates/db_schema/src/impls/local_user.rs b/crates/db_schema/src/impls/local_user.rs index d2599f4f..4c540a0d 100644 --- a/crates/db_schema/src/impls/local_user.rs +++ b/crates/db_schema/src/impls/local_user.rs @@ -67,7 +67,7 @@ mod safe_settings_type { } impl LocalUser { - pub fn register(conn: &PgConnection, form: &LocalUserForm) -> Result { + pub fn register(conn: &mut PgConnection, form: &LocalUserForm) -> Result { let mut edited_user = form.clone(); let password_hash = form .password_encrypted @@ -79,7 +79,7 @@ impl LocalUser { } pub fn update_password( - conn: &PgConnection, + conn: &mut PgConnection, local_user_id: LocalUserId, new_password: &str, ) -> Result { @@ -93,14 +93,14 @@ impl LocalUser { .get_result::(conn) } - pub fn set_all_users_email_verified(conn: &PgConnection) -> Result, Error> { + pub fn set_all_users_email_verified(conn: &mut PgConnection) -> Result, Error> { diesel::update(local_user) .set(email_verified.eq(true)) .get_results::(conn) } pub fn set_all_users_registration_applications_accepted( - conn: &PgConnection, + conn: &mut PgConnection, ) -> Result, Error> { diesel::update(local_user) .set(accepted_application.eq(true)) @@ -111,13 +111,13 @@ impl LocalUser { impl Crud for LocalUser { type Form = LocalUserForm; type IdType = LocalUserId; - fn read(conn: &PgConnection, local_user_id: LocalUserId) -> Result { + fn read(conn: &mut PgConnection, local_user_id: LocalUserId) -> Result { local_user.find(local_user_id).first::(conn) } - fn delete(conn: &PgConnection, local_user_id: LocalUserId) -> Result { + fn delete(conn: &mut PgConnection, local_user_id: LocalUserId) -> Result { diesel::delete(local_user.find(local_user_id)).execute(conn) } - fn create(conn: &PgConnection, form: &LocalUserForm) -> Result { + fn create(conn: &mut PgConnection, form: &LocalUserForm) -> Result { let local_user_ = insert_into(local_user) .values(form) .get_result::(conn)?; @@ -126,7 +126,7 @@ impl Crud for LocalUser { Ok(local_user_) } fn update( - conn: &PgConnection, + conn: &mut PgConnection, local_user_id: LocalUserId, form: &LocalUserForm, ) -> Result { diff --git a/crates/db_schema/src/impls/local_user_language.rs b/crates/db_schema/src/impls/local_user_language.rs index d38a0869..4ed2b499 100644 --- a/crates/db_schema/src/impls/local_user_language.rs +++ b/crates/db_schema/src/impls/local_user_language.rs @@ -9,7 +9,7 @@ impl LocalUserLanguage { /// /// If no language_id vector is given, it will show all languages pub fn update_user_languages( - conn: &PgConnection, + conn: &mut PgConnection, language_ids: Option>, for_local_user_id: LocalUserId, ) -> Result<(), Error> { @@ -23,7 +23,7 @@ impl LocalUserLanguage { .collect(), ); - conn.build_transaction().read_write().run(|| { + conn.build_transaction().read_write().run(|conn| { // Clear the current user languages delete(local_user_language.filter(local_user_id.eq(for_local_user_id))).execute(conn)?; diff --git a/crates/db_schema/src/impls/moderator.rs b/crates/db_schema/src/impls/moderator.rs index 976db493..6ec2f81b 100644 --- a/crates/db_schema/src/impls/moderator.rs +++ b/crates/db_schema/src/impls/moderator.rs @@ -4,19 +4,23 @@ use diesel::{dsl::*, result::Error, *}; impl Crud for ModRemovePost { type Form = ModRemovePostForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_remove_post::dsl::*; mod_remove_post.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModRemovePostForm) -> Result { use crate::schema::mod_remove_post::dsl::*; insert_into(mod_remove_post) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result { + fn update( + conn: &mut PgConnection, + from_id: i32, + form: &ModRemovePostForm, + ) -> Result { use crate::schema::mod_remove_post::dsl::*; diesel::update(mod_remove_post.find(from_id)) .set(form) @@ -27,19 +31,19 @@ impl Crud for ModRemovePost { impl Crud for ModLockPost { type Form = ModLockPostForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_lock_post::dsl::*; mod_lock_post.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModLockPostForm) -> Result { use crate::schema::mod_lock_post::dsl::*; insert_into(mod_lock_post) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result { + fn update(conn: &mut PgConnection, from_id: i32, form: &ModLockPostForm) -> Result { use crate::schema::mod_lock_post::dsl::*; diesel::update(mod_lock_post.find(from_id)) .set(form) @@ -50,19 +54,23 @@ impl Crud for ModLockPost { impl Crud for ModStickyPost { type Form = ModStickyPostForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_sticky_post::dsl::*; mod_sticky_post.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModStickyPostForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModStickyPostForm) -> Result { use crate::schema::mod_sticky_post::dsl::*; insert_into(mod_sticky_post) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &ModStickyPostForm) -> Result { + fn update( + conn: &mut PgConnection, + from_id: i32, + form: &ModStickyPostForm, + ) -> Result { use crate::schema::mod_sticky_post::dsl::*; diesel::update(mod_sticky_post.find(from_id)) .set(form) @@ -73,19 +81,23 @@ impl Crud for ModStickyPost { impl Crud for ModRemoveComment { type Form = ModRemoveCommentForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_remove_comment::dsl::*; mod_remove_comment.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModRemoveCommentForm) -> Result { use crate::schema::mod_remove_comment::dsl::*; insert_into(mod_remove_comment) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result { + fn update( + conn: &mut PgConnection, + from_id: i32, + form: &ModRemoveCommentForm, + ) -> Result { use crate::schema::mod_remove_comment::dsl::*; diesel::update(mod_remove_comment.find(from_id)) .set(form) @@ -96,12 +108,12 @@ impl Crud for ModRemoveComment { impl Crud for ModRemoveCommunity { type Form = ModRemoveCommunityForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_remove_community::dsl::*; mod_remove_community.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModRemoveCommunityForm) -> Result { use crate::schema::mod_remove_community::dsl::*; insert_into(mod_remove_community) .values(form) @@ -109,7 +121,7 @@ impl Crud for ModRemoveCommunity { } fn update( - conn: &PgConnection, + conn: &mut PgConnection, from_id: i32, form: &ModRemoveCommunityForm, ) -> Result { @@ -123,12 +135,12 @@ impl Crud for ModRemoveCommunity { impl Crud for ModBanFromCommunity { type Form = ModBanFromCommunityForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_ban_from_community::dsl::*; mod_ban_from_community.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModBanFromCommunityForm) -> Result { use crate::schema::mod_ban_from_community::dsl::*; insert_into(mod_ban_from_community) .values(form) @@ -136,7 +148,7 @@ impl Crud for ModBanFromCommunity { } fn update( - conn: &PgConnection, + conn: &mut PgConnection, from_id: i32, form: &ModBanFromCommunityForm, ) -> Result { @@ -150,17 +162,17 @@ impl Crud for ModBanFromCommunity { impl Crud for ModBan { type Form = ModBanForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_ban::dsl::*; mod_ban.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModBanForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModBanForm) -> Result { use crate::schema::mod_ban::dsl::*; insert_into(mod_ban).values(form).get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result { + fn update(conn: &mut PgConnection, from_id: i32, form: &ModBanForm) -> Result { use crate::schema::mod_ban::dsl::*; diesel::update(mod_ban.find(from_id)) .set(form) @@ -172,19 +184,23 @@ impl Crud for ModHideCommunity { type Form = ModHideCommunityForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_hide_community::dsl::*; mod_hide_community.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModHideCommunityForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModHideCommunityForm) -> Result { use crate::schema::mod_hide_community::dsl::*; insert_into(mod_hide_community) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &ModHideCommunityForm) -> Result { + fn update( + conn: &mut PgConnection, + from_id: i32, + form: &ModHideCommunityForm, + ) -> Result { use crate::schema::mod_hide_community::dsl::*; diesel::update(mod_hide_community.find(from_id)) .set(form) @@ -195,19 +211,23 @@ impl Crud for ModHideCommunity { impl Crud for ModAddCommunity { type Form = ModAddCommunityForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_add_community::dsl::*; mod_add_community.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModAddCommunityForm) -> Result { use crate::schema::mod_add_community::dsl::*; insert_into(mod_add_community) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result { + fn update( + conn: &mut PgConnection, + from_id: i32, + form: &ModAddCommunityForm, + ) -> Result { use crate::schema::mod_add_community::dsl::*; diesel::update(mod_add_community.find(from_id)) .set(form) @@ -218,12 +238,12 @@ impl Crud for ModAddCommunity { impl Crud for ModTransferCommunity { type Form = ModTransferCommunityForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_transfer_community::dsl::*; mod_transfer_community.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModTransferCommunityForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModTransferCommunityForm) -> Result { use crate::schema::mod_transfer_community::dsl::*; insert_into(mod_transfer_community) .values(form) @@ -231,7 +251,7 @@ impl Crud for ModTransferCommunity { } fn update( - conn: &PgConnection, + conn: &mut PgConnection, from_id: i32, form: &ModTransferCommunityForm, ) -> Result { @@ -245,17 +265,17 @@ impl Crud for ModTransferCommunity { impl Crud for ModAdd { type Form = ModAddForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::mod_add::dsl::*; mod_add.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &ModAddForm) -> Result { + fn create(conn: &mut PgConnection, form: &ModAddForm) -> Result { use crate::schema::mod_add::dsl::*; insert_into(mod_add).values(form).get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result { + fn update(conn: &mut PgConnection, from_id: i32, form: &ModAddForm) -> Result { use crate::schema::mod_add::dsl::*; diesel::update(mod_add.find(from_id)) .set(form) @@ -266,19 +286,19 @@ impl Crud for ModAdd { impl Crud for AdminPurgePerson { type Form = AdminPurgePersonForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::admin_purge_person::dsl::*; admin_purge_person.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &Self::Form) -> Result { + fn create(conn: &mut PgConnection, form: &Self::Form) -> Result { use crate::schema::admin_purge_person::dsl::*; insert_into(admin_purge_person) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &Self::Form) -> Result { + fn update(conn: &mut PgConnection, from_id: i32, form: &Self::Form) -> Result { use crate::schema::admin_purge_person::dsl::*; diesel::update(admin_purge_person.find(from_id)) .set(form) @@ -289,19 +309,19 @@ impl Crud for AdminPurgePerson { impl Crud for AdminPurgeCommunity { type Form = AdminPurgeCommunityForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::admin_purge_community::dsl::*; admin_purge_community.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &Self::Form) -> Result { + fn create(conn: &mut PgConnection, form: &Self::Form) -> Result { use crate::schema::admin_purge_community::dsl::*; insert_into(admin_purge_community) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &Self::Form) -> Result { + fn update(conn: &mut PgConnection, from_id: i32, form: &Self::Form) -> Result { use crate::schema::admin_purge_community::dsl::*; diesel::update(admin_purge_community.find(from_id)) .set(form) @@ -312,19 +332,19 @@ impl Crud for AdminPurgeCommunity { impl Crud for AdminPurgePost { type Form = AdminPurgePostForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::admin_purge_post::dsl::*; admin_purge_post.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &Self::Form) -> Result { + fn create(conn: &mut PgConnection, form: &Self::Form) -> Result { use crate::schema::admin_purge_post::dsl::*; insert_into(admin_purge_post) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &Self::Form) -> Result { + fn update(conn: &mut PgConnection, from_id: i32, form: &Self::Form) -> Result { use crate::schema::admin_purge_post::dsl::*; diesel::update(admin_purge_post.find(from_id)) .set(form) @@ -335,19 +355,19 @@ impl Crud for AdminPurgePost { impl Crud for AdminPurgeComment { type Form = AdminPurgeCommentForm; type IdType = i32; - fn read(conn: &PgConnection, from_id: i32) -> Result { + fn read(conn: &mut PgConnection, from_id: i32) -> Result { use crate::schema::admin_purge_comment::dsl::*; admin_purge_comment.find(from_id).first::(conn) } - fn create(conn: &PgConnection, form: &Self::Form) -> Result { + fn create(conn: &mut PgConnection, form: &Self::Form) -> Result { use crate::schema::admin_purge_comment::dsl::*; insert_into(admin_purge_comment) .values(form) .get_result::(conn) } - fn update(conn: &PgConnection, from_id: i32, form: &Self::Form) -> Result { + fn update(conn: &mut PgConnection, from_id: i32, form: &Self::Form) -> Result { use crate::schema::admin_purge_comment::dsl::*; diesel::update(admin_purge_comment.find(from_id)) .set(form) @@ -368,7 +388,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_mod = PersonForm { name: "the mod".into(), @@ -376,7 +396,7 @@ mod tests { ..PersonForm::default() }; - let inserted_mod = Person::create(&conn, &new_mod).unwrap(); + let inserted_mod = Person::create(conn, &new_mod).unwrap(); let new_person = PersonForm { name: "jim2".into(), @@ -384,7 +404,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let new_community = CommunityForm { name: "mod_community".to_string(), @@ -393,7 +413,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let new_post = PostForm { name: "A test post thweep".into(), @@ -402,7 +422,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let comment_form = CommentForm { content: "A test comment".into(), @@ -411,7 +431,7 @@ mod tests { ..CommentForm::default() }; - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); // Now the actual tests @@ -422,8 +442,8 @@ mod tests { reason: None, removed: None, }; - let inserted_mod_remove_post = ModRemovePost::create(&conn, &mod_remove_post_form).unwrap(); - let read_mod_remove_post = ModRemovePost::read(&conn, inserted_mod_remove_post.id).unwrap(); + let inserted_mod_remove_post = ModRemovePost::create(conn, &mod_remove_post_form).unwrap(); + let read_mod_remove_post = ModRemovePost::read(conn, inserted_mod_remove_post.id).unwrap(); let expected_mod_remove_post = ModRemovePost { id: inserted_mod_remove_post.id, post_id: inserted_post.id, @@ -440,8 +460,8 @@ mod tests { post_id: inserted_post.id, locked: None, }; - let inserted_mod_lock_post = ModLockPost::create(&conn, &mod_lock_post_form).unwrap(); - let read_mod_lock_post = ModLockPost::read(&conn, inserted_mod_lock_post.id).unwrap(); + let inserted_mod_lock_post = ModLockPost::create(conn, &mod_lock_post_form).unwrap(); + let read_mod_lock_post = ModLockPost::read(conn, inserted_mod_lock_post.id).unwrap(); let expected_mod_lock_post = ModLockPost { id: inserted_mod_lock_post.id, post_id: inserted_post.id, @@ -457,8 +477,8 @@ mod tests { post_id: inserted_post.id, stickied: None, }; - let inserted_mod_sticky_post = ModStickyPost::create(&conn, &mod_sticky_post_form).unwrap(); - let read_mod_sticky_post = ModStickyPost::read(&conn, inserted_mod_sticky_post.id).unwrap(); + let inserted_mod_sticky_post = ModStickyPost::create(conn, &mod_sticky_post_form).unwrap(); + let read_mod_sticky_post = ModStickyPost::read(conn, inserted_mod_sticky_post.id).unwrap(); let expected_mod_sticky_post = ModStickyPost { id: inserted_mod_sticky_post.id, post_id: inserted_post.id, @@ -476,9 +496,9 @@ mod tests { removed: None, }; let inserted_mod_remove_comment = - ModRemoveComment::create(&conn, &mod_remove_comment_form).unwrap(); + ModRemoveComment::create(conn, &mod_remove_comment_form).unwrap(); let read_mod_remove_comment = - ModRemoveComment::read(&conn, inserted_mod_remove_comment.id).unwrap(); + ModRemoveComment::read(conn, inserted_mod_remove_comment.id).unwrap(); let expected_mod_remove_comment = ModRemoveComment { id: inserted_mod_remove_comment.id, comment_id: inserted_comment.id, @@ -498,9 +518,9 @@ mod tests { expires: None, }; let inserted_mod_remove_community = - ModRemoveCommunity::create(&conn, &mod_remove_community_form).unwrap(); + ModRemoveCommunity::create(conn, &mod_remove_community_form).unwrap(); let read_mod_remove_community = - ModRemoveCommunity::read(&conn, inserted_mod_remove_community.id).unwrap(); + ModRemoveCommunity::read(conn, inserted_mod_remove_community.id).unwrap(); let expected_mod_remove_community = ModRemoveCommunity { id: inserted_mod_remove_community.id, community_id: inserted_community.id, @@ -522,9 +542,9 @@ mod tests { expires: None, }; let inserted_mod_ban_from_community = - ModBanFromCommunity::create(&conn, &mod_ban_from_community_form).unwrap(); + ModBanFromCommunity::create(conn, &mod_ban_from_community_form).unwrap(); let read_mod_ban_from_community = - ModBanFromCommunity::read(&conn, inserted_mod_ban_from_community.id).unwrap(); + ModBanFromCommunity::read(conn, inserted_mod_ban_from_community.id).unwrap(); let expected_mod_ban_from_community = ModBanFromCommunity { id: inserted_mod_ban_from_community.id, community_id: inserted_community.id, @@ -545,8 +565,8 @@ mod tests { banned: None, expires: None, }; - let inserted_mod_ban = ModBan::create(&conn, &mod_ban_form).unwrap(); - let read_mod_ban = ModBan::read(&conn, inserted_mod_ban.id).unwrap(); + let inserted_mod_ban = ModBan::create(conn, &mod_ban_form).unwrap(); + let read_mod_ban = ModBan::read(conn, inserted_mod_ban.id).unwrap(); let expected_mod_ban = ModBan { id: inserted_mod_ban.id, mod_person_id: inserted_mod.id, @@ -566,9 +586,9 @@ mod tests { removed: None, }; let inserted_mod_add_community = - ModAddCommunity::create(&conn, &mod_add_community_form).unwrap(); + ModAddCommunity::create(conn, &mod_add_community_form).unwrap(); let read_mod_add_community = - ModAddCommunity::read(&conn, inserted_mod_add_community.id).unwrap(); + ModAddCommunity::read(conn, inserted_mod_add_community.id).unwrap(); let expected_mod_add_community = ModAddCommunity { id: inserted_mod_add_community.id, community_id: inserted_community.id, @@ -585,8 +605,8 @@ mod tests { other_person_id: inserted_person.id, removed: None, }; - let inserted_mod_add = ModAdd::create(&conn, &mod_add_form).unwrap(); - let read_mod_add = ModAdd::read(&conn, inserted_mod_add.id).unwrap(); + let inserted_mod_add = ModAdd::create(conn, &mod_add_form).unwrap(); + let read_mod_add = ModAdd::read(conn, inserted_mod_add.id).unwrap(); let expected_mod_add = ModAdd { id: inserted_mod_add.id, mod_person_id: inserted_mod.id, @@ -595,11 +615,11 @@ mod tests { when_: inserted_mod_add.when_, }; - Comment::delete(&conn, inserted_comment.id).unwrap(); - Post::delete(&conn, inserted_post.id).unwrap(); - Community::delete(&conn, inserted_community.id).unwrap(); - Person::delete(&conn, inserted_person.id).unwrap(); - Person::delete(&conn, inserted_mod.id).unwrap(); + Comment::delete(conn, inserted_comment.id).unwrap(); + Post::delete(conn, inserted_post.id).unwrap(); + Community::delete(conn, inserted_community.id).unwrap(); + Person::delete(conn, inserted_person.id).unwrap(); + Person::delete(conn, inserted_mod.id).unwrap(); assert_eq!(expected_mod_remove_post, read_mod_remove_post); assert_eq!(expected_mod_lock_post, read_mod_lock_post); diff --git a/crates/db_schema/src/impls/password_reset_request.rs b/crates/db_schema/src/impls/password_reset_request.rs index 780c6c28..dfa56e20 100644 --- a/crates/db_schema/src/impls/password_reset_request.rs +++ b/crates/db_schema/src/impls/password_reset_request.rs @@ -10,18 +10,18 @@ use sha2::{Digest, Sha256}; impl Crud for PasswordResetRequest { type Form = PasswordResetRequestForm; type IdType = i32; - fn read(conn: &PgConnection, password_reset_request_id: i32) -> Result { + fn read(conn: &mut PgConnection, password_reset_request_id: i32) -> Result { password_reset_request .find(password_reset_request_id) .first::(conn) } - fn create(conn: &PgConnection, form: &PasswordResetRequestForm) -> Result { + fn create(conn: &mut PgConnection, form: &PasswordResetRequestForm) -> Result { insert_into(password_reset_request) .values(form) .get_result::(conn) } fn update( - conn: &PgConnection, + conn: &mut PgConnection, password_reset_request_id: i32, form: &PasswordResetRequestForm, ) -> Result { @@ -33,7 +33,7 @@ impl Crud for PasswordResetRequest { impl PasswordResetRequest { pub fn create_token( - conn: &PgConnection, + conn: &mut PgConnection, from_local_user_id: LocalUserId, token: &str, ) -> Result { @@ -48,7 +48,10 @@ impl PasswordResetRequest { Self::create(conn, &form) } - pub fn read_from_token(conn: &PgConnection, token: &str) -> Result { + pub fn read_from_token( + conn: &mut PgConnection, + token: &str, + ) -> Result { let mut hasher = Sha256::new(); hasher.update(token); let token_hash: String = bytes_to_hex(hasher.finalize().to_vec()); @@ -83,7 +86,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "thommy prw".into(), @@ -91,7 +94,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let new_local_user = LocalUserForm { person_id: Some(inserted_person.id), @@ -99,13 +102,13 @@ mod tests { ..LocalUserForm::default() }; - let inserted_local_user = LocalUser::create(&conn, &new_local_user).unwrap(); + let inserted_local_user = LocalUser::create(conn, &new_local_user).unwrap(); let token = "nope"; let token_encrypted_ = "ca3704aa0b06f5954c79ee837faa152d84d6b2d42838f0637a15eda8337dbdce"; let inserted_password_reset_request = - PasswordResetRequest::create_token(&conn, inserted_local_user.id, token).unwrap(); + PasswordResetRequest::create_token(conn, inserted_local_user.id, token).unwrap(); let expected_password_reset_request = PasswordResetRequest { id: inserted_password_reset_request.id, @@ -114,8 +117,8 @@ mod tests { published: inserted_password_reset_request.published, }; - let read_password_reset_request = PasswordResetRequest::read_from_token(&conn, token).unwrap(); - let num_deleted = Person::delete(&conn, inserted_person.id).unwrap(); + let read_password_reset_request = PasswordResetRequest::read_from_token(conn, token).unwrap(); + let num_deleted = Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(expected_password_reset_request, read_password_reset_request); assert_eq!( diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index 6e4398f6..de99d4b6 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -66,124 +66,26 @@ mod safe_type { } } -mod safe_type_alias_1 { - use crate::{schema::person_alias_1::columns::*, source::person::PersonAlias1, traits::ToSafe}; - - type Columns = ( - id, - name, - display_name, - avatar, - banned, - published, - updated, - actor_id, - bio, - local, - banner, - deleted, - inbox_url, - shared_inbox_url, - matrix_user_id, - admin, - bot_account, - ban_expires, - ); - - impl ToSafe for PersonAlias1 { - type SafeColumns = Columns; - fn safe_columns_tuple() -> Self::SafeColumns { - ( - id, - name, - display_name, - avatar, - banned, - published, - updated, - actor_id, - bio, - local, - banner, - deleted, - inbox_url, - shared_inbox_url, - matrix_user_id, - admin, - bot_account, - ban_expires, - ) - } - } -} - -mod safe_type_alias_2 { - use crate::{schema::person_alias_2::columns::*, source::person::PersonAlias2, traits::ToSafe}; - - type Columns = ( - id, - name, - display_name, - avatar, - banned, - published, - updated, - actor_id, - bio, - local, - banner, - deleted, - inbox_url, - shared_inbox_url, - matrix_user_id, - admin, - bot_account, - ban_expires, - ); - - impl ToSafe for PersonAlias2 { - type SafeColumns = Columns; - fn safe_columns_tuple() -> Self::SafeColumns { - ( - id, - name, - display_name, - avatar, - banned, - published, - updated, - actor_id, - bio, - local, - banner, - deleted, - inbox_url, - shared_inbox_url, - matrix_user_id, - admin, - bot_account, - ban_expires, - ) - } - } -} - impl Crud for Person { type Form = PersonForm; type IdType = PersonId; - fn read(conn: &PgConnection, person_id: PersonId) -> Result { + fn read(conn: &mut PgConnection, person_id: PersonId) -> Result { person .filter(deleted.eq(false)) .find(person_id) .first::(conn) } - fn delete(conn: &PgConnection, person_id: PersonId) -> Result { + fn delete(conn: &mut PgConnection, person_id: PersonId) -> Result { diesel::delete(person.find(person_id)).execute(conn) } - fn create(conn: &PgConnection, form: &PersonForm) -> Result { + fn create(conn: &mut PgConnection, form: &PersonForm) -> Result { insert_into(person).values(form).get_result::(conn) } - fn update(conn: &PgConnection, person_id: PersonId, form: &PersonForm) -> Result { + fn update( + conn: &mut PgConnection, + person_id: PersonId, + form: &PersonForm, + ) -> Result { diesel::update(person.find(person_id)) .set(form) .get_result::(conn) @@ -192,7 +94,7 @@ impl Crud for Person { impl Person { pub fn ban_person( - conn: &PgConnection, + conn: &mut PgConnection, person_id: PersonId, ban: bool, expires: Option, @@ -202,19 +104,23 @@ impl Person { .get_result::(conn) } - pub fn add_admin(conn: &PgConnection, person_id: PersonId, added: bool) -> Result { + pub fn add_admin( + conn: &mut PgConnection, + person_id: PersonId, + added: bool, + ) -> Result { diesel::update(person.find(person_id)) .set(admin.eq(added)) .get_result::(conn) } - pub fn mark_as_updated(conn: &PgConnection, person_id: PersonId) -> Result { + pub fn mark_as_updated(conn: &mut PgConnection, person_id: PersonId) -> Result { diesel::update(person.find(person_id)) .set((last_refreshed_at.eq(naive_now()),)) .get_result::(conn) } - pub fn delete_account(conn: &PgConnection, person_id: PersonId) -> Result { + pub fn delete_account(conn: &mut PgConnection, person_id: PersonId) -> Result { use crate::schema::local_user; // Set the local user info to none @@ -238,7 +144,7 @@ impl Person { .get_result::(conn) } - pub fn upsert(conn: &PgConnection, person_form: &PersonForm) -> Result { + pub fn upsert(conn: &mut PgConnection, person_form: &PersonForm) -> Result { insert_into(person) .values(person_form) .on_conflict(actor_id) @@ -248,7 +154,7 @@ impl Person { } pub fn update_deleted( - conn: &PgConnection, + conn: &mut PgConnection, person_id: PersonId, new_deleted: bool, ) -> Result { @@ -258,13 +164,16 @@ impl Person { .get_result::(conn) } - pub fn leave_admin(conn: &PgConnection, person_id: PersonId) -> Result { + pub fn leave_admin(conn: &mut PgConnection, person_id: PersonId) -> Result { diesel::update(person.find(person_id)) .set(admin.eq(false)) .get_result::(conn) } - pub fn remove_avatar_and_banner(conn: &PgConnection, person_id: PersonId) -> Result { + pub fn remove_avatar_and_banner( + conn: &mut PgConnection, + person_id: PersonId, + ) -> Result { diesel::update(person.find(person_id)) .set(( avatar.eq::>(None), @@ -283,7 +192,7 @@ pub fn is_banned(banned_: bool, expires: Option) -> bool } impl ApubActor for Person { - fn read_from_apub_id(conn: &PgConnection, object_id: &DbUrl) -> Result, Error> { + fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result, Error> { use crate::schema::person::dsl::*; Ok( person @@ -296,7 +205,7 @@ impl ApubActor for Person { } fn read_from_name( - conn: &PgConnection, + conn: &mut PgConnection, from_name: &str, include_deleted: bool, ) -> Result { @@ -311,7 +220,7 @@ impl ApubActor for Person { } fn read_from_name_and_domain( - conn: &PgConnection, + conn: &mut PgConnection, person_name: &str, protocol_domain: &str, ) -> Result { @@ -329,7 +238,7 @@ mod tests { #[test] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "holly".into(), @@ -337,7 +246,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let expected_person = Person { id: inserted_person.id, @@ -363,9 +272,9 @@ mod tests { ban_expires: None, }; - let read_person = Person::read(&conn, inserted_person.id).unwrap(); - let updated_person = Person::update(&conn, inserted_person.id, &new_person).unwrap(); - let num_deleted = Person::delete(&conn, inserted_person.id).unwrap(); + let read_person = Person::read(conn, inserted_person.id).unwrap(); + let updated_person = Person::update(conn, inserted_person.id, &new_person).unwrap(); + let num_deleted = Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(expected_person, read_person); assert_eq!(expected_person, inserted_person); diff --git a/crates/db_schema/src/impls/person_block.rs b/crates/db_schema/src/impls/person_block.rs index d1b77680..6ee617d6 100644 --- a/crates/db_schema/src/impls/person_block.rs +++ b/crates/db_schema/src/impls/person_block.rs @@ -7,7 +7,7 @@ use diesel::{dsl::*, result::Error, *}; impl PersonBlock { pub fn read( - conn: &PgConnection, + conn: &mut PgConnection, for_person_id: PersonId, for_recipient_id: PersonId, ) -> Result { @@ -21,7 +21,7 @@ impl PersonBlock { impl Blockable for PersonBlock { type Form = PersonBlockForm; - fn block(conn: &PgConnection, person_block_form: &PersonBlockForm) -> Result { + fn block(conn: &mut PgConnection, person_block_form: &PersonBlockForm) -> Result { use crate::schema::person_block::dsl::*; insert_into(person_block) .values(person_block_form) @@ -30,7 +30,7 @@ impl Blockable for PersonBlock { .set(person_block_form) .get_result::(conn) } - fn unblock(conn: &PgConnection, person_block_form: &Self::Form) -> Result { + fn unblock(conn: &mut PgConnection, person_block_form: &Self::Form) -> Result { use crate::schema::person_block::dsl::*; diesel::delete( person_block diff --git a/crates/db_schema/src/impls/person_mention.rs b/crates/db_schema/src/impls/person_mention.rs index 3ddcd664..fc91c76e 100644 --- a/crates/db_schema/src/impls/person_mention.rs +++ b/crates/db_schema/src/impls/person_mention.rs @@ -8,12 +8,15 @@ use diesel::{dsl::*, result::Error, *}; impl Crud for PersonMention { type Form = PersonMentionForm; type IdType = PersonMentionId; - fn read(conn: &PgConnection, person_mention_id: PersonMentionId) -> Result { + fn read(conn: &mut PgConnection, person_mention_id: PersonMentionId) -> Result { use crate::schema::person_mention::dsl::*; person_mention.find(person_mention_id).first::(conn) } - fn create(conn: &PgConnection, person_mention_form: &PersonMentionForm) -> Result { + fn create( + conn: &mut PgConnection, + person_mention_form: &PersonMentionForm, + ) -> Result { use crate::schema::person_mention::dsl::*; // since the return here isnt utilized, we dont need to do an update // but get_result doesnt return the existing row here @@ -26,7 +29,7 @@ impl Crud for PersonMention { } fn update( - conn: &PgConnection, + conn: &mut PgConnection, person_mention_id: PersonMentionId, person_mention_form: &PersonMentionForm, ) -> Result { @@ -39,7 +42,7 @@ impl Crud for PersonMention { impl PersonMention { pub fn update_read( - conn: &PgConnection, + conn: &mut PgConnection, person_mention_id: PersonMentionId, new_read: bool, ) -> Result { @@ -50,7 +53,7 @@ impl PersonMention { } pub fn mark_all_as_read( - conn: &PgConnection, + conn: &mut PgConnection, for_recipient_id: PersonId, ) -> Result, Error> { use crate::schema::person_mention::dsl::*; @@ -63,7 +66,7 @@ impl PersonMention { .get_results::(conn) } pub fn read_by_comment_and_person( - conn: &PgConnection, + conn: &mut PgConnection, for_comment_id: CommentId, for_recipient_id: PersonId, ) -> Result { @@ -93,7 +96,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "terrylake".into(), @@ -101,7 +104,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let recipient_form = PersonForm { name: "terrylakes recipient".into(), @@ -109,7 +112,7 @@ mod tests { ..PersonForm::default() }; - let inserted_recipient = Person::create(&conn, &recipient_form).unwrap(); + let inserted_recipient = Person::create(conn, &recipient_form).unwrap(); let new_community = CommunityForm { name: "test community lake".to_string(), @@ -118,7 +121,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let new_post = PostForm { name: "A test post".into(), @@ -127,7 +130,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let comment_form = CommentForm { content: "A test comment".into(), @@ -136,7 +139,7 @@ mod tests { ..CommentForm::default() }; - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); let person_mention_form = PersonMentionForm { recipient_id: inserted_recipient.id, @@ -144,7 +147,7 @@ mod tests { read: None, }; - let inserted_mention = PersonMention::create(&conn, &person_mention_form).unwrap(); + let inserted_mention = PersonMention::create(conn, &person_mention_form).unwrap(); let expected_mention = PersonMention { id: inserted_mention.id, @@ -154,14 +157,14 @@ mod tests { published: inserted_mention.published, }; - let read_mention = PersonMention::read(&conn, inserted_mention.id).unwrap(); + let read_mention = PersonMention::read(conn, inserted_mention.id).unwrap(); let updated_mention = - PersonMention::update(&conn, inserted_mention.id, &person_mention_form).unwrap(); - Comment::delete(&conn, inserted_comment.id).unwrap(); - Post::delete(&conn, inserted_post.id).unwrap(); - Community::delete(&conn, inserted_community.id).unwrap(); - Person::delete(&conn, inserted_person.id).unwrap(); - Person::delete(&conn, inserted_recipient.id).unwrap(); + PersonMention::update(conn, inserted_mention.id, &person_mention_form).unwrap(); + Comment::delete(conn, inserted_comment.id).unwrap(); + Post::delete(conn, inserted_post.id).unwrap(); + Community::delete(conn, inserted_community.id).unwrap(); + Person::delete(conn, inserted_person.id).unwrap(); + Person::delete(conn, inserted_recipient.id).unwrap(); assert_eq!(expected_mention, read_mention); assert_eq!(expected_mention, inserted_mention); diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index 07c652e3..4fa60159 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -19,22 +19,22 @@ use url::Url; impl Crud for Post { type Form = PostForm; type IdType = PostId; - fn read(conn: &PgConnection, post_id: PostId) -> Result { + fn read(conn: &mut PgConnection, post_id: PostId) -> Result { use crate::schema::post::dsl::*; post.find(post_id).first::(conn) } - fn delete(conn: &PgConnection, post_id: PostId) -> Result { + fn delete(conn: &mut PgConnection, post_id: PostId) -> Result { use crate::schema::post::dsl::*; diesel::delete(post.find(post_id)).execute(conn) } - fn create(conn: &PgConnection, new_post: &PostForm) -> Result { + fn create(conn: &mut PgConnection, new_post: &PostForm) -> Result { use crate::schema::post::dsl::*; insert_into(post).values(new_post).get_result::(conn) } - fn update(conn: &PgConnection, post_id: PostId, new_post: &PostForm) -> Result { + fn update(conn: &mut PgConnection, post_id: PostId, new_post: &PostForm) -> Result { use crate::schema::post::dsl::*; diesel::update(post.find(post_id)) .set(new_post) @@ -44,7 +44,7 @@ impl Crud for Post { impl Post { pub fn list_for_community( - conn: &PgConnection, + conn: &mut PgConnection, the_community_id: CommunityId, ) -> Result, Error> { use crate::schema::post::dsl::*; @@ -58,7 +58,11 @@ impl Post { .load::(conn) } - pub fn update_ap_id(conn: &PgConnection, post_id: PostId, apub_id: DbUrl) -> Result { + pub fn update_ap_id( + conn: &mut PgConnection, + post_id: PostId, + apub_id: DbUrl, + ) -> Result { use crate::schema::post::dsl::*; diesel::update(post.find(post_id)) @@ -67,7 +71,7 @@ impl Post { } pub fn permadelete_for_creator( - conn: &PgConnection, + conn: &mut PgConnection, for_creator_id: PersonId, ) -> Result, Error> { use crate::schema::post::dsl::*; @@ -87,7 +91,7 @@ impl Post { } pub fn update_deleted( - conn: &PgConnection, + conn: &mut PgConnection, post_id: PostId, new_deleted: bool, ) -> Result { @@ -98,7 +102,7 @@ impl Post { } pub fn update_removed( - conn: &PgConnection, + conn: &mut PgConnection, post_id: PostId, new_removed: bool, ) -> Result { @@ -109,7 +113,7 @@ impl Post { } pub fn update_removed_for_creator( - conn: &PgConnection, + conn: &mut PgConnection, for_creator_id: PersonId, for_community_id: Option, new_removed: bool, @@ -129,7 +133,7 @@ impl Post { } pub fn update_locked( - conn: &PgConnection, + conn: &mut PgConnection, post_id: PostId, new_locked: bool, ) -> Result { @@ -140,7 +144,7 @@ impl Post { } pub fn update_stickied( - conn: &PgConnection, + conn: &mut PgConnection, post_id: PostId, new_stickied: bool, ) -> Result { @@ -154,7 +158,7 @@ impl Post { person_id == post_creator_id } - pub fn upsert(conn: &PgConnection, post_form: &PostForm) -> Result { + pub fn upsert(conn: &mut PgConnection, post_form: &PostForm) -> Result { use crate::schema::post::dsl::*; insert_into(post) .values(post_form) @@ -163,7 +167,7 @@ impl Post { .set(post_form) .get_result::(conn) } - pub fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result, Error> { + pub fn read_from_apub_id(conn: &mut PgConnection, object_id: Url) -> Result, Error> { use crate::schema::post::dsl::*; let object_id: DbUrl = object_id.into(); Ok( @@ -176,7 +180,7 @@ impl Post { } pub fn fetch_pictrs_posts_for_creator( - conn: &PgConnection, + conn: &mut PgConnection, for_creator_id: PersonId, ) -> Result, Error> { use crate::schema::post::dsl::*; @@ -190,7 +194,7 @@ impl Post { /// Sets the url and thumbnails fields to None pub fn remove_pictrs_post_images_and_thumbnails_for_creator( - conn: &PgConnection, + conn: &mut PgConnection, for_creator_id: PersonId, ) -> Result, Error> { use crate::schema::post::dsl::*; @@ -209,7 +213,7 @@ impl Post { } pub fn fetch_pictrs_posts_for_community( - conn: &PgConnection, + conn: &mut PgConnection, for_community_id: CommunityId, ) -> Result, Error> { use crate::schema::post::dsl::*; @@ -222,7 +226,7 @@ impl Post { /// Sets the url and thumbnails fields to None pub fn remove_pictrs_post_images_and_thumbnails_for_community( - conn: &PgConnection, + conn: &mut PgConnection, for_community_id: CommunityId, ) -> Result, Error> { use crate::schema::post::dsl::*; @@ -244,7 +248,7 @@ impl Post { impl Likeable for PostLike { type Form = PostLikeForm; type IdType = PostId; - fn like(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result { + fn like(conn: &mut PgConnection, post_like_form: &PostLikeForm) -> Result { use crate::schema::post_like::dsl::*; insert_into(post_like) .values(post_like_form) @@ -253,7 +257,7 @@ impl Likeable for PostLike { .set(post_like_form) .get_result::(conn) } - fn remove(conn: &PgConnection, person_id: PersonId, post_id: PostId) -> Result { + fn remove(conn: &mut PgConnection, person_id: PersonId, post_id: PostId) -> Result { use crate::schema::post_like::dsl; diesel::delete( dsl::post_like @@ -266,7 +270,7 @@ impl Likeable for PostLike { impl Saveable for PostSaved { type Form = PostSavedForm; - fn save(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result { + fn save(conn: &mut PgConnection, post_saved_form: &PostSavedForm) -> Result { use crate::schema::post_saved::dsl::*; insert_into(post_saved) .values(post_saved_form) @@ -275,7 +279,7 @@ impl Saveable for PostSaved { .set(post_saved_form) .get_result::(conn) } - fn unsave(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result { + fn unsave(conn: &mut PgConnection, post_saved_form: &PostSavedForm) -> Result { use crate::schema::post_saved::dsl::*; diesel::delete( post_saved @@ -288,7 +292,7 @@ impl Saveable for PostSaved { impl Readable for PostRead { type Form = PostReadForm; - fn mark_as_read(conn: &PgConnection, post_read_form: &PostReadForm) -> Result { + fn mark_as_read(conn: &mut PgConnection, post_read_form: &PostReadForm) -> Result { use crate::schema::post_read::dsl::*; insert_into(post_read) .values(post_read_form) @@ -298,7 +302,10 @@ impl Readable for PostRead { .get_result::(conn) } - fn mark_as_unread(conn: &PgConnection, post_read_form: &PostReadForm) -> Result { + fn mark_as_unread( + conn: &mut PgConnection, + post_read_form: &PostReadForm, + ) -> Result { use crate::schema::post_read::dsl::*; diesel::delete( post_read @@ -339,7 +346,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "jim".into(), @@ -347,7 +354,7 @@ mod tests { ..PersonForm::default() }; - let inserted_person = Person::create(&conn, &new_person).unwrap(); + let inserted_person = Person::create(conn, &new_person).unwrap(); let new_community = CommunityForm { name: "test community_3".to_string(), @@ -356,7 +363,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); let new_post = PostForm { name: "A test post".into(), @@ -365,7 +372,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let expected_post = Post { id: inserted_post.id, @@ -397,7 +404,7 @@ mod tests { score: 1, }; - let inserted_post_like = PostLike::like(&conn, &post_like_form).unwrap(); + let inserted_post_like = PostLike::like(conn, &post_like_form).unwrap(); let expected_post_like = PostLike { id: inserted_post_like.id, @@ -413,7 +420,7 @@ mod tests { person_id: inserted_person.id, }; - let inserted_post_saved = PostSaved::save(&conn, &post_saved_form).unwrap(); + let inserted_post_saved = PostSaved::save(conn, &post_saved_form).unwrap(); let expected_post_saved = PostSaved { id: inserted_post_saved.id, @@ -428,7 +435,7 @@ mod tests { person_id: inserted_person.id, }; - let inserted_post_read = PostRead::mark_as_read(&conn, &post_read_form).unwrap(); + let inserted_post_read = PostRead::mark_as_read(conn, &post_read_form).unwrap(); let expected_post_read = PostRead { id: inserted_post_read.id, @@ -437,14 +444,14 @@ mod tests { published: inserted_post_read.published, }; - let read_post = Post::read(&conn, inserted_post.id).unwrap(); - let updated_post = Post::update(&conn, inserted_post.id, &new_post).unwrap(); - let like_removed = PostLike::remove(&conn, inserted_person.id, inserted_post.id).unwrap(); - let saved_removed = PostSaved::unsave(&conn, &post_saved_form).unwrap(); - let read_removed = PostRead::mark_as_unread(&conn, &post_read_form).unwrap(); - let num_deleted = Post::delete(&conn, inserted_post.id).unwrap(); - Community::delete(&conn, inserted_community.id).unwrap(); - Person::delete(&conn, inserted_person.id).unwrap(); + let read_post = Post::read(conn, inserted_post.id).unwrap(); + let updated_post = Post::update(conn, inserted_post.id, &new_post).unwrap(); + let like_removed = PostLike::remove(conn, inserted_person.id, inserted_post.id).unwrap(); + let saved_removed = PostSaved::unsave(conn, &post_saved_form).unwrap(); + let read_removed = PostRead::mark_as_unread(conn, &post_read_form).unwrap(); + let num_deleted = Post::delete(conn, inserted_post.id).unwrap(); + Community::delete(conn, inserted_community.id).unwrap(); + Person::delete(conn, inserted_person.id).unwrap(); assert_eq!(expected_post, read_post); assert_eq!(expected_post, inserted_post); diff --git a/crates/db_schema/src/impls/post_report.rs b/crates/db_schema/src/impls/post_report.rs index 58e2f44b..f9a1eab2 100644 --- a/crates/db_schema/src/impls/post_report.rs +++ b/crates/db_schema/src/impls/post_report.rs @@ -14,7 +14,7 @@ impl Reportable for PostReport { /// /// * `conn` - the postgres connection /// * `post_report_form` - the filled CommentReportForm to insert - fn report(conn: &PgConnection, post_report_form: &PostReportForm) -> Result { + fn report(conn: &mut PgConnection, post_report_form: &PostReportForm) -> Result { use crate::schema::post_report::dsl::*; insert_into(post_report) .values(post_report_form) @@ -27,7 +27,7 @@ impl Reportable for PostReport { /// * `report_id` - the id of the report to resolve /// * `by_resolver_id` - the id of the user resolving the report fn resolve( - conn: &PgConnection, + conn: &mut PgConnection, report_id: Self::IdType, by_resolver_id: PersonId, ) -> Result { @@ -47,7 +47,7 @@ impl Reportable for PostReport { /// * `report_id` - the id of the report to unresolve /// * `by_resolver_id` - the id of the user unresolving the report fn unresolve( - conn: &PgConnection, + conn: &mut PgConnection, report_id: Self::IdType, by_resolver_id: PersonId, ) -> Result { diff --git a/crates/db_schema/src/impls/private_message.rs b/crates/db_schema/src/impls/private_message.rs index b2407bdf..2ec1702e 100644 --- a/crates/db_schema/src/impls/private_message.rs +++ b/crates/db_schema/src/impls/private_message.rs @@ -11,12 +11,15 @@ use url::Url; impl Crud for PrivateMessage { type Form = PrivateMessageForm; type IdType = PrivateMessageId; - fn read(conn: &PgConnection, private_message_id: PrivateMessageId) -> Result { + fn read(conn: &mut PgConnection, private_message_id: PrivateMessageId) -> Result { use crate::schema::private_message::dsl::*; private_message.find(private_message_id).first::(conn) } - fn create(conn: &PgConnection, private_message_form: &PrivateMessageForm) -> Result { + fn create( + conn: &mut PgConnection, + private_message_form: &PrivateMessageForm, + ) -> Result { use crate::schema::private_message::dsl::*; insert_into(private_message) .values(private_message_form) @@ -24,7 +27,7 @@ impl Crud for PrivateMessage { } fn update( - conn: &PgConnection, + conn: &mut PgConnection, private_message_id: PrivateMessageId, private_message_form: &PrivateMessageForm, ) -> Result { @@ -33,7 +36,7 @@ impl Crud for PrivateMessage { .set(private_message_form) .get_result::(conn) } - fn delete(conn: &PgConnection, pm_id: Self::IdType) -> Result { + fn delete(conn: &mut PgConnection, pm_id: Self::IdType) -> Result { use crate::schema::private_message::dsl::*; diesel::delete(private_message.find(pm_id)).execute(conn) } @@ -41,7 +44,7 @@ impl Crud for PrivateMessage { impl PrivateMessage { pub fn update_ap_id( - conn: &PgConnection, + conn: &mut PgConnection, private_message_id: PrivateMessageId, apub_id: DbUrl, ) -> Result { @@ -53,7 +56,7 @@ impl PrivateMessage { } pub fn update_content( - conn: &PgConnection, + conn: &mut PgConnection, private_message_id: PrivateMessageId, new_content: &str, ) -> Result { @@ -64,7 +67,7 @@ impl PrivateMessage { } pub fn update_deleted( - conn: &PgConnection, + conn: &mut PgConnection, private_message_id: PrivateMessageId, new_deleted: bool, ) -> Result { @@ -75,7 +78,7 @@ impl PrivateMessage { } pub fn update_read( - conn: &PgConnection, + conn: &mut PgConnection, private_message_id: PrivateMessageId, new_read: bool, ) -> Result { @@ -86,7 +89,7 @@ impl PrivateMessage { } pub fn mark_all_as_read( - conn: &PgConnection, + conn: &mut PgConnection, for_recipient_id: PersonId, ) -> Result, Error> { use crate::schema::private_message::dsl::*; @@ -100,7 +103,7 @@ impl PrivateMessage { } pub fn upsert( - conn: &PgConnection, + conn: &mut PgConnection, private_message_form: &PrivateMessageForm, ) -> Result { use crate::schema::private_message::dsl::*; @@ -113,7 +116,7 @@ impl PrivateMessage { } pub fn read_from_apub_id( - conn: &PgConnection, + conn: &mut PgConnection, object_id: Url, ) -> Result, LemmyError> { use crate::schema::private_message::dsl::*; @@ -147,7 +150,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let creator_form = PersonForm { name: "creator_pm".into(), @@ -155,7 +158,7 @@ mod tests { ..PersonForm::default() }; - let inserted_creator = Person::create(&conn, &creator_form).unwrap(); + let inserted_creator = Person::create(conn, &creator_form).unwrap(); let recipient_form = PersonForm { name: "recipient_pm".into(), @@ -163,7 +166,7 @@ mod tests { ..PersonForm::default() }; - let inserted_recipient = Person::create(&conn, &recipient_form).unwrap(); + let inserted_recipient = Person::create(conn, &recipient_form).unwrap(); let private_message_form = PrivateMessageForm { content: "A test private message".into(), @@ -172,7 +175,7 @@ mod tests { ..PrivateMessageForm::default() }; - let inserted_private_message = PrivateMessage::create(&conn, &private_message_form).unwrap(); + let inserted_private_message = PrivateMessage::create(conn, &private_message_form).unwrap(); let expected_private_message = PrivateMessage { id: inserted_private_message.id, @@ -187,15 +190,15 @@ mod tests { local: true, }; - let read_private_message = PrivateMessage::read(&conn, inserted_private_message.id).unwrap(); + let read_private_message = PrivateMessage::read(conn, inserted_private_message.id).unwrap(); let updated_private_message = - PrivateMessage::update(&conn, inserted_private_message.id, &private_message_form).unwrap(); + PrivateMessage::update(conn, inserted_private_message.id, &private_message_form).unwrap(); let deleted_private_message = - PrivateMessage::update_deleted(&conn, inserted_private_message.id, true).unwrap(); + PrivateMessage::update_deleted(conn, inserted_private_message.id, true).unwrap(); let marked_read_private_message = - PrivateMessage::update_read(&conn, inserted_private_message.id, true).unwrap(); - Person::delete(&conn, inserted_creator.id).unwrap(); - Person::delete(&conn, inserted_recipient.id).unwrap(); + PrivateMessage::update_read(conn, inserted_private_message.id, true).unwrap(); + Person::delete(conn, inserted_creator.id).unwrap(); + Person::delete(conn, inserted_recipient.id).unwrap(); assert_eq!(expected_private_message, read_private_message); assert_eq!(expected_private_message, updated_private_message); diff --git a/crates/db_schema/src/impls/private_message_report.rs b/crates/db_schema/src/impls/private_message_report.rs index 45ced6ce..08fe4d28 100644 --- a/crates/db_schema/src/impls/private_message_report.rs +++ b/crates/db_schema/src/impls/private_message_report.rs @@ -13,7 +13,10 @@ impl Reportable for PrivateMessageReport { /// /// * `conn` - the postgres connection /// * `comment_report_form` - the filled CommentReportForm to insert - fn report(conn: &PgConnection, pm_report_form: &PrivateMessageReportForm) -> Result { + fn report( + conn: &mut PgConnection, + pm_report_form: &PrivateMessageReportForm, + ) -> Result { use crate::schema::private_message_report::dsl::*; insert_into(private_message_report) .values(pm_report_form) @@ -26,7 +29,7 @@ impl Reportable for PrivateMessageReport { /// * `report_id` - the id of the report to resolve /// * `by_resolver_id` - the id of the user resolving the report fn resolve( - conn: &PgConnection, + conn: &mut PgConnection, report_id: Self::IdType, by_resolver_id: PersonId, ) -> Result { @@ -46,7 +49,7 @@ impl Reportable for PrivateMessageReport { /// * `report_id` - the id of the report to unresolve /// * `by_resolver_id` - the id of the user unresolving the report fn unresolve( - conn: &PgConnection, + conn: &mut PgConnection, report_id: Self::IdType, by_resolver_id: PersonId, ) -> Result { diff --git a/crates/db_schema/src/impls/registration_application.rs b/crates/db_schema/src/impls/registration_application.rs index 5147dbb7..6868a1da 100644 --- a/crates/db_schema/src/impls/registration_application.rs +++ b/crates/db_schema/src/impls/registration_application.rs @@ -4,26 +4,26 @@ use diesel::{insert_into, result::Error, ExpressionMethods, PgConnection, QueryD impl Crud for RegistrationApplication { type Form = RegistrationApplicationForm; type IdType = i32; - fn create(conn: &PgConnection, form: &Self::Form) -> Result { + fn create(conn: &mut PgConnection, form: &Self::Form) -> Result { use crate::schema::registration_application::dsl::*; insert_into(registration_application) .values(form) .get_result::(conn) } - fn read(conn: &PgConnection, id_: Self::IdType) -> Result { + fn read(conn: &mut PgConnection, id_: Self::IdType) -> Result { use crate::schema::registration_application::dsl::*; registration_application.find(id_).first::(conn) } - fn update(conn: &PgConnection, id_: Self::IdType, form: &Self::Form) -> Result { + fn update(conn: &mut PgConnection, id_: Self::IdType, form: &Self::Form) -> Result { use crate::schema::registration_application::dsl::*; diesel::update(registration_application.find(id_)) .set(form) .get_result::(conn) } - fn delete(conn: &PgConnection, id_: Self::IdType) -> Result { + fn delete(conn: &mut PgConnection, id_: Self::IdType) -> Result { use crate::schema::registration_application::dsl::*; diesel::delete(registration_application.find(id_)).execute(conn) } @@ -31,7 +31,7 @@ impl Crud for RegistrationApplication { impl RegistrationApplication { pub fn find_by_local_user_id( - conn: &PgConnection, + conn: &mut PgConnection, local_user_id_: LocalUserId, ) -> Result { use crate::schema::registration_application::dsl::*; diff --git a/crates/db_schema/src/impls/secret.rs b/crates/db_schema/src/impls/secret.rs index 3fb9b32b..1f92ee24 100644 --- a/crates/db_schema/src/impls/secret.rs +++ b/crates/db_schema/src/impls/secret.rs @@ -4,12 +4,12 @@ use diesel::{result::Error, *}; impl Secret { /// Initialize the Secrets from the DB. /// Warning: You should only call this once. - pub fn init(conn: &PgConnection) -> Result { + pub fn init(conn: &mut PgConnection) -> Result { read_secrets(conn) } } -fn read_secrets(conn: &PgConnection) -> Result { +fn read_secrets(conn: &mut PgConnection) -> Result { use crate::schema::secret::dsl::*; secret.first::(conn) } diff --git a/crates/db_schema/src/impls/site.rs b/crates/db_schema/src/impls/site.rs index 6c71f076..fb944f52 100644 --- a/crates/db_schema/src/impls/site.rs +++ b/crates/db_schema/src/impls/site.rs @@ -5,35 +5,35 @@ use url::Url; impl Crud for Site { type Form = SiteForm; type IdType = i32; - fn read(conn: &PgConnection, _site_id: i32) -> Result { + fn read(conn: &mut PgConnection, _site_id: i32) -> Result { use crate::schema::site::dsl::*; site.first::(conn) } - fn create(conn: &PgConnection, new_site: &SiteForm) -> Result { + fn create(conn: &mut PgConnection, new_site: &SiteForm) -> Result { use crate::schema::site::dsl::*; insert_into(site).values(new_site).get_result::(conn) } - fn update(conn: &PgConnection, site_id: i32, new_site: &SiteForm) -> Result { + fn update(conn: &mut PgConnection, site_id: i32, new_site: &SiteForm) -> Result { use crate::schema::site::dsl::*; diesel::update(site.find(site_id)) .set(new_site) .get_result::(conn) } - fn delete(conn: &PgConnection, site_id: i32) -> Result { + fn delete(conn: &mut PgConnection, site_id: i32) -> Result { use crate::schema::site::dsl::*; diesel::delete(site.find(site_id)).execute(conn) } } impl Site { - pub fn read_local_site(conn: &PgConnection) -> Result { + pub fn read_local_site(conn: &mut PgConnection) -> Result { use crate::schema::site::dsl::*; site.order_by(id).first::(conn) } - pub fn upsert(conn: &PgConnection, site_form: &SiteForm) -> Result { + pub fn upsert(conn: &mut PgConnection, site_form: &SiteForm) -> Result { use crate::schema::site::dsl::*; insert_into(site) .values(site_form) @@ -43,7 +43,7 @@ impl Site { .get_result::(conn) } - pub fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result, Error> { + pub fn read_from_apub_id(conn: &mut PgConnection, object_id: Url) -> Result, Error> { use crate::schema::site::dsl::*; let object_id: DbUrl = object_id.into(); Ok( @@ -55,7 +55,7 @@ impl Site { ) } - pub fn read_remote_sites(conn: &PgConnection) -> Result, Error> { + pub fn read_remote_sites(conn: &mut PgConnection) -> Result, Error> { use crate::schema::site::dsl::*; site.order_by(id).offset(1).get_results::(conn) } diff --git a/crates/db_schema/src/lib.rs b/crates/db_schema/src/lib.rs index 901ff287..086c7029 100644 --- a/crates/db_schema/src/lib.rs +++ b/crates/db_schema/src/lib.rs @@ -48,7 +48,7 @@ pub enum CommentSortType { Old, } -#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq)] +#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)] pub enum ListingType { All, Local, @@ -65,14 +65,14 @@ pub enum SearchType { Url, } -#[derive(EnumString, Display, Debug, PartialEq, Serialize, Deserialize, Clone, Copy)] +#[derive(EnumString, Display, Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy)] pub enum SubscribedType { Subscribed, NotSubscribed, Pending, } -#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq)] +#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)] pub enum ModlogActionType { All, ModRemovePost, diff --git a/crates/db_schema/src/newtypes.rs b/crates/db_schema/src/newtypes.rs index 4431103c..5d23b12a 100644 --- a/crates/db_schema/src/newtypes.rs +++ b/crates/db_schema/src/newtypes.rs @@ -86,9 +86,9 @@ pub struct LocalUserLanguageId(pub i32); pub struct CommentReplyId(i32); #[repr(transparent)] -#[derive(Clone, PartialEq, Serialize, Deserialize, Debug)] +#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] #[cfg_attr(feature = "full", derive(AsExpression, FromSqlRow))] -#[cfg_attr(feature = "full", sql_type = "diesel::sql_types::Text")] +#[cfg_attr(feature = "full", diesel(sql_type = diesel::sql_types::Text))] pub struct DbUrl(pub(crate) Url); #[derive(Serialize, Deserialize)] diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 2d6ff612..e0d7167e 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -531,59 +531,6 @@ table! { } } -// These are necessary since diesel doesn't have self joins / aliases -table! { - person_alias_1 (id) { - id -> Int4, - name -> Varchar, - display_name -> Nullable, - avatar -> Nullable, - banned -> Bool, - published -> Timestamp, - updated -> Nullable, - actor_id -> Varchar, - bio -> Nullable, - local -> Bool, - private_key -> Nullable, - public_key -> Text, - last_refreshed_at -> Timestamp, - banner -> Nullable, - deleted -> Bool, - inbox_url -> Varchar, - shared_inbox_url -> Nullable, - matrix_user_id -> Nullable, - admin -> Bool, - bot_account -> Bool, - ban_expires -> Nullable, - } -} - -table! { - person_alias_2 (id) { - id -> Int4, - name -> Varchar, - display_name -> Nullable, - avatar -> Nullable, - banned -> Bool, - published -> Timestamp, - updated -> Nullable, - actor_id -> Varchar, - bio -> Nullable, - local -> Bool, - private_key -> Nullable, - public_key -> Text, - last_refreshed_at -> Timestamp, - banner -> Nullable, - deleted -> Bool, - inbox_url -> Varchar, - shared_inbox_url -> Nullable, - matrix_user_id -> Nullable, - admin -> Bool, - bot_account -> Bool, - ban_expires -> Nullable, - } -} - table! { secret(id) { id -> Int4, @@ -677,18 +624,7 @@ table! { } } -joinable!(person_mention -> person_alias_1 (recipient_id)); -joinable!(comment_reply -> person_alias_1 (recipient_id)); -joinable!(post -> person_alias_1 (creator_id)); -joinable!(comment -> person_alias_1 (creator_id)); -joinable!(private_message_report -> person_alias_1 (resolver_id)); - -joinable!(post_report -> person_alias_2 (resolver_id)); -joinable!(comment_report -> person_alias_2 (resolver_id)); -joinable!(private_message_report -> person_alias_2 (resolver_id)); - joinable!(person_block -> person (person_id)); -joinable!(person_block -> person_alias_1 (target_id)); joinable!(comment -> person (creator_id)); joinable!(comment -> post (post_id)); @@ -800,8 +736,6 @@ allow_tables_to_appear_in_same_query!( private_message_report, site, site_aggregates, - person_alias_1, - person_alias_2, admin_purge_comment, admin_purge_community, admin_purge_person, diff --git a/crates/db_schema/src/source/activity.rs b/crates/db_schema/src/source/activity.rs index 5d09ebfd..2d256a5b 100644 --- a/crates/db_schema/src/source/activity.rs +++ b/crates/db_schema/src/source/activity.rs @@ -2,8 +2,8 @@ use crate::{newtypes::DbUrl, schema::activity}; use serde_json::Value; use std::fmt::Debug; -#[derive(PartialEq, Debug, Queryable, Identifiable)] -#[table_name = "activity"] +#[derive(PartialEq, Eq, Debug, Queryable, Identifiable)] +#[diesel(table_name = activity)] pub struct Activity { pub id: i32, pub data: Value, @@ -15,7 +15,7 @@ pub struct Activity { } #[derive(Insertable, AsChangeset)] -#[table_name = "activity"] +#[diesel(table_name = activity)] pub struct ActivityForm { pub data: Value, pub local: Option, diff --git a/crates/db_schema/src/source/comment.rs b/crates/db_schema/src/source/comment.rs index 81dba6e6..d9117bae 100644 --- a/crates/db_schema/src/source/comment.rs +++ b/crates/db_schema/src/source/comment.rs @@ -5,10 +5,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::{comment, comment_like, comment_saved}; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", belongs_to(crate::source::post::Post))] -#[cfg_attr(feature = "full", table_name = "comment")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))] +#[cfg_attr(feature = "full", diesel(table_name = comment))] pub struct Comment { pub id: CommentId, pub creator_id: PersonId, @@ -28,7 +28,7 @@ pub struct Comment { #[derive(Clone, Default)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "comment")] +#[cfg_attr(feature = "full", diesel(table_name = comment))] pub struct CommentForm { pub creator_id: PersonId, pub post_id: PostId, @@ -43,10 +43,10 @@ pub struct CommentForm { pub language_id: Option, } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))] -#[cfg_attr(feature = "full", belongs_to(Comment))] -#[cfg_attr(feature = "full", table_name = "comment_like")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))] +#[cfg_attr(feature = "full", diesel(table_name = comment_like))] pub struct CommentLike { pub id: i32, pub person_id: PersonId, @@ -58,7 +58,7 @@ pub struct CommentLike { #[derive(Clone)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "comment_like")] +#[cfg_attr(feature = "full", diesel(table_name = comment_like))] pub struct CommentLikeForm { pub person_id: PersonId, pub comment_id: CommentId, @@ -66,10 +66,10 @@ pub struct CommentLikeForm { pub score: i16, } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))] -#[cfg_attr(feature = "full", belongs_to(Comment))] -#[cfg_attr(feature = "full", table_name = "comment_saved")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))] +#[cfg_attr(feature = "full", diesel(table_name = comment_saved))] pub struct CommentSaved { pub id: i32, pub comment_id: CommentId, @@ -78,7 +78,7 @@ pub struct CommentSaved { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "comment_saved")] +#[cfg_attr(feature = "full", diesel(table_name = comment_saved))] pub struct CommentSavedForm { pub comment_id: CommentId, pub person_id: PersonId, diff --git a/crates/db_schema/src/source/comment_reply.rs b/crates/db_schema/src/source/comment_reply.rs index 015a150b..737d8df6 100644 --- a/crates/db_schema/src/source/comment_reply.rs +++ b/crates/db_schema/src/source/comment_reply.rs @@ -4,10 +4,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::comment_reply; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", belongs_to(crate::source::comment::Comment))] -#[cfg_attr(feature = "full", table_name = "comment_reply")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))] +#[cfg_attr(feature = "full", diesel(table_name = comment_reply))] /// This table keeps a list of replies to comments and posts. pub struct CommentReply { pub id: CommentReplyId, @@ -18,7 +18,7 @@ pub struct CommentReply { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "comment_reply")] +#[cfg_attr(feature = "full", diesel(table_name = comment_reply))] pub struct CommentReplyForm { pub recipient_id: PersonId, pub comment_id: CommentId, diff --git a/crates/db_schema/src/source/comment_report.rs b/crates/db_schema/src/source/comment_report.rs index 25689576..6cc328d0 100644 --- a/crates/db_schema/src/source/comment_report.rs +++ b/crates/db_schema/src/source/comment_report.rs @@ -4,10 +4,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::comment_report; -#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)] +#[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", belongs_to(crate::source::comment::Comment))] -#[cfg_attr(feature = "full", table_name = "comment_report")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))] +#[cfg_attr(feature = "full", diesel(table_name = comment_report))] pub struct CommentReport { pub id: CommentReportId, pub creator_id: PersonId, @@ -22,7 +22,7 @@ pub struct CommentReport { #[derive(Clone)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "comment_report")] +#[cfg_attr(feature = "full", diesel(table_name = comment_report))] pub struct CommentReportForm { pub creator_id: PersonId, pub comment_id: CommentId, diff --git a/crates/db_schema/src/source/community.rs b/crates/db_schema/src/source/community.rs index 498869e9..074141cc 100644 --- a/crates/db_schema/src/source/community.rs +++ b/crates/db_schema/src/source/community.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::{community, community_follower, community_moderator, community_person_ban}; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "community")] +#[cfg_attr(feature = "full", diesel(table_name = community))] pub struct Community { pub id: CommunityId, pub name: String, @@ -32,9 +32,9 @@ pub struct Community { } /// A safe representation of community, without the sensitive info -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "community")] +#[cfg_attr(feature = "full", diesel(table_name = community))] pub struct CommunitySafe { pub id: CommunityId, pub name: String, @@ -55,7 +55,7 @@ pub struct CommunitySafe { #[derive(Debug, Default)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "community")] +#[cfg_attr(feature = "full", diesel(table_name = community))] pub struct CommunityForm { pub name: String, pub title: String, @@ -79,10 +79,13 @@ pub struct CommunityForm { pub posting_restricted_to_mods: Option, } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))] -#[cfg_attr(feature = "full", belongs_to(Community))] -#[cfg_attr(feature = "full", table_name = "community_moderator")] +#[cfg_attr( + feature = "full", + diesel(belongs_to(crate::source::community::Community)) +)] +#[cfg_attr(feature = "full", diesel(table_name = community_moderator))] pub struct CommunityModerator { pub id: i32, pub community_id: CommunityId, @@ -92,16 +95,19 @@ pub struct CommunityModerator { #[derive(Clone)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "community_moderator")] +#[cfg_attr(feature = "full", diesel(table_name = community_moderator))] pub struct CommunityModeratorForm { pub community_id: CommunityId, pub person_id: PersonId, } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))] -#[cfg_attr(feature = "full", belongs_to(Community))] -#[cfg_attr(feature = "full", table_name = "community_person_ban")] +#[cfg_attr( + feature = "full", + diesel(belongs_to(crate::source::community::Community)) +)] +#[cfg_attr(feature = "full", diesel(table_name = community_person_ban))] pub struct CommunityPersonBan { pub id: i32, pub community_id: CommunityId, @@ -112,17 +118,20 @@ pub struct CommunityPersonBan { #[derive(Clone)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "community_person_ban")] +#[cfg_attr(feature = "full", diesel(table_name = community_person_ban))] pub struct CommunityPersonBanForm { pub community_id: CommunityId, pub person_id: PersonId, pub expires: Option>, } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))] -#[cfg_attr(feature = "full", belongs_to(Community))] -#[cfg_attr(feature = "full", table_name = "community_follower")] +#[cfg_attr( + feature = "full", + diesel(belongs_to(crate::source::community::Community)) +)] +#[cfg_attr(feature = "full", diesel(table_name = community_follower))] pub struct CommunityFollower { pub id: i32, pub community_id: CommunityId, @@ -133,7 +142,7 @@ pub struct CommunityFollower { #[derive(Clone)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "community_follower")] +#[cfg_attr(feature = "full", diesel(table_name = community_follower))] pub struct CommunityFollowerForm { pub community_id: CommunityId, pub person_id: PersonId, diff --git a/crates/db_schema/src/source/community_block.rs b/crates/db_schema/src/source/community_block.rs index d2c40a33..8011e9ee 100644 --- a/crates/db_schema/src/source/community_block.rs +++ b/crates/db_schema/src/source/community_block.rs @@ -4,10 +4,13 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::community_block; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", belongs_to(crate::source::community::Community))] -#[cfg_attr(feature = "full", table_name = "community_block")] +#[cfg_attr( + feature = "full", + diesel(belongs_to(crate::source::community::Community)) +)] +#[cfg_attr(feature = "full", diesel(table_name = community_block))] pub struct CommunityBlock { pub id: CommunityBlockId, pub person_id: PersonId, @@ -16,7 +19,7 @@ pub struct CommunityBlock { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "community_block")] +#[cfg_attr(feature = "full", diesel(table_name = community_block))] pub struct CommunityBlockForm { pub person_id: PersonId, pub community_id: CommunityId, diff --git a/crates/db_schema/src/source/email_verification.rs b/crates/db_schema/src/source/email_verification.rs index 8d63670f..d541421f 100644 --- a/crates/db_schema/src/source/email_verification.rs +++ b/crates/db_schema/src/source/email_verification.rs @@ -5,7 +5,7 @@ use crate::schema::email_verification; #[derive(Clone)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "email_verification")] +#[cfg_attr(feature = "full", diesel(table_name = email_verification))] pub struct EmailVerification { pub id: i32, pub local_user_id: LocalUserId, @@ -15,7 +15,7 @@ pub struct EmailVerification { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "email_verification")] +#[cfg_attr(feature = "full", diesel(table_name = email_verification))] pub struct EmailVerificationForm { pub local_user_id: LocalUserId, pub email: String, diff --git a/crates/db_schema/src/source/language.rs b/crates/db_schema/src/source/language.rs index 042eba3b..3c52eb47 100644 --- a/crates/db_schema/src/source/language.rs +++ b/crates/db_schema/src/source/language.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::language; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "language")] +#[cfg_attr(feature = "full", diesel(table_name = language))] pub struct Language { pub id: LanguageId, pub code: String, diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs index 7c24d61b..4b3a3414 100644 --- a/crates/db_schema/src/source/local_user.rs +++ b/crates/db_schema/src/source/local_user.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::local_user; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "local_user")] +#[cfg_attr(feature = "full", diesel(table_name = local_user))] pub struct LocalUser { pub id: LocalUserId, pub person_id: PersonId, @@ -31,7 +31,7 @@ pub struct LocalUser { // TODO redo these, check table defaults #[derive(Clone, Default)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "local_user")] +#[cfg_attr(feature = "full", diesel(table_name = local_user))] pub struct LocalUserForm { pub person_id: Option, pub password_encrypted: Option, @@ -52,9 +52,9 @@ pub struct LocalUserForm { } /// A local user view that removes password encrypted -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "local_user")] +#[cfg_attr(feature = "full", diesel(table_name = local_user))] pub struct LocalUserSettings { pub id: LocalUserId, pub person_id: PersonId, diff --git a/crates/db_schema/src/source/local_user_language.rs b/crates/db_schema/src/source/local_user_language.rs index 64492ee3..b6129d0c 100644 --- a/crates/db_schema/src/source/local_user_language.rs +++ b/crates/db_schema/src/source/local_user_language.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::local_user_language; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "local_user_language")] +#[cfg_attr(feature = "full", diesel(table_name = local_user_language))] pub struct LocalUserLanguage { #[serde(skip)] pub id: LocalUserLanguageId, @@ -16,7 +16,7 @@ pub struct LocalUserLanguage { #[derive(Clone)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "local_user_language")] +#[cfg_attr(feature = "full", diesel(table_name = local_user_language))] pub struct LocalUserLanguageForm { pub local_user_id: LocalUserId, pub language_id: LanguageId, diff --git a/crates/db_schema/src/source/moderator.rs b/crates/db_schema/src/source/moderator.rs index 7f13eaa9..d234ed99 100644 --- a/crates/db_schema/src/source/moderator.rs +++ b/crates/db_schema/src/source/moderator.rs @@ -20,9 +20,9 @@ use crate::schema::{ mod_transfer_community, }; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_remove_post")] +#[cfg_attr(feature = "full", diesel(table_name = mod_remove_post))] pub struct ModRemovePost { pub id: i32, pub mod_person_id: PersonId, @@ -33,7 +33,7 @@ pub struct ModRemovePost { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_remove_post")] +#[cfg_attr(feature = "full", diesel(table_name = mod_remove_post))] pub struct ModRemovePostForm { pub mod_person_id: PersonId, pub post_id: PostId, @@ -41,9 +41,9 @@ pub struct ModRemovePostForm { pub removed: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_lock_post")] +#[cfg_attr(feature = "full", diesel(table_name = mod_lock_post))] pub struct ModLockPost { pub id: i32, pub mod_person_id: PersonId, @@ -53,16 +53,16 @@ pub struct ModLockPost { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_lock_post")] +#[cfg_attr(feature = "full", diesel(table_name = mod_lock_post))] pub struct ModLockPostForm { pub mod_person_id: PersonId, pub post_id: PostId, pub locked: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_sticky_post")] +#[cfg_attr(feature = "full", diesel(table_name = mod_sticky_post))] pub struct ModStickyPost { pub id: i32, pub mod_person_id: PersonId, @@ -72,16 +72,16 @@ pub struct ModStickyPost { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_sticky_post")] +#[cfg_attr(feature = "full", diesel(table_name = mod_sticky_post))] pub struct ModStickyPostForm { pub mod_person_id: PersonId, pub post_id: PostId, pub stickied: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_remove_comment")] +#[cfg_attr(feature = "full", diesel(table_name = mod_remove_comment))] pub struct ModRemoveComment { pub id: i32, pub mod_person_id: PersonId, @@ -92,7 +92,7 @@ pub struct ModRemoveComment { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_remove_comment")] +#[cfg_attr(feature = "full", diesel(table_name = mod_remove_comment))] pub struct ModRemoveCommentForm { pub mod_person_id: PersonId, pub comment_id: CommentId, @@ -100,9 +100,9 @@ pub struct ModRemoveCommentForm { pub removed: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_remove_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_remove_community))] pub struct ModRemoveCommunity { pub id: i32, pub mod_person_id: PersonId, @@ -114,7 +114,7 @@ pub struct ModRemoveCommunity { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_remove_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_remove_community))] pub struct ModRemoveCommunityForm { pub mod_person_id: PersonId, pub community_id: CommunityId, @@ -123,9 +123,9 @@ pub struct ModRemoveCommunityForm { pub expires: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_ban_from_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_ban_from_community))] pub struct ModBanFromCommunity { pub id: i32, pub mod_person_id: PersonId, @@ -138,7 +138,7 @@ pub struct ModBanFromCommunity { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_ban_from_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_ban_from_community))] pub struct ModBanFromCommunityForm { pub mod_person_id: PersonId, pub other_person_id: PersonId, @@ -148,9 +148,9 @@ pub struct ModBanFromCommunityForm { pub expires: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_ban")] +#[cfg_attr(feature = "full", diesel(table_name = mod_ban))] pub struct ModBan { pub id: i32, pub mod_person_id: PersonId, @@ -162,16 +162,16 @@ pub struct ModBan { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_hide_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_hide_community))] pub struct ModHideCommunityForm { pub community_id: CommunityId, pub mod_person_id: PersonId, pub hidden: Option, pub reason: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_hide_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_hide_community))] pub struct ModHideCommunity { pub id: i32, pub community_id: CommunityId, @@ -182,7 +182,7 @@ pub struct ModHideCommunity { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_ban")] +#[cfg_attr(feature = "full", diesel(table_name = mod_ban))] pub struct ModBanForm { pub mod_person_id: PersonId, pub other_person_id: PersonId, @@ -191,9 +191,9 @@ pub struct ModBanForm { pub expires: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_add_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_add_community))] pub struct ModAddCommunity { pub id: i32, pub mod_person_id: PersonId, @@ -204,7 +204,7 @@ pub struct ModAddCommunity { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_add_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_add_community))] pub struct ModAddCommunityForm { pub mod_person_id: PersonId, pub other_person_id: PersonId, @@ -212,9 +212,9 @@ pub struct ModAddCommunityForm { pub removed: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_transfer_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_transfer_community))] pub struct ModTransferCommunity { pub id: i32, pub mod_person_id: PersonId, @@ -225,7 +225,7 @@ pub struct ModTransferCommunity { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_transfer_community")] +#[cfg_attr(feature = "full", diesel(table_name = mod_transfer_community))] pub struct ModTransferCommunityForm { pub mod_person_id: PersonId, pub other_person_id: PersonId, @@ -233,9 +233,9 @@ pub struct ModTransferCommunityForm { pub removed: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "mod_add")] +#[cfg_attr(feature = "full", diesel(table_name = mod_add))] pub struct ModAdd { pub id: i32, pub mod_person_id: PersonId, @@ -245,16 +245,16 @@ pub struct ModAdd { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "mod_add")] +#[cfg_attr(feature = "full", diesel(table_name = mod_add))] pub struct ModAddForm { pub mod_person_id: PersonId, pub other_person_id: PersonId, pub removed: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "admin_purge_person")] +#[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))] pub struct AdminPurgePerson { pub id: i32, pub admin_person_id: PersonId, @@ -263,15 +263,15 @@ pub struct AdminPurgePerson { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "admin_purge_person")] +#[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))] pub struct AdminPurgePersonForm { pub admin_person_id: PersonId, pub reason: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "admin_purge_community")] +#[cfg_attr(feature = "full", diesel(table_name = admin_purge_community))] pub struct AdminPurgeCommunity { pub id: i32, pub admin_person_id: PersonId, @@ -280,15 +280,15 @@ pub struct AdminPurgeCommunity { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "admin_purge_community")] +#[cfg_attr(feature = "full", diesel(table_name = admin_purge_community))] pub struct AdminPurgeCommunityForm { pub admin_person_id: PersonId, pub reason: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "admin_purge_post")] +#[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))] pub struct AdminPurgePost { pub id: i32, pub admin_person_id: PersonId, @@ -298,16 +298,16 @@ pub struct AdminPurgePost { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "admin_purge_post")] +#[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))] pub struct AdminPurgePostForm { pub admin_person_id: PersonId, pub community_id: CommunityId, pub reason: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "admin_purge_comment")] +#[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))] pub struct AdminPurgeComment { pub id: i32, pub admin_person_id: PersonId, @@ -317,7 +317,7 @@ pub struct AdminPurgeComment { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "admin_purge_comment")] +#[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))] pub struct AdminPurgeCommentForm { pub admin_person_id: PersonId, pub post_id: PostId, diff --git a/crates/db_schema/src/source/password_reset_request.rs b/crates/db_schema/src/source/password_reset_request.rs index 3df7fab0..159b0b7e 100644 --- a/crates/db_schema/src/source/password_reset_request.rs +++ b/crates/db_schema/src/source/password_reset_request.rs @@ -3,9 +3,9 @@ use crate::newtypes::LocalUserId; #[cfg(feature = "full")] use crate::schema::password_reset_request; -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "password_reset_request")] +#[cfg_attr(feature = "full", diesel(table_name = password_reset_request))] pub struct PasswordResetRequest { pub id: i32, pub token_encrypted: String, @@ -14,7 +14,7 @@ pub struct PasswordResetRequest { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "password_reset_request")] +#[cfg_attr(feature = "full", diesel(table_name = password_reset_request))] pub struct PasswordResetRequestForm { pub local_user_id: LocalUserId, pub token_encrypted: String, diff --git a/crates/db_schema/src/source/person.rs b/crates/db_schema/src/source/person.rs index e4888ddb..5d9d603d 100644 --- a/crates/db_schema/src/source/person.rs +++ b/crates/db_schema/src/source/person.rs @@ -2,11 +2,11 @@ use crate::newtypes::{DbUrl, PersonId}; use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] -use crate::schema::{person, person_alias_1, person_alias_2}; +use crate::schema::person; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "person")] +#[cfg_attr(feature = "full", diesel(table_name = person))] pub struct Person { pub id: PersonId, pub name: String, @@ -32,9 +32,9 @@ pub struct Person { } /// A safe representation of person, without the sensitive info -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "person")] +#[cfg_attr(feature = "full", diesel(table_name = person))] pub struct PersonSafe { pub id: PersonId, pub name: String, @@ -56,111 +56,9 @@ pub struct PersonSafe { pub ban_expires: Option, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] -#[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "person_alias_1")] -pub struct PersonAlias1 { - pub id: PersonId, - pub name: String, - pub display_name: Option, - pub avatar: Option, - pub banned: bool, - pub published: chrono::NaiveDateTime, - pub updated: Option, - pub actor_id: DbUrl, - pub bio: Option, - pub local: bool, - pub private_key: Option, - pub public_key: String, - pub last_refreshed_at: chrono::NaiveDateTime, - pub banner: Option, - pub deleted: bool, - pub inbox_url: DbUrl, - pub shared_inbox_url: Option, - pub matrix_user_id: Option, - pub admin: bool, - pub bot_account: bool, - pub ban_expires: Option, -} - -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] -#[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "person_alias_1")] -pub struct PersonSafeAlias1 { - pub id: PersonId, - pub name: String, - pub display_name: Option, - pub avatar: Option, - pub banned: bool, - pub published: chrono::NaiveDateTime, - pub updated: Option, - pub actor_id: DbUrl, - pub bio: Option, - pub local: bool, - pub banner: Option, - pub deleted: bool, - pub inbox_url: DbUrl, - pub shared_inbox_url: Option, - pub matrix_user_id: Option, - pub admin: bool, - pub bot_account: bool, - pub ban_expires: Option, -} - -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] -#[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "person_alias_2")] -pub struct PersonAlias2 { - pub id: PersonId, - pub name: String, - pub display_name: Option, - pub avatar: Option, - pub banned: bool, - pub published: chrono::NaiveDateTime, - pub updated: Option, - pub actor_id: DbUrl, - pub bio: Option, - pub local: bool, - pub private_key: Option, - pub public_key: String, - pub last_refreshed_at: chrono::NaiveDateTime, - pub banner: Option, - pub deleted: bool, - pub inbox_url: DbUrl, - pub shared_inbox_url: Option, - pub matrix_user_id: Option, - pub admin: bool, - pub bot_account: bool, - pub ban_expires: Option, -} - -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] -#[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "person_alias_1")] -pub struct PersonSafeAlias2 { - pub id: PersonId, - pub name: String, - pub display_name: Option, - pub avatar: Option, - pub banned: bool, - pub published: chrono::NaiveDateTime, - pub updated: Option, - pub actor_id: DbUrl, - pub bio: Option, - pub local: bool, - pub banner: Option, - pub deleted: bool, - pub inbox_url: DbUrl, - pub shared_inbox_url: Option, - pub matrix_user_id: Option, - pub admin: bool, - pub bot_account: bool, - pub ban_expires: Option, -} - #[derive(Clone, Default)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "person")] +#[cfg_attr(feature = "full", diesel(table_name = person))] pub struct PersonForm { pub name: String, pub display_name: Option>, diff --git a/crates/db_schema/src/source/person_block.rs b/crates/db_schema/src/source/person_block.rs index 46920acb..e5a365b5 100644 --- a/crates/db_schema/src/source/person_block.rs +++ b/crates/db_schema/src/source/person_block.rs @@ -4,9 +4,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::person_block; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", table_name = "person_block")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))] +#[cfg_attr(feature = "full", diesel(table_name = person_block))] pub struct PersonBlock { pub id: PersonBlockId, pub person_id: PersonId, @@ -15,7 +16,7 @@ pub struct PersonBlock { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "person_block")] +#[cfg_attr(feature = "full", diesel(table_name = person_block))] pub struct PersonBlockForm { pub person_id: PersonId, pub target_id: PersonId, diff --git a/crates/db_schema/src/source/person_mention.rs b/crates/db_schema/src/source/person_mention.rs index 5716cb8c..a12563e5 100644 --- a/crates/db_schema/src/source/person_mention.rs +++ b/crates/db_schema/src/source/person_mention.rs @@ -4,10 +4,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::person_mention; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", belongs_to(crate::source::comment::Comment))] -#[cfg_attr(feature = "full", table_name = "person_mention")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))] +#[cfg_attr(feature = "full", diesel(table_name = person_mention))] pub struct PersonMention { pub id: PersonMentionId, pub recipient_id: PersonId, @@ -17,7 +17,7 @@ pub struct PersonMention { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "person_mention")] +#[cfg_attr(feature = "full", diesel(table_name = person_mention))] pub struct PersonMentionForm { pub recipient_id: PersonId, pub comment_id: CommentId, diff --git a/crates/db_schema/src/source/post.rs b/crates/db_schema/src/source/post.rs index 7e192a72..e9f383fe 100644 --- a/crates/db_schema/src/source/post.rs +++ b/crates/db_schema/src/source/post.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::{post, post_like, post_read, post_saved}; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "post")] +#[cfg_attr(feature = "full", diesel(table_name = post))] pub struct Post { pub id: PostId, pub name: String, @@ -32,7 +32,7 @@ pub struct Post { #[derive(Default)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "post")] +#[cfg_attr(feature = "full", diesel(table_name = post))] pub struct PostForm { pub name: String, pub creator_id: PersonId, @@ -55,10 +55,10 @@ pub struct PostForm { pub language_id: Option, } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))] -#[cfg_attr(feature = "full", belongs_to(Post))] -#[cfg_attr(feature = "full", table_name = "post_like")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))] +#[cfg_attr(feature = "full", diesel(table_name = post_like))] pub struct PostLike { pub id: i32, pub post_id: PostId, @@ -69,17 +69,17 @@ pub struct PostLike { #[derive(Clone)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "post_like")] +#[cfg_attr(feature = "full", diesel(table_name = post_like))] pub struct PostLikeForm { pub post_id: PostId, pub person_id: PersonId, pub score: i16, } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))] -#[cfg_attr(feature = "full", belongs_to(Post))] -#[cfg_attr(feature = "full", table_name = "post_saved")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))] +#[cfg_attr(feature = "full", diesel(table_name = post_saved))] pub struct PostSaved { pub id: i32, pub post_id: PostId, @@ -88,16 +88,16 @@ pub struct PostSaved { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "post_saved")] +#[cfg_attr(feature = "full", diesel(table_name = post_saved))] pub struct PostSavedForm { pub post_id: PostId, pub person_id: PersonId, } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))] -#[cfg_attr(feature = "full", belongs_to(Post))] -#[cfg_attr(feature = "full", table_name = "post_read")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))] +#[cfg_attr(feature = "full", diesel(table_name = post_read))] pub struct PostRead { pub id: i32, pub post_id: PostId, @@ -106,7 +106,7 @@ pub struct PostRead { } #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "post_read")] +#[cfg_attr(feature = "full", diesel(table_name = post_read))] pub struct PostReadForm { pub post_id: PostId, pub person_id: PersonId, diff --git a/crates/db_schema/src/source/post_report.rs b/crates/db_schema/src/source/post_report.rs index afb33469..abee0f32 100644 --- a/crates/db_schema/src/source/post_report.rs +++ b/crates/db_schema/src/source/post_report.rs @@ -4,10 +4,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::post_report; -#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)] +#[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)] #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))] -#[cfg_attr(feature = "full", belongs_to(crate::source::post::Post))] -#[cfg_attr(feature = "full", table_name = "post_report")] +#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))] // Is this the right assoc? +#[cfg_attr(feature = "full", diesel(table_name = post_report))] pub struct PostReport { pub id: PostReportId, pub creator_id: PersonId, @@ -24,7 +24,7 @@ pub struct PostReport { #[derive(Clone)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "post_report")] +#[cfg_attr(feature = "full", diesel(table_name = post_report))] pub struct PostReportForm { pub creator_id: PersonId, pub post_id: PostId, diff --git a/crates/db_schema/src/source/private_message.rs b/crates/db_schema/src/source/private_message.rs index fa697a51..9b2cb342 100644 --- a/crates/db_schema/src/source/private_message.rs +++ b/crates/db_schema/src/source/private_message.rs @@ -4,9 +4,13 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::private_message; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] -#[cfg_attr(feature = "full", table_name = "private_message")] +#[cfg_attr( + feature = "full", + diesel(belongs_to(crate::source::person::Person, foreign_key = creator_id) +))] // Is this the right assoc? +#[cfg_attr(feature = "full", diesel(table_name = private_message))] pub struct PrivateMessage { pub id: PrivateMessageId, pub creator_id: PersonId, @@ -22,7 +26,7 @@ pub struct PrivateMessage { #[derive(Default)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "private_message")] +#[cfg_attr(feature = "full", diesel(table_name = private_message))] pub struct PrivateMessageForm { pub creator_id: PersonId, pub recipient_id: PersonId, diff --git a/crates/db_schema/src/source/private_message_report.rs b/crates/db_schema/src/source/private_message_report.rs index ba563aa7..8cf3b0f0 100644 --- a/crates/db_schema/src/source/private_message_report.rs +++ b/crates/db_schema/src/source/private_message_report.rs @@ -4,13 +4,13 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::private_message_report; -#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)] +#[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)] #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))] #[cfg_attr( feature = "full", - belongs_to(crate::source::private_message::PrivateMessage) + diesel(belongs_to(crate::source::private_message::PrivateMessage)) )] -#[cfg_attr(feature = "full", table_name = "private_message_report")] +#[cfg_attr(feature = "full", diesel(table_name = private_message_report))] pub struct PrivateMessageReport { pub id: PrivateMessageReportId, pub creator_id: PersonId, @@ -25,7 +25,7 @@ pub struct PrivateMessageReport { #[derive(Clone)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "private_message_report")] +#[cfg_attr(feature = "full", diesel(table_name = private_message_report))] pub struct PrivateMessageReportForm { pub creator_id: PersonId, pub private_message_id: PrivateMessageId, diff --git a/crates/db_schema/src/source/registration_application.rs b/crates/db_schema/src/source/registration_application.rs index c874427a..ecf4eb3e 100644 --- a/crates/db_schema/src/source/registration_application.rs +++ b/crates/db_schema/src/source/registration_application.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::registration_application; -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "registration_application")] +#[cfg_attr(feature = "full", diesel(table_name = registration_application))] pub struct RegistrationApplication { pub id: i32, pub local_user_id: LocalUserId, @@ -18,7 +18,7 @@ pub struct RegistrationApplication { #[derive(Default)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "registration_application")] +#[cfg_attr(feature = "full", diesel(table_name = registration_application))] pub struct RegistrationApplicationForm { pub local_user_id: Option, pub answer: Option, diff --git a/crates/db_schema/src/source/secret.rs b/crates/db_schema/src/source/secret.rs index d32a3ac7..8b955ec5 100644 --- a/crates/db_schema/src/source/secret.rs +++ b/crates/db_schema/src/source/secret.rs @@ -3,7 +3,7 @@ use crate::schema::secret; #[derive(Clone)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "secret")] +#[cfg_attr(feature = "full", diesel(table_name = secret))] pub struct Secret { pub id: i32, pub jwt_secret: String, diff --git a/crates/db_schema/src/source/site.rs b/crates/db_schema/src/source/site.rs index 7975071c..82876d83 100644 --- a/crates/db_schema/src/source/site.rs +++ b/crates/db_schema/src/source/site.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "full")] use crate::schema::site; -#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "full", derive(Queryable, Identifiable))] -#[cfg_attr(feature = "full", table_name = "site")] +#[cfg_attr(feature = "full", diesel(table_name = site))] pub struct Site { pub id: i32, pub name: String, @@ -37,7 +37,7 @@ pub struct Site { #[derive(Default)] #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] -#[cfg_attr(feature = "full", table_name = "site")] +#[cfg_attr(feature = "full", diesel(table_name = site))] pub struct SiteForm { pub name: String, pub sidebar: Option>, diff --git a/crates/db_schema/src/traits.rs b/crates/db_schema/src/traits.rs index f2f6ae92..102d0c0b 100644 --- a/crates/db_schema/src/traits.rs +++ b/crates/db_schema/src/traits.rs @@ -4,16 +4,16 @@ use diesel::{result::Error, PgConnection}; pub trait Crud { type Form; type IdType; - fn create(conn: &PgConnection, form: &Self::Form) -> Result + fn create(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; - fn read(conn: &PgConnection, id: Self::IdType) -> Result + fn read(conn: &mut PgConnection, id: Self::IdType) -> Result where Self: Sized; - fn update(conn: &PgConnection, id: Self::IdType, form: &Self::Form) -> Result + fn update(conn: &mut PgConnection, id: Self::IdType, form: &Self::Form) -> Result where Self: Sized; - fn delete(_conn: &PgConnection, _id: Self::IdType) -> Result + fn delete(_conn: &mut PgConnection, _id: Self::IdType) -> Result where Self: Sized, { @@ -23,28 +23,29 @@ pub trait Crud { pub trait Followable { type Form; - fn follow(conn: &PgConnection, form: &Self::Form) -> Result + fn follow(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; fn follow_accepted( - conn: &PgConnection, + conn: &mut PgConnection, community_id: CommunityId, person_id: PersonId, ) -> Result where Self: Sized; - fn unfollow(conn: &PgConnection, form: &Self::Form) -> Result + fn unfollow(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; - fn has_local_followers(conn: &PgConnection, community_id: CommunityId) -> Result; + fn has_local_followers(conn: &mut PgConnection, community_id: CommunityId) + -> Result; } pub trait Joinable { type Form; - fn join(conn: &PgConnection, form: &Self::Form) -> Result + fn join(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; - fn leave(conn: &PgConnection, form: &Self::Form) -> Result + fn leave(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; } @@ -52,11 +53,11 @@ pub trait Joinable { pub trait Likeable { type Form; type IdType; - fn like(conn: &PgConnection, form: &Self::Form) -> Result + fn like(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; fn remove( - conn: &PgConnection, + conn: &mut PgConnection, person_id: PersonId, item_id: Self::IdType, ) -> Result @@ -66,40 +67,40 @@ pub trait Likeable { pub trait Bannable { type Form; - fn ban(conn: &PgConnection, form: &Self::Form) -> Result + fn ban(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; - fn unban(conn: &PgConnection, form: &Self::Form) -> Result + fn unban(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; } pub trait Saveable { type Form; - fn save(conn: &PgConnection, form: &Self::Form) -> Result + fn save(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; - fn unsave(conn: &PgConnection, form: &Self::Form) -> Result + fn unsave(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; } pub trait Blockable { type Form; - fn block(conn: &PgConnection, form: &Self::Form) -> Result + fn block(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; - fn unblock(conn: &PgConnection, form: &Self::Form) -> Result + fn unblock(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; } pub trait Readable { type Form; - fn mark_as_read(conn: &PgConnection, form: &Self::Form) -> Result + fn mark_as_read(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; - fn mark_as_unread(conn: &PgConnection, form: &Self::Form) -> Result + fn mark_as_unread(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; } @@ -107,18 +108,18 @@ pub trait Readable { pub trait Reportable { type Form; type IdType; - fn report(conn: &PgConnection, form: &Self::Form) -> Result + fn report(conn: &mut PgConnection, form: &Self::Form) -> Result where Self: Sized; fn resolve( - conn: &PgConnection, + conn: &mut PgConnection, report_id: Self::IdType, resolver_id: PersonId, ) -> Result where Self: Sized; fn unresolve( - conn: &PgConnection, + conn: &mut PgConnection, report_id: Self::IdType, resolver_id: PersonId, ) -> Result @@ -149,20 +150,20 @@ pub trait ViewToVec { pub trait ApubActor { // TODO: this should be in a trait ApubObject (and implemented for Post, Comment, PrivateMessage as well) - fn read_from_apub_id(conn: &PgConnection, object_id: &DbUrl) -> Result, Error> + fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result, Error> where Self: Sized; /// - actor_name is the name of the community or user to read. /// - include_deleted, if true, will return communities or users that were deleted/removed fn read_from_name( - conn: &PgConnection, + conn: &mut PgConnection, actor_name: &str, include_deleted: bool, ) -> Result where Self: Sized; fn read_from_name_and_domain( - conn: &PgConnection, + conn: &mut PgConnection, actor_name: &str, protocol_domain: &str, ) -> Result diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index 93404da3..798786b0 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -1,19 +1,21 @@ -use crate::{newtypes::DbUrl, CommentSortType, SortType}; +use crate::{diesel_migrations::MigrationHarness, newtypes::DbUrl, CommentSortType, SortType}; use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject}; use chrono::NaiveDateTime; use diesel::{ backend::Backend, deserialize::FromSql, + pg::Pg, result::Error::QueryBuilderError, serialize::{Output, ToSql}, sql_types::Text, Connection, PgConnection, }; +use diesel_migrations::EmbeddedMigrations; use lemmy_utils::error::LemmyError; use once_cell::sync::Lazy; use regex::Regex; -use std::{env, env::VarError, io::Write}; +use std::{env, env::VarError}; use url::Url; const FETCH_LIMIT_DEFAULT: i64 = 10; @@ -98,7 +100,7 @@ pub fn diesel_option_overwrite_to_url( } } -embed_migrations!(); +pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!(); pub fn establish_unpooled_connection() -> PgConnection { let db_url = match get_database_url_from_env() { @@ -108,9 +110,11 @@ pub fn establish_unpooled_connection() -> PgConnection { e ), }; - let conn = + let mut conn = PgConnection::establish(&db_url).unwrap_or_else(|_| panic!("Error connecting to {}", db_url)); - embedded_migrations::run(&conn).expect("load migrations"); + let _ = &mut conn + .run_pending_migrations(MIGRATIONS) + .unwrap_or_else(|_| panic!("Couldn't run DB Migrations")); conn } @@ -146,12 +150,9 @@ pub mod functions { sql_function!(fn lower(x: Text) -> Text); } -impl ToSql for DbUrl -where - String: ToSql, -{ - fn to_sql(&self, out: &mut Output) -> diesel::serialize::Result { - self.0.to_string().to_sql(out) +impl ToSql for DbUrl { + fn to_sql(&self, out: &mut Output) -> diesel::serialize::Result { + >::to_sql(&self.0.to_string(), &mut out.reborrow()) } } @@ -159,8 +160,8 @@ impl FromSql for DbUrl where String: FromSql, { - fn from_sql(bytes: Option<&DB::RawValue>) -> diesel::deserialize::Result { - let str = String::from_sql(bytes)?; + fn from_sql(value: diesel::backend::RawValue<'_, DB>) -> diesel::deserialize::Result { + let str = String::from_sql(value)?; Ok(DbUrl(Url::parse(&str)?)) } } diff --git a/crates/db_views/Cargo.toml b/crates/db_views/Cargo.toml index 85448b26..3046c4e7 100644 --- a/crates/db_views/Cargo.toml +++ b/crates/db_views/Cargo.toml @@ -16,11 +16,11 @@ full = ["lemmy_db_schema/full", "diesel", "tracing"] [dependencies] lemmy_db_schema = { version = "=0.16.5", path = "../db_schema" } -diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"], optional = true } -serde = { version = "1.0.136", features = ["derive"] } -tracing = { version = "0.1.32", optional = true } -diesel_ltree = "0.2.7" +diesel = { version = "2.0.0", features = ["postgres","chrono","r2d2","serde_json"], optional = true } +serde = { version = "1.0.145", features = ["derive"] } +tracing = { version = "0.1.36", optional = true } +diesel_ltree = "0.3.0" typed-builder = "0.10.0" [dev-dependencies] -serial_test = "0.6.0" +serial_test = "0.9.0" diff --git a/crates/db_views/src/comment_report_view.rs b/crates/db_views/src/comment_report_view.rs index 8c9c124d..50564b0a 100644 --- a/crates/db_views/src/comment_report_view.rs +++ b/crates/db_views/src/comment_report_view.rs @@ -12,15 +12,13 @@ use lemmy_db_schema::{ community_moderator, community_person_ban, person, - person_alias_1, - person_alias_2, post, }, source::{ comment::Comment, comment_report::CommentReport, community::{Community, CommunityPersonBan, CommunitySafe}, - person::{Person, PersonAlias1, PersonAlias2, PersonSafe, PersonSafeAlias1, PersonSafeAlias2}, + person::{Person, PersonSafe}, post::Post, }, traits::{ToSafe, ViewToVec}, @@ -34,11 +32,11 @@ type CommentReportViewTuple = ( Post, CommunitySafe, PersonSafe, - PersonSafeAlias1, + PersonSafe, CommentAggregates, Option, Option, - Option, + Option, ); impl CommentReportView { @@ -46,10 +44,12 @@ impl CommentReportView { /// /// * `report_id` - the report id to obtain pub fn read( - conn: &PgConnection, + conn: &mut PgConnection, report_id: CommentReportId, my_person_id: PersonId, ) -> Result { + let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2); + let ( comment_report, comment, @@ -67,7 +67,7 @@ impl CommentReportView { .inner_join(post::table.on(comment::post_id.eq(post::id))) .inner_join(community::table.on(post::community_id.eq(community::id))) .inner_join(person::table.on(comment_report::creator_id.eq(person::id))) - .inner_join(person_alias_1::table.on(comment::creator_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(comment::creator_id.eq(person_alias_1.field(person::id)))) .inner_join( comment_aggregates::table.on(comment_report::comment_id.eq(comment_aggregates::comment_id)), ) @@ -91,7 +91,8 @@ impl CommentReportView { ), ) .left_join( - person_alias_2::table.on(comment_report::resolver_id.eq(person_alias_2::id.nullable())), + person_alias_2 + .on(comment_report::resolver_id.eq(person_alias_2.field(person::id).nullable())), ) .select(( comment_report::all_columns, @@ -99,11 +100,13 @@ impl CommentReportView { post::all_columns, Community::safe_columns_tuple(), Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), comment_aggregates::all_columns, community_person_ban::all_columns.nullable(), comment_like::score.nullable(), - PersonAlias2::safe_columns_tuple().nullable(), + person_alias_2 + .fields(Person::safe_columns_tuple()) + .nullable(), )) .first::(conn)?; @@ -125,7 +128,7 @@ impl CommentReportView { /// Returns the current unresolved post report count for the communities you mod pub fn get_report_count( - conn: &PgConnection, + conn: &mut PgConnection, my_person_id: PersonId, admin: bool, community_id: Option, @@ -164,7 +167,7 @@ impl CommentReportView { #[builder(field_defaults(default))] pub struct CommentReportQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, #[builder(!default)] my_person_id: PersonId, #[builder(!default)] @@ -177,12 +180,14 @@ pub struct CommentReportQuery<'a> { impl<'a> CommentReportQuery<'a> { pub fn list(self) -> Result, Error> { + let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2); + let mut query = comment_report::table .inner_join(comment::table) .inner_join(post::table.on(comment::post_id.eq(post::id))) .inner_join(community::table.on(post::community_id.eq(community::id))) .inner_join(person::table.on(comment_report::creator_id.eq(person::id))) - .inner_join(person_alias_1::table.on(comment::creator_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(comment::creator_id.eq(person_alias_1.field(person::id)))) .inner_join( comment_aggregates::table.on(comment_report::comment_id.eq(comment_aggregates::comment_id)), ) @@ -206,7 +211,8 @@ impl<'a> CommentReportQuery<'a> { ), ) .left_join( - person_alias_2::table.on(comment_report::resolver_id.eq(person_alias_2::id.nullable())), + person_alias_2 + .on(comment_report::resolver_id.eq(person_alias_2.field(person::id).nullable())), ) .select(( comment_report::all_columns, @@ -214,11 +220,13 @@ impl<'a> CommentReportQuery<'a> { post::all_columns, Community::safe_columns_tuple(), Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), comment_aggregates::all_columns, community_person_ban::all_columns.nullable(), comment_like::score.nullable(), - PersonAlias2::safe_columns_tuple().nullable(), + person_alias_2 + .fields(Person::safe_columns_tuple()) + .nullable(), )) .into_boxed(); @@ -291,7 +299,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "timmy_crv".into(), @@ -299,7 +307,7 @@ mod tests { ..PersonForm::default() }; - let inserted_timmy = Person::create(&conn, &new_person).unwrap(); + let inserted_timmy = Person::create(conn, &new_person).unwrap(); let new_person_2 = PersonForm { name: "sara_crv".into(), @@ -307,7 +315,7 @@ mod tests { ..PersonForm::default() }; - let inserted_sara = Person::create(&conn, &new_person_2).unwrap(); + let inserted_sara = Person::create(conn, &new_person_2).unwrap(); // Add a third person, since new ppl can only report something once. let new_person_3 = PersonForm { @@ -316,7 +324,7 @@ mod tests { ..PersonForm::default() }; - let inserted_jessica = Person::create(&conn, &new_person_3).unwrap(); + let inserted_jessica = Person::create(conn, &new_person_3).unwrap(); let new_community = CommunityForm { name: "test community crv".to_string(), @@ -325,7 +333,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); // Make timmy a mod let timmy_moderator_form = CommunityModeratorForm { @@ -333,7 +341,7 @@ mod tests { person_id: inserted_timmy.id, }; - let _inserted_moderator = CommunityModerator::join(&conn, &timmy_moderator_form).unwrap(); + let _inserted_moderator = CommunityModerator::join(conn, &timmy_moderator_form).unwrap(); let new_post = PostForm { name: "A test post crv".into(), @@ -342,7 +350,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); let comment_form = CommentForm { content: "A test comment 32".into(), @@ -351,7 +359,7 @@ mod tests { ..CommentForm::default() }; - let inserted_comment = Comment::create(&conn, &comment_form, None).unwrap(); + let inserted_comment = Comment::create(conn, &comment_form, None).unwrap(); // sara reports let sara_report_form = CommentReportForm { @@ -361,7 +369,7 @@ mod tests { reason: "from sara".into(), }; - let inserted_sara_report = CommentReport::report(&conn, &sara_report_form).unwrap(); + let inserted_sara_report = CommentReport::report(conn, &sara_report_form).unwrap(); // jessica reports let jessica_report_form = CommentReportForm { @@ -371,12 +379,12 @@ mod tests { reason: "from jessica".into(), }; - let inserted_jessica_report = CommentReport::report(&conn, &jessica_report_form).unwrap(); + let inserted_jessica_report = CommentReport::report(conn, &jessica_report_form).unwrap(); - let agg = CommentAggregates::read(&conn, inserted_comment.id).unwrap(); + let agg = CommentAggregates::read(conn, inserted_comment.id).unwrap(); let read_jessica_report_view = - CommentReportView::read(&conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); + CommentReportView::read(conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); let expected_jessica_report_view = CommentReportView { comment_report: inserted_jessica_report.to_owned(), comment: inserted_comment.to_owned(), @@ -418,7 +426,7 @@ mod tests { matrix_user_id: None, ban_expires: None, }, - comment_creator: PersonSafeAlias1 { + comment_creator: PersonSafe { id: inserted_timmy.id, name: inserted_timmy.name.to_owned(), display_name: None, @@ -479,7 +487,7 @@ mod tests { // Do a batch read of timmys reports let reports = CommentReportQuery::builder() - .conn(&conn) + .conn(conn) .my_person_id(inserted_timmy.id) .admin(false) .build() @@ -496,13 +504,13 @@ mod tests { // Make sure the counts are correct let report_count = - CommentReportView::get_report_count(&conn, inserted_timmy.id, false, None).unwrap(); + CommentReportView::get_report_count(conn, inserted_timmy.id, false, None).unwrap(); assert_eq!(2, report_count); // Try to resolve the report - CommentReport::resolve(&conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); + CommentReport::resolve(conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); let read_jessica_report_view_after_resolve = - CommentReportView::read(&conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); + CommentReportView::read(conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); let mut expected_jessica_report_view_after_resolve = expected_jessica_report_view; expected_jessica_report_view_after_resolve @@ -516,7 +524,7 @@ mod tests { .updated = read_jessica_report_view_after_resolve .comment_report .updated; - expected_jessica_report_view_after_resolve.resolver = Some(PersonSafeAlias2 { + expected_jessica_report_view_after_resolve.resolver = Some(PersonSafe { id: inserted_timmy.id, name: inserted_timmy.name.to_owned(), display_name: None, @@ -545,7 +553,7 @@ mod tests { // Do a batch read of timmys reports // It should only show saras, which is unresolved let reports_after_resolve = CommentReportQuery::builder() - .conn(&conn) + .conn(conn) .my_person_id(inserted_timmy.id) .admin(false) .build() @@ -556,12 +564,12 @@ mod tests { // Make sure the counts are correct let report_count_after_resolved = - CommentReportView::get_report_count(&conn, inserted_timmy.id, false, None).unwrap(); + CommentReportView::get_report_count(conn, inserted_timmy.id, false, None).unwrap(); assert_eq!(1, report_count_after_resolved); - Person::delete(&conn, inserted_timmy.id).unwrap(); - Person::delete(&conn, inserted_sara.id).unwrap(); - Person::delete(&conn, inserted_jessica.id).unwrap(); - Community::delete(&conn, inserted_community.id).unwrap(); + Person::delete(conn, inserted_timmy.id).unwrap(); + Person::delete(conn, inserted_sara.id).unwrap(); + Person::delete(conn, inserted_jessica.id).unwrap(); + Community::delete(conn, inserted_community.id).unwrap(); } } diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 0efc4e11..c3597dc2 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -49,7 +49,7 @@ type CommentViewTuple = ( impl CommentView { pub fn read( - conn: &PgConnection, + conn: &mut PgConnection, comment_id: CommentId, my_person_id: Option, ) -> Result { @@ -154,7 +154,7 @@ impl CommentView { #[builder(field_defaults(default))] pub struct CommentQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, listing_type: Option, sort: Option, community_id: Option, @@ -421,7 +421,7 @@ mod tests { inserted_community: Community, } - fn init_data(conn: &PgConnection) -> Data { + fn init_data(conn: &mut PgConnection) -> Data { let new_person = PersonForm { name: "timmy".into(), public_key: Some("pubkey".to_string()), @@ -570,16 +570,16 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); - let data = init_data(&conn); + let conn = &mut establish_unpooled_connection(); + let data = init_data(conn); - let expected_comment_view_no_person = expected_comment_view(&data, &conn); + let expected_comment_view_no_person = expected_comment_view(&data, conn); let mut expected_comment_view_with_person = expected_comment_view_no_person.to_owned(); expected_comment_view_with_person.my_vote = Some(1); let read_comment_views_no_person = CommentQuery::builder() - .conn(&conn) + .conn(conn) .post_id(Some(data.inserted_post.id)) .build() .list() @@ -591,7 +591,7 @@ mod tests { ); let read_comment_views_with_person = CommentQuery::builder() - .conn(&conn) + .conn(conn) .post_id(Some(data.inserted_post.id)) .local_user(Some(&data.inserted_local_user)) .build() @@ -607,7 +607,7 @@ mod tests { assert_eq!(5, read_comment_views_with_person.len()); let read_comment_from_blocked_person = CommentView::read( - &conn, + conn, data.inserted_comment_1.id, Some(data.inserted_person.id), ) @@ -616,18 +616,18 @@ mod tests { // Make sure block set the creator blocked assert!(read_comment_from_blocked_person.creator_blocked); - cleanup(data, &conn); + cleanup(data, conn); } #[test] #[serial] fn test_comment_tree() { - let conn = establish_unpooled_connection(); - let data = init_data(&conn); + let conn = &mut establish_unpooled_connection(); + let data = init_data(conn); let top_path = data.inserted_comment_0.path.clone(); let read_comment_views_top_path = CommentQuery::builder() - .conn(&conn) + .conn(conn) .post_id(Some(data.inserted_post.id)) .parent_path(Some(top_path)) .build() @@ -636,7 +636,7 @@ mod tests { let child_path = data.inserted_comment_1.path.clone(); let read_comment_views_child_path = CommentQuery::builder() - .conn(&conn) + .conn(conn) .post_id(Some(data.inserted_post.id)) .parent_path(Some(child_path)) .build() @@ -656,7 +656,7 @@ mod tests { assert!(!child_comments.contains(&data.inserted_comment_2)); let read_comment_views_top_max_depth = CommentQuery::builder() - .conn(&conn) + .conn(conn) .post_id(Some(data.inserted_post.id)) .max_depth(Some(1)) .build() @@ -665,14 +665,14 @@ mod tests { // Make sure a depth limited one only has the top comment assert_eq!( - expected_comment_view(&data, &conn), + expected_comment_view(&data, conn), read_comment_views_top_max_depth[0] ); assert_eq!(1, read_comment_views_top_max_depth.len()); let child_path = data.inserted_comment_1.path.clone(); let read_comment_views_parent_max_depth = CommentQuery::builder() - .conn(&conn) + .conn(conn) .post_id(Some(data.inserted_post.id)) .parent_path(Some(child_path)) .max_depth(Some(1)) @@ -688,19 +688,19 @@ mod tests { .eq("Comment 3")); assert_eq!(3, read_comment_views_parent_max_depth.len()); - cleanup(data, &conn); + cleanup(data, conn); } #[test] #[serial] fn test_languages() { - let conn = establish_unpooled_connection(); - let data = init_data(&conn); + let conn = &mut establish_unpooled_connection(); + let data = init_data(conn); // by default, user has all languages enabled and should see all comments // (except from blocked user) let all_languages = CommentQuery::builder() - .conn(&conn) + .conn(conn) .local_user(Some(&data.inserted_local_user)) .build() .list() @@ -708,15 +708,15 @@ mod tests { assert_eq!(5, all_languages.len()); // change user lang to finnish, should only show single finnish comment - let finnish_id = Language::read_id_from_code(&conn, "fi").unwrap(); + let finnish_id = Language::read_id_from_code(conn, "fi").unwrap(); LocalUserLanguage::update_user_languages( - &conn, + conn, Some(vec![finnish_id]), data.inserted_local_user.id, ) .unwrap(); let finnish_comment = CommentQuery::builder() - .conn(&conn) + .conn(conn) .local_user(Some(&data.inserted_local_user)) .build() .list() @@ -729,25 +729,25 @@ mod tests { assert_eq!(finnish_id, finnish_comment[0].comment.language_id); // now show all comments with undetermined language (which is the default value) - let undetermined_id = Language::read_id_from_code(&conn, "und").unwrap(); + let undetermined_id = Language::read_id_from_code(conn, "und").unwrap(); LocalUserLanguage::update_user_languages( - &conn, + conn, Some(vec![undetermined_id]), data.inserted_local_user.id, ) .unwrap(); let undetermined_comment = CommentQuery::builder() - .conn(&conn) + .conn(conn) .local_user(Some(&data.inserted_local_user)) .build() .list() .unwrap(); assert_eq!(3, undetermined_comment.len()); - cleanup(data, &conn); + cleanup(data, conn); } - fn cleanup(data: Data, conn: &PgConnection) { + fn cleanup(data: Data, conn: &mut PgConnection) { CommentLike::remove(conn, data.inserted_person.id, data.inserted_comment_0.id).unwrap(); Comment::delete(conn, data.inserted_comment_0.id).unwrap(); Comment::delete(conn, data.inserted_comment_1.id).unwrap(); @@ -757,7 +757,7 @@ mod tests { Person::delete(conn, data.inserted_person_2.id).unwrap(); } - fn expected_comment_view(data: &Data, conn: &PgConnection) -> CommentView { + fn expected_comment_view(data: &Data, conn: &mut PgConnection) -> CommentView { let agg = CommentAggregates::read(conn, data.inserted_comment_0.id).unwrap(); CommentView { creator_banned_from_community: false, diff --git a/crates/db_views/src/local_user_discussion_language_view.rs b/crates/db_views/src/local_user_discussion_language_view.rs index 5c88a2f5..0268de1c 100644 --- a/crates/db_views/src/local_user_discussion_language_view.rs +++ b/crates/db_views/src/local_user_discussion_language_view.rs @@ -14,7 +14,7 @@ type LocalUserDiscussionLanguageViewTuple = (LocalUserSettings, Language); impl LocalUserDiscussionLanguageView { pub fn read_languages( - conn: &PgConnection, + conn: &mut PgConnection, local_user_id: LocalUserId, ) -> Result, Error> { let res = local_user_language::table diff --git a/crates/db_views/src/local_user_view.rs b/crates/db_views/src/local_user_view.rs index 12c26df6..0e6d24b1 100644 --- a/crates/db_views/src/local_user_view.rs +++ b/crates/db_views/src/local_user_view.rs @@ -15,7 +15,7 @@ use lemmy_db_schema::{ type LocalUserViewTuple = (LocalUser, Person, PersonAggregates); impl LocalUserView { - pub fn read(conn: &PgConnection, local_user_id: LocalUserId) -> Result { + pub fn read(conn: &mut PgConnection, local_user_id: LocalUserId) -> Result { let (local_user, person, counts) = local_user::table .find(local_user_id) .inner_join(person::table) @@ -33,7 +33,7 @@ impl LocalUserView { }) } - pub fn read_person(conn: &PgConnection, person_id: PersonId) -> Result { + pub fn read_person(conn: &mut PgConnection, person_id: PersonId) -> Result { let (local_user, person, counts) = local_user::table .filter(person::id.eq(person_id)) .inner_join(person::table) @@ -52,7 +52,7 @@ impl LocalUserView { } // TODO check where this is used - pub fn read_from_name(conn: &PgConnection, name: &str) -> Result { + pub fn read_from_name(conn: &mut PgConnection, name: &str) -> Result { let (local_user, person, counts) = local_user::table .filter(person::name.eq(name)) .inner_join(person::table) @@ -70,7 +70,10 @@ impl LocalUserView { }) } - pub fn find_by_email_or_name(conn: &PgConnection, name_or_email: &str) -> Result { + pub fn find_by_email_or_name( + conn: &mut PgConnection, + name_or_email: &str, + ) -> Result { let (local_user, person, counts) = local_user::table .inner_join(person::table) .inner_join(person_aggregates::table.on(person::id.eq(person_aggregates::person_id))) @@ -92,7 +95,7 @@ impl LocalUserView { }) } - pub fn find_by_email(conn: &PgConnection, from_email: &str) -> Result { + pub fn find_by_email(conn: &mut PgConnection, from_email: &str) -> Result { let (local_user, person, counts) = local_user::table .inner_join(person::table) .inner_join(person_aggregates::table.on(person::id.eq(person_aggregates::person_id))) @@ -114,7 +117,7 @@ impl LocalUserView { type LocalUserSettingsViewTuple = (LocalUserSettings, PersonSafe, PersonAggregates); impl LocalUserSettingsView { - pub fn read(conn: &PgConnection, local_user_id: LocalUserId) -> Result { + pub fn read(conn: &mut PgConnection, local_user_id: LocalUserId) -> Result { let (local_user, person, counts) = local_user::table .find(local_user_id) .inner_join(person::table) diff --git a/crates/db_views/src/post_report_view.rs b/crates/db_views/src/post_report_view.rs index 1a519fff..472795b5 100644 --- a/crates/db_views/src/post_report_view.rs +++ b/crates/db_views/src/post_report_view.rs @@ -8,8 +8,6 @@ use lemmy_db_schema::{ community_moderator, community_person_ban, person, - person_alias_1, - person_alias_2, post, post_aggregates, post_like, @@ -17,7 +15,7 @@ use lemmy_db_schema::{ }, source::{ community::{Community, CommunityPersonBan, CommunitySafe}, - person::{Person, PersonAlias1, PersonAlias2, PersonSafe, PersonSafeAlias1, PersonSafeAlias2}, + person::{Person, PersonSafe}, post::Post, post_report::PostReport, }, @@ -31,11 +29,11 @@ type PostReportViewTuple = ( Post, CommunitySafe, PersonSafe, - PersonSafeAlias1, + PersonSafe, Option, Option, PostAggregates, - Option, + Option, ); impl PostReportView { @@ -43,10 +41,12 @@ impl PostReportView { /// /// * `report_id` - the report id to obtain pub fn read( - conn: &PgConnection, + conn: &mut PgConnection, report_id: PostReportId, my_person_id: PersonId, ) -> Result { + let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2); + let ( post_report, post, @@ -62,7 +62,7 @@ impl PostReportView { .inner_join(post::table) .inner_join(community::table.on(post::community_id.eq(community::id))) .inner_join(person::table.on(post_report::creator_id.eq(person::id))) - .inner_join(person_alias_1::table.on(post::creator_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id)))) .left_join( community_person_ban::table.on( post::community_id @@ -84,18 +84,18 @@ impl PostReportView { ) .inner_join(post_aggregates::table.on(post_report::post_id.eq(post_aggregates::post_id))) .left_join( - person_alias_2::table.on(post_report::resolver_id.eq(person_alias_2::id.nullable())), + person_alias_2.on(post_report::resolver_id.eq(person_alias_2.field(person::id).nullable())), ) .select(( post_report::all_columns, post::all_columns, Community::safe_columns_tuple(), Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), community_person_ban::all_columns.nullable(), post_like::score.nullable(), post_aggregates::all_columns, - PersonAlias2::safe_columns_tuple().nullable(), + person_alias_2.fields(Person::safe_columns_tuple().nullable()), )) .first::(conn)?; @@ -116,7 +116,7 @@ impl PostReportView { /// returns the current unresolved post report count for the communities you mod pub fn get_report_count( - conn: &PgConnection, + conn: &mut PgConnection, my_person_id: PersonId, admin: bool, community_id: Option, @@ -153,7 +153,7 @@ impl PostReportView { #[builder(field_defaults(default))] pub struct PostReportQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, #[builder(!default)] my_person_id: PersonId, #[builder(!default)] @@ -166,11 +166,13 @@ pub struct PostReportQuery<'a> { impl<'a> PostReportQuery<'a> { pub fn list(self) -> Result, Error> { + let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2); + let mut query = post_report::table .inner_join(post::table) .inner_join(community::table.on(post::community_id.eq(community::id))) .inner_join(person::table.on(post_report::creator_id.eq(person::id))) - .inner_join(person_alias_1::table.on(post::creator_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id)))) .left_join( community_person_ban::table.on( post::community_id @@ -192,18 +194,20 @@ impl<'a> PostReportQuery<'a> { ) .inner_join(post_aggregates::table.on(post_report::post_id.eq(post_aggregates::post_id))) .left_join( - person_alias_2::table.on(post_report::resolver_id.eq(person_alias_2::id.nullable())), + person_alias_2.on(post_report::resolver_id.eq(person_alias_2.field(person::id).nullable())), ) .select(( post_report::all_columns, post::all_columns, Community::safe_columns_tuple(), Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), community_person_ban::all_columns.nullable(), post_like::score.nullable(), post_aggregates::all_columns, - PersonAlias2::safe_columns_tuple().nullable(), + person_alias_2 + .fields(Person::safe_columns_tuple()) + .nullable(), )) .into_boxed(); @@ -280,7 +284,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person = PersonForm { name: "timmy_prv".into(), @@ -288,7 +292,7 @@ mod tests { ..PersonForm::default() }; - let inserted_timmy = Person::create(&conn, &new_person).unwrap(); + let inserted_timmy = Person::create(conn, &new_person).unwrap(); let new_person_2 = PersonForm { name: "sara_prv".into(), @@ -296,7 +300,7 @@ mod tests { ..PersonForm::default() }; - let inserted_sara = Person::create(&conn, &new_person_2).unwrap(); + let inserted_sara = Person::create(conn, &new_person_2).unwrap(); // Add a third person, since new ppl can only report something once. let new_person_3 = PersonForm { @@ -305,7 +309,7 @@ mod tests { ..PersonForm::default() }; - let inserted_jessica = Person::create(&conn, &new_person_3).unwrap(); + let inserted_jessica = Person::create(conn, &new_person_3).unwrap(); let new_community = CommunityForm { name: "test community prv".to_string(), @@ -314,7 +318,7 @@ mod tests { ..CommunityForm::default() }; - let inserted_community = Community::create(&conn, &new_community).unwrap(); + let inserted_community = Community::create(conn, &new_community).unwrap(); // Make timmy a mod let timmy_moderator_form = CommunityModeratorForm { @@ -322,7 +326,7 @@ mod tests { person_id: inserted_timmy.id, }; - let _inserted_moderator = CommunityModerator::join(&conn, &timmy_moderator_form).unwrap(); + let _inserted_moderator = CommunityModerator::join(conn, &timmy_moderator_form).unwrap(); let new_post = PostForm { name: "A test post crv".into(), @@ -331,7 +335,7 @@ mod tests { ..PostForm::default() }; - let inserted_post = Post::create(&conn, &new_post).unwrap(); + let inserted_post = Post::create(conn, &new_post).unwrap(); // sara reports let sara_report_form = PostReportForm { @@ -343,7 +347,7 @@ mod tests { reason: "from sara".into(), }; - let inserted_sara_report = PostReport::report(&conn, &sara_report_form).unwrap(); + let inserted_sara_report = PostReport::report(conn, &sara_report_form).unwrap(); // jessica reports let jessica_report_form = PostReportForm { @@ -355,12 +359,12 @@ mod tests { reason: "from jessica".into(), }; - let inserted_jessica_report = PostReport::report(&conn, &jessica_report_form).unwrap(); + let inserted_jessica_report = PostReport::report(conn, &jessica_report_form).unwrap(); - let agg = PostAggregates::read(&conn, inserted_post.id).unwrap(); + let agg = PostAggregates::read(conn, inserted_post.id).unwrap(); let read_jessica_report_view = - PostReportView::read(&conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); + PostReportView::read(conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); let expected_jessica_report_view = PostReportView { post_report: inserted_jessica_report.to_owned(), post: inserted_post.to_owned(), @@ -401,7 +405,7 @@ mod tests { matrix_user_id: None, ban_expires: None, }, - post_creator: PersonSafeAlias1 { + post_creator: PersonSafe { id: inserted_timmy.id, name: inserted_timmy.name.to_owned(), display_name: None, @@ -466,7 +470,7 @@ mod tests { // Do a batch read of timmys reports let reports = PostReportQuery::builder() - .conn(&conn) + .conn(conn) .my_person_id(inserted_timmy.id) .admin(false) .build() @@ -483,13 +487,13 @@ mod tests { // Make sure the counts are correct let report_count = - PostReportView::get_report_count(&conn, inserted_timmy.id, false, None).unwrap(); + PostReportView::get_report_count(conn, inserted_timmy.id, false, None).unwrap(); assert_eq!(2, report_count); // Try to resolve the report - PostReport::resolve(&conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); + PostReport::resolve(conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); let read_jessica_report_view_after_resolve = - PostReportView::read(&conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); + PostReportView::read(conn, inserted_jessica_report.id, inserted_timmy.id).unwrap(); let mut expected_jessica_report_view_after_resolve = expected_jessica_report_view; expected_jessica_report_view_after_resolve @@ -501,7 +505,7 @@ mod tests { expected_jessica_report_view_after_resolve .post_report .updated = read_jessica_report_view_after_resolve.post_report.updated; - expected_jessica_report_view_after_resolve.resolver = Some(PersonSafeAlias2 { + expected_jessica_report_view_after_resolve.resolver = Some(PersonSafe { id: inserted_timmy.id, name: inserted_timmy.name.to_owned(), display_name: None, @@ -530,7 +534,7 @@ mod tests { // Do a batch read of timmys reports // It should only show saras, which is unresolved let reports_after_resolve = PostReportQuery::builder() - .conn(&conn) + .conn(conn) .my_person_id(inserted_timmy.id) .admin(false) .build() @@ -540,12 +544,12 @@ mod tests { // Make sure the counts are correct let report_count_after_resolved = - PostReportView::get_report_count(&conn, inserted_timmy.id, false, None).unwrap(); + PostReportView::get_report_count(conn, inserted_timmy.id, false, None).unwrap(); assert_eq!(1, report_count_after_resolved); - Person::delete(&conn, inserted_timmy.id).unwrap(); - Person::delete(&conn, inserted_sara.id).unwrap(); - Person::delete(&conn, inserted_jessica.id).unwrap(); - Community::delete(&conn, inserted_community.id).unwrap(); + Person::delete(conn, inserted_timmy.id).unwrap(); + Person::delete(conn, inserted_sara.id).unwrap(); + Person::delete(conn, inserted_jessica.id).unwrap(); + Community::delete(conn, inserted_community.id).unwrap(); } } diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index f81194f1..3a4c87f5 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -50,7 +50,7 @@ type PostViewTuple = ( impl PostView { pub fn read( - conn: &PgConnection, + conn: &mut PgConnection, post_id: PostId, my_person_id: Option, ) -> Result { @@ -164,7 +164,7 @@ impl PostView { #[builder(field_defaults(default))] pub struct PostQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, listing_type: Option, sort: Option, creator_id: Option, @@ -460,7 +460,7 @@ mod tests { inserted_post: Post, } - fn init_data(conn: &PgConnection) -> Data { + fn init_data(conn: &mut PgConnection) -> Data { let person_name = "tegan".to_string(); let new_person = PersonForm { @@ -556,18 +556,18 @@ mod tests { #[test] #[serial] fn post_listing_with_person() { - let conn = establish_unpooled_connection(); - let data = init_data(&conn); + let conn = &mut establish_unpooled_connection(); + let data = init_data(conn); let local_user_form = LocalUserForm { show_bot_accounts: Some(false), ..Default::default() }; let inserted_local_user = - LocalUser::update(&conn, data.inserted_local_user.id, &local_user_form).unwrap(); + LocalUser::update(conn, data.inserted_local_user.id, &local_user_form).unwrap(); let read_post_listing = PostQuery::builder() - .conn(&conn) + .conn(conn) .sort(Some(SortType::New)) .community_id(Some(data.inserted_community.id)) .local_user(Some(&inserted_local_user)) @@ -576,9 +576,9 @@ mod tests { .unwrap(); let post_listing_single_with_person = - PostView::read(&conn, data.inserted_post.id, Some(data.inserted_person.id)).unwrap(); + PostView::read(conn, data.inserted_post.id, Some(data.inserted_person.id)).unwrap(); - let mut expected_post_listing_with_user = expected_post_view(&data, &conn); + let mut expected_post_listing_with_user = expected_post_view(&data, conn); // Should be only one person, IE the bot post, and blocked should be missing assert_eq!(1, read_post_listing.len()); @@ -595,10 +595,10 @@ mod tests { ..Default::default() }; let inserted_local_user = - LocalUser::update(&conn, data.inserted_local_user.id, &local_user_form).unwrap(); + LocalUser::update(conn, data.inserted_local_user.id, &local_user_form).unwrap(); let post_listings_with_bots = PostQuery::builder() - .conn(&conn) + .conn(conn) .sort(Some(SortType::New)) .community_id(Some(data.inserted_community.id)) .local_user(Some(&inserted_local_user)) @@ -608,17 +608,17 @@ mod tests { // should include bot post which has "undetermined" language assert_eq!(2, post_listings_with_bots.len()); - cleanup(data, &conn); + cleanup(data, conn); } #[test] #[serial] fn post_listing_no_person() { - let conn = establish_unpooled_connection(); - let data = init_data(&conn); + let conn = &mut establish_unpooled_connection(); + let data = init_data(conn); let read_post_listing_multiple_no_person = PostQuery::builder() - .conn(&conn) + .conn(conn) .sort(Some(SortType::New)) .community_id(Some(data.inserted_community.id)) .build() @@ -626,9 +626,9 @@ mod tests { .unwrap(); let read_post_listing_single_no_person = - PostView::read(&conn, data.inserted_post.id, None).unwrap(); + PostView::read(conn, data.inserted_post.id, None).unwrap(); - let expected_post_listing_no_person = expected_post_view(&data, &conn); + let expected_post_listing_no_person = expected_post_view(&data, conn); // Should be 2 posts, with the bot post, and the blocked assert_eq!(3, read_post_listing_multiple_no_person.len()); @@ -642,23 +642,23 @@ mod tests { read_post_listing_single_no_person ); - cleanup(data, &conn); + cleanup(data, conn); } #[test] #[serial] fn post_listing_block_community() { - let conn = establish_unpooled_connection(); - let data = init_data(&conn); + let conn = &mut establish_unpooled_connection(); + let data = init_data(conn); let community_block = CommunityBlockForm { person_id: data.inserted_person.id, community_id: data.inserted_community.id, }; - CommunityBlock::block(&conn, &community_block).unwrap(); + CommunityBlock::block(conn, &community_block).unwrap(); let read_post_listings_with_person_after_block = PostQuery::builder() - .conn(&conn) + .conn(conn) .sort(Some(SortType::New)) .community_id(Some(data.inserted_community.id)) .local_user(Some(&data.inserted_local_user)) @@ -668,15 +668,15 @@ mod tests { // Should be 0 posts after the community block assert_eq!(0, read_post_listings_with_person_after_block.len()); - CommunityBlock::unblock(&conn, &community_block).unwrap(); - cleanup(data, &conn); + CommunityBlock::unblock(conn, &community_block).unwrap(); + cleanup(data, conn); } #[test] #[serial] fn post_listing_like() { - let conn = establish_unpooled_connection(); - let data = init_data(&conn); + let conn = &mut establish_unpooled_connection(); + let data = init_data(conn); let post_like_form = PostLikeForm { post_id: data.inserted_post.id, @@ -684,7 +684,7 @@ mod tests { score: 1, }; - let inserted_post_like = PostLike::like(&conn, &post_like_form).unwrap(); + let inserted_post_like = PostLike::like(conn, &post_like_form).unwrap(); let expected_post_like = PostLike { id: inserted_post_like.id, @@ -696,18 +696,18 @@ mod tests { assert_eq!(expected_post_like, inserted_post_like); let like_removed = - PostLike::remove(&conn, data.inserted_person.id, data.inserted_post.id).unwrap(); + PostLike::remove(conn, data.inserted_person.id, data.inserted_post.id).unwrap(); assert_eq!(1, like_removed); - cleanup(data, &conn); + cleanup(data, conn); } #[test] #[serial] fn post_listing_person_language() { - let conn = establish_unpooled_connection(); - let data = init_data(&conn); + let conn = &mut establish_unpooled_connection(); + let data = init_data(conn); - let spanish_id = Language::read_id_from_code(&conn, "es").unwrap(); + let spanish_id = Language::read_id_from_code(conn, "es").unwrap(); let post_spanish = PostForm { name: "asffgdsc".to_string(), creator_id: data.inserted_person.id, @@ -716,10 +716,10 @@ mod tests { ..PostForm::default() }; - Post::create(&conn, &post_spanish).unwrap(); + Post::create(conn, &post_spanish).unwrap(); let post_listings_all = PostQuery::builder() - .conn(&conn) + .conn(conn) .sort(Some(SortType::New)) .local_user(Some(&data.inserted_local_user)) .build() @@ -729,16 +729,16 @@ mod tests { // no language filters specified, all posts should be returned assert_eq!(3, post_listings_all.len()); - let french_id = Language::read_id_from_code(&conn, "fr").unwrap(); + let french_id = Language::read_id_from_code(conn, "fr").unwrap(); LocalUserLanguage::update_user_languages( - &conn, + conn, Some(vec![french_id]), data.inserted_local_user.id, ) .unwrap(); let post_listing_french = PostQuery::builder() - .conn(&conn) + .conn(conn) .sort(Some(SortType::New)) .local_user(Some(&data.inserted_local_user)) .build() @@ -749,15 +749,15 @@ mod tests { assert_eq!(1, post_listing_french.len()); assert_eq!(french_id, post_listing_french[0].post.language_id); - let undetermined_id = Language::read_id_from_code(&conn, "und").unwrap(); + let undetermined_id = Language::read_id_from_code(conn, "und").unwrap(); LocalUserLanguage::update_user_languages( - &conn, + conn, Some(vec![french_id, undetermined_id]), data.inserted_local_user.id, ) .unwrap(); let post_listings_french_und = PostQuery::builder() - .conn(&conn) + .conn(conn) .sort(Some(SortType::New)) .local_user(Some(&data.inserted_local_user)) .build() @@ -772,10 +772,10 @@ mod tests { ); assert_eq!(french_id, post_listings_french_und[1].post.language_id); - cleanup(data, &conn); + cleanup(data, conn); } - fn cleanup(data: Data, conn: &PgConnection) { + fn cleanup(data: Data, conn: &mut PgConnection) { let num_deleted = Post::delete(conn, data.inserted_post.id).unwrap(); Community::delete(conn, data.inserted_community.id).unwrap(); Person::delete(conn, data.inserted_person.id).unwrap(); @@ -784,7 +784,7 @@ mod tests { assert_eq!(1, num_deleted); } - fn expected_post_view(data: &Data, conn: &PgConnection) -> PostView { + fn expected_post_view(data: &Data, conn: &mut PgConnection) -> PostView { let (inserted_person, inserted_community, inserted_post) = ( &data.inserted_person, &data.inserted_community, diff --git a/crates/db_views/src/private_message_report_view.rs b/crates/db_views/src/private_message_report_view.rs index c7b2f590..9a597684 100644 --- a/crates/db_views/src/private_message_report_view.rs +++ b/crates/db_views/src/private_message_report_view.rs @@ -2,9 +2,9 @@ use crate::structs::PrivateMessageReportView; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PrivateMessageReportId, - schema::{person, person_alias_1, person_alias_2, private_message, private_message_report}, + schema::{person, private_message, private_message_report}, source::{ - person::{Person, PersonAlias1, PersonAlias2, PersonSafe, PersonSafeAlias1, PersonSafeAlias2}, + person::{Person, PersonSafe}, private_message::PrivateMessage, private_message_report::PrivateMessageReport, }, @@ -17,33 +17,39 @@ type PrivateMessageReportViewTuple = ( PrivateMessageReport, PrivateMessage, PersonSafe, - PersonSafeAlias1, - Option, + PersonSafe, + Option, ); impl PrivateMessageReportView { /// returns the PrivateMessageReportView for the provided report_id /// /// * `report_id` - the report id to obtain - pub fn read(conn: &PgConnection, report_id: PrivateMessageReportId) -> Result { + pub fn read(conn: &mut PgConnection, report_id: PrivateMessageReportId) -> Result { + let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2); + let (private_message_report, private_message, private_message_creator, creator, resolver) = private_message_report::table .find(report_id) .inner_join(private_message::table) .inner_join(person::table.on(private_message::creator_id.eq(person::id))) .inner_join( - person_alias_1::table.on(private_message_report::creator_id.eq(person_alias_1::id)), + person_alias_1 + .on(private_message_report::creator_id.eq(person_alias_1.field(person::id))), ) .left_join( - person_alias_2::table - .on(private_message_report::resolver_id.eq(person_alias_2::id.nullable())), + person_alias_2.on( + private_message_report::resolver_id.eq(person_alias_2.field(person::id).nullable()), + ), ) .select(( private_message_report::all_columns, private_message::all_columns, Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), - PersonAlias2::safe_columns_tuple().nullable(), + person_alias_1.fields(Person::safe_columns_tuple()), + person_alias_2 + .fields(Person::safe_columns_tuple()) + .nullable(), )) .first::(conn)?; @@ -57,7 +63,7 @@ impl PrivateMessageReportView { } /// Returns the current unresolved post report count for the communities you mod - pub fn get_report_count(conn: &PgConnection) -> Result { + pub fn get_report_count(conn: &mut PgConnection) -> Result { use diesel::dsl::*; private_message_report::table @@ -73,7 +79,7 @@ impl PrivateMessageReportView { #[builder(field_defaults(default))] pub struct PrivateMessageReportQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, page: Option, limit: Option, unresolved_only: Option, @@ -81,22 +87,26 @@ pub struct PrivateMessageReportQuery<'a> { impl<'a> PrivateMessageReportQuery<'a> { pub fn list(self) -> Result, Error> { + let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2); + let mut query = private_message_report::table .inner_join(private_message::table) .inner_join(person::table.on(private_message::creator_id.eq(person::id))) .inner_join( - person_alias_1::table.on(private_message_report::creator_id.eq(person_alias_1::id)), + person_alias_1.on(private_message_report::creator_id.eq(person_alias_1.field(person::id))), ) .left_join( - person_alias_2::table - .on(private_message_report::resolver_id.eq(person_alias_2::id.nullable())), + person_alias_2 + .on(private_message_report::resolver_id.eq(person_alias_2.field(person::id).nullable())), ) .select(( private_message_report::all_columns, private_message::all_columns, Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), - PersonAlias2::safe_columns_tuple().nullable(), + person_alias_1.fields(Person::safe_columns_tuple()), + person_alias_2 + .fields(Person::safe_columns_tuple()) + .nullable(), )) .into_boxed(); @@ -150,21 +160,21 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let new_person_1 = PersonForm { name: "timmy_mrv".into(), public_key: Some("pubkey".to_string()), ..PersonForm::default() }; - let inserted_timmy = Person::create(&conn, &new_person_1).unwrap(); + let inserted_timmy = Person::create(conn, &new_person_1).unwrap(); let new_person_2 = PersonForm { name: "jessica_mrv".into(), public_key: Some("pubkey".to_string()), ..PersonForm::default() }; - let inserted_jessica = Person::create(&conn, &new_person_2).unwrap(); + let inserted_jessica = Person::create(conn, &new_person_2).unwrap(); // timmy sends private message to jessica let pm_form = PrivateMessageForm { @@ -173,7 +183,7 @@ mod tests { content: "something offensive".to_string(), ..Default::default() }; - let pm = PrivateMessage::create(&conn, &pm_form).unwrap(); + let pm = PrivateMessage::create(conn, &pm_form).unwrap(); // jessica reports private message let pm_report_form = PrivateMessageReportForm { @@ -182,10 +192,10 @@ mod tests { private_message_id: pm.id, reason: "its offensive".to_string(), }; - let pm_report = PrivateMessageReport::report(&conn, &pm_report_form).unwrap(); + let pm_report = PrivateMessageReport::report(conn, &pm_report_form).unwrap(); let reports = PrivateMessageReportQuery::builder() - .conn(&conn) + .conn(conn) .build() .list() .unwrap(); @@ -201,13 +211,13 @@ mod tests { public_key: Some("pubkey".to_string()), ..PersonForm::default() }; - let inserted_admin = Person::create(&conn, &new_person_3).unwrap(); + let inserted_admin = Person::create(conn, &new_person_3).unwrap(); // admin resolves the report (after taking appropriate action) - PrivateMessageReport::resolve(&conn, pm_report.id, inserted_admin.id).unwrap(); + PrivateMessageReport::resolve(conn, pm_report.id, inserted_admin.id).unwrap(); let reports = PrivateMessageReportQuery::builder() - .conn(&conn) + .conn(conn) .unresolved_only(Some(false)) .build() .list() diff --git a/crates/db_views/src/private_message_view.rs b/crates/db_views/src/private_message_view.rs index 151c50aa..281df8ba 100644 --- a/crates/db_views/src/private_message_view.rs +++ b/crates/db_views/src/private_message_view.rs @@ -2,9 +2,9 @@ use crate::structs::PrivateMessageView; use diesel::{pg::Pg, result::Error, *}; use lemmy_db_schema::{ newtypes::{PersonId, PrivateMessageId}, - schema::{person, person_alias_1, private_message}, + schema::{person, private_message}, source::{ - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, private_message::PrivateMessage, }, traits::{ToSafe, ViewToVec}, @@ -13,19 +13,26 @@ use lemmy_db_schema::{ use tracing::debug; use typed_builder::TypedBuilder; -type PrivateMessageViewTuple = (PrivateMessage, PersonSafe, PersonSafeAlias1); +type PrivateMessageViewTuple = (PrivateMessage, PersonSafe, PersonSafe); impl PrivateMessageView { - pub fn read(conn: &PgConnection, private_message_id: PrivateMessageId) -> Result { + pub fn read( + conn: &mut PgConnection, + private_message_id: PrivateMessageId, + ) -> Result { + let person_alias_1 = diesel::alias!(person as person1); + let (private_message, creator, recipient) = private_message::table .find(private_message_id) .inner_join(person::table.on(private_message::creator_id.eq(person::id))) - .inner_join(person_alias_1::table.on(private_message::recipient_id.eq(person_alias_1::id))) + .inner_join( + person_alias_1.on(private_message::recipient_id.eq(person_alias_1.field(person::id))), + ) .order_by(private_message::published.desc()) .select(( private_message::all_columns, Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), )) .first::(conn)?; @@ -37,7 +44,10 @@ impl PrivateMessageView { } /// Gets the number of unread messages - pub fn get_unread_messages(conn: &PgConnection, my_person_id: PersonId) -> Result { + pub fn get_unread_messages( + conn: &mut PgConnection, + my_person_id: PersonId, + ) -> Result { use diesel::dsl::*; private_message::table .filter(private_message::read.eq(false)) @@ -52,7 +62,7 @@ impl PrivateMessageView { #[builder(field_defaults(default))] pub struct PrivateMessageQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, #[builder(!default)] recipient_id: PersonId, unread_only: Option, @@ -62,13 +72,17 @@ pub struct PrivateMessageQuery<'a> { impl<'a> PrivateMessageQuery<'a> { pub fn list(self) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); + let mut query = private_message::table .inner_join(person::table.on(private_message::creator_id.eq(person::id))) - .inner_join(person_alias_1::table.on(private_message::recipient_id.eq(person_alias_1::id))) + .inner_join( + person_alias_1.on(private_message::recipient_id.eq(person_alias_1.field(person::id))), + ) .select(( private_message::all_columns, Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), )) .into_boxed(); diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index c4f040f4..b4c84829 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -1,10 +1,10 @@ use crate::structs::RegistrationApplicationView; use diesel::{dsl::count, result::Error, *}; use lemmy_db_schema::{ - schema::{local_user, person, person_alias_1, registration_application}, + schema::{local_user, person, registration_application}, source::{ local_user::{LocalUser, LocalUserSettings}, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, registration_application::RegistrationApplication, }, traits::{ToSafe, ToSafeSettings, ViewToVec}, @@ -16,11 +16,13 @@ type RegistrationApplicationViewTuple = ( RegistrationApplication, LocalUserSettings, PersonSafe, - Option, + Option, ); impl RegistrationApplicationView { - pub fn read(conn: &PgConnection, registration_application_id: i32) -> Result { + pub fn read(conn: &mut PgConnection, registration_application_id: i32) -> Result { + let person_alias_1 = diesel::alias!(person as person1); + let (registration_application, creator_local_user, creator, admin) = registration_application::table .find(registration_application_id) @@ -29,15 +31,17 @@ impl RegistrationApplicationView { ) .inner_join(person::table.on(local_user::person_id.eq(person::id))) .left_join( - person_alias_1::table - .on(registration_application::admin_id.eq(person_alias_1::id.nullable())), + person_alias_1 + .on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())), ) .order_by(registration_application::published.desc()) .select(( registration_application::all_columns, LocalUser::safe_settings_columns_tuple(), Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple().nullable(), + person_alias_1 + .fields(Person::safe_columns_tuple()) + .nullable(), )) .first::(conn)?; @@ -50,13 +54,18 @@ impl RegistrationApplicationView { } /// Returns the current unread registration_application count - pub fn get_unread_count(conn: &PgConnection, verified_email_only: bool) -> Result { + pub fn get_unread_count( + conn: &mut PgConnection, + verified_email_only: bool, + ) -> Result { + let person_alias_1 = diesel::alias!(person as person1); + let mut query = registration_application::table .inner_join(local_user::table.on(registration_application::local_user_id.eq(local_user::id))) .inner_join(person::table.on(local_user::person_id.eq(person::id))) .left_join( - person_alias_1::table - .on(registration_application::admin_id.eq(person_alias_1::id.nullable())), + person_alias_1 + .on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())), ) .filter(registration_application::admin_id.is_null()) .into_boxed(); @@ -75,7 +84,7 @@ impl RegistrationApplicationView { #[builder(field_defaults(default))] pub struct RegistrationApplicationQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, unread_only: Option, verified_email_only: Option, page: Option, @@ -84,19 +93,23 @@ pub struct RegistrationApplicationQuery<'a> { impl<'a> RegistrationApplicationQuery<'a> { pub fn list(self) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); + let mut query = registration_application::table .inner_join(local_user::table.on(registration_application::local_user_id.eq(local_user::id))) .inner_join(person::table.on(local_user::person_id.eq(person::id))) .left_join( - person_alias_1::table - .on(registration_application::admin_id.eq(person_alias_1::id.nullable())), + person_alias_1 + .on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())), ) .order_by(registration_application::published.desc()) .select(( registration_application::all_columns, LocalUser::safe_settings_columns_tuple(), Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple().nullable(), + person_alias_1 + .fields(Person::safe_columns_tuple()) + .nullable(), )) .into_boxed(); @@ -156,7 +169,7 @@ mod tests { #[test] #[serial] fn test_crud() { - let conn = establish_unpooled_connection(); + let conn = &mut establish_unpooled_connection(); let timmy_person_form = PersonForm { name: "timmy_rav".into(), @@ -165,7 +178,7 @@ mod tests { ..PersonForm::default() }; - let inserted_timmy_person = Person::create(&conn, &timmy_person_form).unwrap(); + let inserted_timmy_person = Person::create(conn, &timmy_person_form).unwrap(); let timmy_local_user_form = LocalUserForm { person_id: Some(inserted_timmy_person.id), @@ -173,7 +186,7 @@ mod tests { ..LocalUserForm::default() }; - let _inserted_timmy_local_user = LocalUser::create(&conn, &timmy_local_user_form).unwrap(); + let _inserted_timmy_local_user = LocalUser::create(conn, &timmy_local_user_form).unwrap(); let sara_person_form = PersonForm { name: "sara_rav".into(), @@ -181,7 +194,7 @@ mod tests { ..PersonForm::default() }; - let inserted_sara_person = Person::create(&conn, &sara_person_form).unwrap(); + let inserted_sara_person = Person::create(conn, &sara_person_form).unwrap(); let sara_local_user_form = LocalUserForm { person_id: Some(inserted_sara_person.id), @@ -189,7 +202,7 @@ mod tests { ..LocalUserForm::default() }; - let inserted_sara_local_user = LocalUser::create(&conn, &sara_local_user_form).unwrap(); + let inserted_sara_local_user = LocalUser::create(conn, &sara_local_user_form).unwrap(); // Sara creates an application let sara_app_form = RegistrationApplicationForm { @@ -198,9 +211,9 @@ mod tests { ..RegistrationApplicationForm::default() }; - let sara_app = RegistrationApplication::create(&conn, &sara_app_form).unwrap(); + let sara_app = RegistrationApplication::create(conn, &sara_app_form).unwrap(); - let read_sara_app_view = RegistrationApplicationView::read(&conn, sara_app.id).unwrap(); + let read_sara_app_view = RegistrationApplicationView::read(conn, sara_app.id).unwrap(); let jess_person_form = PersonForm { name: "jess_rav".into(), @@ -208,7 +221,7 @@ mod tests { ..PersonForm::default() }; - let inserted_jess_person = Person::create(&conn, &jess_person_form).unwrap(); + let inserted_jess_person = Person::create(conn, &jess_person_form).unwrap(); let jess_local_user_form = LocalUserForm { person_id: Some(inserted_jess_person.id), @@ -216,7 +229,7 @@ mod tests { ..LocalUserForm::default() }; - let inserted_jess_local_user = LocalUser::create(&conn, &jess_local_user_form).unwrap(); + let inserted_jess_local_user = LocalUser::create(conn, &jess_local_user_form).unwrap(); // Sara creates an application let jess_app_form = RegistrationApplicationForm { @@ -225,9 +238,9 @@ mod tests { ..RegistrationApplicationForm::default() }; - let jess_app = RegistrationApplication::create(&conn, &jess_app_form).unwrap(); + let jess_app = RegistrationApplication::create(conn, &jess_app_form).unwrap(); - let read_jess_app_view = RegistrationApplicationView::read(&conn, jess_app.id).unwrap(); + let read_jess_app_view = RegistrationApplicationView::read(conn, jess_app.id).unwrap(); let mut expected_sara_app_view = RegistrationApplicationView { registration_application: sara_app.to_owned(), @@ -277,7 +290,7 @@ mod tests { // Do a batch read of the applications let apps = RegistrationApplicationQuery::builder() - .conn(&conn) + .conn(conn) .unread_only(Some(true)) .build() .list() @@ -292,7 +305,7 @@ mod tests { ); // Make sure the counts are correct - let unread_count = RegistrationApplicationView::get_unread_count(&conn, false).unwrap(); + let unread_count = RegistrationApplicationView::get_unread_count(conn, false).unwrap(); assert_eq!(unread_count, 2); // Approve the application @@ -302,7 +315,7 @@ mod tests { ..RegistrationApplicationForm::default() }; - RegistrationApplication::update(&conn, sara_app.id, &approve_form).unwrap(); + RegistrationApplication::update(conn, sara_app.id, &approve_form).unwrap(); // Update the local_user row let approve_local_user_form = LocalUserForm { @@ -310,10 +323,10 @@ mod tests { ..LocalUserForm::default() }; - LocalUser::update(&conn, inserted_sara_local_user.id, &approve_local_user_form).unwrap(); + LocalUser::update(conn, inserted_sara_local_user.id, &approve_local_user_form).unwrap(); let read_sara_app_view_after_approve = - RegistrationApplicationView::read(&conn, sara_app.id).unwrap(); + RegistrationApplicationView::read(conn, sara_app.id).unwrap(); // Make sure the columns changed expected_sara_app_view @@ -321,7 +334,7 @@ mod tests { .accepted_application = true; expected_sara_app_view.registration_application.admin_id = Some(inserted_timmy_person.id); - expected_sara_app_view.admin = Some(PersonSafeAlias1 { + expected_sara_app_view.admin = Some(PersonSafe { id: inserted_timmy_person.id, name: inserted_timmy_person.name.to_owned(), display_name: None, @@ -346,7 +359,7 @@ mod tests { // Do a batch read of apps again // It should show only jessicas which is unresolved let apps_after_resolve = RegistrationApplicationQuery::builder() - .conn(&conn) + .conn(conn) .unread_only(Some(true)) .build() .list() @@ -355,19 +368,19 @@ mod tests { // Make sure the counts are correct let unread_count_after_approve = - RegistrationApplicationView::get_unread_count(&conn, false).unwrap(); + RegistrationApplicationView::get_unread_count(conn, false).unwrap(); assert_eq!(unread_count_after_approve, 1); // Make sure the not undenied_only has all the apps let all_apps = RegistrationApplicationQuery::builder() - .conn(&conn) + .conn(conn) .build() .list() .unwrap(); assert_eq!(all_apps.len(), 2); - Person::delete(&conn, inserted_timmy_person.id).unwrap(); - Person::delete(&conn, inserted_sara_person.id).unwrap(); - Person::delete(&conn, inserted_jess_person.id).unwrap(); + Person::delete(conn, inserted_timmy_person.id).unwrap(); + Person::delete(conn, inserted_sara_person.id).unwrap(); + Person::delete(conn, inserted_jess_person.id).unwrap(); } } diff --git a/crates/db_views/src/site_view.rs b/crates/db_views/src/site_view.rs index c630216f..03ee0d7d 100644 --- a/crates/db_views/src/site_view.rs +++ b/crates/db_views/src/site_view.rs @@ -7,7 +7,7 @@ use lemmy_db_schema::{ }; impl SiteView { - pub fn read_local(conn: &PgConnection) -> Result { + pub fn read_local(conn: &mut PgConnection) -> Result { let (mut site, counts) = site::table .inner_join(site_aggregates::table) .select((site::all_columns, site_aggregates::all_columns)) diff --git a/crates/db_views/src/structs.rs b/crates/db_views/src/structs.rs index 1d509a13..83f1e122 100644 --- a/crates/db_views/src/structs.rs +++ b/crates/db_views/src/structs.rs @@ -6,7 +6,7 @@ use lemmy_db_schema::{ community::CommunitySafe, language::Language, local_user::{LocalUser, LocalUserSettings}, - person::{Person, PersonSafe, PersonSafeAlias1, PersonSafeAlias2}, + person::{Person, PersonSafe}, post::Post, post_report::PostReport, private_message::PrivateMessage, @@ -18,21 +18,21 @@ use lemmy_db_schema::{ }; use serde::{Deserialize, Serialize}; -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct CommentReportView { pub comment_report: CommentReport, pub comment: Comment, pub post: Post, pub community: CommunitySafe, pub creator: PersonSafe, - pub comment_creator: PersonSafeAlias1, + pub comment_creator: PersonSafe, pub counts: CommentAggregates, pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan pub my_vote: Option, // Left join to CommentLike - pub resolver: Option, + pub resolver: Option, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct CommentView { pub comment: Comment, pub creator: PersonSafe, @@ -60,20 +60,20 @@ pub struct LocalUserSettingsView { pub counts: PersonAggregates, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct PostReportView { pub post_report: PostReport, pub post: Post, pub community: CommunitySafe, pub creator: PersonSafe, - pub post_creator: PersonSafeAlias1, + pub post_creator: PersonSafe, pub creator_banned_from_community: bool, pub my_vote: Option, pub counts: PostAggregates, - pub resolver: Option, + pub resolver: Option, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct PostView { pub post: Post, pub creator: PersonSafe, @@ -88,28 +88,28 @@ pub struct PostView { pub language: Language, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct PrivateMessageView { pub private_message: PrivateMessage, pub creator: PersonSafe, - pub recipient: PersonSafeAlias1, + pub recipient: PersonSafe, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct PrivateMessageReportView { pub private_message_report: PrivateMessageReport, pub private_message: PrivateMessage, pub private_message_creator: PersonSafe, - pub creator: PersonSafeAlias1, - pub resolver: Option, + pub creator: PersonSafe, + pub resolver: Option, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct RegistrationApplicationView { pub registration_application: RegistrationApplication, pub creator_local_user: LocalUserSettings, pub creator: PersonSafe, - pub admin: Option, + pub admin: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/crates/db_views_actor/Cargo.toml b/crates/db_views_actor/Cargo.toml index d64d1e19..e49990ae 100644 --- a/crates/db_views_actor/Cargo.toml +++ b/crates/db_views_actor/Cargo.toml @@ -16,6 +16,6 @@ full = ["lemmy_db_schema/full", "diesel"] [dependencies] lemmy_db_schema = { version = "=0.16.5", path = "../db_schema" } -diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"], optional = true } -serde = { version = "1.0.136", features = ["derive"] } +diesel = { version = "2.0.0", features = ["postgres","chrono","r2d2","serde_json"], optional = true } +serde = { version = "1.0.145", features = ["derive"] } typed-builder = "0.10.0" diff --git a/crates/db_views_actor/src/comment_reply_view.rs b/crates/db_views_actor/src/comment_reply_view.rs index c8f9df9c..39ba74cc 100644 --- a/crates/db_views_actor/src/comment_reply_view.rs +++ b/crates/db_views_actor/src/comment_reply_view.rs @@ -13,7 +13,6 @@ use lemmy_db_schema::{ community_follower, community_person_ban, person, - person_alias_1, person_block, post, }, @@ -21,7 +20,7 @@ use lemmy_db_schema::{ comment::{Comment, CommentSaved}, comment_reply::CommentReply, community::{Community, CommunityFollower, CommunityPersonBan, CommunitySafe}, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, person_block::PersonBlock, post::Post, }, @@ -37,7 +36,7 @@ type CommentReplyViewTuple = ( PersonSafe, Post, CommunitySafe, - PersonSafeAlias1, + PersonSafe, CommentAggregates, Option, Option, @@ -48,10 +47,12 @@ type CommentReplyViewTuple = ( impl CommentReplyView { pub fn read( - conn: &PgConnection, + conn: &mut PgConnection, comment_reply_id: CommentReplyId, my_person_id: Option, ) -> Result { + let person_alias_1 = diesel::alias!(person as person1); + // The left join below will return None in this case let person_id_join = my_person_id.unwrap_or(PersonId(-1)); @@ -74,7 +75,7 @@ impl CommentReplyView { .inner_join(person::table.on(comment::creator_id.eq(person::id))) .inner_join(post::table.on(comment::post_id.eq(post::id))) .inner_join(community::table.on(post::community_id.eq(community::id))) - .inner_join(person_alias_1::table) + .inner_join(person_alias_1) .inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id))) .left_join( community_person_ban::table.on( @@ -122,7 +123,7 @@ impl CommentReplyView { Person::safe_columns_tuple(), post::all_columns, Community::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), comment_aggregates::all_columns, community_person_ban::all_columns.nullable(), community_follower::all_columns.nullable(), @@ -149,7 +150,7 @@ impl CommentReplyView { } /// Gets the number of unread replies - pub fn get_unread_replies(conn: &PgConnection, my_person_id: PersonId) -> Result { + pub fn get_unread_replies(conn: &mut PgConnection, my_person_id: PersonId) -> Result { use diesel::dsl::*; comment_reply::table @@ -164,7 +165,7 @@ impl CommentReplyView { #[builder(field_defaults(default))] pub struct CommentReplyQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, my_person_id: Option, recipient_id: Option, sort: Option, @@ -178,6 +179,8 @@ impl<'a> CommentReplyQuery<'a> { pub fn list(self) -> Result, Error> { use diesel::dsl::*; + let person_alias_1 = diesel::alias!(person as person1); + // The left join below will return None in this case let person_id_join = self.my_person_id.unwrap_or(PersonId(-1)); @@ -186,7 +189,7 @@ impl<'a> CommentReplyQuery<'a> { .inner_join(person::table.on(comment::creator_id.eq(person::id))) .inner_join(post::table.on(comment::post_id.eq(post::id))) .inner_join(community::table.on(post::community_id.eq(community::id))) - .inner_join(person_alias_1::table) + .inner_join(person_alias_1) .inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id))) .left_join( community_person_ban::table.on( @@ -234,7 +237,7 @@ impl<'a> CommentReplyQuery<'a> { Person::safe_columns_tuple(), post::all_columns, Community::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), comment_aggregates::all_columns, community_person_ban::all_columns.nullable(), community_follower::all_columns.nullable(), diff --git a/crates/db_views_actor/src/community_block_view.rs b/crates/db_views_actor/src/community_block_view.rs index 59d48ea2..96204e7d 100644 --- a/crates/db_views_actor/src/community_block_view.rs +++ b/crates/db_views_actor/src/community_block_view.rs @@ -13,7 +13,7 @@ use lemmy_db_schema::{ type CommunityBlockViewTuple = (PersonSafe, CommunitySafe); impl CommunityBlockView { - pub fn for_person(conn: &PgConnection, person_id: PersonId) -> Result, Error> { + pub fn for_person(conn: &mut PgConnection, person_id: PersonId) -> Result, Error> { let res = community_block::table .inner_join(person::table) .inner_join(community::table) diff --git a/crates/db_views_actor/src/community_follower_view.rs b/crates/db_views_actor/src/community_follower_view.rs index 6441536e..fb8ae023 100644 --- a/crates/db_views_actor/src/community_follower_view.rs +++ b/crates/db_views_actor/src/community_follower_view.rs @@ -13,7 +13,10 @@ use lemmy_db_schema::{ type CommunityFollowerViewTuple = (CommunitySafe, PersonSafe); impl CommunityFollowerView { - pub fn for_community(conn: &PgConnection, community_id: CommunityId) -> Result, Error> { + pub fn for_community( + conn: &mut PgConnection, + community_id: CommunityId, + ) -> Result, Error> { let res = community_follower::table .inner_join(community::table) .inner_join(person::table) @@ -28,7 +31,7 @@ impl CommunityFollowerView { Ok(Self::from_tuple_to_vec(res)) } - pub fn for_person(conn: &PgConnection, person_id: PersonId) -> Result, Error> { + pub fn for_person(conn: &mut PgConnection, person_id: PersonId) -> Result, Error> { let res = community_follower::table .inner_join(community::table) .inner_join(person::table) diff --git a/crates/db_views_actor/src/community_moderator_view.rs b/crates/db_views_actor/src/community_moderator_view.rs index b2df9551..eeda7ed6 100644 --- a/crates/db_views_actor/src/community_moderator_view.rs +++ b/crates/db_views_actor/src/community_moderator_view.rs @@ -13,7 +13,10 @@ use lemmy_db_schema::{ type CommunityModeratorViewTuple = (CommunitySafe, PersonSafe); impl CommunityModeratorView { - pub fn for_community(conn: &PgConnection, community_id: CommunityId) -> Result, Error> { + pub fn for_community( + conn: &mut PgConnection, + community_id: CommunityId, + ) -> Result, Error> { let res = community_moderator::table .inner_join(community::table) .inner_join(person::table) @@ -28,7 +31,7 @@ impl CommunityModeratorView { Ok(Self::from_tuple_to_vec(res)) } - pub fn for_person(conn: &PgConnection, person_id: PersonId) -> Result, Error> { + pub fn for_person(conn: &mut PgConnection, person_id: PersonId) -> Result, Error> { let res = community_moderator::table .inner_join(community::table) .inner_join(person::table) @@ -45,7 +48,7 @@ impl CommunityModeratorView { /// Finds all communities first mods / creators /// Ideally this should be a group by, but diesel doesn't support it yet - pub fn get_community_first_mods(conn: &PgConnection) -> Result, Error> { + pub fn get_community_first_mods(conn: &mut PgConnection) -> Result, Error> { let res = community_moderator::table .inner_join(community::table) .inner_join(person::table) diff --git a/crates/db_views_actor/src/community_person_ban_view.rs b/crates/db_views_actor/src/community_person_ban_view.rs index 6d765e07..8672ad21 100644 --- a/crates/db_views_actor/src/community_person_ban_view.rs +++ b/crates/db_views_actor/src/community_person_ban_view.rs @@ -12,7 +12,7 @@ use lemmy_db_schema::{ impl CommunityPersonBanView { pub fn get( - conn: &PgConnection, + conn: &mut PgConnection, from_person_id: PersonId, from_community_id: CommunityId, ) -> Result { diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views_actor/src/community_view.rs index 0701ab43..5a65b887 100644 --- a/crates/db_views_actor/src/community_view.rs +++ b/crates/db_views_actor/src/community_view.rs @@ -25,7 +25,7 @@ type CommunityViewTuple = ( impl CommunityView { pub fn read( - conn: &PgConnection, + conn: &mut PgConnection, community_id: CommunityId, my_person_id: Option, ) -> Result { @@ -66,7 +66,7 @@ impl CommunityView { } pub fn is_mod_or_admin( - conn: &PgConnection, + conn: &mut PgConnection, person_id: PersonId, community_id: CommunityId, ) -> bool { @@ -97,7 +97,7 @@ impl CommunityView { #[builder(field_defaults(default))] pub struct CommunityQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, listing_type: Option, sort: Option, local_user: Option<&'a LocalUser>, diff --git a/crates/db_views_actor/src/person_block_view.rs b/crates/db_views_actor/src/person_block_view.rs index 19ff2633..90d56ccd 100644 --- a/crates/db_views_actor/src/person_block_view.rs +++ b/crates/db_views_actor/src/person_block_view.rs @@ -2,21 +2,23 @@ use crate::structs::PersonBlockView; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{person, person_alias_1, person_block}, - source::person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + schema::{person, person_block}, + source::person::{Person, PersonSafe}, traits::{ToSafe, ViewToVec}, }; -type PersonBlockViewTuple = (PersonSafe, PersonSafeAlias1); +type PersonBlockViewTuple = (PersonSafe, PersonSafe); impl PersonBlockView { - pub fn for_person(conn: &PgConnection, person_id: PersonId) -> Result, Error> { + pub fn for_person(conn: &mut PgConnection, person_id: PersonId) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); + let res = person_block::table .inner_join(person::table) - .inner_join(person_alias_1::table) // TODO I dont know if this will be smart abt the column + .inner_join(person_alias_1) .select(( Person::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), )) .filter(person_block::person_id.eq(person_id)) .order_by(person_block::published) diff --git a/crates/db_views_actor/src/person_mention_view.rs b/crates/db_views_actor/src/person_mention_view.rs index 30136705..e4863db4 100644 --- a/crates/db_views_actor/src/person_mention_view.rs +++ b/crates/db_views_actor/src/person_mention_view.rs @@ -12,7 +12,6 @@ use lemmy_db_schema::{ community_follower, community_person_ban, person, - person_alias_1, person_block, person_mention, post, @@ -20,7 +19,7 @@ use lemmy_db_schema::{ source::{ comment::{Comment, CommentSaved}, community::{Community, CommunityFollower, CommunityPersonBan, CommunitySafe}, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, person_block::PersonBlock, person_mention::PersonMention, post::Post, @@ -37,7 +36,7 @@ type PersonMentionViewTuple = ( PersonSafe, Post, CommunitySafe, - PersonSafeAlias1, + PersonSafe, CommentAggregates, Option, Option, @@ -48,10 +47,12 @@ type PersonMentionViewTuple = ( impl PersonMentionView { pub fn read( - conn: &PgConnection, + conn: &mut PgConnection, person_mention_id: PersonMentionId, my_person_id: Option, ) -> Result { + let person_alias_1 = diesel::alias!(person as person1); + // The left join below will return None in this case let person_id_join = my_person_id.unwrap_or(PersonId(-1)); @@ -74,7 +75,7 @@ impl PersonMentionView { .inner_join(person::table.on(comment::creator_id.eq(person::id))) .inner_join(post::table.on(comment::post_id.eq(post::id))) .inner_join(community::table.on(post::community_id.eq(community::id))) - .inner_join(person_alias_1::table) + .inner_join(person_alias_1) .inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id))) .left_join( community_person_ban::table.on( @@ -122,7 +123,7 @@ impl PersonMentionView { Person::safe_columns_tuple(), post::all_columns, Community::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), comment_aggregates::all_columns, community_person_ban::all_columns.nullable(), community_follower::all_columns.nullable(), @@ -149,7 +150,10 @@ impl PersonMentionView { } /// Gets the number of unread mentions - pub fn get_unread_mentions(conn: &PgConnection, my_person_id: PersonId) -> Result { + pub fn get_unread_mentions( + conn: &mut PgConnection, + my_person_id: PersonId, + ) -> Result { use diesel::dsl::*; person_mention::table @@ -164,7 +168,7 @@ impl PersonMentionView { #[builder(field_defaults(default))] pub struct PersonMentionQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, my_person_id: Option, recipient_id: Option, sort: Option, @@ -178,6 +182,8 @@ impl<'a> PersonMentionQuery<'a> { pub fn list(self) -> Result, Error> { use diesel::dsl::*; + let person_alias_1 = diesel::alias!(person as person1); + // The left join below will return None in this case let person_id_join = self.my_person_id.unwrap_or(PersonId(-1)); @@ -186,7 +192,7 @@ impl<'a> PersonMentionQuery<'a> { .inner_join(person::table.on(comment::creator_id.eq(person::id))) .inner_join(post::table.on(comment::post_id.eq(post::id))) .inner_join(community::table.on(post::community_id.eq(community::id))) - .inner_join(person_alias_1::table) + .inner_join(person_alias_1) .inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id))) .left_join( community_person_ban::table.on( @@ -234,7 +240,7 @@ impl<'a> PersonMentionQuery<'a> { Person::safe_columns_tuple(), post::all_columns, Community::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), comment_aggregates::all_columns, community_person_ban::all_columns.nullable(), community_follower::all_columns.nullable(), diff --git a/crates/db_views_actor/src/person_view.rs b/crates/db_views_actor/src/person_view.rs index 35044469..af0927a8 100644 --- a/crates/db_views_actor/src/person_view.rs +++ b/crates/db_views_actor/src/person_view.rs @@ -14,7 +14,7 @@ use typed_builder::TypedBuilder; type PersonViewSafeTuple = (PersonSafe, PersonAggregates); impl PersonViewSafe { - pub fn read(conn: &PgConnection, person_id: PersonId) -> Result { + pub fn read(conn: &mut PgConnection, person_id: PersonId) -> Result { let (person, counts) = person::table .find(person_id) .inner_join(person_aggregates::table) @@ -23,7 +23,7 @@ impl PersonViewSafe { Ok(Self { person, counts }) } - pub fn admins(conn: &PgConnection) -> Result, Error> { + pub fn admins(conn: &mut PgConnection) -> Result, Error> { let admins = person::table .inner_join(person_aggregates::table) .select((Person::safe_columns_tuple(), person_aggregates::all_columns)) @@ -34,7 +34,7 @@ impl PersonViewSafe { Ok(Self::from_tuple_to_vec(admins)) } - pub fn banned(conn: &PgConnection) -> Result, Error> { + pub fn banned(conn: &mut PgConnection) -> Result, Error> { let banned = person::table .inner_join(person_aggregates::table) .select((Person::safe_columns_tuple(), person_aggregates::all_columns)) @@ -55,7 +55,7 @@ impl PersonViewSafe { #[builder(field_defaults(default))] pub struct PersonQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, sort: Option, search_term: Option, page: Option, diff --git a/crates/db_views_actor/src/structs.rs b/crates/db_views_actor/src/structs.rs index 43654c31..91d40e96 100644 --- a/crates/db_views_actor/src/structs.rs +++ b/crates/db_views_actor/src/structs.rs @@ -4,7 +4,7 @@ use lemmy_db_schema::{ comment::Comment, comment_reply::CommentReply, community::CommunitySafe, - person::{PersonSafe, PersonSafeAlias1}, + person::PersonSafe, person_mention::PersonMention, post::Post, }, @@ -47,17 +47,17 @@ pub struct CommunityView { #[derive(Debug, Serialize, Deserialize, Clone)] pub struct PersonBlockView { pub person: PersonSafe, - pub target: PersonSafeAlias1, + pub target: PersonSafe, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct PersonMentionView { pub person_mention: PersonMention, pub comment: Comment, pub creator: PersonSafe, pub post: Post, pub community: CommunitySafe, - pub recipient: PersonSafeAlias1, + pub recipient: PersonSafe, pub counts: CommentAggregates, pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan pub subscribed: SubscribedType, // Left join to CommunityFollower @@ -66,14 +66,14 @@ pub struct PersonMentionView { pub my_vote: Option, // Left join to CommentLike } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct CommentReplyView { pub comment_reply: CommentReply, pub comment: Comment, pub creator: PersonSafe, pub post: Post, pub community: CommunitySafe, - pub recipient: PersonSafeAlias1, + pub recipient: PersonSafe, pub counts: CommentAggregates, pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan pub subscribed: SubscribedType, // Left join to CommunityFollower diff --git a/crates/db_views_moderator/Cargo.toml b/crates/db_views_moderator/Cargo.toml index b00752ad..e2823993 100644 --- a/crates/db_views_moderator/Cargo.toml +++ b/crates/db_views_moderator/Cargo.toml @@ -16,5 +16,5 @@ full = ["lemmy_db_schema/full", "diesel"] [dependencies] lemmy_db_schema = { version = "=0.16.5", path = "../db_schema" } -diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"], optional = true } -serde = { version = "1.0.136", features = ["derive"] } +diesel = { version = "2.0.0", features = ["postgres","chrono","r2d2","serde_json"], optional = true } +serde = { version = "1.0.145", features = ["derive"] } diff --git a/crates/db_views_moderator/src/admin_purge_comment_view.rs b/crates/db_views_moderator/src/admin_purge_comment_view.rs index cd94a085..035f86d1 100644 --- a/crates/db_views_moderator/src/admin_purge_comment_view.rs +++ b/crates/db_views_moderator/src/admin_purge_comment_view.rs @@ -15,7 +15,7 @@ use lemmy_db_schema::{ type AdminPurgeCommentViewTuple = (AdminPurgeComment, Option, Post); impl AdminPurgeCommentView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); diff --git a/crates/db_views_moderator/src/admin_purge_community_view.rs b/crates/db_views_moderator/src/admin_purge_community_view.rs index 80528d00..fb582d6d 100644 --- a/crates/db_views_moderator/src/admin_purge_community_view.rs +++ b/crates/db_views_moderator/src/admin_purge_community_view.rs @@ -14,7 +14,7 @@ use lemmy_db_schema::{ type AdminPurgeCommunityViewTuple = (AdminPurgeCommunity, Option); impl AdminPurgeCommunityView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); diff --git a/crates/db_views_moderator/src/admin_purge_person_view.rs b/crates/db_views_moderator/src/admin_purge_person_view.rs index 84a33a53..023bcb37 100644 --- a/crates/db_views_moderator/src/admin_purge_person_view.rs +++ b/crates/db_views_moderator/src/admin_purge_person_view.rs @@ -14,7 +14,7 @@ use lemmy_db_schema::{ type AdminPurgePersonViewTuple = (AdminPurgePerson, Option); impl AdminPurgePersonView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); diff --git a/crates/db_views_moderator/src/admin_purge_post_view.rs b/crates/db_views_moderator/src/admin_purge_post_view.rs index 9a7f7399..6a65c7a4 100644 --- a/crates/db_views_moderator/src/admin_purge_post_view.rs +++ b/crates/db_views_moderator/src/admin_purge_post_view.rs @@ -15,7 +15,7 @@ use lemmy_db_schema::{ type AdminPurgePostViewTuple = (AdminPurgePost, Option, CommunitySafe); impl AdminPurgePostView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); diff --git a/crates/db_views_moderator/src/mod_add_community_view.rs b/crates/db_views_moderator/src/mod_add_community_view.rs index 4c4d8f87..b7b9e93a 100644 --- a/crates/db_views_moderator/src/mod_add_community_view.rs +++ b/crates/db_views_moderator/src/mod_add_community_view.rs @@ -2,11 +2,11 @@ use crate::structs::{ModAddCommunityView, ModlogListParams}; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{community, mod_add_community, person, person_alias_1}, + schema::{community, mod_add_community, person}, source::{ community::{Community, CommunitySafe}, moderator::ModAddCommunity, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, }, traits::{ToSafe, ViewToVec}, utils::limit_and_offset, @@ -16,11 +16,12 @@ type ModAddCommunityViewTuple = ( ModAddCommunity, Option, CommunitySafe, - PersonSafeAlias1, + PersonSafe, ); impl ModAddCommunityView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); @@ -32,13 +33,13 @@ impl ModAddCommunityView { .left_join(person::table.on(admin_names_join)) .inner_join(community::table) .inner_join( - person_alias_1::table.on(mod_add_community::other_person_id.eq(person_alias_1::id)), + person_alias_1.on(mod_add_community::other_person_id.eq(person_alias_1.field(person::id))), ) .select(( mod_add_community::all_columns, Person::safe_columns_tuple().nullable(), Community::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), )) .into_boxed(); @@ -51,7 +52,7 @@ impl ModAddCommunityView { }; if let Some(other_person_id) = params.other_person_id { - query = query.filter(person_alias_1::id.eq(other_person_id)); + query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); }; let (limit, offset) = limit_and_offset(params.page, params.limit)?; diff --git a/crates/db_views_moderator/src/mod_add_view.rs b/crates/db_views_moderator/src/mod_add_view.rs index fe9afea5..e7155250 100644 --- a/crates/db_views_moderator/src/mod_add_view.rs +++ b/crates/db_views_moderator/src/mod_add_view.rs @@ -2,19 +2,20 @@ use crate::structs::{ModAddView, ModlogListParams}; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{mod_add, person, person_alias_1}, + schema::{mod_add, person}, source::{ moderator::ModAdd, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, }, traits::{ToSafe, ViewToVec}, utils::limit_and_offset, }; -type ModAddViewTuple = (ModAdd, Option, PersonSafeAlias1); +type ModAddViewTuple = (ModAdd, Option, PersonSafe); impl ModAddView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); @@ -24,11 +25,11 @@ impl ModAddView { .and(show_mod_names_expr.or(person::id.eq(admin_person_id_join))); let mut query = mod_add::table .left_join(person::table.on(admin_names_join)) - .inner_join(person_alias_1::table.on(mod_add::other_person_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(mod_add::other_person_id.eq(person_alias_1.field(person::id)))) .select(( mod_add::all_columns, Person::safe_columns_tuple().nullable(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), )) .into_boxed(); @@ -37,7 +38,7 @@ impl ModAddView { }; if let Some(other_person_id) = params.other_person_id { - query = query.filter(person_alias_1::id.eq(other_person_id)); + query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); }; let (limit, offset) = limit_and_offset(params.page, params.limit)?; diff --git a/crates/db_views_moderator/src/mod_ban_from_community_view.rs b/crates/db_views_moderator/src/mod_ban_from_community_view.rs index 9c5cc7f7..bf885dbc 100644 --- a/crates/db_views_moderator/src/mod_ban_from_community_view.rs +++ b/crates/db_views_moderator/src/mod_ban_from_community_view.rs @@ -2,11 +2,11 @@ use crate::structs::{ModBanFromCommunityView, ModlogListParams}; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{community, mod_ban_from_community, person, person_alias_1}, + schema::{community, mod_ban_from_community, person}, source::{ community::{Community, CommunitySafe}, moderator::ModBanFromCommunity, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, }, traits::{ToSafe, ViewToVec}, utils::limit_and_offset, @@ -16,11 +16,12 @@ type ModBanFromCommunityViewTuple = ( ModBanFromCommunity, Option, CommunitySafe, - PersonSafeAlias1, + PersonSafe, ); impl ModBanFromCommunityView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); @@ -32,13 +33,14 @@ impl ModBanFromCommunityView { .left_join(person::table.on(admin_names_join)) .inner_join(community::table) .inner_join( - person_alias_1::table.on(mod_ban_from_community::other_person_id.eq(person_alias_1::id)), + person_alias_1 + .on(mod_ban_from_community::other_person_id.eq(person_alias_1.field(person::id))), ) .select(( mod_ban_from_community::all_columns, Person::safe_columns_tuple().nullable(), Community::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), )) .into_boxed(); diff --git a/crates/db_views_moderator/src/mod_ban_view.rs b/crates/db_views_moderator/src/mod_ban_view.rs index 43e577a3..94bfbc8d 100644 --- a/crates/db_views_moderator/src/mod_ban_view.rs +++ b/crates/db_views_moderator/src/mod_ban_view.rs @@ -2,19 +2,20 @@ use crate::structs::{ModBanView, ModlogListParams}; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{mod_ban, person, person_alias_1}, + schema::{mod_ban, person}, source::{ moderator::ModBan, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, }, traits::{ToSafe, ViewToVec}, utils::limit_and_offset, }; -type ModBanViewTuple = (ModBan, Option, PersonSafeAlias1); +type ModBanViewTuple = (ModBan, Option, PersonSafe); impl ModBanView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); @@ -24,11 +25,11 @@ impl ModBanView { .and(show_mod_names_expr.or(person::id.eq(admin_person_id_join))); let mut query = mod_ban::table .left_join(person::table.on(admin_names_join)) - .inner_join(person_alias_1::table.on(mod_ban::other_person_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(mod_ban::other_person_id.eq(person_alias_1.field(person::id)))) .select(( mod_ban::all_columns, Person::safe_columns_tuple().nullable(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), )) .into_boxed(); @@ -37,7 +38,7 @@ impl ModBanView { }; if let Some(other_person_id) = params.other_person_id { - query = query.filter(person_alias_1::id.eq(other_person_id)); + query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); }; let (limit, offset) = limit_and_offset(params.page, params.limit)?; diff --git a/crates/db_views_moderator/src/mod_hide_community_view.rs b/crates/db_views_moderator/src/mod_hide_community_view.rs index 24514a3d..0250d2e7 100644 --- a/crates/db_views_moderator/src/mod_hide_community_view.rs +++ b/crates/db_views_moderator/src/mod_hide_community_view.rs @@ -16,7 +16,7 @@ type ModHideCommunityViewTuple = (ModHideCommunity, Option, Communit impl ModHideCommunityView { // Pass in mod_id as admin_id because only admins can do this action - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); diff --git a/crates/db_views_moderator/src/mod_lock_post_view.rs b/crates/db_views_moderator/src/mod_lock_post_view.rs index dad5c5b5..6d88c5ae 100644 --- a/crates/db_views_moderator/src/mod_lock_post_view.rs +++ b/crates/db_views_moderator/src/mod_lock_post_view.rs @@ -2,7 +2,7 @@ use crate::structs::{ModLockPostView, ModlogListParams}; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{community, mod_lock_post, person, person_alias_1, post}, + schema::{community, mod_lock_post, person, post}, source::{ community::{Community, CommunitySafe}, moderator::ModLockPost, @@ -16,7 +16,8 @@ use lemmy_db_schema::{ type ModLockPostViewTuple = (ModLockPost, Option, Post, CommunitySafe); impl ModLockPostView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); @@ -28,7 +29,7 @@ impl ModLockPostView { .left_join(person::table.on(admin_names_join)) .inner_join(post::table) .inner_join(community::table.on(post::community_id.eq(community::id))) - .inner_join(person_alias_1::table.on(post::creator_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id)))) .select(( mod_lock_post::all_columns, Person::safe_columns_tuple().nullable(), @@ -46,7 +47,7 @@ impl ModLockPostView { }; if let Some(other_person_id) = params.other_person_id { - query = query.filter(person_alias_1::id.eq(other_person_id)); + query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); }; let (limit, offset) = limit_and_offset(params.page, params.limit)?; diff --git a/crates/db_views_moderator/src/mod_remove_comment_view.rs b/crates/db_views_moderator/src/mod_remove_comment_view.rs index 2ee230d1..c0b58845 100644 --- a/crates/db_views_moderator/src/mod_remove_comment_view.rs +++ b/crates/db_views_moderator/src/mod_remove_comment_view.rs @@ -2,12 +2,12 @@ use crate::structs::{ModRemoveCommentView, ModlogListParams}; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{comment, community, mod_remove_comment, person, person_alias_1, post}, + schema::{comment, community, mod_remove_comment, person, post}, source::{ comment::Comment, community::{Community, CommunitySafe}, moderator::ModRemoveComment, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, post::Post, }, traits::{ToSafe, ViewToVec}, @@ -18,13 +18,14 @@ type ModRemoveCommentViewTuple = ( ModRemoveComment, Option, Comment, - PersonSafeAlias1, + PersonSafe, Post, CommunitySafe, ); impl ModRemoveCommentView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { + let person_alias_1 = diesel::alias!(lemmy_db_schema::schema::person as person1); let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); @@ -35,14 +36,14 @@ impl ModRemoveCommentView { let mut query = mod_remove_comment::table .left_join(person::table.on(admin_names_join)) .inner_join(comment::table) - .inner_join(person_alias_1::table.on(comment::creator_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(comment::creator_id.eq(person_alias_1.field(person::id)))) .inner_join(post::table.on(comment::post_id.eq(post::id))) .inner_join(community::table.on(post::community_id.eq(community::id))) .select(( mod_remove_comment::all_columns, Person::safe_columns_tuple().nullable(), comment::all_columns, - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), post::all_columns, Community::safe_columns_tuple(), )) @@ -57,7 +58,7 @@ impl ModRemoveCommentView { }; if let Some(other_person_id) = params.other_person_id { - query = query.filter(person_alias_1::id.eq(other_person_id)); + query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); }; let (limit, offset) = limit_and_offset(params.page, params.limit)?; diff --git a/crates/db_views_moderator/src/mod_remove_community_view.rs b/crates/db_views_moderator/src/mod_remove_community_view.rs index ec462df9..ffd62d45 100644 --- a/crates/db_views_moderator/src/mod_remove_community_view.rs +++ b/crates/db_views_moderator/src/mod_remove_community_view.rs @@ -15,7 +15,7 @@ use lemmy_db_schema::{ type ModRemoveCommunityTuple = (ModRemoveCommunity, Option, CommunitySafe); impl ModRemoveCommunityView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); diff --git a/crates/db_views_moderator/src/mod_remove_post_view.rs b/crates/db_views_moderator/src/mod_remove_post_view.rs index 497305ec..c1bc2e8f 100644 --- a/crates/db_views_moderator/src/mod_remove_post_view.rs +++ b/crates/db_views_moderator/src/mod_remove_post_view.rs @@ -2,7 +2,7 @@ use crate::structs::{ModRemovePostView, ModlogListParams}; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{community, mod_remove_post, person, person_alias_1, post}, + schema::{community, mod_remove_post, person, post}, source::{ community::{Community, CommunitySafe}, moderator::ModRemovePost, @@ -16,7 +16,8 @@ use lemmy_db_schema::{ type ModRemovePostViewTuple = (ModRemovePost, Option, Post, CommunitySafe); impl ModRemovePostView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); @@ -28,7 +29,7 @@ impl ModRemovePostView { .left_join(person::table.on(admin_names_join)) .inner_join(post::table) .inner_join(community::table.on(post::community_id.eq(community::id))) - .inner_join(person_alias_1::table.on(post::creator_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id)))) .select(( mod_remove_post::all_columns, Person::safe_columns_tuple().nullable(), @@ -46,7 +47,7 @@ impl ModRemovePostView { }; if let Some(other_person_id) = params.other_person_id { - query = query.filter(person_alias_1::id.eq(other_person_id)); + query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); }; let (limit, offset) = limit_and_offset(params.page, params.limit)?; diff --git a/crates/db_views_moderator/src/mod_sticky_post_view.rs b/crates/db_views_moderator/src/mod_sticky_post_view.rs index a47e1dc8..d802de69 100644 --- a/crates/db_views_moderator/src/mod_sticky_post_view.rs +++ b/crates/db_views_moderator/src/mod_sticky_post_view.rs @@ -2,7 +2,7 @@ use crate::structs::{ModStickyPostView, ModlogListParams}; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{community, mod_sticky_post, person, person_alias_1, post}, + schema::{community, mod_sticky_post, person, post}, source::{ community::{Community, CommunitySafe}, moderator::ModStickyPost, @@ -16,7 +16,8 @@ use lemmy_db_schema::{ type ModStickyPostViewTuple = (ModStickyPost, Option, Post, CommunitySafe); impl ModStickyPostView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); @@ -27,7 +28,7 @@ impl ModStickyPostView { let mut query = mod_sticky_post::table .left_join(person::table.on(admin_names_join)) .inner_join(post::table) - .inner_join(person_alias_1::table.on(post::creator_id.eq(person_alias_1::id))) + .inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id)))) .inner_join(community::table.on(post::community_id.eq(community::id))) .select(( mod_sticky_post::all_columns, @@ -46,7 +47,7 @@ impl ModStickyPostView { }; if let Some(other_person_id) = params.other_person_id { - query = query.filter(person_alias_1::id.eq(other_person_id)); + query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); }; let (limit, offset) = limit_and_offset(params.page, params.limit)?; diff --git a/crates/db_views_moderator/src/mod_transfer_community_view.rs b/crates/db_views_moderator/src/mod_transfer_community_view.rs index bada7b39..bea839eb 100644 --- a/crates/db_views_moderator/src/mod_transfer_community_view.rs +++ b/crates/db_views_moderator/src/mod_transfer_community_view.rs @@ -2,11 +2,11 @@ use crate::structs::{ModTransferCommunityView, ModlogListParams}; use diesel::{result::Error, *}; use lemmy_db_schema::{ newtypes::PersonId, - schema::{community, mod_transfer_community, person, person_alias_1}, + schema::{community, mod_transfer_community, person}, source::{ community::{Community, CommunitySafe}, moderator::ModTransferCommunity, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, }, traits::{ToSafe, ViewToVec}, utils::limit_and_offset, @@ -16,11 +16,12 @@ type ModTransferCommunityViewTuple = ( ModTransferCommunity, Option, CommunitySafe, - PersonSafeAlias1, + PersonSafe, ); impl ModTransferCommunityView { - pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result, Error> { + pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result, Error> { + let person_alias_1 = diesel::alias!(person as person1); let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1)); let show_mod_names = !params.hide_modlog_names; let show_mod_names_expr = show_mod_names.as_sql::(); @@ -32,13 +33,14 @@ impl ModTransferCommunityView { .left_join(person::table.on(admin_names_join)) .inner_join(community::table) .inner_join( - person_alias_1::table.on(mod_transfer_community::other_person_id.eq(person_alias_1::id)), + person_alias_1 + .on(mod_transfer_community::other_person_id.eq(person_alias_1.field(person::id))), ) .select(( mod_transfer_community::all_columns, Person::safe_columns_tuple().nullable(), Community::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), )) .into_boxed(); @@ -51,7 +53,7 @@ impl ModTransferCommunityView { }; if let Some(other_person_id) = params.other_person_id { - query = query.filter(person_alias_1::id.eq(other_person_id)); + query = query.filter(person_alias_1.field(person::id).eq(other_person_id)); }; let (limit, offset) = limit_and_offset(params.page, params.limit)?; diff --git a/crates/db_views_moderator/src/structs.rs b/crates/db_views_moderator/src/structs.rs index 4f6fbbd3..863de070 100644 --- a/crates/db_views_moderator/src/structs.rs +++ b/crates/db_views_moderator/src/structs.rs @@ -20,7 +20,7 @@ use lemmy_db_schema::{ ModStickyPost, ModTransferCommunity, }, - person::{PersonSafe, PersonSafeAlias1}, + person::PersonSafe, post::Post, }, }; @@ -31,14 +31,14 @@ pub struct ModAddCommunityView { pub mod_add_community: ModAddCommunity, pub moderator: Option, pub community: CommunitySafe, - pub modded_person: PersonSafeAlias1, + pub modded_person: PersonSafe, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct ModAddView { pub mod_add: ModAdd, pub moderator: Option, - pub modded_person: PersonSafeAlias1, + pub modded_person: PersonSafe, } #[derive(Debug, Serialize, Deserialize, Clone)] @@ -46,14 +46,14 @@ pub struct ModBanFromCommunityView { pub mod_ban_from_community: ModBanFromCommunity, pub moderator: Option, pub community: CommunitySafe, - pub banned_person: PersonSafeAlias1, + pub banned_person: PersonSafe, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct ModBanView { pub mod_ban: ModBan, pub moderator: Option, - pub banned_person: PersonSafeAlias1, + pub banned_person: PersonSafe, } #[derive(Debug, Serialize, Deserialize, Clone)] @@ -76,7 +76,7 @@ pub struct ModRemoveCommentView { pub mod_remove_comment: ModRemoveComment, pub moderator: Option, pub comment: Comment, - pub commenter: PersonSafeAlias1, + pub commenter: PersonSafe, pub post: Post, pub community: CommunitySafe, } @@ -109,7 +109,7 @@ pub struct ModTransferCommunityView { pub mod_transfer_community: ModTransferCommunity, pub moderator: Option, pub community: CommunitySafe, - pub modded_person: PersonSafeAlias1, + pub modded_person: PersonSafe, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml index b6af9986..bda019d3 100644 --- a/crates/routes/Cargo.toml +++ b/crates/routes/Cargo.toml @@ -19,17 +19,17 @@ lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor" } lemmy_db_schema = { version = "=0.16.5", path = "../db_schema" } lemmy_api_common = { version = "=0.16.5", path = "../api_common" } lemmy_apub = { version = "=0.16.5", path = "../apub" } -diesel = "1.4.8" -actix-web = { version = "4.0.1", default-features = false, features = ["rustls"] } -anyhow = "1.0.56" -chrono = { version = "0.4.19", features = ["serde"], default-features = false } -futures = "0.3.21" -reqwest = { version = "0.11.10", features = ["stream"] } -reqwest-middleware = "0.1.5" -rss = "2.0.0" -serde = { version = "1.0.136", features = ["derive"] } -url = { version = "2.2.2", features = ["serde"] } -strum = "0.24.0" -once_cell = "1.10.0" -tracing = "0.1.32" -tokio = { version = "1.17.0", features = ["sync"] } +diesel = "2.0.0" +actix-web = { version = "4.2.1", default-features = false, features = ["rustls"] } +anyhow = "1.0.65" +chrono = { version = "0.4.22", features = ["serde"], default-features = false } +futures = "0.3.24" +reqwest = { version = "0.11.12", features = ["stream"] } +reqwest-middleware = "0.1.6" +rss = "2.0.1" +serde = { version = "1.0.145", features = ["derive"] } +url = { version = "2.3.1", features = ["serde"] } +strum = "0.24.1" +once_cell = "1.15.0" +tracing = "0.1.36" +tokio = { version = "1.21.1", features = ["sync"] } diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index 592aeb2d..1943c280 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -178,7 +178,7 @@ fn get_sort_type(info: web::Query) -> Result { #[tracing::instrument(skip_all)] fn get_feed_user( - conn: &PgConnection, + conn: &mut PgConnection, sort_type: &SortType, user_name: &str, protocol_and_hostname: &str, @@ -209,7 +209,7 @@ fn get_feed_user( #[tracing::instrument(skip_all)] fn get_feed_community( - conn: &PgConnection, + conn: &mut PgConnection, sort_type: &SortType, community_name: &str, protocol_and_hostname: &str, @@ -243,7 +243,7 @@ fn get_feed_community( #[tracing::instrument(skip_all)] fn get_feed_front( - conn: &PgConnection, + conn: &mut PgConnection, jwt_secret: &str, sort_type: &SortType, jwt: &str, @@ -280,7 +280,7 @@ fn get_feed_front( #[tracing::instrument(skip_all)] fn get_feed_inbox( - conn: &PgConnection, + conn: &mut PgConnection, jwt_secret: &str, jwt: &str, protocol_and_hostname: &str, diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index d0fe8af9..ff58c377 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -14,35 +14,35 @@ path = "src/lib.rs" doctest = false [dependencies] -regex = "1.5.5" -chrono = { version = "0.4.19", features = ["serde", "clock"], default-features = false } -lettre = "0.10.0-rc.7" -tracing = "0.1.32" +regex = "1.6.0" +chrono = { version = "0.4.22", features = ["serde", "clock"], default-features = false } +lettre = "0.10.1" +tracing = "0.1.36" tracing-error = "0.2.0" -itertools = "0.10.3" +itertools = "0.10.5" rand = "0.8.5" -serde = { version = "1.0.136", features = ["derive"] } -serde_json = { version = "1.0.79", features = ["preserve_order"] } -comrak = { version = "0.12.1", default-features = false } -once_cell = "1.10.0" -openssl = "0.10.38" -url = { version = "2.2.2", features = ["serde"] } -actix-web = { version = "4.0.1", default-features = false, features = ["rustls"] } -anyhow = "1.0.56" -reqwest-middleware = "0.1.5" -strum = "0.24.0" -strum_macros = "0.24.0" -futures = "0.3.21" -diesel = "1.4.8" -http = "0.2.6" +serde = { version = "1.0.145", features = ["derive"] } +serde_json = { version = "1.0.85", features = ["preserve_order"] } +comrak = { version = "0.14.0", default-features = false } +once_cell = "1.15.0" +openssl = "0.10.41" +url = { version = "2.3.1", features = ["serde"] } +actix-web = { version = "4.2.1", default-features = false, features = ["rustls"] } +anyhow = "1.0.65" +reqwest-middleware = "0.1.6" +strum = "0.24.1" +strum_macros = "0.24.3" +futures = "0.3.24" +diesel = { version = "2.0.0", features = ["chrono"] } +http = "0.2.8" deser-hjson = "1.0.2" smart-default = "0.6.0" -jsonwebtoken = "8.0.1" +jsonwebtoken = "8.1.1" doku = { version = "0.12.0", features = ["url-2"] } -uuid = { version = "0.8.2", features = ["serde", "v4"] } -html2text = "0.3.1" +uuid = { version = "1.1.2", features = ["serde", "v4"] } +html2text = "0.4.2" rosetta-i18n = "0.1.2" -parking_lot = "0.12.0" +parking_lot = "0.12.1" [build-dependencies] rosetta-build = "0.1.2" diff --git a/crates/websocket/Cargo.toml b/crates/websocket/Cargo.toml index 5cfa9717..dba9b106 100644 --- a/crates/websocket/Cargo.toml +++ b/crates/websocket/Cargo.toml @@ -19,20 +19,20 @@ lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["f lemmy_db_schema = { version = "=0.16.5", path = "../db_schema", features = ["full"] } lemmy_db_views = { version = "=0.16.5", path = "../db_views", features = ["full"] } lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", features = ["full"] } -reqwest-middleware = "0.1.5" -tracing = "0.1.32" +reqwest-middleware = "0.1.6" +tracing = "0.1.36" rand = "0.8.5" -serde = { version = "1.0.136", features = ["derive"] } -serde_json = { version = "1.0.79", features = ["preserve_order"] } +serde = { version = "1.0.145", features = ["derive"] } +serde_json = { version = "1.0.85", features = ["preserve_order"] } actix = "0.13.0" -anyhow = "1.0.56" -diesel = "1.4.8" +anyhow = "1.0.65" +diesel = "2.0.0" background-jobs = "0.12.0" -tokio = "1.17.0" -strum = "0.24.0" -strum_macros = "0.24.0" -chrono = { version = "0.4.19", features = ["serde"], default-features = false } -actix-web = { version = "4.0.1", default-features = false, features = ["rustls"] } +tokio = "1.21.1" +strum = "0.24.1" +strum_macros = "0.24.3" +chrono = { version = "0.4.22", features = ["serde"], default-features = false } +actix-web = { version = "4.2.1", default-features = false, features = ["rustls"] } actix-web-actors = { version = "4.1.0", default-features = false } opentelemetry = "0.17.0" tracing-opentelemetry = "0.17.2" diff --git a/migrations/2022-09-24-161829_remove_table_aliases/down.sql b/migrations/2022-09-24-161829_remove_table_aliases/down.sql new file mode 100644 index 00000000..39b439a0 --- /dev/null +++ b/migrations/2022-09-24-161829_remove_table_aliases/down.sql @@ -0,0 +1,2 @@ +create view person_alias_1 as select * from person; +create view person_alias_2 as select * from person; diff --git a/migrations/2022-09-24-161829_remove_table_aliases/up.sql b/migrations/2022-09-24-161829_remove_table_aliases/up.sql new file mode 100644 index 00000000..36eabeca --- /dev/null +++ b/migrations/2022-09-24-161829_remove_table_aliases/up.sql @@ -0,0 +1,2 @@ +-- Drop the alias views +drop view person_alias_1, person_alias_2; diff --git a/src/code_migrations.rs b/src/code_migrations.rs index a41f4694..977e6808 100644 --- a/src/code_migrations.rs +++ b/src/code_migrations.rs @@ -30,7 +30,7 @@ use tracing::info; use url::Url; pub fn run_advanced_migrations( - conn: &PgConnection, + conn: &mut PgConnection, protocol_and_hostname: &str, ) -> Result<(), LemmyError> { user_updates_2020_04_02(conn, protocol_and_hostname)?; @@ -47,7 +47,7 @@ pub fn run_advanced_migrations( } fn user_updates_2020_04_02( - conn: &PgConnection, + conn: &mut PgConnection, protocol_and_hostname: &str, ) -> Result<(), LemmyError> { use lemmy_db_schema::schema::person::dsl::*; @@ -85,7 +85,7 @@ fn user_updates_2020_04_02( } fn community_updates_2020_04_02( - conn: &PgConnection, + conn: &mut PgConnection, protocol_and_hostname: &str, ) -> Result<(), LemmyError> { use lemmy_db_schema::schema::community::dsl::*; @@ -130,7 +130,7 @@ fn community_updates_2020_04_02( } fn post_updates_2020_04_03( - conn: &PgConnection, + conn: &mut PgConnection, protocol_and_hostname: &str, ) -> Result<(), LemmyError> { use lemmy_db_schema::schema::post::dsl::*; @@ -158,7 +158,7 @@ fn post_updates_2020_04_03( } fn comment_updates_2020_04_03( - conn: &PgConnection, + conn: &mut PgConnection, protocol_and_hostname: &str, ) -> Result<(), LemmyError> { use lemmy_db_schema::schema::comment::dsl::*; @@ -186,7 +186,7 @@ fn comment_updates_2020_04_03( } fn private_message_updates_2020_05_05( - conn: &PgConnection, + conn: &mut PgConnection, protocol_and_hostname: &str, ) -> Result<(), LemmyError> { use lemmy_db_schema::schema::private_message::dsl::*; @@ -214,7 +214,7 @@ fn private_message_updates_2020_05_05( } fn post_thumbnail_url_updates_2020_07_27( - conn: &PgConnection, + conn: &mut PgConnection, protocol_and_hostname: &str, ) -> Result<(), LemmyError> { use lemmy_db_schema::schema::post::dsl::*; @@ -243,7 +243,7 @@ fn post_thumbnail_url_updates_2020_07_27( /// We are setting inbox and follower URLs for local and remote actors alike, because for now /// all federated instances are also Lemmy and use the same URL scheme. -fn apub_columns_2021_02_02(conn: &PgConnection) -> Result<(), LemmyError> { +fn apub_columns_2021_02_02(conn: &mut PgConnection) -> Result<(), LemmyError> { info!("Running apub_columns_2021_02_02"); { use lemmy_db_schema::schema::person::dsl::*; @@ -291,7 +291,7 @@ fn apub_columns_2021_02_02(conn: &PgConnection) -> Result<(), LemmyError> { /// Before this point, there is only a single value in the site table which refers to the local /// Lemmy instance, so thats all we need to update. fn instance_actor_2022_01_28( - conn: &PgConnection, + conn: &mut PgConnection, protocol_and_hostname: &str, ) -> Result<(), LemmyError> { info!("Running instance_actor_2021_09_29"); @@ -321,7 +321,7 @@ fn instance_actor_2022_01_28( /// key field is empty, generate a new keypair. It would be possible to regenerate only the pubkey, /// but thats more complicated and has no benefit, as federation is already broken for these actors. /// https://github.com/LemmyNet/lemmy/issues/2347 -fn regenerate_public_keys_2022_07_05(conn: &PgConnection) -> Result<(), LemmyError> { +fn regenerate_public_keys_2022_07_05(conn: &mut PgConnection) -> Result<(), LemmyError> { info!("Running regenerate_public_keys_2022_07_05"); { diff --git a/src/main.rs b/src/main.rs index 07be683e..3c0bf3f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,14 @@ #[macro_use] extern crate diesel_migrations; +use crate::diesel_migrations::MigrationHarness; use actix::prelude::*; use actix_web::{web::Data, *}; use diesel::{ r2d2::{ConnectionManager, Pool}, PgConnection, }; +use diesel_migrations::EmbeddedMigrations; use doku::json::{AutoComments, Formatting}; use lemmy_api::match_websocket_operation; use lemmy_api_common::{ @@ -41,7 +43,7 @@ use std::{ }; use tracing_actix_web::TracingLogger; -embed_migrations!(); +pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!(); /// Max timeout for http requests pub const REQWEST_TIMEOUT: Duration = Duration::from_secs(10); @@ -77,7 +79,9 @@ async fn main() -> Result<(), LemmyError> { // Run the migrations from code let protocol_and_hostname = settings.get_protocol_and_hostname(); blocking(&pool, move |conn| { - embedded_migrations::run(conn)?; + let _ = conn + .run_pending_migrations(MIGRATIONS) + .map_err(|_| LemmyError::from_message("Couldn't run migrations"))?; run_advanced_migrations(conn, &protocol_and_hostname)?; Ok(()) as Result<(), LemmyError> }) @@ -96,8 +100,8 @@ async fn main() -> Result<(), LemmyError> { }; // Initialize the secrets - let conn = pool.get()?; - let secret = Secret::init(&conn).expect("Couldn't initialize secrets."); + let conn = &mut pool.get()?; + let secret = Secret::init(conn).expect("Couldn't initialize secrets."); println!( "Starting http server at {}:{}", @@ -117,13 +121,13 @@ async fn main() -> Result<(), LemmyError> { }; let client = ClientBuilder::new(reqwest_client.clone()) - .with(TracingMiddleware) + .with(TracingMiddleware::default()) .with(RetryTransientMiddleware::new_with_policy(retry_policy)) .build(); // Pictrs cannot use the retry middleware let pictrs_client = ClientBuilder::new(reqwest_client.clone()) - .with(TracingMiddleware) + .with(TracingMiddleware::default()) .build(); check_private_instance_and_federation_enabled(&pool, &settings).await?; diff --git a/src/scheduled_tasks.rs b/src/scheduled_tasks.rs index df54868f..108de672 100644 --- a/src/scheduled_tasks.rs +++ b/src/scheduled_tasks.rs @@ -11,24 +11,24 @@ use tracing::info; pub fn setup(pool: DbPool) -> Result<(), LemmyError> { let mut scheduler = Scheduler::new(); - let conn = pool.get()?; - active_counts(&conn); - update_banned_when_expired(&conn); + let mut conn = pool.get()?; + active_counts(&mut conn); + update_banned_when_expired(&mut conn); // On startup, reindex the tables non-concurrently // TODO remove this for now, since it slows down startup a lot on lemmy.ml - reindex_aggregates_tables(&conn, true); + reindex_aggregates_tables(&mut conn, true); scheduler.every(1.hour()).run(move || { - active_counts(&conn); - update_banned_when_expired(&conn); - reindex_aggregates_tables(&conn, true); - drop_ccnew_indexes(&conn); + active_counts(&mut conn); + update_banned_when_expired(&mut conn); + reindex_aggregates_tables(&mut conn, true); + drop_ccnew_indexes(&mut conn); }); - let conn = pool.get()?; - clear_old_activities(&conn); + let mut conn = pool.get()?; + clear_old_activities(&mut conn); scheduler.every(1.weeks()).run(move || { - clear_old_activities(&conn); + clear_old_activities(&mut conn); }); // Manually run the scheduler in an event loop @@ -41,7 +41,7 @@ pub fn setup(pool: DbPool) -> Result<(), LemmyError> { /// Reindex the aggregates tables every one hour /// This is necessary because hot_rank is actually a mutable function: /// https://dba.stackexchange.com/questions/284052/how-to-create-an-index-based-on-a-time-based-function-in-postgres?noredirect=1#comment555727_284052 -fn reindex_aggregates_tables(conn: &PgConnection, concurrently: bool) { +fn reindex_aggregates_tables(conn: &mut PgConnection, concurrently: bool) { for table_name in &[ "post_aggregates", "comment_aggregates", @@ -51,7 +51,7 @@ fn reindex_aggregates_tables(conn: &PgConnection, concurrently: bool) { } } -fn reindex_table(conn: &PgConnection, table_name: &str, concurrently: bool) { +fn reindex_table(conn: &mut PgConnection, table_name: &str, concurrently: bool) { let concurrently_str = if concurrently { "concurrently" } else { "" }; info!("Reindexing table {} {} ...", concurrently_str, table_name); let query = format!("reindex table {} {}", concurrently_str, table_name); @@ -60,14 +60,14 @@ fn reindex_table(conn: &PgConnection, table_name: &str, concurrently: bool) { } /// Clear old activities (this table gets very large) -fn clear_old_activities(conn: &PgConnection) { +fn clear_old_activities(conn: &mut PgConnection) { info!("Clearing old activities..."); Activity::delete_olds(conn).expect("clear old activities"); info!("Done."); } /// Re-calculate the site and community active counts every 12 hours -fn active_counts(conn: &PgConnection) { +fn active_counts(conn: &mut PgConnection) { info!("Updating active site and community aggregates ..."); let intervals = vec![ @@ -96,7 +96,7 @@ fn active_counts(conn: &PgConnection) { } /// Set banned to false after ban expires -fn update_banned_when_expired(conn: &PgConnection) { +fn update_banned_when_expired(conn: &mut PgConnection) { info!("Updating banned column if it expires ..."); let update_ban_expires_stmt = "update person set banned = false where banned = true and ban_expires < now()"; @@ -107,7 +107,7 @@ fn update_banned_when_expired(conn: &PgConnection) { /// Drops the phantom CCNEW indexes created by postgres /// https://github.com/LemmyNet/lemmy/issues/2431 -fn drop_ccnew_indexes(conn: &PgConnection) { +fn drop_ccnew_indexes(conn: &mut PgConnection) { info!("Dropping phantom ccnew indexes..."); let drop_stmt = "select drop_ccnew_indexes()"; sql_query(drop_stmt)