]> Untitled Git - lemmy.git/commitdiff
Diesel 2.0.0 upgrade (#2452)
authorDessalines <dessalines@users.noreply.github.com>
Mon, 26 Sep 2022 14:09:32 +0000 (10:09 -0400)
committerGitHub <noreply@github.com>
Mon, 26 Sep 2022 14:09:32 +0000 (14:09 +0000)
* 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 <stevenc1@gmail.com>
Co-authored-by: Nutomic <me@nutomic.com>
155 files changed:
.drone.yml
Cargo.lock
Cargo.toml
crates/api/Cargo.toml
crates/api/src/comment/like.rs
crates/api/src/comment/save.rs
crates/api/src/comment_report/resolve.rs
crates/api/src/community/add_mod.rs
crates/api/src/community/ban.rs
crates/api/src/community/block.rs
crates/api/src/community/follow.rs
crates/api/src/community/transfer.rs
crates/api/src/lib.rs
crates/api/src/local_user/ban_person.rs
crates/api/src/local_user/block.rs
crates/api/src/local_user/notifications/mark_mention_read.rs
crates/api/src/local_user/notifications/mark_reply_read.rs
crates/api/src/post/like.rs
crates/api/src/post/save.rs
crates/api/src/post_report/resolve.rs
crates/api/src/private_message_report/resolve.rs
crates/api_common/Cargo.toml
crates/api_common/src/post.rs
crates/api_common/src/utils.rs
crates/api_crud/Cargo.toml
crates/api_crud/src/comment/create.rs
crates/api_crud/src/community/create.rs
crates/api_crud/src/post/create.rs
crates/api_crud/src/site/create.rs
crates/api_crud/src/user/read.rs
crates/apub/Cargo.toml
crates/apub/src/activities/block/block_user.rs
crates/apub/src/activities/block/undo_block_user.rs
crates/apub/src/activities/create_or_update/comment.rs
crates/apub/src/activities/create_or_update/post.rs
crates/apub/src/activities/mod.rs
crates/apub/src/collections/community_moderators.rs
crates/apub/src/fetcher/user_or_community.rs
crates/apub/src/objects/comment.rs
crates/apub/src/objects/community.rs
crates/apub/src/objects/instance.rs
crates/apub/src/objects/person.rs
crates/apub/src/objects/post.rs
crates/apub/src/objects/private_message.rs
crates/apub/src/protocol/activities/mod.rs
crates/apub/src/protocol/activities/voting/vote.rs
crates/apub/src/protocol/objects/instance.rs
crates/apub/src/protocol/objects/page.rs
crates/apub/src/protocol/objects/person.rs
crates/apub_lib/Cargo.toml [new file with mode: 0644]
crates/db_schema/Cargo.toml
crates/db_schema/src/aggregates/comment_aggregates.rs
crates/db_schema/src/aggregates/community_aggregates.rs
crates/db_schema/src/aggregates/person_aggregates.rs
crates/db_schema/src/aggregates/post_aggregates.rs
crates/db_schema/src/aggregates/site_aggregates.rs
crates/db_schema/src/aggregates/structs.rs
crates/db_schema/src/impls/activity.rs
crates/db_schema/src/impls/comment.rs
crates/db_schema/src/impls/comment_reply.rs
crates/db_schema/src/impls/comment_report.rs
crates/db_schema/src/impls/community.rs
crates/db_schema/src/impls/community_block.rs
crates/db_schema/src/impls/email_verification.rs
crates/db_schema/src/impls/language.rs
crates/db_schema/src/impls/local_user.rs
crates/db_schema/src/impls/local_user_language.rs
crates/db_schema/src/impls/moderator.rs
crates/db_schema/src/impls/password_reset_request.rs
crates/db_schema/src/impls/person.rs
crates/db_schema/src/impls/person_block.rs
crates/db_schema/src/impls/person_mention.rs
crates/db_schema/src/impls/post.rs
crates/db_schema/src/impls/post_report.rs
crates/db_schema/src/impls/private_message.rs
crates/db_schema/src/impls/private_message_report.rs
crates/db_schema/src/impls/registration_application.rs
crates/db_schema/src/impls/secret.rs
crates/db_schema/src/impls/site.rs
crates/db_schema/src/lib.rs
crates/db_schema/src/newtypes.rs
crates/db_schema/src/schema.rs
crates/db_schema/src/source/activity.rs
crates/db_schema/src/source/comment.rs
crates/db_schema/src/source/comment_reply.rs
crates/db_schema/src/source/comment_report.rs
crates/db_schema/src/source/community.rs
crates/db_schema/src/source/community_block.rs
crates/db_schema/src/source/email_verification.rs
crates/db_schema/src/source/language.rs
crates/db_schema/src/source/local_user.rs
crates/db_schema/src/source/local_user_language.rs
crates/db_schema/src/source/moderator.rs
crates/db_schema/src/source/password_reset_request.rs
crates/db_schema/src/source/person.rs
crates/db_schema/src/source/person_block.rs
crates/db_schema/src/source/person_mention.rs
crates/db_schema/src/source/post.rs
crates/db_schema/src/source/post_report.rs
crates/db_schema/src/source/private_message.rs
crates/db_schema/src/source/private_message_report.rs
crates/db_schema/src/source/registration_application.rs
crates/db_schema/src/source/secret.rs
crates/db_schema/src/source/site.rs
crates/db_schema/src/traits.rs
crates/db_schema/src/utils.rs
crates/db_views/Cargo.toml
crates/db_views/src/comment_report_view.rs
crates/db_views/src/comment_view.rs
crates/db_views/src/local_user_discussion_language_view.rs
crates/db_views/src/local_user_view.rs
crates/db_views/src/post_report_view.rs
crates/db_views/src/post_view.rs
crates/db_views/src/private_message_report_view.rs
crates/db_views/src/private_message_view.rs
crates/db_views/src/registration_application_view.rs
crates/db_views/src/site_view.rs
crates/db_views/src/structs.rs
crates/db_views_actor/Cargo.toml
crates/db_views_actor/src/comment_reply_view.rs
crates/db_views_actor/src/community_block_view.rs
crates/db_views_actor/src/community_follower_view.rs
crates/db_views_actor/src/community_moderator_view.rs
crates/db_views_actor/src/community_person_ban_view.rs
crates/db_views_actor/src/community_view.rs
crates/db_views_actor/src/person_block_view.rs
crates/db_views_actor/src/person_mention_view.rs
crates/db_views_actor/src/person_view.rs
crates/db_views_actor/src/structs.rs
crates/db_views_moderator/Cargo.toml
crates/db_views_moderator/src/admin_purge_comment_view.rs
crates/db_views_moderator/src/admin_purge_community_view.rs
crates/db_views_moderator/src/admin_purge_person_view.rs
crates/db_views_moderator/src/admin_purge_post_view.rs
crates/db_views_moderator/src/mod_add_community_view.rs
crates/db_views_moderator/src/mod_add_view.rs
crates/db_views_moderator/src/mod_ban_from_community_view.rs
crates/db_views_moderator/src/mod_ban_view.rs
crates/db_views_moderator/src/mod_hide_community_view.rs
crates/db_views_moderator/src/mod_lock_post_view.rs
crates/db_views_moderator/src/mod_remove_comment_view.rs
crates/db_views_moderator/src/mod_remove_community_view.rs
crates/db_views_moderator/src/mod_remove_post_view.rs
crates/db_views_moderator/src/mod_sticky_post_view.rs
crates/db_views_moderator/src/mod_transfer_community_view.rs
crates/db_views_moderator/src/structs.rs
crates/routes/Cargo.toml
crates/routes/src/feeds.rs
crates/utils/Cargo.toml
crates/websocket/Cargo.toml
migrations/2022-09-24-161829_remove_table_aliases/down.sql [new file with mode: 0644]
migrations/2022-09-24-161829_remove_table_aliases/up.sql [new file with mode: 0644]
src/code_migrations.rs
src/main.rs
src/scheduled_tasks.rs

index de4114c6af7aae299cb198e337807719fe3cef06..43057f64bf4c2e5ec7986f7e116880c5164f4ed6 100644 (file)
@@ -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
index c1bfba5addcdd64d87505d2e9c95d347ea7b5f68..fbfb99d1dfebb1fb88ac7042089876b413fc22b9 100644 (file)
@@ -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"
index c53d248fdf22a88e252c689f03300596046df0ab..18cf4eb39170cb34b9cbe18d8fffea82c362bab9 100644 (file)
@@ -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 }
index 2b80f16e06601b5cd976d9539c1f4bbdeb4bfd0f..737fa7cc504e1a79399e03a7232f1d081b00e114 100644 (file)
@@ -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"
index 144de4bfc585714a91b3eb57a4a3edb306093e8c..4e527dd0acecc52a49eead11caa0623a40c0ea36 100644 (file)
@@ -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"))?;
index 4d599739a254560d8a990968de7d3cf45b6b1e70..e1a26d57304c87ce4446539f4972c797c359eed3 100644 (file)
@@ -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"))?;
index 2c016b95e4b9e8ec61b2c104a2b98ef37bb16764..c0b8a40007b309b47a9418ddfa3806b20657b4bf 100644 (file)
@@ -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 {
index b8999e4b71f4d77352a8ccd5433f1fda7861bc53..f0c5ed178f98025974d77ab33e7691e8135a978e 100644 (file)
@@ -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"))?;
index 07e287835427a2193989682a927a5499b4f3f7f2..9ea0c5c93c9ee39a2aa6479dff198cab3e96a424 100644 (file)
@@ -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"))?;
index 2f5f5f904b48149afcbe0ef76d222c7881480e27..5f01ac3d7f86a4562e827ed376a21c0c9c9cdb99 100644 (file)
@@ -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"))?;
index 666892042f04e493efa68c34d028cd88436bb207..7a5e3198575685b39e56c5044e6ee999c9b7b545 100644 (file)
@@ -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"))?;
index fe34bbfa4f4f4b21cb7a44c05ac461490bb2c609..1b6abb21b91589218e461cd12ccb2d02fdd7ba74 100644 (file)
@@ -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"))?;
index 2659535a0ceafa745a990519af379b5d78e8cf42..e3419f3843daf03a898120dec95edd036cf22cc3 100644 (file)
@@ -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);
   }
 }
index cc239cac18b69fe96347da02d5ffd44c341d0981..c2f09da7d53d1e6339e4723d6f6042b7c1f1bade 100644 (file)
@@ -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"))?;
index da21dcdd8872042f3a9d75ad3bf31457e8f52546..3f1b36f239a52f952912c4e82a41d86c344adbc0 100644 (file)
@@ -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"))?;
index b097ddc41b73026e4b9d7fcdcd9b29d81e6bd414..2179ada05db9714a12e86c39553de494379a3cb8 100644 (file)
@@ -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"))?;
index 46d158863165a108cdb14b27e889061e461a5f49..3e502f39c5d0e6b1122612caf42c7528ab57b413 100644 (file)
@@ -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"))?;
index 5197225602bc290fd5f86f275d47e6e33ba872bf..ef9546753c42eaf6cf6b1e8a73eaa81b5f3708d4 100644 (file)
@@ -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"))?;
index 25bb6c3cec13246af84380105df485915d0d29a1..ff41581c3a8d4570feacc7050fc997d7b6b7ebb2 100644 (file)
@@ -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"))?;
index 469f96b359139173b7fc522edf90ae7bd4aff698..120a76f138bb155821e23f0ecd550690b8844cfd 100644 (file)
@@ -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 {
index 7b3500b49953d5aa9531bd239bd548dcf36598dd..03aab70bf4574119b4957ba2452198223f057f30 100644 (file)
@@ -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 {
index 65cac3084e3d44de8b3a597194e8c4637d8e54b7..e7f6c07c3f14942a0af43a7796b8e21ada92577c 100644 (file)
@@ -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"] }
index c9d92380d5bee26c5da0b857d01e7469cf8c24e4..4f486e0598da8ead2abc90eddd4122a72707a816 100644 (file)
@@ -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<String>,
   pub description: Option<String>,
index d2a009787745609e1faaaa7063c3a0d00bbf24da..ce6831e398fe17bc7dd310f3f85a91a8b5023b0c 100644 (file)
@@ -42,15 +42,15 @@ use tracing::warn;
 
 pub async fn blocking<F, T>(pool: &DbPool, f: F) -> Result<T, LemmyError>
 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<T, LemmyError>
   })
@@ -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"))?;
index 0d709aa255ccb929fa529cb60ea81aa889f1c5d1..301015ad80b5202a1a5f0d9f31a4d4f292050a8a 100644 (file)
@@ -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"
index 73408fa9881138a675d6f4f78995834ed7ffa8ed..7ab0f20b6d0b0e96a904be242185cb52763428cd 100644 (file)
@@ -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"))?;
index e12e3965c309b4f4daaeb109e3e3dcea88355d01..a0c40457a2d3ca952971f0f9d1cf8dcbc7a45b54 100644 (file)
@@ -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"))?;
index 64a2382736ef5bf61d1752d6c3da2bdcfbbba4f2..0d4271a80bde6cf9dedbcb0d70d34e0cf8252cbe 100644 (file)
@@ -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"))?;
index c61e3feae2873cf7ee18d5b0156415ad7f7662b0..d74117f43ef25b0a327bda126596f07ca970a0ec 100644 (file)
@@ -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"))?;
index d47bc5337dc33a30ea4f0f90268361ad1250b7e6..d9d26f0cdd4ef76df0c0f97176ccf86613e1a346 100644 (file)
@@ -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??;
 
index 2714eb8bd7a4fc045906d81eb244a6e1632f3ef7..31b7dcbe0cbac69555f53fa68ede4a0fc018c528 100644 (file)
@@ -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"
index a18002f1fe4c6e849b06bffacba2e263341428bf..5297cda73af61c99edfc9b5d56b8af261cfa0712 100644 (file)
@@ -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?
index 97ac3482522ec59bf8bf9dd613e3084da2e34d93..ee6f631aee0a137747898850bce7d8b01a0fae21 100644 (file)
@@ -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??;
index e3b01feb1dde6c95f17cd572bd91f0370bd53cde..dad6ada9bf96e5ddcfeead994ef646ef35c56347 100644 (file)
@@ -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??;
index 5d6f99548efd4cd646f7100f8250f3ee0c5f7b6e..5ac57fb00e7863815a59ee6e3c31ac7478186832 100644 (file)
@@ -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??;
index 4b884e4f1dc0701be1145ebfeb7cc2df85da2edf..bd928e72ca174ec0a8021e08411f147427d5342c 100644 (file)
@@ -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"));
   }
index 2c0c4cd90e8ed4a10b2a663ae90651f5a2e9162d..9f4374dbb6df3585733c611d76f7d4ba443552ea 100644 (file)
@@ -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();
   }
 }
index 1ed9bb0f0425c6c39907d2000b6c8fa1ccc8317b..da23ad59a180a85395d27aa9f325e12fa8f4b014 100644 (file)
@@ -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,
index 840d3a511e059ef4fab3f41aff533c56077790b6..41d7f19da0a28521fef7e47b706896c09b129f47 100644 (file)
@@ -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);
   }
 
index 6e2f409a6b839e347136b7be715858462e1b7ae1..cf2dab94eb48c4d33cb92efe3a6c79cc20417f42 100644 (file)
@@ -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();
   }
 }
index 5e80422193c862edffa92dbcb683e5b86fa963c3..dbf2f9f3a05fdd362139c58c42052c49d627d2ed 100644 (file)
@@ -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();
   }
 }
index 0b1dd84de2a7ee3752cdea0ceecd8022a129cf6c..b1a892a321244ee9788ea732b98f5977e00eef62 100644 (file)
@@ -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();
   }
 }
index 93273466d3e6b518dfa3d03b1e5daa2075600bad..4789bdc1ba2d8b4dd8551ad61d2aaaffe57eeb1f 100644 (file)
@@ -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();
   }
 }
index 8a8f9b4af7916dd6e5f13c1e17174d147f97a07b..3aef60c64d67dfed7ea7347dbd7761bfa5b49e38 100644 (file)
@@ -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);
   }
 }
index 3b8c9e20ceec8a9d60b9bc153eaee941a6f7fe14..324c8b68f3be5c43d72535bee18aca5934905707 100644 (file)
@@ -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,
index 2bc674f1d8179617fd543153049203352b4e33fb..8541b1369cec2115b9188b792d16c1005486a4d9 100644 (file)
@@ -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,
index b921ad207fef580feb9960ca4580aafed5548da8..d8b997b43d8962b928526196fd1b4e39e0e7f648 100644 (file)
@@ -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,
index 555a98999b370124996c4cb317d5ac7e5e8465db..1cf55acaa68a94fb4859429996493e43339acafa 100644 (file)
@@ -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,
index ac52e46ac234b2ee469cc9af4db57da67b60cddf..eb473250357984e0928c0f637ebee37145f41188 100644 (file)
@@ -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 (file)
index 0000000..3aaebd4
--- /dev/null
@@ -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"] }
index 7d0a38172d5fb47f1ab825e6dcb3cc848d24b7d5..fc5e91b80ea996034c6e503a6929d52777707747 100644 (file)
@@ -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"
index 679efeac0f2cd73f23e62ff07e4ecdfd7dcf5aae..c24e0b94a508afe9a3f91db916d0f996d1d6476e 100644 (file)
@@ -6,7 +6,7 @@ use crate::{
 use diesel::{result::Error, *};
 
 impl CommentAggregates {
-  pub fn read(conn: &PgConnection, comment_id: CommentId) -> Result<Self, Error> {
+  pub fn read(conn: &mut PgConnection, comment_id: CommentId) -> Result<Self, Error> {
     comment_aggregates::table
       .filter(comment_aggregates::comment_id.eq(comment_id))
       .first::<Self>(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);
   }
 }
index 1643fead72b8926d28c884ef286576db4dbdf849..9dfa710fbea0531bf2da8999d27896dbbb830374 100644 (file)
@@ -6,7 +6,7 @@ use crate::{
 use diesel::{result::Error, *};
 
 impl CommunityAggregates {
-  pub fn read(conn: &PgConnection, community_id: CommunityId) -> Result<Self, Error> {
+  pub fn read(conn: &mut PgConnection, community_id: CommunityId) -> Result<Self, Error> {
     community_aggregates::table
       .filter(community_aggregates::community_id.eq(community_id))
       .first::<Self>(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());
   }
 }
index 29ece732903de409f65a48f23b42c4129c6918f9..ff0cb843711cf6ff3fb71061bf2e1136d2e98512 100644 (file)
@@ -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<Self, Error> {
+  pub fn read(conn: &mut PgConnection, person_id: PersonId) -> Result<Self, Error> {
     person_aggregates::table
       .filter(person_aggregates::person_id.eq(person_id))
       .first::<Self>(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());
   }
 }
index 0ef20773d2903ed9a07774fe2e81e53604d4d2ca..1782d4d69de708d1c4a551cbbb16c331c35f7965 100644 (file)
@@ -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<Self, Error> {
+  pub fn read(conn: &mut PgConnection, post_id: PostId) -> Result<Self, Error> {
     post_aggregates::table
       .filter(post_aggregates::post_id.eq(post_id))
       .first::<Self>(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());
   }
 }
index 86a46e83f0e63263470aa25fe6b0c9a143c0725b..fa60b15dccc3fe202f93b68369d0c9f34cd3b32a 100644 (file)
@@ -2,7 +2,7 @@ use crate::{aggregates::structs::SiteAggregates, schema::site_aggregates};
 use diesel::{result::Error, *};
 
 impl SiteAggregates {
-  pub fn read(conn: &PgConnection) -> Result<Self, Error> {
+  pub fn read(conn: &mut PgConnection) -> Result<Self, Error> {
     site_aggregates::table.first::<Self>(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());
   }
 }
index 328c38a8608d160673c2252ec72f6c72c8f6f7e2..15fce13b2bb849d00d6167dabfa682702bf653fc 100644 (file)
@@ -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,
index b22550a4e75df4f1c726ec86d2c7a400adad5ba6..87b78a1d61fb765333a26e0558aa189a5427bbbd 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, activity_id: i32) -> Result<Self, Error> {
     use crate::schema::activity::dsl::*;
     activity.find(activity_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, new_activity: &ActivityForm) -> Result<Self, Error> {
     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<Self, Error> {
@@ -31,7 +31,7 @@ impl Crud for Activity {
       .set(new_activity)
       .get_result::<Self>(conn)
   }
-  fn delete(conn: &PgConnection, activity_id: i32) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, activity_id: i32) -> Result<usize, Error> {
     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<Activity, Error> {
+  pub fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result<Activity, Error> {
     use crate::schema::activity::dsl::*;
     activity.filter(ap_id.eq(object_id)).first::<Self>(conn)
   }
 
-  pub fn delete_olds(conn: &PgConnection) -> Result<usize, Error> {
+  pub fn delete_olds(conn: &mut PgConnection) -> Result<usize, Error> {
     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);
index 5eaedcb95fa66580e967db36f4d2654c57f63299..eca5328de1eb65ff160281af1d7d5dd7f541f742 100644 (file)
@@ -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<Self, Error> {
@@ -29,7 +29,7 @@ impl Comment {
   }
 
   pub fn permadelete_for_creator(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     for_creator_id: PersonId,
   ) -> Result<Vec<Self>, 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<Self, Error> {
@@ -54,7 +54,7 @@ impl Comment {
   }
 
   pub fn update_removed(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     comment_id: CommentId,
     new_removed: bool,
   ) -> Result<Self, Error> {
@@ -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<Vec<Self>, Error> {
@@ -76,7 +76,7 @@ impl Comment {
   }
 
   pub fn create(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     comment_form: &CommentForm,
     parent_path: Option<&Ltree>,
   ) -> Result<Comment, Error> {
@@ -141,7 +141,7 @@ where ca.comment_id = c.id",
       inserted_comment
     }
   }
-  pub fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, Error> {
+  pub fn read_from_apub_id(conn: &mut PgConnection, object_id: Url) -> Result<Option<Self>, 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<Self, Error> {
+  fn read(conn: &mut PgConnection, comment_id: CommentId) -> Result<Self, Error> {
     use crate::schema::comment::dsl::*;
     comment.find(comment_id).first::<Self>(conn)
   }
 
-  fn delete(conn: &PgConnection, comment_id: CommentId) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, comment_id: CommentId) -> Result<usize, Error> {
     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<Self, Error> {
+  fn create(_conn: &mut PgConnection, _comment_form: &CommentForm) -> Result<Self, Error> {
     unimplemented!();
   }
 
   fn update(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     comment_id: CommentId,
     comment_form: &CommentForm,
   ) -> Result<Self, Error> {
@@ -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<Self, Error> {
+  fn like(conn: &mut PgConnection, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
     use crate::schema::comment_like::dsl::*;
     insert_into(comment_like)
       .values(comment_like_form)
@@ -210,7 +210,7 @@ impl Likeable for CommentLike {
       .get_result::<Self>(conn)
   }
   fn remove(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     person_id: PersonId,
     comment_id: CommentId,
   ) -> Result<usize, Error> {
@@ -226,7 +226,7 @@ impl Likeable for CommentLike {
 
 impl Saveable for CommentSaved {
   type Form = CommentSavedForm;
-  fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
+  fn save(conn: &mut PgConnection, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
     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::<Self>(conn)
   }
-  fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<usize, Error> {
+  fn unsave(
+    conn: &mut PgConnection,
+    comment_saved_form: &CommentSavedForm,
+  ) -> Result<usize, Error> {
     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);
index 271e5e7184bc9d0eeeebdbebf3ebd6db0bb5b3ac..8fed2ce47f03f24ccc2a7c61809938491880e737 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, comment_reply_id: CommentReplyId) -> Result<Self, Error> {
     use crate::schema::comment_reply::dsl::*;
     comment_reply.find(comment_reply_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, comment_reply_form: &CommentReplyForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, comment_reply_form: &CommentReplyForm) -> Result<Self, Error> {
     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<Self, Error> {
@@ -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<CommentReply, Error> {
@@ -50,7 +50,7 @@ impl CommentReply {
   }
 
   pub fn mark_all_as_read(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     for_recipient_id: PersonId,
   ) -> Result<Vec<CommentReply>, Error> {
     use crate::schema::comment_reply::dsl::*;
@@ -63,7 +63,10 @@ impl CommentReply {
     .get_results::<Self>(conn)
   }
 
-  pub fn read_by_comment(conn: &PgConnection, for_comment_id: CommentId) -> Result<Self, Error> {
+  pub fn read_by_comment(
+    conn: &mut PgConnection,
+    for_comment_id: CommentId,
+  ) -> Result<Self, Error> {
     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);
index 56e917e028f0135effae2521ef156ff9fc20f8d8..ebafddab776a8f380252752588fe506d4465a99b 100644 (file)
@@ -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<Self, Error> {
+  fn report(
+    conn: &mut PgConnection,
+    comment_report_form: &CommentReportForm,
+  ) -> Result<Self, Error> {
     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<usize, Error> {
@@ -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<usize, Error> {
index eb92d7a0b3c181ccebed138a1740cb267807bdd5..574c0ee2d23536e0edc8d119007dd1d4fcd5f615 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, community_id: CommunityId) -> Result<Self, Error> {
     use crate::schema::community::dsl::*;
     community.find(community_id).first::<Self>(conn)
   }
 
-  fn delete(conn: &PgConnection, community_id: CommunityId) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, community_id: CommunityId) -> Result<usize, Error> {
     use crate::schema::community::dsl::*;
     diesel::delete(community.find(community_id)).execute(conn)
   }
 
-  fn create(conn: &PgConnection, new_community: &CommunityForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, new_community: &CommunityForm) -> Result<Self, Error> {
     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<Self, Error> {
@@ -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<Community, Error> {
@@ -115,7 +115,7 @@ impl Community {
   }
 
   pub fn update_removed(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     community_id: CommunityId,
     new_removed: bool,
   ) -> Result<Community, Error> {
@@ -125,12 +125,15 @@ impl Community {
       .get_result::<Self>(conn)
   }
 
-  pub fn distinct_federated_communities(conn: &PgConnection) -> Result<Vec<DbUrl>, Error> {
+  pub fn distinct_federated_communities(conn: &mut PgConnection) -> Result<Vec<DbUrl>, Error> {
     use crate::schema::community::dsl::*;
     community.select(actor_id).distinct().load::<DbUrl>(conn)
   }
 
-  pub fn upsert(conn: &PgConnection, community_form: &CommunityForm) -> Result<Community, Error> {
+  pub fn upsert(
+    conn: &mut PgConnection,
+    community_form: &CommunityForm,
+  ) -> Result<Community, Error> {
     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<Self, Error> {
     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<Self, Error> {
     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<usize, Error> {
     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<usize, Error> {
     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<Vec<CommunityId>, 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<Self, Error> {
     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<usize, Error> {
     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<Self, Error> {
     use crate::schema::community_follower::dsl::*;
@@ -281,7 +284,7 @@ impl Followable for CommunityFollower {
       .get_result::<Self>(conn)
   }
   fn follow_accepted(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     community_id_: CommunityId,
     person_id_: PersonId,
   ) -> Result<Self, Error>
@@ -298,7 +301,7 @@ impl Followable for CommunityFollower {
     .get_result::<Self>(conn)
   }
   fn unfollow(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     community_follower_form: &CommunityFollowerForm,
   ) -> Result<usize, Error> {
     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<bool, Error> {
+  fn has_local_followers(
+    conn: &mut PgConnection,
+    community_id_: CommunityId,
+  ) -> Result<bool, Error> {
     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<Option<Self>, Error> {
+  fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result<Option<Self>, 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<Community, Error> {
@@ -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<Community, Error> {
@@ -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);
index bbad2f122437fe7936117a77ac5c955a1dc831b8..49a86173476e1376d5167c0d9f53821c130bffd6 100644 (file)
@@ -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<Self, Error> {
+  fn block(conn: &mut PgConnection, community_block_form: &Self::Form) -> Result<Self, Error> {
     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::<Self>(conn)
   }
-  fn unblock(conn: &PgConnection, community_block_form: &Self::Form) -> Result<usize, Error> {
+  fn unblock(conn: &mut PgConnection, community_block_form: &Self::Form) -> Result<usize, Error> {
     use crate::schema::community_block::dsl::*;
     diesel::delete(
       community_block
index c270373914ecc5c0830d82b23f60e136b22f4d17..33415cf0205e74a8fb80a1139d2258ebacdc09d6 100644 (file)
@@ -12,33 +12,37 @@ use diesel::{
 impl Crud for EmailVerification {
   type Form = EmailVerificationForm;
   type IdType = i32;
-  fn create(conn: &PgConnection, form: &EmailVerificationForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &EmailVerificationForm) -> Result<Self, Error> {
     use crate::schema::email_verification::dsl::*;
     insert_into(email_verification)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn read(conn: &PgConnection, id_: i32) -> Result<Self, Error> {
+  fn read(conn: &mut PgConnection, id_: i32) -> Result<Self, Error> {
     use crate::schema::email_verification::dsl::*;
     email_verification.find(id_).first::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, id_: i32, form: &EmailVerificationForm) -> Result<Self, Error> {
+  fn update(
+    conn: &mut PgConnection,
+    id_: i32,
+    form: &EmailVerificationForm,
+  ) -> Result<Self, Error> {
     use crate::schema::email_verification::dsl::*;
     diesel::update(email_verification.find(id_))
       .set(form)
       .get_result::<Self>(conn)
   }
 
-  fn delete(conn: &PgConnection, id_: i32) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, id_: i32) -> Result<usize, Error> {
     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<Self, Error> {
+  pub fn read_for_token(conn: &mut PgConnection, token: &str) -> Result<Self, Error> {
     use crate::schema::email_verification::dsl::*;
     email_verification
       .filter(verification_token.eq(token))
@@ -46,7 +50,7 @@ impl EmailVerification {
       .first::<Self>(conn)
   }
   pub fn delete_old_tokens_for_local_user(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     local_user_id_: LocalUserId,
   ) -> Result<usize, Error> {
     use crate::schema::email_verification::dsl::*;
index f2895e807ea3c44f70d391447fcdd9b6602c467a..0aef28f207dce535e823524163f9cbc754c8c31f 100644 (file)
@@ -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<Vec<Language>, Error> {
+  pub fn read_all(conn: &mut PgConnection) -> Result<Vec<Language>, Error> {
     use crate::schema::language::dsl::*;
     language.load::<Self>(conn)
   }
 
-  pub fn read_from_id(conn: &PgConnection, id_: LanguageId) -> Result<Language, Error> {
+  pub fn read_from_id(conn: &mut PgConnection, id_: LanguageId) -> Result<Language, Error> {
     use crate::schema::language::dsl::*;
     language.filter(id.eq(id_)).first::<Self>(conn)
   }
 
-  pub fn read_id_from_code(conn: &PgConnection, code_: &str) -> Result<LanguageId, Error> {
+  pub fn read_id_from_code(conn: &mut PgConnection, code_: &str) -> Result<LanguageId, Error> {
     use crate::schema::language::dsl::*;
     Ok(language.filter(code.eq(code_)).first::<Self>(conn)?.id)
   }
 
   pub fn read_id_from_code_opt(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     code_: Option<&str>,
   ) -> Result<Option<LanguageId>, Error> {
     if let Some(code_) = code_ {
@@ -28,7 +28,7 @@ impl Language {
     }
   }
 
-  pub fn read_undetermined(conn: &PgConnection) -> Result<LanguageId, Error> {
+  pub fn read_undetermined(conn: &mut PgConnection) -> Result<LanguageId, Error> {
     use crate::schema::language::dsl::*;
     Ok(language.filter(code.eq("und")).first::<Self>(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);
index d2599f4ff51100fdda5605e7e7f1afe4a74c54e8..4c540a0d182cd92ea06367e371b4220ce46f41a1 100644 (file)
@@ -67,7 +67,7 @@ mod safe_settings_type {
 }
 
 impl LocalUser {
-  pub fn register(conn: &PgConnection, form: &LocalUserForm) -> Result<Self, Error> {
+  pub fn register(conn: &mut PgConnection, form: &LocalUserForm) -> Result<Self, Error> {
     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<Self, Error> {
@@ -93,14 +93,14 @@ impl LocalUser {
       .get_result::<Self>(conn)
   }
 
-  pub fn set_all_users_email_verified(conn: &PgConnection) -> Result<Vec<Self>, Error> {
+  pub fn set_all_users_email_verified(conn: &mut PgConnection) -> Result<Vec<Self>, Error> {
     diesel::update(local_user)
       .set(email_verified.eq(true))
       .get_results::<Self>(conn)
   }
 
   pub fn set_all_users_registration_applications_accepted(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
   ) -> Result<Vec<Self>, 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<Self, Error> {
+  fn read(conn: &mut PgConnection, local_user_id: LocalUserId) -> Result<Self, Error> {
     local_user.find(local_user_id).first::<Self>(conn)
   }
-  fn delete(conn: &PgConnection, local_user_id: LocalUserId) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, local_user_id: LocalUserId) -> Result<usize, Error> {
     diesel::delete(local_user.find(local_user_id)).execute(conn)
   }
-  fn create(conn: &PgConnection, form: &LocalUserForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &LocalUserForm) -> Result<Self, Error> {
     let local_user_ = insert_into(local_user)
       .values(form)
       .get_result::<Self>(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<Self, Error> {
index d38a0869157c439c68028d224d0321f856a581fe..4ed2b4990f5c36aa5517ccc26e29176f3f483b66 100644 (file)
@@ -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<Vec<LanguageId>>,
     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)?;
 
index 976db49361fdfc9b821135d38f2bb1cb731a822b..6ec2f81b369b539ab2a2d5b93505a0d4194b61d6 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_remove_post::dsl::*;
     mod_remove_post.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModRemovePostForm) -> Result<Self, Error> {
     use crate::schema::mod_remove_post::dsl::*;
     insert_into(mod_remove_post)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
+  fn update(
+    conn: &mut PgConnection,
+    from_id: i32,
+    form: &ModRemovePostForm,
+  ) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_lock_post::dsl::*;
     mod_lock_post.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModLockPostForm) -> Result<Self, Error> {
     use crate::schema::mod_lock_post::dsl::*;
     insert_into(mod_lock_post)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_sticky_post::dsl::*;
     mod_sticky_post.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModStickyPostForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModStickyPostForm) -> Result<Self, Error> {
     use crate::schema::mod_sticky_post::dsl::*;
     insert_into(mod_sticky_post)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &ModStickyPostForm) -> Result<Self, Error> {
+  fn update(
+    conn: &mut PgConnection,
+    from_id: i32,
+    form: &ModStickyPostForm,
+  ) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_remove_comment::dsl::*;
     mod_remove_comment.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModRemoveCommentForm) -> Result<Self, Error> {
     use crate::schema::mod_remove_comment::dsl::*;
     insert_into(mod_remove_comment)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
+  fn update(
+    conn: &mut PgConnection,
+    from_id: i32,
+    form: &ModRemoveCommentForm,
+  ) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_remove_community::dsl::*;
     mod_remove_community.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
     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<Self, Error> {
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_ban_from_community::dsl::*;
     mod_ban_from_community.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
     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<Self, Error> {
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_ban::dsl::*;
     mod_ban.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModBanForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModBanForm) -> Result<Self, Error> {
     use crate::schema::mod_ban::dsl::*;
     insert_into(mod_ban).values(form).get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_hide_community::dsl::*;
     mod_hide_community.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModHideCommunityForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModHideCommunityForm) -> Result<Self, Error> {
     use crate::schema::mod_hide_community::dsl::*;
     insert_into(mod_hide_community)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &ModHideCommunityForm) -> Result<Self, Error> {
+  fn update(
+    conn: &mut PgConnection,
+    from_id: i32,
+    form: &ModHideCommunityForm,
+  ) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_add_community::dsl::*;
     mod_add_community.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModAddCommunityForm) -> Result<Self, Error> {
     use crate::schema::mod_add_community::dsl::*;
     insert_into(mod_add_community)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
+  fn update(
+    conn: &mut PgConnection,
+    from_id: i32,
+    form: &ModAddCommunityForm,
+  ) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_transfer_community::dsl::*;
     mod_transfer_community.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModTransferCommunityForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModTransferCommunityForm) -> Result<Self, Error> {
     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<Self, Error> {
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::mod_add::dsl::*;
     mod_add.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &ModAddForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &ModAddForm) -> Result<Self, Error> {
     use crate::schema::mod_add::dsl::*;
     insert_into(mod_add).values(form).get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::admin_purge_person::dsl::*;
     admin_purge_person.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error> {
     use crate::schema::admin_purge_person::dsl::*;
     insert_into(admin_purge_person)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &Self::Form) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, from_id: i32, form: &Self::Form) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::admin_purge_community::dsl::*;
     admin_purge_community.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error> {
     use crate::schema::admin_purge_community::dsl::*;
     insert_into(admin_purge_community)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &Self::Form) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, from_id: i32, form: &Self::Form) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::admin_purge_post::dsl::*;
     admin_purge_post.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error> {
     use crate::schema::admin_purge_post::dsl::*;
     insert_into(admin_purge_post)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &Self::Form) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, from_id: i32, form: &Self::Form) -> Result<Self, Error> {
     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<Self, Error> {
+  fn read(conn: &mut PgConnection, from_id: i32) -> Result<Self, Error> {
     use crate::schema::admin_purge_comment::dsl::*;
     admin_purge_comment.find(from_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error> {
     use crate::schema::admin_purge_comment::dsl::*;
     insert_into(admin_purge_comment)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, from_id: i32, form: &Self::Form) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, from_id: i32, form: &Self::Form) -> Result<Self, Error> {
     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);
index 780c6c2804abd14698b1072b30319df10ac0ee3b..dfa56e209508161d3676676ef8632e19062baf02 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, password_reset_request_id: i32) -> Result<Self, Error> {
     password_reset_request
       .find(password_reset_request_id)
       .first::<Self>(conn)
   }
-  fn create(conn: &PgConnection, form: &PasswordResetRequestForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &PasswordResetRequestForm) -> Result<Self, Error> {
     insert_into(password_reset_request)
       .values(form)
       .get_result::<Self>(conn)
   }
   fn update(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     password_reset_request_id: i32,
     form: &PasswordResetRequestForm,
   ) -> Result<Self, Error> {
@@ -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<PasswordResetRequest, Error> {
@@ -48,7 +48,10 @@ impl PasswordResetRequest {
 
     Self::create(conn, &form)
   }
-  pub fn read_from_token(conn: &PgConnection, token: &str) -> Result<PasswordResetRequest, Error> {
+  pub fn read_from_token(
+    conn: &mut PgConnection,
+    token: &str,
+  ) -> Result<PasswordResetRequest, Error> {
     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!(
index 6e4398f6834fafcc3fcb051b79daf80fcd7c06ee..de99d4b63dc2223a58daa749636ea9085a34404a 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, person_id: PersonId) -> Result<Self, Error> {
     person
       .filter(deleted.eq(false))
       .find(person_id)
       .first::<Self>(conn)
   }
-  fn delete(conn: &PgConnection, person_id: PersonId) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, person_id: PersonId) -> Result<usize, Error> {
     diesel::delete(person.find(person_id)).execute(conn)
   }
-  fn create(conn: &PgConnection, form: &PersonForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &PersonForm) -> Result<Self, Error> {
     insert_into(person).values(form).get_result::<Self>(conn)
   }
-  fn update(conn: &PgConnection, person_id: PersonId, form: &PersonForm) -> Result<Self, Error> {
+  fn update(
+    conn: &mut PgConnection,
+    person_id: PersonId,
+    form: &PersonForm,
+  ) -> Result<Self, Error> {
     diesel::update(person.find(person_id))
       .set(form)
       .get_result::<Self>(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<chrono::NaiveDateTime>,
@@ -202,19 +104,23 @@ impl Person {
       .get_result::<Self>(conn)
   }
 
-  pub fn add_admin(conn: &PgConnection, person_id: PersonId, added: bool) -> Result<Self, Error> {
+  pub fn add_admin(
+    conn: &mut PgConnection,
+    person_id: PersonId,
+    added: bool,
+  ) -> Result<Self, Error> {
     diesel::update(person.find(person_id))
       .set(admin.eq(added))
       .get_result::<Self>(conn)
   }
 
-  pub fn mark_as_updated(conn: &PgConnection, person_id: PersonId) -> Result<Person, Error> {
+  pub fn mark_as_updated(conn: &mut PgConnection, person_id: PersonId) -> Result<Person, Error> {
     diesel::update(person.find(person_id))
       .set((last_refreshed_at.eq(naive_now()),))
       .get_result::<Self>(conn)
   }
 
-  pub fn delete_account(conn: &PgConnection, person_id: PersonId) -> Result<Person, Error> {
+  pub fn delete_account(conn: &mut PgConnection, person_id: PersonId) -> Result<Person, Error> {
     use crate::schema::local_user;
 
     // Set the local user info to none
@@ -238,7 +144,7 @@ impl Person {
       .get_result::<Self>(conn)
   }
 
-  pub fn upsert(conn: &PgConnection, person_form: &PersonForm) -> Result<Person, Error> {
+  pub fn upsert(conn: &mut PgConnection, person_form: &PersonForm) -> Result<Person, Error> {
     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<Person, Error> {
@@ -258,13 +164,16 @@ impl Person {
       .get_result::<Self>(conn)
   }
 
-  pub fn leave_admin(conn: &PgConnection, person_id: PersonId) -> Result<Self, Error> {
+  pub fn leave_admin(conn: &mut PgConnection, person_id: PersonId) -> Result<Self, Error> {
     diesel::update(person.find(person_id))
       .set(admin.eq(false))
       .get_result::<Self>(conn)
   }
 
-  pub fn remove_avatar_and_banner(conn: &PgConnection, person_id: PersonId) -> Result<Self, Error> {
+  pub fn remove_avatar_and_banner(
+    conn: &mut PgConnection,
+    person_id: PersonId,
+  ) -> Result<Self, Error> {
     diesel::update(person.find(person_id))
       .set((
         avatar.eq::<Option<String>>(None),
@@ -283,7 +192,7 @@ pub fn is_banned(banned_: bool, expires: Option<chrono::NaiveDateTime>) -> bool
 }
 
 impl ApubActor for Person {
-  fn read_from_apub_id(conn: &PgConnection, object_id: &DbUrl) -> Result<Option<Self>, Error> {
+  fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result<Option<Self>, 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<Person, Error> {
@@ -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<Person, Error> {
@@ -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);
index d1b776805f8ae446d6af48c447cb916a6be2e264..6ee617d61cc7b4ab7ad9c866ea3dee7292c5d148 100644 (file)
@@ -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<Self, Error> {
@@ -21,7 +21,7 @@ impl PersonBlock {
 
 impl Blockable for PersonBlock {
   type Form = PersonBlockForm;
-  fn block(conn: &PgConnection, person_block_form: &PersonBlockForm) -> Result<Self, Error> {
+  fn block(conn: &mut PgConnection, person_block_form: &PersonBlockForm) -> Result<Self, Error> {
     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::<Self>(conn)
   }
-  fn unblock(conn: &PgConnection, person_block_form: &Self::Form) -> Result<usize, Error> {
+  fn unblock(conn: &mut PgConnection, person_block_form: &Self::Form) -> Result<usize, Error> {
     use crate::schema::person_block::dsl::*;
     diesel::delete(
       person_block
index 3ddcd664be26e282336ac413735ff4bbe6eb7846..fc91c76e5b3424a550f5a8f2e8ae8994ef86cbe0 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, person_mention_id: PersonMentionId) -> Result<Self, Error> {
     use crate::schema::person_mention::dsl::*;
     person_mention.find(person_mention_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, person_mention_form: &PersonMentionForm) -> Result<Self, Error> {
+  fn create(
+    conn: &mut PgConnection,
+    person_mention_form: &PersonMentionForm,
+  ) -> Result<Self, Error> {
     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<Self, Error> {
@@ -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<PersonMention, Error> {
@@ -50,7 +53,7 @@ impl PersonMention {
   }
 
   pub fn mark_all_as_read(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     for_recipient_id: PersonId,
   ) -> Result<Vec<PersonMention>, Error> {
     use crate::schema::person_mention::dsl::*;
@@ -63,7 +66,7 @@ impl PersonMention {
     .get_results::<Self>(conn)
   }
   pub fn read_by_comment_and_person(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     for_comment_id: CommentId,
     for_recipient_id: PersonId,
   ) -> Result<Self, Error> {
@@ -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);
index 07c652e3148265b32d117500803f3c29cf60351b..4fa60159294d4fcad67d5c5f9cc3edcf4610bfd5 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, post_id: PostId) -> Result<Self, Error> {
     use crate::schema::post::dsl::*;
     post.find(post_id).first::<Self>(conn)
   }
 
-  fn delete(conn: &PgConnection, post_id: PostId) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, post_id: PostId) -> Result<usize, Error> {
     use crate::schema::post::dsl::*;
     diesel::delete(post.find(post_id)).execute(conn)
   }
 
-  fn create(conn: &PgConnection, new_post: &PostForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, new_post: &PostForm) -> Result<Self, Error> {
     use crate::schema::post::dsl::*;
     insert_into(post).values(new_post).get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, post_id: PostId, new_post: &PostForm) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, post_id: PostId, new_post: &PostForm) -> Result<Self, Error> {
     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<Vec<Self>, Error> {
     use crate::schema::post::dsl::*;
@@ -58,7 +58,11 @@ impl Post {
       .load::<Self>(conn)
   }
 
-  pub fn update_ap_id(conn: &PgConnection, post_id: PostId, apub_id: DbUrl) -> Result<Self, Error> {
+  pub fn update_ap_id(
+    conn: &mut PgConnection,
+    post_id: PostId,
+    apub_id: DbUrl,
+  ) -> Result<Self, Error> {
     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<Vec<Self>, 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<Self, Error> {
@@ -98,7 +102,7 @@ impl Post {
   }
 
   pub fn update_removed(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     post_id: PostId,
     new_removed: bool,
   ) -> Result<Self, Error> {
@@ -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<CommunityId>,
     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<Self, Error> {
@@ -140,7 +144,7 @@ impl Post {
   }
 
   pub fn update_stickied(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     post_id: PostId,
     new_stickied: bool,
   ) -> Result<Self, Error> {
@@ -154,7 +158,7 @@ impl Post {
     person_id == post_creator_id
   }
 
-  pub fn upsert(conn: &PgConnection, post_form: &PostForm) -> Result<Post, Error> {
+  pub fn upsert(conn: &mut PgConnection, post_form: &PostForm) -> Result<Post, Error> {
     use crate::schema::post::dsl::*;
     insert_into(post)
       .values(post_form)
@@ -163,7 +167,7 @@ impl Post {
       .set(post_form)
       .get_result::<Self>(conn)
   }
-  pub fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, Error> {
+  pub fn read_from_apub_id(conn: &mut PgConnection, object_id: Url) -> Result<Option<Self>, 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<Vec<Self>, 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<Vec<Self>, 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<Vec<Self>, 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<Vec<Self>, 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<Self, Error> {
+  fn like(conn: &mut PgConnection, post_like_form: &PostLikeForm) -> Result<Self, Error> {
     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::<Self>(conn)
   }
-  fn remove(conn: &PgConnection, person_id: PersonId, post_id: PostId) -> Result<usize, Error> {
+  fn remove(conn: &mut PgConnection, person_id: PersonId, post_id: PostId) -> Result<usize, Error> {
     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<Self, Error> {
+  fn save(conn: &mut PgConnection, post_saved_form: &PostSavedForm) -> Result<Self, Error> {
     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::<Self>(conn)
   }
-  fn unsave(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<usize, Error> {
+  fn unsave(conn: &mut PgConnection, post_saved_form: &PostSavedForm) -> Result<usize, Error> {
     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<Self, Error> {
+  fn mark_as_read(conn: &mut PgConnection, post_read_form: &PostReadForm) -> Result<Self, Error> {
     use crate::schema::post_read::dsl::*;
     insert_into(post_read)
       .values(post_read_form)
@@ -298,7 +302,10 @@ impl Readable for PostRead {
       .get_result::<Self>(conn)
   }
 
-  fn mark_as_unread(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<usize, Error> {
+  fn mark_as_unread(
+    conn: &mut PgConnection,
+    post_read_form: &PostReadForm,
+  ) -> Result<usize, Error> {
     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);
index 58e2f44b0adb26f1ec07b962ce4c831702f1d357..f9a1eab200af82cbd9d92097034ee9b5cd1ecdae 100644 (file)
@@ -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<Self, Error> {
+  fn report(conn: &mut PgConnection, post_report_form: &PostReportForm) -> Result<Self, Error> {
     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<usize, Error> {
@@ -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<usize, Error> {
index b2407bdfab5759bfbf7fb4e2df1b359c853e2828..2ec1702eae418681aa3687a9e5df1cb029633bf1 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, private_message_id: PrivateMessageId) -> Result<Self, Error> {
     use crate::schema::private_message::dsl::*;
     private_message.find(private_message_id).first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, private_message_form: &PrivateMessageForm) -> Result<Self, Error> {
+  fn create(
+    conn: &mut PgConnection,
+    private_message_form: &PrivateMessageForm,
+  ) -> Result<Self, Error> {
     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<Self, Error> {
@@ -33,7 +36,7 @@ impl Crud for PrivateMessage {
       .set(private_message_form)
       .get_result::<Self>(conn)
   }
-  fn delete(conn: &PgConnection, pm_id: Self::IdType) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, pm_id: Self::IdType) -> Result<usize, Error> {
     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<PrivateMessage, Error> {
@@ -53,7 +56,7 @@ impl PrivateMessage {
   }
 
   pub fn update_content(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     private_message_id: PrivateMessageId,
     new_content: &str,
   ) -> Result<PrivateMessage, Error> {
@@ -64,7 +67,7 @@ impl PrivateMessage {
   }
 
   pub fn update_deleted(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     private_message_id: PrivateMessageId,
     new_deleted: bool,
   ) -> Result<PrivateMessage, Error> {
@@ -75,7 +78,7 @@ impl PrivateMessage {
   }
 
   pub fn update_read(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     private_message_id: PrivateMessageId,
     new_read: bool,
   ) -> Result<PrivateMessage, Error> {
@@ -86,7 +89,7 @@ impl PrivateMessage {
   }
 
   pub fn mark_all_as_read(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     for_recipient_id: PersonId,
   ) -> Result<Vec<PrivateMessage>, 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<PrivateMessage, Error> {
     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<Option<Self>, 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);
index 45ced6ce0c2aeca429f77c49066cc18838aac580..08fe4d28552fc3b80f05f0bb4faa3ac4dd0bb943 100644 (file)
@@ -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<Self, Error> {
+  fn report(
+    conn: &mut PgConnection,
+    pm_report_form: &PrivateMessageReportForm,
+  ) -> Result<Self, Error> {
     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<usize, Error> {
@@ -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<usize, Error> {
index 5147dbb7ab3a84a69ed61d1d5872d301e6bac215..6868a1da763091200f68a2f270e1599703bafb7c 100644 (file)
@@ -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<Self, Error> {
+  fn create(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error> {
     use crate::schema::registration_application::dsl::*;
     insert_into(registration_application)
       .values(form)
       .get_result::<Self>(conn)
   }
 
-  fn read(conn: &PgConnection, id_: Self::IdType) -> Result<Self, Error> {
+  fn read(conn: &mut PgConnection, id_: Self::IdType) -> Result<Self, Error> {
     use crate::schema::registration_application::dsl::*;
     registration_application.find(id_).first::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, id_: Self::IdType, form: &Self::Form) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, id_: Self::IdType, form: &Self::Form) -> Result<Self, Error> {
     use crate::schema::registration_application::dsl::*;
     diesel::update(registration_application.find(id_))
       .set(form)
       .get_result::<Self>(conn)
   }
 
-  fn delete(conn: &PgConnection, id_: Self::IdType) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, id_: Self::IdType) -> Result<usize, Error> {
     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<Self, Error> {
     use crate::schema::registration_application::dsl::*;
index 3fb9b32bd83f1ad71b26b2c57a18ae5bf2a5ef83..1f92ee24008b2d01131ea77122aa4339e5747c99 100644 (file)
@@ -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<Secret, Error> {
+  pub fn init(conn: &mut PgConnection) -> Result<Secret, Error> {
     read_secrets(conn)
   }
 }
 
-fn read_secrets(conn: &PgConnection) -> Result<Secret, Error> {
+fn read_secrets(conn: &mut PgConnection) -> Result<Secret, Error> {
   use crate::schema::secret::dsl::*;
   secret.first::<Secret>(conn)
 }
index 6c71f076ed1ab6665dc66c6c01f39901081f9da8..fb944f527ada47638b5148d589858fb07eeef74e 100644 (file)
@@ -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<Self, Error> {
+  fn read(conn: &mut PgConnection, _site_id: i32) -> Result<Self, Error> {
     use crate::schema::site::dsl::*;
     site.first::<Self>(conn)
   }
 
-  fn create(conn: &PgConnection, new_site: &SiteForm) -> Result<Self, Error> {
+  fn create(conn: &mut PgConnection, new_site: &SiteForm) -> Result<Self, Error> {
     use crate::schema::site::dsl::*;
     insert_into(site).values(new_site).get_result::<Self>(conn)
   }
 
-  fn update(conn: &PgConnection, site_id: i32, new_site: &SiteForm) -> Result<Self, Error> {
+  fn update(conn: &mut PgConnection, site_id: i32, new_site: &SiteForm) -> Result<Self, Error> {
     use crate::schema::site::dsl::*;
     diesel::update(site.find(site_id))
       .set(new_site)
       .get_result::<Self>(conn)
   }
-  fn delete(conn: &PgConnection, site_id: i32) -> Result<usize, Error> {
+  fn delete(conn: &mut PgConnection, site_id: i32) -> Result<usize, Error> {
     use crate::schema::site::dsl::*;
     diesel::delete(site.find(site_id)).execute(conn)
   }
 }
 
 impl Site {
-  pub fn read_local_site(conn: &PgConnection) -> Result<Self, Error> {
+  pub fn read_local_site(conn: &mut PgConnection) -> Result<Self, Error> {
     use crate::schema::site::dsl::*;
     site.order_by(id).first::<Self>(conn)
   }
 
-  pub fn upsert(conn: &PgConnection, site_form: &SiteForm) -> Result<Site, Error> {
+  pub fn upsert(conn: &mut PgConnection, site_form: &SiteForm) -> Result<Site, Error> {
     use crate::schema::site::dsl::*;
     insert_into(site)
       .values(site_form)
@@ -43,7 +43,7 @@ impl Site {
       .get_result::<Self>(conn)
   }
 
-  pub fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, Error> {
+  pub fn read_from_apub_id(conn: &mut PgConnection, object_id: Url) -> Result<Option<Self>, 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<Vec<Self>, Error> {
+  pub fn read_remote_sites(conn: &mut PgConnection) -> Result<Vec<Self>, Error> {
     use crate::schema::site::dsl::*;
     site.order_by(id).offset(1).get_results::<Self>(conn)
   }
index 901ff287aa4c3ed01630d55617f6123243586a5f..086c7029cee953b74f9ef1a57d5f2d4094c9fd31 100644 (file)
@@ -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,
index 4431103cced6a6775912b73d6363052553ec294f..5d23b12a88f842d83cfd6257fc67e67ca01dc8d3 100644 (file)
@@ -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)]
index 2d6ff6124e1a95d232d261664c733c9a11cfbc57..e0d7167e7bf1b53467bcf772947326902b9aacef 100644 (file)
@@ -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<Varchar>,
-        avatar -> Nullable<Varchar>,
-        banned -> Bool,
-        published -> Timestamp,
-        updated -> Nullable<Timestamp>,
-        actor_id -> Varchar,
-        bio -> Nullable<Text>,
-        local -> Bool,
-        private_key -> Nullable<Text>,
-        public_key -> Text,
-        last_refreshed_at -> Timestamp,
-        banner -> Nullable<Varchar>,
-        deleted -> Bool,
-        inbox_url -> Varchar,
-        shared_inbox_url -> Nullable<Varchar>,
-        matrix_user_id -> Nullable<Text>,
-        admin -> Bool,
-        bot_account -> Bool,
-        ban_expires -> Nullable<Timestamp>,
-    }
-}
-
-table! {
-    person_alias_2 (id) {
-        id -> Int4,
-        name -> Varchar,
-        display_name -> Nullable<Varchar>,
-        avatar -> Nullable<Varchar>,
-        banned -> Bool,
-        published -> Timestamp,
-        updated -> Nullable<Timestamp>,
-        actor_id -> Varchar,
-        bio -> Nullable<Text>,
-        local -> Bool,
-        private_key -> Nullable<Text>,
-        public_key -> Text,
-        last_refreshed_at -> Timestamp,
-        banner -> Nullable<Varchar>,
-        deleted -> Bool,
-        inbox_url -> Varchar,
-        shared_inbox_url -> Nullable<Varchar>,
-        matrix_user_id -> Nullable<Text>,
-        admin -> Bool,
-        bot_account -> Bool,
-        ban_expires -> Nullable<Timestamp>,
-    }
-}
-
 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,
index 5d09ebfd5893315a6c3eaa568ac90240d8a1aeba..2d256a5b3c894dfabae7cbbf99ebb920d4116717 100644 (file)
@@ -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<bool>,
index 81dba6e66719ec6adb818b30bd3e8d5deabbc1f2..d9117bae134270b4d2ed3f78a5b9bab6b66d207c 100644 (file)
@@ -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<LanguageId>,
 }
 
-#[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,
index 015a150b2d6a4298156c10fbbd51ed8fe95349c8..737d8df6a5aca9f7b34252eb9e47010f69fe1760 100644 (file)
@@ -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,
index 256895760c89edefdb1370c74e117add1e21e679..6cc328d0de29f4d4adf6ba2c4288aa4237a33e73 100644 (file)
@@ -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,
index 498869e960efb76aeefd00e11f3cbb4137828ba0..074141cc822727def2eb895fdc09ceea470ecc71 100644 (file)
@@ -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<bool>,
 }
 
-#[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<Option<chrono::NaiveDateTime>>,
 }
 
-#[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,
index d2c40a3369001dc38771b1b54f30962eb62567de..8011e9ee57f02f6b102e7fc73b393b4b3207af17 100644 (file)
@@ -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,
index 8d63670f2dc8354a869da39d4e901423bb3004b2..d541421f2fd4df1fe9963d3374134d945a0a97c1 100644 (file)
@@ -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,
index 042eba3bf3c596ff78aa22db1a3cf3b9b5eba385..3c52eb47bf7eea958212b61573bdb4222d1f8ddd 100644 (file)
@@ -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,
index 7c24d61bcea37a563b9c5a767daf3274f8901f95..4b3a3414484c24ccd400a261d7d2d417e4836e8f 100644 (file)
@@ -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<PersonId>,
   pub password_encrypted: Option<String>,
@@ -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,
index 64492ee37425609eaba82295c54d210192ad9be8..b6129d0ceb1e2c29a168b748fa5c04192f396751 100644 (file)
@@ -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,
index 7f13eaa9cce8fdcb7fb3fa13d7784a2b63e121ef..d234ed9902af87554f575e4c976c93ea380031e3 100644 (file)
@@ -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<bool>,
 }
 
-#[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<bool>,
 }
 
-#[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<bool>,
 }
 
-#[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<bool>,
 }
 
-#[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<chrono::NaiveDateTime>,
 }
 
-#[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<chrono::NaiveDateTime>,
 }
 
-#[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<bool>,
   pub reason: Option<String>,
 }
-#[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<chrono::NaiveDateTime>,
 }
 
-#[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<bool>,
 }
 
-#[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<bool>,
 }
 
-#[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<bool>,
 }
 
-#[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<String>,
 }
 
-#[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<String>,
 }
 
-#[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<String>,
 }
 
-#[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,
index 3df7fab0fbbd3e5f7c02cc359a2971a4ea8cbfb2..159b0b7e66fd04518dcda86e012ce2853258a363 100644 (file)
@@ -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,
index e4888ddbf576b5f689cbddfca596724524acf0b0..5d9d603de85d1d64b31bcaf70511304cb6744f8a 100644 (file)
@@ -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<chrono::NaiveDateTime>,
 }
 
-#[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<String>,
-  pub avatar: Option<DbUrl>,
-  pub banned: bool,
-  pub published: chrono::NaiveDateTime,
-  pub updated: Option<chrono::NaiveDateTime>,
-  pub actor_id: DbUrl,
-  pub bio: Option<String>,
-  pub local: bool,
-  pub private_key: Option<String>,
-  pub public_key: String,
-  pub last_refreshed_at: chrono::NaiveDateTime,
-  pub banner: Option<DbUrl>,
-  pub deleted: bool,
-  pub inbox_url: DbUrl,
-  pub shared_inbox_url: Option<DbUrl>,
-  pub matrix_user_id: Option<String>,
-  pub admin: bool,
-  pub bot_account: bool,
-  pub ban_expires: Option<chrono::NaiveDateTime>,
-}
-
-#[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<String>,
-  pub avatar: Option<DbUrl>,
-  pub banned: bool,
-  pub published: chrono::NaiveDateTime,
-  pub updated: Option<chrono::NaiveDateTime>,
-  pub actor_id: DbUrl,
-  pub bio: Option<String>,
-  pub local: bool,
-  pub banner: Option<DbUrl>,
-  pub deleted: bool,
-  pub inbox_url: DbUrl,
-  pub shared_inbox_url: Option<DbUrl>,
-  pub matrix_user_id: Option<String>,
-  pub admin: bool,
-  pub bot_account: bool,
-  pub ban_expires: Option<chrono::NaiveDateTime>,
-}
-
-#[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<String>,
-  pub avatar: Option<DbUrl>,
-  pub banned: bool,
-  pub published: chrono::NaiveDateTime,
-  pub updated: Option<chrono::NaiveDateTime>,
-  pub actor_id: DbUrl,
-  pub bio: Option<String>,
-  pub local: bool,
-  pub private_key: Option<String>,
-  pub public_key: String,
-  pub last_refreshed_at: chrono::NaiveDateTime,
-  pub banner: Option<DbUrl>,
-  pub deleted: bool,
-  pub inbox_url: DbUrl,
-  pub shared_inbox_url: Option<DbUrl>,
-  pub matrix_user_id: Option<String>,
-  pub admin: bool,
-  pub bot_account: bool,
-  pub ban_expires: Option<chrono::NaiveDateTime>,
-}
-
-#[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<String>,
-  pub avatar: Option<DbUrl>,
-  pub banned: bool,
-  pub published: chrono::NaiveDateTime,
-  pub updated: Option<chrono::NaiveDateTime>,
-  pub actor_id: DbUrl,
-  pub bio: Option<String>,
-  pub local: bool,
-  pub banner: Option<DbUrl>,
-  pub deleted: bool,
-  pub inbox_url: DbUrl,
-  pub shared_inbox_url: Option<DbUrl>,
-  pub matrix_user_id: Option<String>,
-  pub admin: bool,
-  pub bot_account: bool,
-  pub ban_expires: Option<chrono::NaiveDateTime>,
-}
-
 #[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<Option<String>>,
index 46920acbf77698bbe7ba4dc3ff6d8926362f1625..e5a365b51307a1b24b9f873b3b985536bb410630 100644 (file)
@@ -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,
index 5716cb8c8360585a1084f991b7699f3841f87605..a12563e5f20f49e342b9cba4008a4cc0ee5d0dd9 100644 (file)
@@ -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,
index 7e192a72aeecc4d32f6326a9193423ef9f9ee95f..e9f383fe5a6e58685471f0b366bff20e86466e7e 100644 (file)
@@ -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<LanguageId>,
 }
 
-#[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,
index afb3346984894354e5f6c729d9240d39820c6198..abee0f32f19b2c4e1277419ea48ea5635601e41d 100644 (file)
@@ -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,
index fa697a51fa11c3b907d9fa6d8b3ea4e33d4603c3..9b2cb342ace8f8cb8fb2ef7f38bb00a76660248d 100644 (file)
@@ -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,
index ba563aa75f0b27d63139714cdfc5e886fefa1e39..8cf3b0f00ccf9e397a71c76f708b6f84e8f579b5 100644 (file)
@@ -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,
index c874427af6f9211970ab569c6d7555cf440893bc..ecf4eb3e875d116381f80d6539ea7983d8dc26cd 100644 (file)
@@ -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<LocalUserId>,
   pub answer: Option<String>,
index d32a3ac73dc3dfb7fcb97175a8861a54a5645000..8b955ec59f5e99130667d45a7023ac70de98dba9 100644 (file)
@@ -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,
index 7975071c7b3d8fffb0a4280120b6e13c06173d72..82876d837200aa229e7e75384357f54259ab46c0 100644 (file)
@@ -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<Option<String>>,
index f2f6ae92e063363eafa297692712e7f6a39e64df..102d0c0b884516740351dd3aa7f289a7309c1e4c 100644 (file)
@@ -4,16 +4,16 @@ use diesel::{result::Error, PgConnection};
 pub trait Crud {
   type Form;
   type IdType;
-  fn create(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
+  fn create(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
-  fn read(conn: &PgConnection, id: Self::IdType) -> Result<Self, Error>
+  fn read(conn: &mut PgConnection, id: Self::IdType) -> Result<Self, Error>
   where
     Self: Sized;
-  fn update(conn: &PgConnection, id: Self::IdType, form: &Self::Form) -> Result<Self, Error>
+  fn update(conn: &mut PgConnection, id: Self::IdType, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
-  fn delete(_conn: &PgConnection, _id: Self::IdType) -> Result<usize, Error>
+  fn delete(_conn: &mut PgConnection, _id: Self::IdType) -> Result<usize, Error>
   where
     Self: Sized,
   {
@@ -23,28 +23,29 @@ pub trait Crud {
 
 pub trait Followable {
   type Form;
-  fn follow(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
+  fn follow(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
   fn follow_accepted(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     community_id: CommunityId,
     person_id: PersonId,
   ) -> Result<Self, Error>
   where
     Self: Sized;
-  fn unfollow(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
+  fn unfollow(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
   where
     Self: Sized;
-  fn has_local_followers(conn: &PgConnection, community_id: CommunityId) -> Result<bool, Error>;
+  fn has_local_followers(conn: &mut PgConnection, community_id: CommunityId)
+    -> Result<bool, Error>;
 }
 
 pub trait Joinable {
   type Form;
-  fn join(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
+  fn join(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
-  fn leave(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
+  fn leave(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
   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<Self, Error>
+  fn like(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
   fn remove(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     person_id: PersonId,
     item_id: Self::IdType,
   ) -> Result<usize, Error>
@@ -66,40 +67,40 @@ pub trait Likeable {
 
 pub trait Bannable {
   type Form;
-  fn ban(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
+  fn ban(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
-  fn unban(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
+  fn unban(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
   where
     Self: Sized;
 }
 
 pub trait Saveable {
   type Form;
-  fn save(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
+  fn save(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
-  fn unsave(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
+  fn unsave(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
   where
     Self: Sized;
 }
 
 pub trait Blockable {
   type Form;
-  fn block(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
+  fn block(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
-  fn unblock(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
+  fn unblock(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
   where
     Self: Sized;
 }
 
 pub trait Readable {
   type Form;
-  fn mark_as_read(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
+  fn mark_as_read(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
-  fn mark_as_unread(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
+  fn mark_as_unread(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
   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<Self, Error>
+  fn report(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
   where
     Self: Sized;
   fn resolve(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     report_id: Self::IdType,
     resolver_id: PersonId,
   ) -> Result<usize, Error>
   where
     Self: Sized;
   fn unresolve(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     report_id: Self::IdType,
     resolver_id: PersonId,
   ) -> Result<usize, Error>
@@ -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<Option<Self>, Error>
+  fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result<Option<Self>, 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<Self, Error>
   where
     Self: Sized;
   fn read_from_name_and_domain(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     actor_name: &str,
     protocol_domain: &str,
   ) -> Result<Self, Error>
index 93404da3ff23c2736ffa0a0d287f0cab6de380ec..798786b06d1cd829b6199f294debba952dcbdd63 100644 (file)
@@ -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<DB: Backend> ToSql<Text, DB> for DbUrl
-where
-  String: ToSql<Text, DB>,
-{
-  fn to_sql<W: Write>(&self, out: &mut Output<W, DB>) -> diesel::serialize::Result {
-    self.0.to_string().to_sql(out)
+impl ToSql<Text, Pg> for DbUrl {
+  fn to_sql(&self, out: &mut Output<Pg>) -> diesel::serialize::Result {
+    <std::string::String as ToSql<Text, Pg>>::to_sql(&self.0.to_string(), &mut out.reborrow())
   }
 }
 
@@ -159,8 +160,8 @@ impl<DB: Backend> FromSql<Text, DB> for DbUrl
 where
   String: FromSql<Text, DB>,
 {
-  fn from_sql(bytes: Option<&DB::RawValue>) -> diesel::deserialize::Result<Self> {
-    let str = String::from_sql(bytes)?;
+  fn from_sql(value: diesel::backend::RawValue<'_, DB>) -> diesel::deserialize::Result<Self> {
+    let str = String::from_sql(value)?;
     Ok(DbUrl(Url::parse(&str)?))
   }
 }
index 85448b2618f4fa2cde8ce58953fcce4f82219b58..3046c4e78229c9f18a86300a244a07e83c7f9c61 100644 (file)
@@ -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"
index 8c9c124d18fbfa8e45ef996ab1bf3e08dd35ca2b..50564b0ab72a7fd471842e01f905ba44b227f14c 100644 (file)
@@ -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<CommunityPersonBan>,
   Option<i16>,
-  Option<PersonSafeAlias2>,
+  Option<PersonSafe>,
 );
 
 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<Self, Error> {
+    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::<CommentReportViewTuple>(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<CommunityId>,
@@ -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<Vec<CommentReportView>, 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();
   }
 }
index 0efc4e11f17a0a0d86ec9b9ac9dc505582b63432..c3597dc25bcb410b11d4ac8fb6d03134549fb6fa 100644 (file)
@@ -49,7 +49,7 @@ type CommentViewTuple = (
 
 impl CommentView {
   pub fn read(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     comment_id: CommentId,
     my_person_id: Option<PersonId>,
   ) -> Result<Self, Error> {
@@ -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<ListingType>,
   sort: Option<CommentSortType>,
   community_id: Option<CommunityId>,
@@ -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,
index 5c88a2f58ecb41d990f7aea1c7e0d4f8db17a15f..0268de1c4297c05ab026337f88688058278c92fd 100644 (file)
@@ -14,7 +14,7 @@ type LocalUserDiscussionLanguageViewTuple = (LocalUserSettings, Language);
 
 impl LocalUserDiscussionLanguageView {
   pub fn read_languages(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     local_user_id: LocalUserId,
   ) -> Result<Vec<Language>, Error> {
     let res = local_user_language::table
index 12c26df6d0987f24d31662d116d50143f8f62096..0e6d24b1164d0139d54fb04be2c014fe2e33f200 100644 (file)
@@ -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<Self, Error> {
+  pub fn read(conn: &mut PgConnection, local_user_id: LocalUserId) -> Result<Self, Error> {
     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<Self, Error> {
+  pub fn read_person(conn: &mut PgConnection, person_id: PersonId) -> Result<Self, Error> {
     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<Self, Error> {
+  pub fn read_from_name(conn: &mut PgConnection, name: &str) -> Result<Self, Error> {
     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<Self, Error> {
+  pub fn find_by_email_or_name(
+    conn: &mut PgConnection,
+    name_or_email: &str,
+  ) -> Result<Self, Error> {
     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<Self, Error> {
+  pub fn find_by_email(conn: &mut PgConnection, from_email: &str) -> Result<Self, Error> {
     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<Self, Error> {
+  pub fn read(conn: &mut PgConnection, local_user_id: LocalUserId) -> Result<Self, Error> {
     let (local_user, person, counts) = local_user::table
       .find(local_user_id)
       .inner_join(person::table)
index 1a519fff5483c232cf5b2e83e8106a08826b37e1..472795b5049a5ab44dd8b4956b603132ae57b8cd 100644 (file)
@@ -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<CommunityPersonBan>,
   Option<i16>,
   PostAggregates,
-  Option<PersonSafeAlias2>,
+  Option<PersonSafe>,
 );
 
 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<Self, Error> {
+    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::<PostReportViewTuple>(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<CommunityId>,
@@ -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<Vec<PostReportView>, 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();
   }
 }
index f81194f160017e6694e344dd7cc97c9627260595..3a4c87f5ae2d1ddec7cf1cc8a181ff69346ee6f0 100644 (file)
@@ -50,7 +50,7 @@ type PostViewTuple = (
 
 impl PostView {
   pub fn read(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     post_id: PostId,
     my_person_id: Option<PersonId>,
   ) -> Result<Self, Error> {
@@ -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<ListingType>,
   sort: Option<SortType>,
   creator_id: Option<PersonId>,
@@ -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,
index c7b2f590884648fd9a66acbdd34e0944e42f2463..9a5976847bbe6c9183cf3f744b529f3b6a779cd9 100644 (file)
@@ -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<PersonSafeAlias2>,
+  PersonSafe,
+  Option<PersonSafe>,
 );
 
 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<Self, Error> {
+  pub fn read(conn: &mut PgConnection, report_id: PrivateMessageReportId) -> Result<Self, Error> {
+    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::<PrivateMessageReportViewTuple>(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<i64, Error> {
+  pub fn get_report_count(conn: &mut PgConnection) -> Result<i64, Error> {
     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<i64>,
   limit: Option<i64>,
   unresolved_only: Option<bool>,
@@ -81,22 +87,26 @@ pub struct PrivateMessageReportQuery<'a> {
 
 impl<'a> PrivateMessageReportQuery<'a> {
   pub fn list(self) -> Result<Vec<PrivateMessageReportView>, 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()
index 151c50aac0977b57ed78794c328ba7a4dc593c59..281df8ba6b358d95f54e6842648d5e6304819499 100644 (file)
@@ -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<Self, Error> {
+  pub fn read(
+    conn: &mut PgConnection,
+    private_message_id: PrivateMessageId,
+  ) -> Result<Self, Error> {
+    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::<PrivateMessageViewTuple>(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<i64, Error> {
+  pub fn get_unread_messages(
+    conn: &mut PgConnection,
+    my_person_id: PersonId,
+  ) -> Result<i64, Error> {
     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<bool>,
@@ -62,13 +72,17 @@ pub struct PrivateMessageQuery<'a> {
 
 impl<'a> PrivateMessageQuery<'a> {
   pub fn list(self) -> Result<Vec<PrivateMessageView>, 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();
 
index c4f040f4ab81e766db1c359a86808f9f45612cc5..b4c848293c5a99754c3d689e08739263a1910a87 100644 (file)
@@ -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<PersonSafeAlias1>,
+  Option<PersonSafe>,
 );
 
 impl RegistrationApplicationView {
-  pub fn read(conn: &PgConnection, registration_application_id: i32) -> Result<Self, Error> {
+  pub fn read(conn: &mut PgConnection, registration_application_id: i32) -> Result<Self, Error> {
+    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::<RegistrationApplicationViewTuple>(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<i64, Error> {
+  pub fn get_unread_count(
+    conn: &mut PgConnection,
+    verified_email_only: bool,
+  ) -> Result<i64, 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())),
       )
       .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<bool>,
   verified_email_only: Option<bool>,
   page: Option<i64>,
@@ -84,19 +93,23 @@ pub struct RegistrationApplicationQuery<'a> {
 
 impl<'a> RegistrationApplicationQuery<'a> {
   pub fn list(self) -> Result<Vec<RegistrationApplicationView>, 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();
   }
 }
index c630216f91ccb56e65447029a544da3a2ee535f8..03ee0d7d93ef89d8c68c34c392f6bd5f3437f564 100644 (file)
@@ -7,7 +7,7 @@ use lemmy_db_schema::{
 };
 
 impl SiteView {
-  pub fn read_local(conn: &PgConnection) -> Result<Self, Error> {
+  pub fn read_local(conn: &mut PgConnection) -> Result<Self, Error> {
     let (mut site, counts) = site::table
       .inner_join(site_aggregates::table)
       .select((site::all_columns, site_aggregates::all_columns))
index 1d509a1399fb7c6bb042fa92c25055e4f84758a6..83f1e122d38c3d7f988767bbc89c3d1f2650ce39 100644 (file)
@@ -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<i16>,                // Left join to CommentLike
-  pub resolver: Option<PersonSafeAlias2>,
+  pub resolver: Option<PersonSafe>,
 }
 
-#[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<i16>,
   pub counts: PostAggregates,
-  pub resolver: Option<PersonSafeAlias2>,
+  pub resolver: Option<PersonSafe>,
 }
 
-#[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<PersonSafeAlias2>,
+  pub creator: PersonSafe,
+  pub resolver: Option<PersonSafe>,
 }
 
-#[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<PersonSafeAlias1>,
+  pub admin: Option<PersonSafe>,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
index d64d1e197dcc8c2499fec10cea55fcc4eda592bf..e49990aea6d50179959cc68fffb4ad8c6f1742ea 100644 (file)
@@ -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"
index c8f9df9ce2b6aa4624899b1b64a64d87103cbade..39ba74ccb2e6dd50fe7b44c4a9671498b1cef057 100644 (file)
@@ -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<CommunityPersonBan>,
   Option<CommunityFollower>,
@@ -48,10 +47,12 @@ type CommentReplyViewTuple = (
 
 impl CommentReplyView {
   pub fn read(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     comment_reply_id: CommentReplyId,
     my_person_id: Option<PersonId>,
   ) -> Result<Self, Error> {
+    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<i64, Error> {
+  pub fn get_unread_replies(conn: &mut PgConnection, my_person_id: PersonId) -> Result<i64, Error> {
     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<PersonId>,
   recipient_id: Option<PersonId>,
   sort: Option<CommentSortType>,
@@ -178,6 +179,8 @@ impl<'a> CommentReplyQuery<'a> {
   pub fn list(self) -> Result<Vec<CommentReplyView>, 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(),
index 59d48ea2a2886dce47dfdbd6389763eba2570472..96204e7d9a2d3cb9bff9c0d004d938ae3fa97502 100644 (file)
@@ -13,7 +13,7 @@ use lemmy_db_schema::{
 type CommunityBlockViewTuple = (PersonSafe, CommunitySafe);
 
 impl CommunityBlockView {
-  pub fn for_person(conn: &PgConnection, person_id: PersonId) -> Result<Vec<Self>, Error> {
+  pub fn for_person(conn: &mut PgConnection, person_id: PersonId) -> Result<Vec<Self>, Error> {
     let res = community_block::table
       .inner_join(person::table)
       .inner_join(community::table)
index 6441536e232e8747f4d88a12c0f3e4cb3a31491d..fb8ae0233fe1e7eae28bc5ef1bb268d5b2e1bfdc 100644 (file)
@@ -13,7 +13,10 @@ use lemmy_db_schema::{
 type CommunityFollowerViewTuple = (CommunitySafe, PersonSafe);
 
 impl CommunityFollowerView {
-  pub fn for_community(conn: &PgConnection, community_id: CommunityId) -> Result<Vec<Self>, Error> {
+  pub fn for_community(
+    conn: &mut PgConnection,
+    community_id: CommunityId,
+  ) -> Result<Vec<Self>, 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<Vec<Self>, Error> {
+  pub fn for_person(conn: &mut PgConnection, person_id: PersonId) -> Result<Vec<Self>, Error> {
     let res = community_follower::table
       .inner_join(community::table)
       .inner_join(person::table)
index b2df95510ff37268ed57f2dba06e3d0bf7430e08..eeda7ed66e2611d6702a86c9b938cfe5a086a090 100644 (file)
@@ -13,7 +13,10 @@ use lemmy_db_schema::{
 type CommunityModeratorViewTuple = (CommunitySafe, PersonSafe);
 
 impl CommunityModeratorView {
-  pub fn for_community(conn: &PgConnection, community_id: CommunityId) -> Result<Vec<Self>, Error> {
+  pub fn for_community(
+    conn: &mut PgConnection,
+    community_id: CommunityId,
+  ) -> Result<Vec<Self>, 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<Vec<Self>, Error> {
+  pub fn for_person(conn: &mut PgConnection, person_id: PersonId) -> Result<Vec<Self>, 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<Vec<Self>, Error> {
+  pub fn get_community_first_mods(conn: &mut PgConnection) -> Result<Vec<Self>, Error> {
     let res = community_moderator::table
       .inner_join(community::table)
       .inner_join(person::table)
index 6d765e07caefe8cd6d2259507883ba2e9426fbe5..8672ad21e7fa1142d1d90a56f750cc04f9e2b0be 100644 (file)
@@ -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<Self, Error> {
index 0701ab430592c2e799f965b71218dfa84a5ba935..5a65b887b92a4e38bf3a13f5bf0245a1fc4e492e 100644 (file)
@@ -25,7 +25,7 @@ type CommunityViewTuple = (
 
 impl CommunityView {
   pub fn read(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     community_id: CommunityId,
     my_person_id: Option<PersonId>,
   ) -> Result<Self, Error> {
@@ -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<ListingType>,
   sort: Option<SortType>,
   local_user: Option<&'a LocalUser>,
index 19ff26337fa07089b2485f86cd53ba1017af2c43..90d56ccd7ba5615f8351b08b72eced64542fe18d 100644 (file)
@@ -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<Vec<Self>, Error> {
+  pub fn for_person(conn: &mut PgConnection, person_id: PersonId) -> Result<Vec<Self>, 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)
index 30136705122d929f1c0b02df0afe53289bcab17e..e4863db4281fdcd469e74346b8e9202cdd4a28ba 100644 (file)
@@ -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<CommunityPersonBan>,
   Option<CommunityFollower>,
@@ -48,10 +47,12 @@ type PersonMentionViewTuple = (
 
 impl PersonMentionView {
   pub fn read(
-    conn: &PgConnection,
+    conn: &mut PgConnection,
     person_mention_id: PersonMentionId,
     my_person_id: Option<PersonId>,
   ) -> Result<Self, Error> {
+    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<i64, Error> {
+  pub fn get_unread_mentions(
+    conn: &mut PgConnection,
+    my_person_id: PersonId,
+  ) -> Result<i64, Error> {
     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<PersonId>,
   recipient_id: Option<PersonId>,
   sort: Option<CommentSortType>,
@@ -178,6 +182,8 @@ impl<'a> PersonMentionQuery<'a> {
   pub fn list(self) -> Result<Vec<PersonMentionView>, 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(),
index 35044469b3839167ed42bcb296a29ff099827235..af0927a8519f0ae503ef1c180109ce4ffd57dae7 100644 (file)
@@ -14,7 +14,7 @@ use typed_builder::TypedBuilder;
 type PersonViewSafeTuple = (PersonSafe, PersonAggregates);
 
 impl PersonViewSafe {
-  pub fn read(conn: &PgConnection, person_id: PersonId) -> Result<Self, Error> {
+  pub fn read(conn: &mut PgConnection, person_id: PersonId) -> Result<Self, Error> {
     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<Vec<Self>, Error> {
+  pub fn admins(conn: &mut PgConnection) -> Result<Vec<Self>, 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<Vec<Self>, Error> {
+  pub fn banned(conn: &mut PgConnection) -> Result<Vec<Self>, 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<SortType>,
   search_term: Option<String>,
   page: Option<i64>,
index 43654c311d1352f6b363112af9e7d404d8d73202..91d40e9627ee916940158f74be99fb83fbb133c1 100644 (file)
@@ -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<i16>,                // 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
index b00752ad4e67900092edec7f002be6952aa3776d..e2823993ea9742525bc7266796d6fd4142818a33 100644 (file)
@@ -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"] }
index cd94a08548095aa40d2ade8544543ff66f8f7a18..035f86d16f79ff140f5835fba4369a016f6748d4 100644 (file)
@@ -15,7 +15,7 @@ use lemmy_db_schema::{
 type AdminPurgeCommentViewTuple = (AdminPurgeComment, Option<PersonSafe>, Post);
 
 impl AdminPurgeCommentView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
index 80528d00b6b4139a923777b4a68f74f7061277bb..fb582d6d200996bb82d3cd95423ded58a6e150b6 100644 (file)
@@ -14,7 +14,7 @@ use lemmy_db_schema::{
 type AdminPurgeCommunityViewTuple = (AdminPurgeCommunity, Option<PersonSafe>);
 
 impl AdminPurgeCommunityView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
index 84a33a53f84fa96cf397e02a2a67dd3de3854a90..023bcb3744b182603930b81978744fc2c4c7bceb 100644 (file)
@@ -14,7 +14,7 @@ use lemmy_db_schema::{
 type AdminPurgePersonViewTuple = (AdminPurgePerson, Option<PersonSafe>);
 
 impl AdminPurgePersonView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
index 9a7f73997b6bdca4f67b408168513d13919a7591..6a65c7a494b2eb30706fcb8b57a48d1cc6a3f275 100644 (file)
@@ -15,7 +15,7 @@ use lemmy_db_schema::{
 type AdminPurgePostViewTuple = (AdminPurgePost, Option<PersonSafe>, CommunitySafe);
 
 impl AdminPurgePostView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
index 4c4d8f8788e9035b15518de6fd748591871e2bdd..b7b9e93a8f7b679b41b6d86955ce93dd0a3cf56f 100644 (file)
@@ -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<PersonSafe>,
   CommunitySafe,
-  PersonSafeAlias1,
+  PersonSafe,
 );
 
 impl ModAddCommunityView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
@@ -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)?;
index fe9afea5ee4b051928ffd0ae04250ccf3587e121..e71552500cb7f0fc594d070c0d19b2e4d778f7fc 100644 (file)
@@ -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<PersonSafe>, PersonSafeAlias1);
+type ModAddViewTuple = (ModAdd, Option<PersonSafe>, PersonSafe);
 
 impl ModAddView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
@@ -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)?;
index 9c5cc7f7734e64ef706b73c4d3c8e3f1270f4eca..bf885dbc16f1db432b4404cab88f644d56f0e2fd 100644 (file)
@@ -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<PersonSafe>,
   CommunitySafe,
-  PersonSafeAlias1,
+  PersonSafe,
 );
 
 impl ModBanFromCommunityView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
@@ -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();
 
index 43e577a31ed44ff5b205a6b71fb5d02a0f910211..94bfbc8d5812156f61638e2ca76610fc094c057e 100644 (file)
@@ -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<PersonSafe>, PersonSafeAlias1);
+type ModBanViewTuple = (ModBan, Option<PersonSafe>, PersonSafe);
 
 impl ModBanView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
@@ -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)?;
index 24514a3df9937d5303baf75bcbea1d8734677ccd..0250d2e7f733054fe060151839b7288b91fc6cf0 100644 (file)
@@ -16,7 +16,7 @@ type ModHideCommunityViewTuple = (ModHideCommunity, Option<PersonSafe>, 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<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
index dad5c5b59ab5c66f3d942b1ca2778c75f1998132..6d88c5ae556a661a3da8c2fc70e819149eb00808 100644 (file)
@@ -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<PersonSafe>, Post, CommunitySafe);
 
 impl ModLockPostView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
@@ -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)?;
index 2ee230d112afe7a959f0ad4f64a574a015ffba23..c0b58845683c25e125ede8173946d7a274a7e53b 100644 (file)
@@ -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<PersonSafe>,
   Comment,
-  PersonSafeAlias1,
+  PersonSafe,
   Post,
   CommunitySafe,
 );
 
 impl ModRemoveCommentView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
@@ -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)?;
index ec462df9fa311ab68b6a82915b85e1eedd7d7874..ffd62d4512c7877cb52b7c85ba7ac2e0c08aad9a 100644 (file)
@@ -15,7 +15,7 @@ use lemmy_db_schema::{
 type ModRemoveCommunityTuple = (ModRemoveCommunity, Option<PersonSafe>, CommunitySafe);
 
 impl ModRemoveCommunityView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
index 497305ecedfee1f192a31619983d50b36d0c5de3..c1bc2e8f5f87de05ab1907ecdfe411ba65c7e79b 100644 (file)
@@ -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<PersonSafe>, Post, CommunitySafe);
 
 impl ModRemovePostView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
@@ -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)?;
index a47e1dc899af88e52b55ee89cf5d7bed5e9d0ef2..d802de696eab2a6ba745b47634d2fa370c0e82d6 100644 (file)
@@ -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<PersonSafe>, Post, CommunitySafe);
 
 impl ModStickyPostView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
@@ -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)?;
index bada7b39f5be9119ffb53cecf6c730d2b92936cb..bea839eb2cea0651e00fe7fe0b05132001d125c7 100644 (file)
@@ -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<PersonSafe>,
   CommunitySafe,
-  PersonSafeAlias1,
+  PersonSafe,
 );
 
 impl ModTransferCommunityView {
-  pub fn list(conn: &PgConnection, params: ModlogListParams) -> Result<Vec<Self>, Error> {
+  pub fn list(conn: &mut PgConnection, params: ModlogListParams) -> Result<Vec<Self>, 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::<diesel::sql_types::Bool>();
@@ -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)?;
index 4f6fbbd3ea0125c8d0c86f2ba95b574372e3236d..863de0704f9a7e9e68f08c018ac4fc1157577fd3 100644 (file)
@@ -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<PersonSafe>,
   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<PersonSafe>,
-  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<PersonSafe>,
   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<PersonSafe>,
-  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<PersonSafe>,
   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<PersonSafe>,
   pub community: CommunitySafe,
-  pub modded_person: PersonSafeAlias1,
+  pub modded_person: PersonSafe,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
index b6af9986d20946251652dfe5a0b91735597dbfb1..bda019d359e8fe771aea0ae1e832260853cf5e4f 100644 (file)
@@ -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"] }
index 592aeb2ddac08f844efbd2f350822039ef612bda..1943c280ee045c6c89641ea02da268e06ef9f994 100644 (file)
@@ -178,7 +178,7 @@ fn get_sort_type(info: web::Query<Params>) -> Result<SortType, ParseError> {
 
 #[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,
index d0fe8af9474a9349aab4ab4dd629c90ccaae6336..ff58c37781ff9e71a284348f8b29272215a9ad68 100644 (file)
@@ -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"
index 5cfa97176ace3a19ab41c8bf074825efe358187b..dba9b10601dff864c6586dfcc735ec79a18d7081 100644 (file)
@@ -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 (file)
index 0000000..39b439a
--- /dev/null
@@ -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 (file)
index 0000000..36eabec
--- /dev/null
@@ -0,0 +1,2 @@
+-- Drop the alias views
+drop view person_alias_1, person_alias_2;
index a41f46943b67303e9c65dbc591b6a8bfdce0792d..977e6808792bb6600b9c5cde7dffeaba192f7e2c 100644 (file)
@@ -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");
 
   {
index 07be683e9c574b71e40b53d16c53485d1b12c8f6..3c0bf3f0206e1f718d4719d4d5dfbe4b0f5fcd37 100644 (file)
@@ -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?;
index df54868fb5f8ce1e96a97a45b8621a32cf9a5935..108de672e45c708195f5849219722487ccc65038 100644 (file)
@@ -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)