]> Untitled Git - lemmy.git/commitdiff
Consolidate reqwest clients, use reqwest-middleware for tracing
authorAode (lion) <asonix@asonix.dog>
Mon, 6 Dec 2021 22:54:34 +0000 (16:54 -0600)
committerAode (lion) <asonix@asonix.dog>
Mon, 6 Dec 2021 22:54:34 +0000 (16:54 -0600)
45 files changed:
Cargo.lock
Cargo.toml
crates/api_crud/src/community/read.rs
crates/api_crud/src/user/read.rs
crates/apub/Cargo.toml
crates/apub/src/activities/comment/create_or_update.rs
crates/apub/src/activities/comment/mod.rs
crates/apub/src/activities/community/add_mod.rs
crates/apub/src/activities/community/block_user.rs
crates/apub/src/activities/community/mod.rs
crates/apub/src/activities/community/remove_mod.rs
crates/apub/src/activities/community/report.rs
crates/apub/src/activities/community/undo_block_user.rs
crates/apub/src/activities/community/update.rs
crates/apub/src/activities/deletion/delete.rs
crates/apub/src/activities/deletion/mod.rs
crates/apub/src/activities/following/accept.rs
crates/apub/src/activities/following/follow.rs
crates/apub/src/activities/following/undo_follow.rs
crates/apub/src/activities/mod.rs
crates/apub/src/activities/voting/undo_vote.rs
crates/apub/src/activities/voting/vote.rs
crates/apub/src/collections/community_moderators.rs
crates/apub/src/fetcher/search.rs
crates/apub/src/fetcher/webfinger.rs
crates/apub/src/http/community.rs
crates/apub/src/http/mod.rs
crates/apub/src/objects/comment.rs
crates/apub/src/objects/community.rs
crates/apub/src/objects/mod.rs
crates/apub/src/objects/person.rs
crates/apub/src/objects/post.rs
crates/apub/src/objects/private_message.rs
crates/apub/src/protocol/objects/note.rs
crates/apub/src/protocol/objects/page.rs
crates/apub_lib/Cargo.toml
crates/apub_lib/src/activity_queue.rs
crates/apub_lib/src/object_id.rs
crates/apub_lib/src/signatures.rs
crates/utils/Cargo.toml
crates/utils/src/request.rs
crates/websocket/Cargo.toml
crates/websocket/src/chat_server.rs
crates/websocket/src/lib.rs
src/main.rs

index 9485c57016b62838e292f7604f59d21d383008f8..c7c76b7e6e723d5eb4f9b39f4d905336dcee44c1 100644 (file)
@@ -4,10 +4,11 @@ version = 3
 
 [[package]]
 name = "activitystreams"
-version = "0.7.0-alpha.11"
+version = "0.7.0-alpha.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3a5da1d857ec9ca65ef8d0469cdd64e7b93b59d6cad26f1444bf84b62f3eadd4"
+checksum = "6bcc3fbb392890a1942b1e5cca76cba93c8ed24b5ff50004cc3289afaab3f92c"
 dependencies = [
+ "activitystreams-kinds",
  "chrono",
  "mime",
  "serde",
@@ -69,9 +70,9 @@ dependencies = [
 
 [[package]]
 name = "actix-http"
-version = "3.0.0-beta.13"
+version = "3.0.0-beta.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1bc3f9d97e32d75fae3ad7d955ac005eea3fd3ea60a89132768700911a60fd94"
+checksum = "055b723746f19534fc5c9a210788686542986d6f1b9cb2900a297bb4c6619f3b"
 dependencies = [
  "actix-codec",
  "actix-rt",
@@ -111,7 +112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6"
 dependencies = [
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -141,9 +142,9 @@ dependencies = [
 
 [[package]]
 name = "actix-server"
-version = "2.0.0-beta.9"
+version = "2.0.0-rc.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "411dd3296dd317ff5eff50baa13f31923ea40ec855dd7f2d3ed8639948f0195f"
+checksum = "78c9b22794b8af1c2e02434873ef858f2a7db40dbbf861ce77a04cd81ac6b767"
 dependencies = [
  "actix-rt",
  "actix-service",
@@ -151,7 +152,7 @@ dependencies = [
  "futures-core",
  "futures-util",
  "log",
- "mio",
+ "mio 0.8.0",
  "num_cpus",
  "socket2",
  "tokio",
@@ -170,9 +171,9 @@ dependencies = [
 
 [[package]]
 name = "actix-tls"
-version = "3.0.0-beta.9"
+version = "3.0.0-rc.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53d4739910b49c77ea88308a9fbfae544524b34884161527f9978c0102052da0"
+checksum = "4a78e066ef965e3501b0710f0722d0741e025b09e01f1af13afba0774efc2f40"
 dependencies = [
  "actix-codec",
  "actix-rt",
@@ -200,9 +201,9 @@ dependencies = [
 
 [[package]]
 name = "actix-web"
-version = "4.0.0-beta.12"
+version = "4.0.0-beta.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e87cfc4efaad42f8a054e269d1b85046397ff4e8707e49128dea3f99a512a9d6"
+checksum = "1657eb2ed5e8ef246b6e951bafb38644ca433042a65a44f02e5601083b71b895"
 dependencies = [
  "actix-codec",
  "actix-http",
@@ -229,7 +230,7 @@ dependencies = [
  "mime",
  "once_cell",
  "paste",
- "pin-project",
+ "pin-project-lite",
  "regex",
  "serde",
  "serde_json",
@@ -264,9 +265,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "dfe80a8828fa88a0420dc8fdd4c16b8207326c917f17701881b063eadc2a8d3b"
 dependencies = [
  "actix-router",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -275,9 +276,9 @@ version = "0.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -323,9 +324,9 @@ dependencies = [
 
 [[package]]
 name = "anyhow"
-version = "1.0.45"
+version = "1.0.51"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7"
+checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203"
 
 [[package]]
 name = "arrayvec"
@@ -358,9 +359,9 @@ version = "0.1.51"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -389,9 +390,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
 
 [[package]]
 name = "awc"
-version = "3.0.0-beta.11"
+version = "3.0.0-beta.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9f7d0c472987e454f41c3f4c7fa336ca139707ab255644b0480144c2060c800"
+checksum = "e9fef22345ed9fc111adf13c3b1e48473136a2669a73680b82d18d6e71e720fe"
 dependencies = [
  "actix-codec",
  "actix-http",
@@ -523,9 +524,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
 
 [[package]]
 name = "bitvec"
-version = "0.19.5"
+version = "0.19.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321"
+checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33"
 dependencies = [
  "funty",
  "radium",
@@ -776,9 +777,9 @@ dependencies = [
 
 [[package]]
 name = "crc32fast"
-version = "1.2.1"
+version = "1.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
+checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836"
 dependencies = [
  "cfg-if",
 ]
@@ -855,10 +856,10 @@ checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b"
 dependencies = [
  "fnv",
  "ident_case",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
  "strsim 0.9.3",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -869,10 +870,10 @@ checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3"
 dependencies = [
  "fnv",
  "ident_case",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
  "strsim 0.10.0",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -883,7 +884,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
 dependencies = [
  "darling_core 0.10.2",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -894,7 +895,7 @@ checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc"
 dependencies = [
  "darling_core 0.13.0",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -915,9 +916,9 @@ checksum = "a2658621297f2cf68762a6f7dc0bb7e1ff2cfd6583daef8ee0fed6f7ec468ec0"
 dependencies = [
  "darling 0.10.2",
  "derive_builder_core",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -927,22 +928,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2791ea3e372c8495c0bc2033991d76b512cd799d07491fbd6890124db9458bef"
 dependencies = [
  "darling 0.10.2",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
 name = "derive_more"
-version = "0.99.16"
+version = "0.99.17"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df"
+checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
 dependencies = [
  "convert_case",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "rustc_version 0.3.3",
- "syn 1.0.81",
+ "rustc_version 0.4.0",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -987,9 +988,9 @@ version = "1.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -1078,9 +1079,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "366b1ae88672638e08f97cc9037ce4e5dca6c2b37699a50c72b846a4c654d4bb"
 dependencies = [
  "darling 0.13.0",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -1207,9 +1208,9 @@ dependencies = [
 
 [[package]]
 name = "futures"
-version = "0.3.17"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca"
+checksum = "8cd0210d8c325c245ff06fd95a3b13689a1a276ac8cfa8e8720cb840bfb84b9e"
 dependencies = [
  "futures-channel",
  "futures-core",
@@ -1222,9 +1223,9 @@ dependencies = [
 
 [[package]]
 name = "futures-channel"
-version = "0.3.17"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888"
+checksum = "7fc8cd39e3dbf865f7340dce6a2d401d24fd37c6fe6c4f0ee0de8bfca2252d27"
 dependencies = [
  "futures-core",
  "futures-sink",
@@ -1232,15 +1233,15 @@ dependencies = [
 
 [[package]]
 name = "futures-core"
-version = "0.3.17"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d"
+checksum = "629316e42fe7c2a0b9a65b47d159ceaa5453ab14e8f0a3c5eedbb8cd55b4a445"
 
 [[package]]
 name = "futures-executor"
-version = "0.3.17"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c"
+checksum = "7b808bf53348a36cab739d7e04755909b9fcaaa69b7d7e588b37b6ec62704c97"
 dependencies = [
  "futures-core",
  "futures-task",
@@ -1249,42 +1250,39 @@ dependencies = [
 
 [[package]]
 name = "futures-io"
-version = "0.3.17"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377"
+checksum = "e481354db6b5c353246ccf6a728b0c5511d752c08da7260546fc0933869daa11"
 
 [[package]]
 name = "futures-macro"
-version = "0.3.17"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb"
+checksum = "a89f17b21645bc4ed773c69af9c9a0effd4a3f1a3876eadd453469f8854e7fdd"
 dependencies = [
- "autocfg 1.0.1",
- "proc-macro-hack",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
 name = "futures-sink"
-version = "0.3.17"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11"
+checksum = "996c6442437b62d21a32cd9906f9c41e7dc1e19a9579843fad948696769305af"
 
 [[package]]
 name = "futures-task"
-version = "0.3.17"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99"
+checksum = "dabf1872aaab32c886832f2276d2f5399887e2bd613698a02359e4ea83f8de12"
 
 [[package]]
 name = "futures-util"
-version = "0.3.17"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481"
+checksum = "41d22213122356472061ac0f1ab2cee28d2bac8491410fd68c2af53d1cedb83e"
 dependencies = [
- "autocfg 1.0.1",
  "futures-channel",
  "futures-core",
  "futures-io",
@@ -1294,8 +1292,6 @@ dependencies = [
  "memchr",
  "pin-project-lite",
  "pin-utils",
- "proc-macro-hack",
- "proc-macro-nested",
  "slab",
 ]
 
@@ -1456,9 +1452,9 @@ dependencies = [
  "log",
  "mac",
  "markup5ever 0.10.1",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -1516,9 +1512,9 @@ dependencies = [
 
 [[package]]
 name = "http-signature-normalization-reqwest"
-version = "0.2.0"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a1e24f3c8b2c8b5eddb82d4cdf07dafe01f5b87f92b81a369dd520a107d33e8"
+checksum = "faa064da2f51cd57c8b95492cbd647ca6a21486de7e6b707e776ab33be76aa31"
 dependencies = [
  "base64 0.13.0",
  "bytes",
@@ -1527,6 +1523,7 @@ dependencies = [
  "http",
  "http-signature-normalization",
  "reqwest",
+ "reqwest-middleware",
  "sha2",
  "thiserror",
  "tokio",
@@ -1859,6 +1856,7 @@ dependencies = [
  "percent-encoding",
  "rand 0.8.4",
  "reqwest",
+ "reqwest-middleware",
  "serde",
  "serde_json",
  "serde_with",
@@ -1892,6 +1890,7 @@ dependencies = [
  "once_cell",
  "openssl",
  "reqwest",
+ "reqwest-middleware",
  "serde",
  "serde_json",
  "sha2",
@@ -1903,9 +1902,9 @@ dependencies = [
 name = "lemmy_apub_lib_derive"
 version = "0.14.4-rc.4"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
  "trybuild",
 ]
 
@@ -2019,6 +2018,8 @@ dependencies = [
  "lemmy_websocket",
  "openssl",
  "reqwest",
+ "reqwest-middleware",
+ "reqwest-tracing",
  "serde",
  "serde_json",
  "strum",
@@ -2054,6 +2055,7 @@ dependencies = [
  "rand 0.8.4",
  "regex",
  "reqwest",
+ "reqwest-middleware",
  "serde",
  "serde_json",
  "smart-default",
@@ -2086,6 +2088,7 @@ dependencies = [
  "lemmy_utils",
  "rand 0.8.4",
  "reqwest",
+ "reqwest-middleware",
  "serde",
  "serde_json",
  "strum",
@@ -2129,9 +2132,9 @@ dependencies = [
 
 [[package]]
 name = "libc"
-version = "0.2.107"
+version = "0.2.109"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219"
+checksum = "f98a04dce437184842841303488f70d0188c5f51437d2a834dc097eafa909a01"
 
 [[package]]
 name = "local-channel"
@@ -2162,9 +2165,9 @@ dependencies = [
 
 [[package]]
 name = "lodepng"
-version = "3.4.6"
+version = "3.4.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e1f7ef1b146a329001ccc6ad5fc1def8300281dda5176e8336b7fd44e440fb96"
+checksum = "24844d5c0b922ddd52fb5bf0964a4c7f8e799a946ec01bb463771eb04fc1a323"
 dependencies = [
  "fallible_collections",
  "flate2",
@@ -2264,9 +2267,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
 
 [[package]]
 name = "memoffset"
-version = "0.6.4"
+version = "0.6.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9"
+checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
 dependencies = [
  "autocfg 1.0.1",
 ]
@@ -2287,9 +2290,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c"
 dependencies = [
  "migrations_internals",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -2298,6 +2301,16 @@ version = "0.3.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
 
+[[package]]
+name = "mime_guess"
+version = "2.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
+dependencies = [
+ "mime",
+ "unicase",
+]
+
 [[package]]
 name = "minimal-lexical"
 version = "0.2.1"
@@ -2336,6 +2349,19 @@ dependencies = [
  "winapi",
 ]
 
+[[package]]
+name = "mio"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2"
+dependencies = [
+ "libc",
+ "log",
+ "miow",
+ "ntapi",
+ "winapi",
+]
+
 [[package]]
 name = "miow"
 version = "0.3.7"
@@ -2590,9 +2616,9 @@ checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
 dependencies = [
  "pest",
  "pest_meta",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -2697,9 +2723,9 @@ version = "1.0.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -2759,12 +2785,6 @@ version = "0.5.19"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
 
-[[package]]
-name = "proc-macro-nested"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
-
 [[package]]
 name = "proc-macro2"
 version = "0.4.30"
@@ -2776,9 +2796,9 @@ dependencies = [
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.32"
+version = "1.0.33"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
+checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a"
 dependencies = [
  "unicode-xid 0.2.2",
 ]
@@ -2808,14 +2828,14 @@ version = "1.0.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
 ]
 
 [[package]]
 name = "quoted_printable"
-version = "0.4.3"
+version = "0.4.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1238256b09923649ec89b08104c4dfe9f6cb2fea734a5db5384e44916d59e9c5"
+checksum = "3fee2dce59f7a43418e3382c766554c614e06a552d53a8f07ef499ea4b332c0f"
 
 [[package]]
 name = "r2d2"
@@ -3121,9 +3141,9 @@ dependencies = [
 
 [[package]]
 name = "reqwest"
-version = "0.11.6"
+version = "0.11.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "66d2927ca2f685faf0fc620ac4834690d29e7abb153add10f5812eef20b5e280"
+checksum = "07bea77bc708afa10e59905c3d4af7c8fd43c9214251673095ff8b14345fcbc5"
 dependencies = [
  "base64 0.13.0",
  "bytes",
@@ -3139,6 +3159,7 @@ dependencies = [
  "lazy_static",
  "log",
  "mime",
+ "mime_guess",
  "native-tls",
  "percent-encoding",
  "pin-project-lite",
@@ -3154,6 +3175,36 @@ dependencies = [
  "winreg",
 ]
 
+[[package]]
+name = "reqwest-middleware"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4eb4bd0c419665f9266097de27649a7723140acd100f2676245e0461278ca97a"
+dependencies = [
+ "anyhow",
+ "async-trait",
+ "futures",
+ "http",
+ "reqwest",
+ "serde",
+ "task-local-extensions",
+ "thiserror",
+]
+
+[[package]]
+name = "reqwest-tracing"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89af431b8c46776b5071a9a739c2b5fadbed6be2c6158d1ac5f71c4da3d2261c"
+dependencies = [
+ "async-trait",
+ "reqwest",
+ "reqwest-middleware",
+ "task-local-extensions",
+ "tokio",
+ "tracing",
+]
+
 [[package]]
 name = "rgb"
 version = "0.8.29"
@@ -3200,18 +3251,18 @@ dependencies = [
 
 [[package]]
 name = "rustc_version"
-version = "0.3.3"
+version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee"
+checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
 dependencies = [
- "semver 0.11.0",
+ "semver 1.0.4",
 ]
 
 [[package]]
 name = "rustls"
-version = "0.20.1"
+version = "0.20.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dac4581f0fc0e0efd529d069e8189ec7b90b8e7680e21beb35141bdc45f36040"
+checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84"
 dependencies = [
  "log",
  "ring",
@@ -3221,15 +3272,15 @@ dependencies = [
 
 [[package]]
 name = "rustversion"
-version = "1.0.5"
+version = "1.0.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088"
+checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f"
 
 [[package]]
 name = "ryu"
-version = "1.0.5"
+version = "1.0.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
+checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568"
 
 [[package]]
 name = "same-file"
@@ -3321,17 +3372,14 @@ version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
 dependencies = [
- "semver-parser 0.7.0",
+ "semver-parser",
 ]
 
 [[package]]
 name = "semver"
-version = "0.11.0"
+version = "1.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
-dependencies = [
- "semver-parser 0.10.2",
-]
+checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012"
 
 [[package]]
 name = "semver-parser"
@@ -3339,15 +3387,6 @@ version = "0.7.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
 
-[[package]]
-name = "semver-parser"
-version = "0.10.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7"
-dependencies = [
- "pest",
-]
-
 [[package]]
 name = "serde"
 version = "1.0.130"
@@ -3363,16 +3402,16 @@ version = "1.0.130"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
 name = "serde_json"
-version = "1.0.70"
+version = "1.0.72"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e277c495ac6cd1a01a58d0a0c574568b4d1ddf14f59965c6a58b8d96400b54f3"
+checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527"
 dependencies = [
  "indexmap",
  "itoa",
@@ -3410,9 +3449,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "12e47be9471c72889ebafb5e14d5ff930d89ae7a67bbdb5f8abb564f845a927e"
 dependencies = [
  "darling 0.13.0",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -3432,9 +3471,9 @@ version = "0.5.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -3546,9 +3585,9 @@ version = "0.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -3602,11 +3641,11 @@ version = "0.5.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
  "serde",
  "serde_derive",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -3616,13 +3655,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
 dependencies = [
  "base-x",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
  "serde",
  "serde_derive",
  "serde_json",
  "sha1",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -3668,7 +3707,7 @@ checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6"
 dependencies = [
  "phf_generator 0.7.24",
  "phf_shared 0.7.24",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
  "string_cache_shared",
 ]
@@ -3681,7 +3720,7 @@ checksum = "f24c8e5e19d22a726626f1a5e16fe15b132dcf21d10177fa5a45ce7962996b97"
 dependencies = [
  "phf_generator 0.8.0",
  "phf_shared 0.8.0",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
 ]
 
@@ -3716,9 +3755,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec"
 dependencies = [
  "heck",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -3745,11 +3784,11 @@ dependencies = [
 
 [[package]]
 name = "syn"
-version = "1.0.81"
+version = "1.0.82"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966"
+checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
  "unicode-xid 0.2.2",
 ]
@@ -3760,6 +3799,15 @@ version = "1.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
 
+[[package]]
+name = "task-local-extensions"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36794203e10c86e5998179e260869d156e0674f02d5451b4a3fb9fd86d02aaab"
+dependencies = [
+ "tokio",
+]
+
 [[package]]
 name = "tempfile"
 version = "3.2.0"
@@ -3809,9 +3857,9 @@ version = "1.0.30"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -3887,10 +3935,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f"
 dependencies = [
  "proc-macro-hack",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
  "standback",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -3918,7 +3966,7 @@ dependencies = [
  "bytes",
  "libc",
  "memchr",
- "mio",
+ "mio 0.7.14",
  "once_cell",
  "parking_lot",
  "pin-project-lite",
@@ -3933,9 +3981,9 @@ version = "1.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -4002,9 +4050,9 @@ dependencies = [
 
 [[package]]
 name = "tracing-actix-web"
-version = "0.5.0-beta.3"
+version = "0.5.0-beta.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "994e4a59135823bdca121a8d086e3fcc71741c8677b47fa95a6afdd15e8f646f"
+checksum = "a90ef8ed903a84ce2c0cf35bd2896e55e22eaa5e2b49c4f16167f4615bb204ac"
 dependencies = [
  "actix-web",
  "pin-project",
@@ -4019,9 +4067,9 @@ version = "0.1.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
 ]
 
 [[package]]
@@ -4066,9 +4114,9 @@ dependencies = [
 
 [[package]]
 name = "tracing-subscriber"
-version = "0.3.2"
+version = "0.3.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7507ec620f809cdf07cccb5bc57b13069a88031b795efd4079b1c71b66c1613d"
+checksum = "245da694cc7fc4729f3f418b304cb57789f1bed2a78c575407ab8a23f53cb4d3"
 dependencies = [
  "ansi_term",
  "lazy_static",
@@ -4090,9 +4138,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
 
 [[package]]
 name = "trybuild"
-version = "1.0.52"
+version = "1.0.53"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "150e726dc059e6fbd4fce3288f5bb3cf70128cf63b0dde23b938a3cad810fb23"
+checksum = "9d664de8ea7e531ad4c0f5a834f20b8cb2b8e6dfe88d05796ee7887518ed67b9"
 dependencies = [
  "dissimilar",
  "glob",
@@ -4137,6 +4185,15 @@ version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c"
 
+[[package]]
+name = "unicase"
+version = "2.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
+dependencies = [
+ "version_check",
+]
+
 [[package]]
 name = "unicode-bidi"
 version = "0.3.7"
@@ -4275,9 +4332,9 @@ dependencies = [
  "bumpalo",
  "lazy_static",
  "log",
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
  "wasm-bindgen-shared",
 ]
 
@@ -4309,9 +4366,9 @@ version = "0.2.78"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab"
 dependencies = [
- "proc-macro2 1.0.32",
+ "proc-macro2 1.0.33",
  "quote 1.0.10",
- "syn 1.0.81",
+ "syn 1.0.82",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
index 040a25cf354472f10d6d5f1099ae7443e5115760..339c8265d36def6b6767d188eaecce54a93b30a2 100644 (file)
@@ -61,6 +61,8 @@ http-signature-normalization-actix = { version = "0.5.0-beta.10", default-featur
 tokio = { version = "1.12.0", features = ["sync"] }
 anyhow = "1.0.44"
 reqwest = { version = "0.11.4", features = ["json"] }
+reqwest-middleware = "0.1.2"
+reqwest-tracing = "0.2.0"
 activitystreams = "0.7.0-alpha.11"
 actix-rt = { version = "2.2.0", default-features = false }
 serde_json = { version = "1.0.68", features = ["preserve_order"] }
index 7a6d435427946908ba2d381df6bf64f11af5fa0b..32ccf73d036a01f6044a0868eb74e918380a2ed3 100644 (file)
@@ -45,7 +45,7 @@ impl PerformCrud for GetCommunity {
             .await?;
 
         ObjectId::<ApubCommunity>::new(community_actor_id)
-          .dereference(context, &mut 0)
+          .dereference(context, context.client(), &mut 0)
           .await
           .map_err(LemmyError::from)
           .map_err(|e| e.with_message("couldnt_find_community"))?
index b63d95c83f807f3797146cb0f4cbe917d4b75a7b..20864ab6c338240a76ade4264d44f52277875c63 100644 (file)
@@ -52,7 +52,7 @@ impl PerformCrud for GetPersonDetails {
           webfinger_resolve::<ApubPerson>(&name, EndpointType::Person, context, &mut 0).await?;
 
         let person = ObjectId::<ApubPerson>::new(actor_id)
-          .dereference(context, &mut 0)
+          .dereference(context, context.client(), &mut 0)
           .await;
         person
           .map_err(LemmyError::from)
index fb4e5f100452ee2ff35965447906d4143f0138ca..47da38d601bb8fadce7fee60869f8d8f256b9b86 100644 (file)
@@ -55,3 +55,4 @@ once_cell = "1.8.0"
 [dev-dependencies]
 serial_test = "0.5.1"
 assert-json-diff = "2.0.1"
+reqwest-middleware = "0.1.2"
index 3b1ee3932cc87d0f97cd5d0b97e4dac1f0e24e34..b0894ab1a4d3cf04e6cf35236b48c1e59a795ec8 100644 (file)
@@ -71,7 +71,9 @@ impl CreateOrUpdateComment {
       .collect();
     let mut inboxes = vec![];
     for t in tagged_users {
-      let person = t.dereference(context, request_counter).await?;
+      let person = t
+        .dereference(context, context.client(), request_counter)
+        .await?;
       inboxes.push(person.shared_inbox_or_inbox_url());
     }
 
index 29c2495260ffc475c82160c8e5bebee1696ce665..e26bdc06ad933f40df9621c84d44a9ed1936d573 100644 (file)
@@ -21,7 +21,9 @@ async fn get_notif_recipients(
 ) -> Result<Vec<LocalUserId>, LemmyError> {
   let post_id = comment.post_id;
   let post = blocking(context.pool(), move |conn| Post::read(conn, post_id)).await??;
-  let actor = actor.dereference(context, request_counter).await?;
+  let actor = actor
+    .dereference(context, context.client(), request_counter)
+    .await?;
 
   // Note:
   // Although mentions could be gotten from the post tags (they are included there), or the ccs,
index 3daedaa2e5f955df63b72a90bc0c5e1ebef51e27..4fba5ccc063b8c085e00343e6c322f58a1d1501d 100644 (file)
@@ -86,7 +86,10 @@ impl ActivityHandler for AddMod {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     let community = self.get_community(context, request_counter).await?;
-    let new_mod = self.object.dereference(context, request_counter).await?;
+    let new_mod = self
+      .object
+      .dereference(context, context.client(), request_counter)
+      .await?;
 
     // If we had to refetch the community while parsing the activity, then the new mod has already
     // been added. Skip it here as it would result in a duplicate key error.
index 140b9a869846a6c11324b19a16b27238a49762c7..cff72c5c8c682a5a06c5c6a570c80eb1404ad9c4 100644 (file)
@@ -93,7 +93,10 @@ impl ActivityHandler for BlockUserFromCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     let community = self.get_community(context, request_counter).await?;
-    let blocked_user = self.object.dereference(context, request_counter).await?;
+    let blocked_user = self
+      .object
+      .dereference(context, context.client(), request_counter)
+      .await?;
 
     let community_user_ban_form = CommunityPersonBanForm {
       community_id: community.id,
@@ -129,6 +132,9 @@ impl GetCommunity for BlockUserFromCommunity {
     context: &LemmyContext,
     request_counter: &mut i32,
   ) -> Result<ApubCommunity, LemmyError> {
-    self.target.dereference(context, request_counter).await
+    self
+      .target
+      .dereference(context, context.client(), request_counter)
+      .await
   }
 }
index 5961fa0478660350f37c0b7ba1287ed6c08a011c..670b9a7b027160cf596970f9824561480e8fc548 100644 (file)
@@ -44,6 +44,6 @@ async fn get_community_from_moderators_url(
 ) -> Result<ApubCommunity, LemmyError> {
   let community_id = Url::parse(&moderators.to_string().replace("/moderators", ""))?;
   ObjectId::new(community_id)
-    .dereference(context, request_counter)
+    .dereference(context, context.client(), request_counter)
     .await
 }
index b6a565f1f72bd744e2d0603e44bec8ac1b7f99a5..448aa23d21e6f0ed6d4e5a2060a478d8286153d8 100644 (file)
@@ -86,7 +86,10 @@ impl ActivityHandler for RemoveMod {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     let community = self.get_community(context, request_counter).await?;
-    let remove_mod = self.object.dereference(context, request_counter).await?;
+    let remove_mod = self
+      .object
+      .dereference(context, context.client(), request_counter)
+      .await?;
 
     let form = CommunityModeratorForm {
       community_id: community.id,
index 35a4266795123d29b482bd973de677a234663728..5ebbd9d7de7ad20b49a98eb8fcaeb0639e29396b 100644 (file)
@@ -74,7 +74,9 @@ impl ActivityHandler for Report {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     verify_activity(&self.id, self.actor.inner(), &context.settings())?;
-    let community = self.to[0].dereference(context, request_counter).await?;
+    let community = self.to[0]
+      .dereference(context, context.client(), request_counter)
+      .await?;
     verify_person_in_community(&self.actor, &community, context, request_counter).await?;
     Ok(())
   }
@@ -85,8 +87,15 @@ impl ActivityHandler for Report {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
-    let actor = self.actor.dereference(context, request_counter).await?;
-    match self.object.dereference(context, request_counter).await? {
+    let actor = self
+      .actor
+      .dereference(context, context.client(), request_counter)
+      .await?;
+    match self
+      .object
+      .dereference(context, context.client(), request_counter)
+      .await?
+    {
       PostOrComment::Post(post) => {
         let report_form = PostReportForm {
           creator_id: actor.id,
index 2a7a2b15088b652e1761507dafcbef7f5a891d22..8add53b6ae25efc73e0d9bdd87c93e21d5705f07 100644 (file)
@@ -87,7 +87,7 @@ impl ActivityHandler for UndoBlockUserFromCommunity {
     let blocked_user = self
       .object
       .object
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
       .await?;
 
     let community_user_ban_form = CommunityPersonBanForm {
index e1c39241cb93ec19ca4ae83a53c6e9d3edccff8c..cddc2e25d34fef0e45a1d09fbdce6fcd8163c2fb 100644 (file)
@@ -121,6 +121,8 @@ impl GetCommunity for UpdateCommunity {
     request_counter: &mut i32,
   ) -> Result<ApubCommunity, LemmyError> {
     let cid = ObjectId::new(self.object.id.clone());
-    cid.dereference(context, request_counter).await
+    cid
+      .dereference(context, context.client(), request_counter)
+      .await
   }
 }
index 9f53a8bfccc2255a50dbf2d6d7282d6430478540..774582b1683ed04d4d5c3bb4f7d732ea1a12b42b 100644 (file)
@@ -139,7 +139,9 @@ pub(in crate::activities) async fn receive_remove_action(
   context: &LemmyContext,
   request_counter: &mut i32,
 ) -> Result<(), LemmyError> {
-  let actor = actor.dereference(context, request_counter).await?;
+  let actor = actor
+    .dereference(context, context.client(), request_counter)
+    .await?;
   use UserOperationCrud::*;
   match DeletableObjects::read_from_db(object, context).await? {
     DeletableObjects::Community(community) => {
index a9c72a3a4758444a8036444d3458733c9990d88e..419469c95ca27a64c6e5a4fa4cbcefa8e43d045d 100644 (file)
@@ -165,7 +165,9 @@ async fn receive_delete_action(
   match DeletableObjects::read_from_db(object, context).await? {
     DeletableObjects::Community(community) => {
       if community.local {
-        let mod_ = actor.dereference(context, request_counter).await?;
+        let mod_ = actor
+          .dereference(context, context.client(), request_counter)
+          .await?;
         let object = DeletableObjects::Community(community.clone());
         send_apub_delete(&mod_, &community.clone(), object, true, context).await?;
       }
index a45dcf3c5f7558919946e9b6201a0bd8bb590d75..690bec28f918bb7638cfa0309425fe9b99f1cd17 100644 (file)
@@ -25,7 +25,7 @@ impl AcceptFollowCommunity {
     let person = follow
       .actor
       .clone()
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
       .await?;
     let accept = AcceptFollowCommunity {
       actor: ObjectId::new(community.actor_id()),
@@ -65,11 +65,14 @@ impl ActivityHandler for AcceptFollowCommunity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
-    let person = self.actor.dereference(context, request_counter).await?;
+    let person = self
+      .actor
+      .dereference(context, context.client(), request_counter)
+      .await?;
     let community = self
       .object
       .actor
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
       .await?;
     // This will throw an error if no follow was requested
     blocking(context.pool(), move |conn| {
index 877df61f38bc447bdacc92a30bef736909f821f6..fb35b0d3239335a8f778bed85c404dd6577cbff6 100644 (file)
@@ -75,7 +75,10 @@ impl ActivityHandler for FollowCommunity {
   ) -> Result<(), LemmyError> {
     verify_activity(&self.id, self.actor.inner(), &context.settings())?;
     verify_person(&self.actor, context, request_counter).await?;
-    let community = self.object.dereference(context, request_counter).await?;
+    let community = self
+      .object
+      .dereference(context, context.client(), request_counter)
+      .await?;
     verify_person_in_community(&self.actor, &community, context, request_counter).await?;
     Ok(())
   }
@@ -86,8 +89,14 @@ impl ActivityHandler for FollowCommunity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
-    let person = self.actor.dereference(context, request_counter).await?;
-    let community = self.object.dereference(context, request_counter).await?;
+    let person = self
+      .actor
+      .dereference(context, context.client(), request_counter)
+      .await?;
+    let community = self
+      .object
+      .dereference(context, context.client(), request_counter)
+      .await?;
     let community_follower_form = CommunityFollowerForm {
       community_id: community.id,
       person_id: person.id,
index 8644cbc50e46b2ed20c3ad7487dbfc4b91d7edb9..73b0366bc2867c41de511e1d17e69f70e10eb221 100644 (file)
@@ -64,11 +64,14 @@ impl ActivityHandler for UndoFollowCommunity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
-    let person = self.actor.dereference(context, request_counter).await?;
+    let person = self
+      .actor
+      .dereference(context, context.client(), request_counter)
+      .await?;
     let community = self
       .object
       .object
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
       .await?;
 
     let community_follower_form = CommunityFollowerForm {
index 8a4c4ffe2f7559371c3d6ee713f059943f1676fa..e09d69255ab0d40eb7c1a63eb53f9f02eb10e23e 100644 (file)
@@ -41,7 +41,9 @@ async fn verify_person(
   context: &LemmyContext,
   request_counter: &mut i32,
 ) -> Result<(), LemmyError> {
-  let person = person_id.dereference(context, request_counter).await?;
+  let person = person_id
+    .dereference(context, context.client(), request_counter)
+    .await?;
   if person.banned {
     let error = LemmyError::from(anyhow::anyhow!("Person {} is banned", person_id));
     return Err(error.with_message("banned"));
@@ -58,7 +60,9 @@ pub(crate) async fn verify_person_in_community(
   context: &LemmyContext,
   request_counter: &mut i32,
 ) -> Result<(), LemmyError> {
-  let person = person_id.dereference(context, request_counter).await?;
+  let person = person_id
+    .dereference(context, context.client(), request_counter)
+    .await?;
   if person.banned {
     return Err(LemmyError::from_message("Person is banned from site"));
   }
@@ -90,7 +94,9 @@ pub(crate) async fn verify_mod_action(
   request_counter: &mut i32,
 ) -> Result<(), LemmyError> {
   if community.local {
-    let actor = actor_id.dereference(context, request_counter).await?;
+    let actor = actor_id
+      .dereference(context, context.client(), request_counter)
+      .await?;
 
     // Note: this will also return true for admins in addition to mods, but as we dont know about
     //       remote admins, it doesnt make any difference.
index 3e8403916f30066b9658a2a8408d6e6761de754b..3606756a3eb1dfba0ea692df659c172cb15ef061 100644 (file)
@@ -86,11 +86,14 @@ impl ActivityHandler for UndoVote {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
-    let actor = self.actor.dereference(context, request_counter).await?;
+    let actor = self
+      .actor
+      .dereference(context, context.client(), request_counter)
+      .await?;
     let object = self
       .object
       .object
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
       .await?;
     match object {
       PostOrComment::Post(p) => undo_vote_post(actor, &p, context).await,
index 283b04359026dd583f254f6505392ab370416436..789a4c67d2345de97e18c0bdf4ce2785d71901af 100644 (file)
@@ -90,8 +90,14 @@ impl ActivityHandler for Vote {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
-    let actor = self.actor.dereference(context, request_counter).await?;
-    let object = self.object.dereference(context, request_counter).await?;
+    let actor = self
+      .actor
+      .dereference(context, context.client(), request_counter)
+      .await?;
+    let object = self
+      .object
+      .dereference(context, context.client(), request_counter)
+      .await?;
     match object {
       PostOrComment::Post(p) => vote_post(&self.kind, actor, &p, context).await,
       PostOrComment::Comment(c) => vote_comment(&self.kind, actor, &c, context).await,
@@ -107,7 +113,10 @@ impl GetCommunity for Vote {
     context: &LemmyContext,
     request_counter: &mut i32,
   ) -> Result<ApubCommunity, LemmyError> {
-    let object = self.object.dereference(context, request_counter).await?;
+    let object = self
+      .object
+      .dereference(context, context.client(), request_counter)
+      .await?;
     let cid = match object {
       PostOrComment::Post(p) => p.community_id,
       PostOrComment::Comment(c) => {
index 1f761917803c0aa321ba4a7733e5275848e37de7..04611ddd068fc7d3a5ce6548d4deb03268c3864c 100644 (file)
@@ -110,7 +110,9 @@ impl ApubObject for ApubCommunityModerators {
     // Add new mods to database which have been added to moderators collection
     for mod_id in apub.ordered_items {
       let mod_id = ObjectId::new(mod_id);
-      let mod_user: ApubPerson = mod_id.dereference(&data.1, request_counter).await?;
+      let mod_user: ApubPerson = mod_id
+        .dereference(&data.1, data.1.client(), request_counter)
+        .await?;
 
       if !current_moderators
         .iter()
@@ -154,7 +156,8 @@ mod tests {
   #[actix_rt::test]
   #[serial]
   async fn test_parse_lemmy_community_moderators() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
     let community = parse_lemmy_community(&context).await;
     let community_id = community.id;
index 816a0516f1d170d4585f38065537b90caf6e83b9..8c53c25c7da64791bb5a8d7a4538f2ffa0d04d21 100644 (file)
@@ -27,7 +27,7 @@ pub async fn search_by_apub_id(
   match Url::parse(query) {
     Ok(url) => {
       ObjectId::new(url)
-        .dereference(context, request_counter)
+        .dereference(context, context.client(), request_counter)
         .await
     }
     Err(_) => {
@@ -43,7 +43,7 @@ pub async fn search_by_apub_id(
           .await?;
           Ok(SearchableObjects::Person(
             ObjectId::new(id)
-              .dereference(context, request_counter)
+              .dereference(context, context.client(), request_counter)
               .await?,
           ))
         }
@@ -57,7 +57,7 @@ pub async fn search_by_apub_id(
           .await?;
           Ok(SearchableObjects::Community(
             ObjectId::new(id)
-              .dereference(context, request_counter)
+              .dereference(context, context.client(), request_counter)
               .await?,
           ))
         }
index 426ec2d6ea68f3b3aa0650bbc81122dde777a0c0..31dedf02c9a0c3db674f0d96ae9424b6a6c455f4 100644 (file)
@@ -84,7 +84,9 @@ where
 
   *request_counter += 1;
   if *request_counter > context.settings().http_fetch_retry_limit {
-    return Err(LemmyError::from(anyhow!("Request retry limit reached")));
+    return Err(LemmyError::from(anyhow::anyhow!(
+      "Request retry limit reached"
+    )));
   }
 
   let response = retry(|| context.client().get(&fetch_url).send()).await?;
@@ -109,7 +111,7 @@ where
     .collect();
   for l in links {
     let object = ObjectId::<Kind>::new(l)
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
       .await;
     if object.is_ok() {
       return object.map(|o| o.actor_id().into());
index d974e31dc194067980ef4f4d840847c395b359f0..599da96bdb7127ba007a23efaa888ee95d88ca4f 100644 (file)
@@ -119,7 +119,9 @@ pub(crate) async fn get_apub_community_outbox(
   .await??;
   let id = ObjectId::new(generate_outbox_url(&community.actor_id)?);
   let outbox_data = CommunityContext(community.into(), context.get_ref().clone());
-  let outbox: ApubCommunityOutbox = id.dereference(&outbox_data, &mut 0).await?;
+  let outbox: ApubCommunityOutbox = id
+    .dereference(&outbox_data, context.client(), &mut 0)
+    .await?;
   Ok(create_apub_response(&outbox.into_apub(&outbox_data).await?))
 }
 
@@ -135,7 +137,9 @@ pub(crate) async fn get_apub_community_moderators(
   .into();
   let id = ObjectId::new(generate_outbox_url(&community.actor_id)?);
   let outbox_data = CommunityContext(community, context.get_ref().clone());
-  let moderators: ApubCommunityModerators = id.dereference(&outbox_data, &mut 0).await?;
+  let moderators: ApubCommunityModerators = id
+    .dereference(&outbox_data, context.client(), &mut 0)
+    .await?;
   Ok(create_apub_response(
     &moderators.into_apub(&outbox_data).await?,
   ))
index 5e40b9d6cd3605b25f450838da44794dc3dbbbb7..d9764fac21d7633a593216c7ec6416941ac2c0d8 100644 (file)
@@ -95,7 +95,7 @@ where
   check_is_apub_id_valid(&activity_data.actor, false, &context.settings())?;
   let request_counter = &mut 0;
   let actor = ObjectId::<UserOrCommunity>::new(activity_data.actor)
-    .dereference(context, request_counter)
+    .dereference(context, context.client(), request_counter)
     .await?;
   verify_signature(&request, &actor.public_key())?;
 
index 57bbbe1227f581d646db9f0bd58b91738b64463a..f525d1f643c5f7e7ab8498d7caddb65e3f52c880 100644 (file)
@@ -179,7 +179,7 @@ impl ApubObject for ApubComment {
   ) -> Result<ApubComment, LemmyError> {
     let creator = note
       .attributed_to
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
       .await?;
     let (post, parent_comment_id) = note.get_parents(context, request_counter).await?;
 
@@ -246,7 +246,8 @@ pub(crate) mod tests {
   #[actix_rt::test]
   #[serial]
   pub(crate) async fn test_parse_lemmy_comment() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
     let url = Url::parse("https://enterprise.lemmy.ml/comment/38741").unwrap();
     let data = prepare_comment_test(&url, &context).await;
@@ -276,7 +277,8 @@ pub(crate) mod tests {
   #[actix_rt::test]
   #[serial]
   async fn test_parse_pleroma_comment() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
     let url = Url::parse("https://enterprise.lemmy.ml/comment/38741").unwrap();
     let data = prepare_comment_test(&url, &context).await;
index c560278e489bfa4455c87ae680a05f712692a864..30f506eb45a2c1174e7a280c0c8679dea4d3e16b 100644 (file)
@@ -147,14 +147,14 @@ impl ApubObject for ApubCommunity {
 
     group
       .outbox
-      .dereference(&outbox_data, request_counter)
+      .dereference(&outbox_data, context.client(), request_counter)
       .await
       .map_err(|e| debug!("{}", e))
       .ok();
 
     if let Some(moderators) = &group.moderators {
       moderators
-        .dereference(&outbox_data, request_counter)
+        .dereference(&outbox_data, context.client(), request_counter)
         .await
         .map_err(|e| debug!("{}", e))
         .ok();
@@ -247,7 +247,8 @@ pub(crate) mod tests {
   #[actix_rt::test]
   #[serial]
   async fn test_parse_lemmy_community() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
     let community = parse_lemmy_community(&context).await;
 
index 5e0a0809648ab33c7c017d0ba94bae72123246eb..46013e1e32460274763264d34e5c688e3069cd14 100644 (file)
@@ -39,6 +39,7 @@ pub(crate) mod tests {
   };
   use lemmy_websocket::{chat_server::ChatServer, LemmyContext};
   use reqwest::Client;
+  use reqwest_middleware::ClientBuilder;
   use serde::de::DeserializeOwned;
   use std::{fs::File, io::BufReader, sync::Arc};
   use tokio::sync::Mutex;
@@ -57,6 +58,8 @@ pub(crate) mod tests {
       .user_agent(build_user_agent(&settings))
       .build()
       .unwrap();
+
+    let client = ClientBuilder::new(client).build();
     let secret = Secret {
       id: 0,
       jwt_secret: "".to_string(),
index a4f858c0a8ef20fce34d5e8b367a51883e97e02e..aa658eb41442e6e92314f95a65ee4a788384a6bd 100644 (file)
@@ -224,7 +224,8 @@ pub(crate) mod tests {
   #[actix_rt::test]
   #[serial]
   async fn test_parse_lemmy_person() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
     let person = parse_lemmy_person(&context).await;
 
@@ -238,7 +239,8 @@ pub(crate) mod tests {
   #[actix_rt::test]
   #[serial]
   async fn test_parse_pleroma_person() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
     let json = file_to_json_object("assets/pleroma/objects/person.json");
     let url = Url::parse("https://queer.hacktivis.me/users/lanodan").unwrap();
index 37c0fb3f8260272c71ea2bda3ef9856de8c7fe00..a8d64c18dc712ba53e8ff27473ef07925139fe7d 100644 (file)
@@ -158,7 +158,7 @@ impl ApubObject for ApubPost {
   ) -> Result<ApubPost, LemmyError> {
     let creator = page
       .attributed_to
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
       .await?;
     let community = page.extract_community(context, request_counter).await?;
 
@@ -216,7 +216,8 @@ mod tests {
   #[actix_rt::test]
   #[serial]
   async fn test_parse_lemmy_post() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
     let community = parse_lemmy_community(&context).await;
     let person = parse_lemmy_person(&context).await;
index a96a14e8909e828a1a5eb85e2983f1478f48e065..c7b053e4f2a5803fbc2bd56a2b1561f480e635e8 100644 (file)
@@ -113,7 +113,7 @@ impl ApubObject for ApubPrivateMessage {
     verify_domains_match(note.attributed_to.inner(), note.id.inner())?;
     let person = note
       .attributed_to
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
       .await?;
     if person.banned {
       return Err(LemmyError::from_message("Person is banned from site"));
@@ -129,9 +129,11 @@ impl ApubObject for ApubPrivateMessage {
   ) -> Result<ApubPrivateMessage, LemmyError> {
     let creator = note
       .attributed_to
-      .dereference(context, request_counter)
+      .dereference(context, context.client(), request_counter)
+      .await?;
+    let recipient = note.to[0]
+      .dereference(context, context.client(), request_counter)
       .await?;
-    let recipient = note.to[0].dereference(context, request_counter).await?;
     let content = if let Some(source) = &note.source {
       source.content.clone()
     } else {
@@ -195,7 +197,8 @@ mod tests {
   #[actix_rt::test]
   #[serial]
   async fn test_parse_lemmy_pm() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
     let url = Url::parse("https://enterprise.lemmy.ml/private_message/1621").unwrap();
     let data = prepare_comment_test(&url, &context).await;
@@ -223,7 +226,8 @@ mod tests {
   #[actix_rt::test]
   #[serial]
   async fn test_parse_pleroma_pm() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
     let url = Url::parse("https://enterprise.lemmy.ml/private_message/1621").unwrap();
     let data = prepare_comment_test(&url, &context).await;
index 39c606b00942fbb2f5a6f7df3bc8a93a60257575..ff463926d428fa53af32481feea50a1329445fb9 100644 (file)
@@ -67,7 +67,7 @@ impl Note {
     let parent = Box::pin(
       self
         .in_reply_to
-        .dereference(context, request_counter)
+        .dereference(context, context.client(), request_counter)
         .await?,
     );
     match parent.deref() {
index bac85600a9a0cd56cc77f689c7280725c9a0f8f2..08b167ddee33b1122f0f6aef69c7e1d31c11fc32 100644 (file)
@@ -70,7 +70,10 @@ impl Page {
     loop {
       if let Some(cid) = to_iter.next() {
         let cid = ObjectId::new(cid.clone());
-        if let Ok(c) = cid.dereference(context, request_counter).await {
+        if let Ok(c) = cid
+          .dereference(context, context.client(), request_counter)
+          .await
+        {
           break Ok(c);
         }
       } else {
index 611c9fbc3cc35c1a77f6a3ff85a456f4ff8249bc..4c65c93694a9bf1b075186b7f9f5a612e8d44308 100644 (file)
@@ -17,6 +17,7 @@ url = { version = "2.2.2", features = ["serde"] }
 serde_json = { version = "1.0.68", features = ["preserve_order"] }
 anyhow = "1.0.44"
 reqwest = { version = "0.11.4", features = ["json"] }
+reqwest-middleware = "0.1.2"
 tracing = "0.1.29"
 base64 = "0.13.0"
 openssl = "0.10.36"
@@ -25,6 +26,6 @@ http = "0.2.5"
 sha2 = "0.9.8"
 actix-web = { version = "4.0.0-beta.9", default-features = false }
 http-signature-normalization-actix = { version = "0.5.0-beta.10", default-features = false, features = ["server", "sha-2"] }
-http-signature-normalization-reqwest = { version = "0.2.0", default-features = false, features = ["sha-2"] }
+http-signature-normalization-reqwest = { version = "0.3.0", default-features = false, features = ["sha-2", "middleware"] }
 background-jobs = "0.11.0"
 diesel = "1.4.8"
index a6562deb7cc3c9e61215c967c3d17aa1acc52364..c02586ce94c7b4971bb5f4e3614b01d2c130a13d 100644 (file)
@@ -10,7 +10,7 @@ use background_jobs::{
   WorkerConfig,
 };
 use lemmy_utils::{location_info, LemmyError};
-use reqwest::Client;
+use reqwest_middleware::ClientWithMiddleware;
 use serde::{Deserialize, Serialize};
 use std::{env, fmt::Debug, future::Future, pin::Pin};
 use tracing::{info, warn};
@@ -21,7 +21,7 @@ pub async fn send_activity(
   actor: &dyn ActorType,
   inboxes: Vec<&Url>,
   activity: String,
-  client: &Client,
+  client: &ClientWithMiddleware,
   activity_queue: &QueueHandle,
 ) -> Result<(), LemmyError> {
   for i in inboxes {
@@ -66,7 +66,7 @@ impl ActixJob for SendActivityTask {
   }
 }
 
-async fn do_send(task: SendActivityTask, client: &Client) -> Result<(), Error> {
+async fn do_send(task: SendActivityTask, client: &ClientWithMiddleware) -> Result<(), Error> {
   info!("Sending {} to {}", task.activity_id, task.inbox);
   let result = sign_and_send(
     client,
@@ -101,10 +101,10 @@ async fn do_send(task: SendActivityTask, client: &Client) -> Result<(), Error> {
   Ok(())
 }
 
-pub fn create_activity_queue() -> Manager {
+pub fn create_activity_queue(client: ClientWithMiddleware) -> Manager {
   // Configure and start our workers
-  WorkerConfig::new_managed(Storage::new(), |_| MyState {
-    client: Client::default(),
+  WorkerConfig::new_managed(Storage::new(), move |_| MyState {
+    client: client.clone(),
   })
   .register::<SendActivityTask>()
   .start()
@@ -112,5 +112,5 @@ pub fn create_activity_queue() -> Manager {
 
 #[derive(Clone)]
 struct MyState {
-  pub client: Client,
+  pub client: ClientWithMiddleware,
 }
index e8d0bd6d2ad03c435992f469b30480cd6c90f88c..5bb862f683e4f5d8cbe2494083466aa6f437d4be 100644 (file)
@@ -2,13 +2,9 @@ use crate::{traits::ApubObject, APUB_JSON_CONTENT_TYPE};
 use activitystreams::chrono::{Duration as ChronoDuration, NaiveDateTime, Utc};
 use anyhow::anyhow;
 use diesel::NotFound;
-use lemmy_utils::{
-  request::{build_user_agent, retry},
-  settings::structs::Settings,
-  LemmyError,
-};
-use once_cell::sync::Lazy;
-use reqwest::{Client, StatusCode};
+use lemmy_utils::{request::retry, settings::structs::Settings, LemmyError};
+use reqwest::StatusCode;
+use reqwest_middleware::ClientWithMiddleware;
 use serde::{Deserialize, Serialize};
 use std::{
   fmt::{Debug, Display, Formatter},
@@ -18,13 +14,6 @@ use std::{
 use tracing::info;
 use url::Url;
 
-static CLIENT: Lazy<Client> = Lazy::new(|| {
-  Client::builder()
-    .user_agent(build_user_agent(&Settings::get()))
-    .build()
-    .expect("Couldn't build client")
-});
-
 /// We store Url on the heap because it is quite large (88 bytes).
 #[derive(Clone, PartialEq, Serialize, Deserialize, Debug)]
 #[serde(transparent)]
@@ -53,6 +42,7 @@ where
   pub async fn dereference(
     &self,
     data: &<Kind as ApubObject>::DataType,
+    client: &ClientWithMiddleware,
     request_counter: &mut i32,
   ) -> Result<Kind, LemmyError> {
     let db_object = self.dereference_from_db(data).await?;
@@ -71,7 +61,7 @@ where
       if let Some(last_refreshed_at) = object.last_refreshed_at() {
         if should_refetch_object(last_refreshed_at) {
           return self
-            .dereference_from_http(data, request_counter, Some(object))
+            .dereference_from_http(data, client, request_counter, Some(object))
             .await;
         }
       }
@@ -80,7 +70,7 @@ where
     // object not found, need to fetch over http
     else {
       self
-        .dereference_from_http(data, request_counter, None)
+        .dereference_from_http(data, client, request_counter, None)
         .await
     }
   }
@@ -107,6 +97,7 @@ where
   async fn dereference_from_http(
     &self,
     data: &<Kind as ApubObject>::DataType,
+    client: &ClientWithMiddleware,
     request_counter: &mut i32,
     db_object: Option<Kind>,
   ) -> Result<Kind, LemmyError> {
@@ -120,7 +111,7 @@ where
     }
 
     let res = retry(|| {
-      CLIENT
+      client
         .get(self.0.as_str())
         .header("Accept", APUB_JSON_CONTENT_TYPE)
         .timeout(Duration::from_secs(60))
index 36c6b9644fe4fa8b770fa38bad3980ec2b177a12..153eb7453f8342f16355968b32cec12a67a97405 100644 (file)
@@ -11,7 +11,8 @@ use openssl::{
   pkey::PKey,
   sign::{Signer, Verifier},
 };
-use reqwest::{Client, Response};
+use reqwest::Response;
+use reqwest_middleware::ClientWithMiddleware;
 use serde::{Deserialize, Serialize};
 use sha2::{Digest, Sha256};
 use std::str::FromStr;
@@ -24,7 +25,7 @@ static HTTP_SIG_CONFIG: Lazy<Config> = Lazy::new(Config::new);
 /// Creates an HTTP post request to `inbox_url`, with the given `client` and `headers`, and
 /// `activity` as request body. The request is signed with `private_key` and then sent.
 pub async fn sign_and_send(
-  client: &Client,
+  client: &ClientWithMiddleware,
   inbox_url: &Url,
   activity: String,
   actor_id: &Url,
@@ -43,7 +44,7 @@ pub async fn sign_and_send(
   );
   headers.insert(HeaderName::from_str("Host")?, HeaderValue::from_str(&host)?);
 
-  let response = client
+  let request = client
     .post(&inbox_url.to_string())
     .headers(headers)
     .signature_with_digest(
@@ -61,6 +62,8 @@ pub async fn sign_and_send(
     )
     .await?;
 
+  let response = client.execute(request).await?;
+
   Ok(response)
 }
 
index 3bd4a0ea8093b96e2b108dd5b9c0582bb2ee53c2..44d510eae5eb13cb02fd283bf8ba1b18fe8d12c4 100644 (file)
@@ -32,6 +32,7 @@ actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["r
 actix-rt = { version = "2.2.0", default-features = false }
 anyhow = "1.0.44"
 reqwest = { version = "0.11.4", features = ["json"] }
+reqwest-middleware = "0.1.2"
 tokio = { version = "1.12.0", features = ["sync"] }
 strum = "0.21.0"
 strum_macros = "0.21.1"
index 88680c0806602fdec595fdf4b2e4e7832110f9ea..10341e801afe6a4546ba5415a4cf0ab4f1df427f 100644 (file)
@@ -1,7 +1,7 @@
 use crate::{settings::structs::Settings, version::VERSION, LemmyError};
 use anyhow::anyhow;
 use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
-use reqwest::Client;
+use reqwest_middleware::ClientWithMiddleware;
 use serde::{Deserialize, Serialize};
 use std::future::Future;
 use thiserror::Error;
@@ -17,30 +17,33 @@ struct SendError(pub String);
 #[error("Error receiving response, {0}")]
 pub struct RecvError(pub String);
 
-pub async fn retry<F, Fut, T>(f: F) -> Result<T, reqwest::Error>
+pub async fn retry<F, Fut, T>(f: F) -> Result<T, reqwest_middleware::Error>
 where
   F: Fn() -> Fut,
-  Fut: Future<Output = Result<T, reqwest::Error>>,
+  Fut: Future<Output = Result<T, reqwest_middleware::Error>>,
 {
   retry_custom(|| async { Ok((f)().await) }).await
 }
 
-async fn retry_custom<F, Fut, T>(f: F) -> Result<T, reqwest::Error>
+async fn retry_custom<F, Fut, T>(f: F) -> Result<T, reqwest_middleware::Error>
 where
   F: Fn() -> Fut,
-  Fut: Future<Output = Result<Result<T, reqwest::Error>, reqwest::Error>>,
+  Fut: Future<Output = Result<Result<T, reqwest_middleware::Error>, reqwest_middleware::Error>>,
 {
-  let mut response: Option<Result<T, reqwest::Error>> = None;
+  let mut response: Option<Result<T, reqwest_middleware::Error>> = None;
 
   for _ in 0u8..3 {
     match (f)().await? {
       Ok(t) => return Ok(t),
-      Err(e) => {
+      Err(reqwest_middleware::Error::Reqwest(e)) => {
         if e.is_timeout() {
-          response = Some(Err(e));
+          response = Some(Err(reqwest_middleware::Error::Reqwest(e)));
           continue;
         }
-        return Err(e);
+        return Err(reqwest_middleware::Error::Reqwest(e));
+      }
+      Err(otherwise) => {
+        return Err(otherwise);
       }
     }
   }
@@ -57,7 +60,10 @@ pub struct SiteMetadata {
 }
 
 /// Fetches the post link html tags (like title, description, image, etc)
-pub async fn fetch_site_metadata(client: &Client, url: &Url) -> Result<SiteMetadata, LemmyError> {
+pub async fn fetch_site_metadata(
+  client: &ClientWithMiddleware,
+  url: &Url,
+) -> Result<SiteMetadata, LemmyError> {
   let response = client.get(url.as_str()).send().await?;
 
   let html = response
@@ -119,7 +125,7 @@ pub(crate) struct PictrsFile {
 }
 
 pub(crate) async fn fetch_pictrs(
-  client: &Client,
+  client: &ClientWithMiddleware,
   settings: &Settings,
   image_url: &Url,
 ) -> Result<PictrsResponse, LemmyError> {
@@ -152,7 +158,7 @@ pub(crate) async fn fetch_pictrs(
 /// Both are options, since the URL might be either an html page, or an image
 /// Returns the SiteMetadata, and a Pictrs URL, if there is a picture associated
 pub async fn fetch_site_data(
-  client: &Client,
+  client: &ClientWithMiddleware,
   settings: &Settings,
   url: Option<&Url>,
 ) -> (Option<SiteMetadata>, Option<Url>) {
@@ -201,7 +207,7 @@ pub async fn fetch_site_data(
   }
 }
 
-async fn is_image_content_type(client: &Client, url: &Url) -> Result<(), LemmyError> {
+async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Result<(), LemmyError> {
   let response = client.get(url.as_str()).send().await?;
   if response
     .headers()
@@ -239,7 +245,8 @@ mod tests {
     let client = reqwest::Client::builder()
       .user_agent(build_user_agent(&settings))
       .build()
-      .unwrap();
+      .unwrap()
+      .into();
     let sample_url = Url::parse("https://www.redspark.nu/en/peoples-war/district-leader-of-chand-led-cpn-arrested-in-bhojpur/").unwrap();
     let sample_res = fetch_site_metadata(&client, &sample_url).await.unwrap();
     assert_eq!(
index 0ee04c86ec42dca30d705c33dbfb8a8bc66a4d51..4340e4865f53b20571eabf731a4d4c7961095f3a 100644 (file)
@@ -19,6 +19,7 @@ lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
 lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
 lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
 reqwest = { version = "0.11.4", features = ["json"] }
+reqwest-middleware = "0.1.2"
 tracing = "0.1.29"
 rand = "0.8.4"
 serde = { version = "1.0.130", features = ["derive"] }
index 5d91800e00ab1d32ebbc5d8e348f5382d4b64a74..53274e386e1ef6c26a71378be3d2a5e957f2f595 100644 (file)
@@ -27,7 +27,7 @@ use lemmy_utils::{
   LemmyError,
 };
 use rand::rngs::ThreadRng;
-use reqwest::Client;
+use reqwest_middleware::ClientWithMiddleware;
 use serde::Serialize;
 use serde_json::Value;
 use std::{
@@ -90,7 +90,7 @@ pub struct ChatServer {
   message_handler_crud: MessageHandlerCrudType,
 
   /// An HTTP Client
-  client: Client,
+  client: ClientWithMiddleware,
 
   activity_queue: QueueHandle,
 }
@@ -110,7 +110,7 @@ impl ChatServer {
     rate_limiter: RateLimit,
     message_handler: MessageHandlerType,
     message_handler_crud: MessageHandlerCrudType,
-    client: Client,
+    client: ClientWithMiddleware,
     activity_queue: QueueHandle,
     settings: Settings,
     secret: Secret,
index f422ac51ef3819f20cdb1e717918778993d00eab..88f0f6a4320f95fa69202d142bea570e3babc695 100644 (file)
@@ -6,7 +6,7 @@ use actix::Addr;
 use background_jobs::QueueHandle;
 use lemmy_db_schema::{source::secret::Secret, DbPool};
 use lemmy_utils::{settings::structs::Settings, LemmyError};
-use reqwest::Client;
+use reqwest_middleware::ClientWithMiddleware;
 use serde::Serialize;
 
 pub mod chat_server;
@@ -18,7 +18,7 @@ pub mod send;
 pub struct LemmyContext {
   pool: DbPool,
   chat_server: Addr<ChatServer>,
-  client: Client,
+  client: ClientWithMiddleware,
   activity_queue: QueueHandle,
   settings: Settings,
   secret: Secret,
@@ -28,7 +28,7 @@ impl LemmyContext {
   pub fn create(
     pool: DbPool,
     chat_server: Addr<ChatServer>,
-    client: Client,
+    client: ClientWithMiddleware,
     activity_queue: QueueHandle,
     settings: Settings,
     secret: Secret,
@@ -48,7 +48,7 @@ impl LemmyContext {
   pub fn chat_server(&self) -> &Addr<ChatServer> {
     &self.chat_server
   }
-  pub fn client(&self) -> &Client {
+  pub fn client(&self) -> &ClientWithMiddleware {
     &self.client
   }
   pub fn activity_queue(&self) -> &QueueHandle {
index 8f130fde26aeada491867be48e047ff2886960e0..c65cf447950152a395024674cd35bc0d91b772cb 100644 (file)
@@ -29,6 +29,8 @@ use lemmy_utils::{
 };
 use lemmy_websocket::{chat_server::ChatServer, LemmyContext};
 use reqwest::Client;
+use reqwest_middleware::ClientBuilder;
+use reqwest_tracing::TracingMiddleware;
 use std::{env, sync::Arc, thread};
 use tokio::sync::Mutex;
 use tracing_actix_web::TracingLogger;
@@ -95,7 +97,9 @@ async fn main() -> Result<(), LemmyError> {
     .user_agent(build_user_agent(&settings))
     .build()?;
 
-  let queue_manager = create_activity_queue();
+  let client = ClientBuilder::new(client).with(TracingMiddleware).build();
+
+  let queue_manager = create_activity_queue(client.clone());
 
   let activity_queue = queue_manager.queue_handle().clone();