Upgrade activitypub_federation to 0.2.0, add setting federation.debug (#2300)

This commit is contained in:
Nutomic 2022-06-08 15:45:39 +00:00 committed by GitHub
parent 7bc2f9fd6d
commit fcaf7a084c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 345 additions and 371 deletions

143
Cargo.lock generated
View file

@ -4,9 +4,9 @@ version = 3
[[package]]
name = "activitypub_federation"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b34a144dc98c419543690aa8f182d8675ebe0610775982b8fdee84a00f70fe"
checksum = "446e75aefabf78ed9cc7e175f0d90c74f478086fb9bc571a9614fb0b7cbe35d4"
dependencies = [
"activitypub_federation_derive",
"actix-web",
@ -19,6 +19,7 @@ dependencies = [
"http",
"http-signature-normalization-actix",
"http-signature-normalization-reqwest",
"itertools",
"once_cell",
"openssl",
"reqwest",
@ -33,13 +34,13 @@ dependencies = [
[[package]]
name = "activitypub_federation_derive"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a2aaf58676b669d3b0dedf6bbb44fa518b5a6657b2959561d77899c668dec2a"
checksum = "07520b54fc0f22ad30b90399b2a2689c6e5c113df0642ca3fa2f7ee823e54126"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -135,7 +136,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6"
dependencies = [
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -287,7 +288,7 @@ dependencies = [
"actix-router",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -298,7 +299,7 @@ checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -344,9 +345,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.56"
version = "1.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc"
[[package]]
name = "arrayvec"
@ -391,18 +392,18 @@ checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
name = "async-trait"
version = "0.1.53"
version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"
checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -862,7 +863,7 @@ dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"strsim",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -876,7 +877,7 @@ dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"strsim",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -890,7 +891,7 @@ dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"strsim",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -901,7 +902,7 @@ checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a"
dependencies = [
"darling_core 0.12.4",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -912,7 +913,7 @@ checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b"
dependencies = [
"darling_core 0.13.1",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -923,7 +924,7 @@ checksum = "ddfc69c5bfcbd2fc09a0f38451d2daf0e372e367986a83906d1b0dbc88134fb5"
dependencies = [
"darling_core 0.14.1",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -962,7 +963,7 @@ dependencies = [
"darling 0.12.4",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -974,7 +975,7 @@ dependencies = [
"darling 0.14.1",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -984,7 +985,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73"
dependencies = [
"derive_builder_core 0.10.2",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -994,7 +995,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68"
dependencies = [
"derive_builder_core 0.11.2",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -1007,7 +1008,7 @@ dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"rustc_version",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -1054,7 +1055,7 @@ checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -1134,7 +1135,7 @@ dependencies = [
"darling 0.13.1",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -1395,7 +1396,7 @@ checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -1587,14 +1588,14 @@ dependencies = [
"markup5ever",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
name = "http"
version = "0.2.6"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03"
checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399"
dependencies = [
"bytes",
"fnv",
@ -1643,9 +1644,9 @@ dependencies = [
[[package]]
name = "http-signature-normalization-reqwest"
version = "0.5.0"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a15d4498e747f1cb1b0114ad651619932eac790815d2dcef0fa89bd016fd991"
checksum = "630652b9b1f4c18064199c57cce4ad0352d1ec6ec8ad8ffcb0c71dea41ac6b79"
dependencies = [
"base64",
"bytes",
@ -2327,7 +2328,7 @@ dependencies = [
"migrations_internals",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -2535,9 +2536,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.10.0"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
[[package]]
name = "opaque-debug"
@ -2547,18 +2548,30 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "openssl"
version = "0.10.38"
version = "0.10.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95"
checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e"
dependencies = [
"bitflags",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.96",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
@ -2567,9 +2580,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.72"
version = "0.9.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb"
checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1"
dependencies = [
"autocfg",
"cc",
@ -2732,7 +2745,7 @@ dependencies = [
"pest_meta",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -2830,7 +2843,7 @@ checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -2893,7 +2906,7 @@ dependencies = [
"proc-macro-error-attr",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
"version_check",
]
@ -2966,7 +2979,7 @@ dependencies = [
"itertools",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -3451,29 +3464,29 @@ checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4"
[[package]]
name = "serde"
version = "1.0.136"
version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.136"
version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
name = "serde_json"
version = "1.0.79"
version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95"
checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c"
dependencies = [
"indexmap",
"itoa",
@ -3513,7 +3526,7 @@ dependencies = [
"darling 0.13.1",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -3537,7 +3550,7 @@ dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"rustversion",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -3636,7 +3649,7 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -3709,7 +3722,7 @@ dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"rustversion",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -3725,9 +3738,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.95"
version = "1.0.96"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942"
checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
@ -3791,7 +3804,7 @@ checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -3894,7 +3907,7 @@ checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -3997,7 +4010,7 @@ dependencies = [
"proc-macro2 1.0.39",
"prost-build",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -4034,9 +4047,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
[[package]]
name = "tracing"
version = "0.1.32"
version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f"
checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09"
dependencies = [
"cfg-if",
"log",
@ -4066,7 +4079,7 @@ checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
]
[[package]]
@ -4361,7 +4374,7 @@ dependencies = [
"log",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
"wasm-bindgen-shared",
]
@ -4395,7 +4408,7 @@ checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
"syn 1.0.96",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]

View file

@ -42,7 +42,7 @@ lemmy_db_schema = { version = "=0.16.5", path = "./crates/db_schema" }
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.1.0"
activitypub_federation = "0.2.0"
diesel = "1.4.8"
diesel_migrations = "1.4.0"
serde = { version = "1.0.136", features = ["derive"] }

View file

@ -1,7 +1,6 @@
#!/bin/bash
set -e
export APUB_TESTING_SEND_SYNC=1
export RUST_BACKTRACE=1
export RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"

View file

@ -66,6 +66,9 @@
# see information. If running number is consistently close to the worker_count, you should
# increase it.
worker_count: 64
# Use federation debug mode. Allows connecting to http and localhost urls. Also sends outgoing
# activities synchronously for easier testing. Do not use in production.
debug: false
}
captcha: {
# Whether captcha is required for signup

View file

@ -21,7 +21,7 @@ lemmy_db_views_moderator = { version = "=0.16.5", path = "../db_views_moderator"
lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", features = ["full"] }
lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
activitypub_federation = "0.1.0"
activitypub_federation = "0.2.0"
diesel = "1.4.8"
bcrypt = "0.12.1"
chrono = { version = "0.4.19", features = ["serde"], default-features = false }

View file

@ -15,7 +15,7 @@ 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"] }
lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
activitypub_federation = "0.1.0"
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"] }

View file

@ -76,9 +76,7 @@ impl PerformCrud for CreateCommunity {
&context.settings().get_protocol_and_hostname(),
)?;
let community_actor_id_wrapped = ObjectId::<ApubCommunity>::new(community_actor_id.clone());
let community_dupe = community_actor_id_wrapped
.dereference_local::<LemmyError>(context)
.await;
let community_dupe = community_actor_id_wrapped.dereference_local(context).await;
if community_dupe.is_ok() {
return Err(LemmyError::from_message("community_already_exists"));
}

View file

@ -19,7 +19,7 @@ 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"] }
lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
activitypub_federation = "0.1.0"
activitypub_federation = "0.2.0"
diesel = "1.4.8"
activitystreams-kinds = "0.2.1"
chrono = { version = "0.4.19", features = ["serde"], default-features = false }

View file

@ -1,6 +1,8 @@
{
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
"to": "http://enterprise.lemmy.ml/c/main",
"to": [
"http://enterprise.lemmy.ml/c/main"
],
"object": "http://enterprise.lemmy.ml/post/7",
"summary": "report this post",
"type": "Flag",

View file

@ -1,12 +1,16 @@
{
"id": "http://enterprise.lemmy.ml/activities/create/987d05fa-f637-46d7-85be-13d112bc269f",
"actor": "http://enterprise.lemmy.ml/u/lemmy_beta",
"to": "http://ds9.lemmy.ml/u/lemmy_alpha",
"to": [
"http://ds9.lemmy.ml/u/lemmy_alpha"
],
"object": {
"type": "ChatMessage",
"id": "http://enterprise.lemmy.ml/private_message/1",
"attributedTo": "http://enterprise.lemmy.ml/u/lemmy_beta",
"to": "http://ds9.lemmy.ml/u/lemmy_alpha",
"to": [
"http://ds9.lemmy.ml/u/lemmy_alpha"
],
"content": "hello",
"mediaType": "text/html",
"source": {

View file

@ -2,7 +2,9 @@
"id": "https://enterprise.lemmy.ml/private_message/1621",
"type": "ChatMessage",
"attributedTo": "https://enterprise.lemmy.ml/u/picard",
"to": "https://queer.hacktivis.me/users/lanodan",
"to": [
"https://queer.hacktivis.me/users/lanodan"
],
"content": "<p>Hello hello, testing</p>\n",
"mediaType": "text/html",
"source": {

View file

@ -1,6 +1,6 @@
use crate::{
activities::{
block::{generate_cc, generate_instance_inboxes, SiteOrCommunity},
block::{generate_cc, SiteOrCommunity},
community::{announce::GetCommunity, send_activity_in_community},
generate_activity_id,
send_lemmy_activity,
@ -10,14 +10,14 @@ use crate::{
},
activity_lists::AnnouncableActivities,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
objects::{community::ApubCommunity, instance::remote_instance_inboxes, person::ApubPerson},
protocol::activities::block::block_user::BlockUser,
ActorType,
};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::ActivityHandler,
traits::{ActivityHandler, Actor},
utils::verify_domains_match,
};
use activitystreams_kinds::{activity::BlockType, public};
@ -89,17 +89,16 @@ impl BlockUser {
context,
)
.await?;
let block_id = block.id.clone();
match target {
SiteOrCommunity::Site(_) => {
let inboxes = generate_instance_inboxes(user, context.pool()).await?;
send_lemmy_activity(context, &block, &block_id, mod_, inboxes, false).await
let inboxes = remote_instance_inboxes(context.pool()).await?;
send_lemmy_activity(context, block, mod_, inboxes, false).await
}
SiteOrCommunity::Community(c) => {
let activity = AnnouncableActivities::BlockUser(block);
let inboxes = vec![user.shared_inbox_or_inbox_url()];
send_activity_in_community(activity, &block_id, mod_, c, inboxes, context).await
let inboxes = vec![user.shared_inbox_or_inbox()];
send_activity_in_community(activity, mod_, c, inboxes, context).await
}
}
}
@ -127,7 +126,7 @@ impl ActivityHandler for BlockUser {
verify_is_public(&self.to, &self.cc)?;
match self
.target
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?
{
SiteOrCommunity::Site(site) => {
@ -165,15 +164,15 @@ impl ActivityHandler for BlockUser {
let expires = self.expires.map(|u| u.naive_local());
let mod_person = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let blocked_person = self
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let target = self
.target
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
match target {
SiteOrCommunity::Site(_site) => {
@ -252,7 +251,7 @@ impl GetCommunity for BlockUser {
) -> Result<ApubCommunity, LemmyError> {
let target = self
.target
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
match target {
SiteOrCommunity::Community(c) => Ok(c),

View file

@ -1,5 +1,5 @@
use crate::{
objects::{community::ApubCommunity, instance::ApubSite, person::ApubPerson},
objects::{community::ApubCommunity, instance::ApubSite},
protocol::objects::{group::Group, instance::Instance},
ActorType,
};
@ -124,16 +124,3 @@ async fn generate_cc(target: &SiteOrCommunity, pool: &DbPool) -> Result<Vec<Url>
SiteOrCommunity::Community(c) => vec![c.actor_id()],
})
}
async fn generate_instance_inboxes(
blocked_user: &ApubPerson,
pool: &DbPool,
) -> Result<Vec<Url>, LemmyError> {
let mut inboxes: Vec<Url> = blocking(pool, Site::read_remote_sites)
.await??
.into_iter()
.map(|s| s.inbox_url.into())
.collect();
inboxes.push(blocked_user.shared_inbox_or_inbox_url());
Ok(inboxes)
}

View file

@ -1,6 +1,6 @@
use crate::{
activities::{
block::{generate_cc, generate_instance_inboxes, SiteOrCommunity},
block::{generate_cc, SiteOrCommunity},
community::{announce::GetCommunity, send_activity_in_community},
generate_activity_id,
send_lemmy_activity,
@ -8,14 +8,14 @@ use crate::{
},
activity_lists::AnnouncableActivities,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
objects::{community::ApubCommunity, instance::remote_instance_inboxes, person::ApubPerson},
protocol::activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
ActorType,
};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::ActivityHandler,
traits::{ActivityHandler, Actor},
utils::verify_domains_match,
};
use activitystreams_kinds::{activity::UndoType, public};
@ -57,15 +57,15 @@ impl UndoBlockUser {
unparsed: Default::default(),
};
let inboxes = vec![user.shared_inbox_or_inbox_url()];
let mut inboxes = vec![user.shared_inbox_or_inbox()];
match target {
SiteOrCommunity::Site(_) => {
let inboxes = generate_instance_inboxes(user, context.pool()).await?;
send_lemmy_activity(context, &undo, &id, mod_, inboxes, false).await
inboxes.append(&mut remote_instance_inboxes(context.pool()).await?);
send_lemmy_activity(context, undo, mod_, inboxes, false).await
}
SiteOrCommunity::Community(c) => {
let activity = AnnouncableActivities::UndoBlockUser(undo);
send_activity_in_community(activity, &id, mod_, c, inboxes, context).await
send_activity_in_community(activity, mod_, c, inboxes, context).await
}
}
}
@ -106,17 +106,17 @@ impl ActivityHandler for UndoBlockUser {
let expires = self.object.expires.map(|u| u.naive_local());
let mod_person = self
.actor
.dereference::<LemmyError>(context, instance, request_counter)
.dereference(context, instance, request_counter)
.await?;
let blocked_person = self
.object
.object
.dereference::<LemmyError>(context, instance, request_counter)
.dereference(context, instance, request_counter)
.await?;
match self
.object
.target
.dereference::<LemmyError>(context, instance, request_counter)
.dereference(context, instance, request_counter)
.await?
{
SiteOrCommunity::Site(_site) => {

View file

@ -18,7 +18,11 @@ use crate::{
protocol::activities::community::add_mod::AddMod,
ActorType,
};
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::{ActivityHandler, Actor},
};
use activitystreams_kinds::{activity::AddType, public};
use lemmy_api_common::utils::blocking;
use lemmy_db_schema::{
@ -56,8 +60,8 @@ impl AddMod {
};
let activity = AnnouncableActivities::AddMod(add);
let inboxes = vec![added_mod.shared_inbox_or_inbox_url()];
send_activity_in_community(activity, &id, actor, community, inboxes, context).await
let inboxes = vec![added_mod.shared_inbox_or_inbox()];
send_activity_in_community(activity, actor, community, inboxes, context).await
}
}
@ -104,7 +108,7 @@ impl ActivityHandler for AddMod {
let community = self.get_community(context, request_counter).await?;
let new_mod = self
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
// If we had to refetch the community while parsing the activity, then the new mod has already
@ -127,7 +131,7 @@ impl ActivityHandler for AddMod {
// write mod log
let actor = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let form = ModAddCommunityForm {
mod_person_id: actor.id,

View file

@ -53,15 +53,7 @@ impl AnnounceActivity {
) -> Result<(), LemmyError> {
let announce = AnnounceActivity::new(object.clone(), community, context)?;
let inboxes = community.get_follower_inboxes(context).await?;
send_lemmy_activity(
context,
&announce,
&announce.id,
community,
inboxes.clone(),
false,
)
.await?;
send_lemmy_activity(context, announce, community, inboxes.clone(), false).await?;
// Pleroma and Mastodon can't handle activities like Announce/Create/Page. So for
// compatibility, we also send Announce/Page so that they can follow Lemmy communities.
@ -71,15 +63,7 @@ impl AnnounceActivity {
_ => return Ok(()),
};
let announce_compat = AnnounceActivity::new(object, community, context)?;
send_lemmy_activity(
context,
&announce_compat,
&announce_compat.id,
community,
inboxes,
false,
)
.await?;
send_lemmy_activity(context, announce_compat, community, inboxes, false).await?;
Ok(())
}
}

View file

@ -6,7 +6,7 @@ use crate::{
protocol::activities::community::announce::AnnounceActivity,
ActorType,
};
use activitypub_federation::core::object_id::ObjectId;
use activitypub_federation::{core::object_id::ObjectId, traits::Actor};
use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext;
use url::Url;
@ -18,16 +18,18 @@ pub mod report;
pub mod update;
#[tracing::instrument(skip_all)]
pub(crate) async fn send_activity_in_community<T: ActorType>(
pub(crate) async fn send_activity_in_community<ActorT>(
activity: AnnouncableActivities,
activity_id: &Url,
actor: &T,
actor: &ActorT,
community: &ApubCommunity,
mut inboxes: Vec<Url>,
context: &LemmyContext,
) -> Result<(), LemmyError> {
inboxes.push(community.shared_inbox_or_inbox_url());
send_lemmy_activity(context, &activity, activity_id, actor, inboxes, false).await?;
) -> Result<(), LemmyError>
where
ActorT: Actor + ActorType,
{
inboxes.push(community.shared_inbox_or_inbox());
send_lemmy_activity(context, activity.clone(), actor, inboxes, false).await?;
if community.local {
AnnounceActivity::send(activity, community, context).await?;
@ -44,6 +46,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::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await
}

View file

@ -18,7 +18,11 @@ use crate::{
protocol::activities::community::remove_mod::RemoveMod,
ActorType,
};
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::{ActivityHandler, Actor},
};
use activitystreams_kinds::{activity::RemoveType, public};
use lemmy_api_common::utils::blocking;
use lemmy_db_schema::{
@ -56,8 +60,8 @@ impl RemoveMod {
};
let activity = AnnouncableActivities::RemoveMod(remove);
let inboxes = vec![removed_mod.shared_inbox_or_inbox_url()];
send_activity_in_community(activity, &id, actor, community, inboxes, context).await
let inboxes = vec![removed_mod.shared_inbox_or_inbox()];
send_activity_in_community(activity, actor, community, inboxes, context).await
}
}
@ -104,7 +108,7 @@ impl ActivityHandler for RemoveMod {
let community = self.get_community(context, request_counter).await?;
let remove_mod = self
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let form = CommunityModeratorForm {
@ -119,7 +123,7 @@ impl ActivityHandler for RemoveMod {
// write mod log
let actor = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let form = ModAddCommunityForm {
mod_person_id: actor.id,

View file

@ -6,7 +6,11 @@ use crate::{
ActorType,
PostOrComment,
};
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::{ActivityHandler, Actor},
};
use activitystreams_kinds::activity::FlagType;
use lemmy_api_common::{comment::CommentReportResponse, post::PostReportResponse, utils::blocking};
use lemmy_db_schema::{
@ -30,9 +34,7 @@ impl Report {
reason: String,
context: &LemmyContext,
) -> Result<(), LemmyError> {
let community = community_id
.dereference_local::<LemmyError>(context)
.await?;
let community = community_id.dereference_local(context).await?;
let kind = FlagType::Flag;
let id = generate_activity_id(
kind.clone(),
@ -40,22 +42,16 @@ impl Report {
)?;
let report = Report {
actor: ObjectId::new(actor.actor_id()),
to: ObjectId::new(community.actor_id()),
to: [ObjectId::new(community.actor_id())],
object: object_id,
summary: reason,
kind,
id: id.clone(),
unparsed: Default::default(),
};
send_lemmy_activity(
context,
&report,
&id,
actor,
vec![community.shared_inbox_or_inbox_url()],
false,
)
.await
let inbox = vec![community.shared_inbox_or_inbox()];
send_lemmy_activity(context, report, actor, inbox, false).await
}
}
@ -78,9 +74,8 @@ impl ActivityHandler for Report {
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
let community = self
.to
.dereference::<LemmyError>(context, local_instance(context), request_counter)
let community = self.to[0]
.dereference(context, local_instance(context), request_counter)
.await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
Ok(())
@ -94,11 +89,11 @@ impl ActivityHandler for Report {
) -> Result<(), LemmyError> {
let actor = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
match self
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?
{
PostOrComment::Post(post) => {

View file

@ -49,7 +49,7 @@ impl UpdateCommunity {
};
let activity = AnnouncableActivities::UpdateCommunity(update);
send_activity_in_community(activity, &id, actor, &community, vec![], context).await
send_activity_in_community(activity, actor, &community, vec![], context).await
}
}
@ -139,7 +139,7 @@ impl GetCommunity for UpdateCommunity {
) -> Result<ApubCommunity, LemmyError> {
let cid = ObjectId::new(self.object.id.clone());
cid
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await
}
}

View file

@ -17,7 +17,7 @@ use crate::{
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::{ActivityHandler, ApubObject},
traits::{ActivityHandler, Actor, ApubObject},
utils::verify_domains_match,
};
use activitystreams_kinds::public;
@ -86,13 +86,13 @@ impl CreateOrUpdateComment {
let mut inboxes = vec![];
for t in tagged_users {
let person = t
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
inboxes.push(person.shared_inbox_or_inbox_url());
inboxes.push(person.shared_inbox_or_inbox());
}
let activity = AnnouncableActivities::CreateOrUpdateComment(create_or_update);
send_activity_in_community(activity, &id, actor, &community, inboxes, context).await
send_activity_in_community(activity, actor, &community, inboxes, context).await
}
}

View file

@ -24,7 +24,7 @@ async fn get_comment_notif_recipients(
let post_id = comment.post_id;
let post = blocking(context.pool(), move |conn| Post::read(conn, post_id)).await??;
let actor = actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
// Note:

View file

@ -69,9 +69,8 @@ impl CreateOrUpdatePost {
.into();
let create_or_update = CreateOrUpdatePost::new(post, actor, &community, kind, context).await?;
let id = create_or_update.id.clone();
let activity = AnnouncableActivities::CreateOrUpdatePost(Box::new(create_or_update));
send_activity_in_community(activity, &id, actor, &community, vec![], context).await
send_activity_in_community(activity, actor, &community, vec![], context).await
}
}

View file

@ -10,7 +10,7 @@ use crate::{
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::{ActivityHandler, ApubObject},
traits::{ActivityHandler, Actor, ApubObject},
utils::verify_domains_match,
};
use lemmy_api_common::utils::blocking;
@ -40,13 +40,13 @@ impl CreateOrUpdatePrivateMessage {
let create_or_update = CreateOrUpdatePrivateMessage {
id: id.clone(),
actor: ObjectId::new(actor.actor_id()),
to: ObjectId::new(recipient.actor_id()),
to: [ObjectId::new(recipient.actor_id())],
object: private_message.into_apub(context).await?,
kind,
unparsed: Default::default(),
};
let inbox = vec![recipient.shared_inbox_or_inbox_url()];
send_lemmy_activity(context, &create_or_update, &id, actor, inbox, true).await
let inbox = vec![recipient.shared_inbox_or_inbox()];
send_lemmy_activity(context, create_or_update, actor, inbox, true).await
}
}
@ -71,7 +71,7 @@ impl ActivityHandler for CreateOrUpdatePrivateMessage {
) -> Result<(), LemmyError> {
verify_person(&self.actor, context, request_counter).await?;
verify_domains_match(self.actor.inner(), self.object.id.inner())?;
verify_domains_match(self.to.inner(), self.object.to.inner())?;
verify_domains_match(self.to[0].inner(), self.object.to[0].inner())?;
ApubPrivateMessage::verify(&self.object, self.actor.inner(), context, request_counter).await?;
Ok(())
}

View file

@ -24,7 +24,6 @@ use lemmy_db_schema::{
ModRemovePost,
ModRemovePostForm,
},
person::Person,
post::Post,
},
traits::Crud,
@ -77,7 +76,7 @@ impl ActivityHandler for Delete {
receive_remove_action(
&self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?,
self.object.id(),
reason,
@ -99,7 +98,7 @@ impl ActivityHandler for Delete {
impl Delete {
pub(in crate::activities::deletion) fn new(
actor: &Person,
actor: &ApubPerson,
object: DeletableObjects,
to: Url,
community: Option<&Community>,

View file

@ -1,7 +1,7 @@
use crate::{
activities::{generate_activity_id, send_lemmy_activity, verify_is_public, verify_person},
local_instance,
objects::person::ApubPerson,
objects::{instance::remote_instance_inboxes, person::ApubPerson},
protocol::activities::deletion::delete_user::DeleteUser,
};
use activitypub_federation::{
@ -11,8 +11,7 @@ use activitypub_federation::{
utils::verify_urls_match,
};
use activitystreams_kinds::{activity::DeleteType, public};
use lemmy_api_common::utils::{blocking, delete_user_account};
use lemmy_db_schema::source::site::Site;
use lemmy_api_common::utils::delete_user_account;
use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext;
use url::Url;
@ -50,7 +49,7 @@ impl ActivityHandler for DeleteUser {
) -> Result<(), LemmyError> {
let actor = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
delete_user_account(actor.id, context.pool()).await?;
Ok(())
@ -74,12 +73,8 @@ impl DeleteUser {
cc: vec![],
};
let remote_sites = blocking(context.pool(), Site::read_remote_sites).await??;
let inboxes = remote_sites
.into_iter()
.map(|s| s.inbox_url.into())
.collect();
send_lemmy_activity(context, &delete, &id, actor, inboxes, true).await?;
let inboxes = remote_instance_inboxes(context.pool()).await?;
send_lemmy_activity(context, delete, actor, inboxes, true).await?;
Ok(())
}
}

View file

@ -21,7 +21,7 @@ use crate::{
};
use activitypub_federation::{
core::object_id::ObjectId,
traits::ApubObject,
traits::{Actor, ApubObject},
utils::verify_domains_match,
};
use activitystreams_kinds::public;
@ -65,22 +65,15 @@ pub async fn send_apub_delete_in_community(
deleted: bool,
context: &LemmyContext,
) -> Result<(), LemmyError> {
let (id, activity) = if deleted {
let actor = ApubPerson::from(actor);
let activity = if deleted {
let delete = Delete::new(&actor, object, public(), Some(&community), reason, context)?;
(delete.id.clone(), AnnouncableActivities::Delete(delete))
AnnouncableActivities::Delete(delete)
} else {
let undo = UndoDelete::new(&actor, object, public(), Some(&community), reason, context)?;
(undo.id.clone(), AnnouncableActivities::UndoDelete(undo))
AnnouncableActivities::UndoDelete(undo)
};
send_activity_in_community(
activity,
&id,
&ApubPerson::from(actor),
&community.into(),
vec![],
context,
)
.await
send_activity_in_community(activity, &actor, &community.into(), vec![], context).await
}
#[tracing::instrument(skip_all)]
@ -97,15 +90,13 @@ pub async fn send_apub_delete_private_message(
.into();
let deletable = DeletableObjects::PrivateMessage(Box::new(pm.into()));
let inbox = vec![recipient.shared_inbox_or_inbox_url()];
let inbox = vec![recipient.shared_inbox_or_inbox()];
if deleted {
let delete = Delete::new(actor, deletable, recipient.actor_id(), None, None, context)?;
let id = delete.id.clone();
send_lemmy_activity(context, &delete, &id, actor, inbox, true).await?;
send_lemmy_activity(context, delete, actor, inbox, true).await?;
} else {
let undo = UndoDelete::new(actor, deletable, recipient.actor_id(), None, None, context)?;
let id = undo.id.clone();
send_lemmy_activity(context, &undo, &id, actor, inbox, true).await?;
send_lemmy_activity(context, undo, actor, inbox, true).await?;
};
Ok(())
}
@ -238,7 +229,7 @@ async fn receive_delete_action(
DeletableObjects::Community(community) => {
if community.local {
let mod_: Person = actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?
.deref()
.clone();

View file

@ -23,7 +23,6 @@ use lemmy_db_schema::{
ModRemovePost,
ModRemovePostForm,
},
person::Person,
post::Post,
},
traits::Crud,
@ -76,7 +75,7 @@ impl ActivityHandler for UndoDelete {
UndoDelete::receive_undo_remove_action(
&self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?,
self.object.object.id(),
context,
@ -98,7 +97,7 @@ impl ActivityHandler for UndoDelete {
impl UndoDelete {
#[tracing::instrument(skip_all)]
pub(in crate::activities::deletion) fn new(
actor: &Person,
actor: &ApubPerson,
object: DeletableObjects,
to: Url,
community: Option<&Community>,

View file

@ -7,7 +7,7 @@ use crate::{
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::ActivityHandler,
traits::{ActivityHandler, Actor},
utils::verify_urls_match,
};
use activitystreams_kinds::activity::AcceptType;
@ -24,14 +24,11 @@ impl AcceptFollowCommunity {
context: &LemmyContext,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
let community = follow
.object
.dereference_local::<LemmyError>(context)
.await?;
let community = follow.object.dereference_local(context).await?;
let person = follow
.actor
.clone()
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let accept = AcceptFollowCommunity {
actor: ObjectId::new(community.actor_id()),
@ -43,8 +40,8 @@ impl AcceptFollowCommunity {
)?,
unparsed: Default::default(),
};
let inbox = vec![person.inbox_url()];
send_lemmy_activity(context, &accept, &accept.id, &community, inbox, true).await
let inbox = vec![person.shared_inbox_or_inbox()];
send_lemmy_activity(context, accept, &community, inbox, true).await
}
}
@ -81,12 +78,12 @@ impl ActivityHandler for AcceptFollowCommunity {
) -> Result<(), LemmyError> {
let person = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let community = self
.object
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
// This will throw an error if no follow was requested
blocking(context.pool(), move |conn| {

View file

@ -10,7 +10,11 @@ use crate::{
protocol::activities::following::{accept::AcceptFollowCommunity, follow::FollowCommunity},
ActorType,
};
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::{ActivityHandler, Actor},
};
use activitystreams_kinds::activity::FollowType;
use lemmy_api_common::utils::blocking;
use lemmy_db_schema::{
@ -56,8 +60,8 @@ impl FollowCommunity {
.await?;
let follow = FollowCommunity::new(actor, community, context)?;
let inbox = vec![community.inbox_url.clone().into()];
send_lemmy_activity(context, &follow, &follow.id, actor, inbox, true).await
let inbox = vec![community.shared_inbox_or_inbox()];
send_lemmy_activity(context, follow, actor, inbox, true).await
}
}
@ -83,7 +87,7 @@ impl ActivityHandler for FollowCommunity {
verify_person(&self.actor, context, request_counter).await?;
let community = self
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
Ok(())
@ -97,11 +101,11 @@ impl ActivityHandler for FollowCommunity {
) -> Result<(), LemmyError> {
let person = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let community = self
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let community_follower_form = CommunityFollowerForm {
community_id: community.id,

View file

@ -8,7 +8,7 @@ use crate::{
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::ActivityHandler,
traits::{ActivityHandler, Actor},
utils::verify_urls_match,
};
use activitystreams_kinds::activity::UndoType;
@ -39,8 +39,8 @@ impl UndoFollowCommunity {
)?,
unparsed: Default::default(),
};
let inbox = vec![community.shared_inbox_or_inbox_url()];
send_lemmy_activity(context, &undo, &undo.id, actor, inbox, true).await
let inbox = vec![community.shared_inbox_or_inbox()];
send_lemmy_activity(context, undo, actor, inbox, true).await
}
}
@ -77,12 +77,12 @@ impl ActivityHandler for UndoFollowCommunity {
) -> Result<(), LemmyError> {
let person = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let community = self
.object
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let community_follower_form = CommunityFollowerForm {

View file

@ -7,8 +7,9 @@ use crate::{
CONTEXT,
};
use activitypub_federation::{
core::{activity_queue::SendActivity, object_id::ObjectId},
core::{activity_queue::send_activity, object_id::ObjectId},
deser::context::WithContext,
traits::{ActivityHandler, Actor},
};
use activitystreams_kinds::public;
use anyhow::anyhow;
@ -39,7 +40,7 @@ async fn verify_person(
request_counter: &mut i32,
) -> Result<(), LemmyError> {
let person = person_id
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
if person.banned {
let err = anyhow!("Person {} is banned", person_id);
@ -58,7 +59,7 @@ pub(crate) async fn verify_person_in_community(
request_counter: &mut i32,
) -> Result<(), LemmyError> {
let person = person_id
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
if person.banned {
return Err(LemmyError::from_message("Person is banned from site"));
@ -91,7 +92,7 @@ pub(crate) async fn verify_mod_action(
) -> Result<(), LemmyError> {
if community.local {
let actor = mod_id
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
// Note: this will also return true for admins in addition to mods, but as we dont know about
@ -166,42 +167,31 @@ where
}
#[tracing::instrument(skip_all)]
async fn send_lemmy_activity<T: Serialize>(
async fn send_lemmy_activity<Activity, ActorT>(
context: &LemmyContext,
activity: &T,
activity_id: &Url,
actor: &dyn ActorType,
inboxes: Vec<Url>,
activity: Activity,
actor: &ActorT,
inbox: Vec<Url>,
sensitive: bool,
) -> Result<(), LemmyError> {
if !context.settings().federation.enabled || inboxes.is_empty() {
return Ok(());
}
) -> Result<(), LemmyError>
where
Activity: ActivityHandler + Serialize,
ActorT: Actor + ActorType,
Activity: ActivityHandler<Error = LemmyError>,
{
info!("Sending activity {}", activity.id().to_string());
let activity = WithContext::new(activity, CONTEXT.deref().clone());
info!("Sending activity {}", activity_id.to_string());
// Don't send anything to ourselves
// TODO: this should be a debug assert
let hostname = context.settings().get_hostname_without_port()?;
let inboxes: Vec<Url> = inboxes
.into_iter()
.filter(|i| i.domain().expect("valid inbox url") != hostname)
.collect();
let serialised_activity = serde_json::to_string(&activity)?;
let object_value = serde_json::to_value(&activity)?;
insert_activity(activity_id, object_value, true, sensitive, context.pool()).await?;
insert_activity(activity.id(), object_value, true, sensitive, context.pool()).await?;
SendActivity {
activity_id: activity_id.clone(),
actor_public_key: actor.get_public_key(),
actor_private_key: actor.private_key().expect("actor has private key"),
inboxes,
activity: serialised_activity,
}
.send(local_instance(context))
send_activity(
activity,
actor.get_public_key(),
actor.private_key().expect("actor has private key"),
inbox,
local_instance(context),
)
.await?;
Ok(())

View file

@ -61,7 +61,7 @@ impl UndoVote {
unparsed: Default::default(),
};
let activity = AnnouncableActivities::UndoVote(undo_vote);
send_activity_in_community(activity, &id, actor, &community, vec![], context).await
send_activity_in_community(activity, actor, &community, vec![], context).await
}
}
@ -99,12 +99,12 @@ impl ActivityHandler for UndoVote {
) -> Result<(), LemmyError> {
let actor = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let object = self
.object
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
match object {
PostOrComment::Post(p) => undo_vote_post(actor, &p, context).await,

View file

@ -60,10 +60,9 @@ impl Vote {
.await??
.into();
let vote = Vote::new(object, actor, &community, kind, context)?;
let vote_id = vote.id.clone();
let activity = AnnouncableActivities::Vote(vote);
send_activity_in_community(activity, &vote_id, actor, &community, vec![], context).await
send_activity_in_community(activity, actor, &community, vec![], context).await
}
}
@ -103,11 +102,11 @@ impl ActivityHandler for Vote {
) -> Result<(), LemmyError> {
let actor = self
.actor
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let object = self
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
match object {
PostOrComment::Post(p) => vote_post(&self.kind, actor, &p, context).await,
@ -126,7 +125,7 @@ impl GetCommunity for Vote {
) -> Result<ApubCommunity, LemmyError> {
let object = self
.object
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let cid = match object {
PostOrComment::Post(p) => p.community_id,

View file

@ -112,7 +112,7 @@ impl ApubObject for ApubCommunityModerators {
for mod_id in apub.ordered_items {
let mod_id = ObjectId::new(mod_id);
let mod_user: ApubPerson = mod_id
.dereference::<LemmyError>(&data.1, local_instance(&data.1), request_counter)
.dereference(&data.1, local_instance(&data.1), request_counter)
.await?;
if !current_moderators

View file

@ -28,7 +28,7 @@ pub async fn search_by_apub_id(
match Url::parse(query) {
Ok(url) => {
ObjectId::new(url)
.dereference::<LemmyError>(context, instance, request_counter)
.dereference(context, instance, request_counter)
.await
}
Err(_) => {
@ -39,7 +39,7 @@ pub async fn search_by_apub_id(
webfinger_resolve_actor::<ApubPerson>(identifier, context, request_counter).await?;
Ok(SearchableObjects::Person(
ObjectId::new(id)
.dereference::<LemmyError>(context, instance, request_counter)
.dereference(context, instance, request_counter)
.await?,
))
}
@ -48,7 +48,7 @@ pub async fn search_by_apub_id(
webfinger_resolve_actor::<ApubCommunity>(identifier, context, request_counter).await?;
Ok(SearchableObjects::Community(
ObjectId::new(id)
.dereference::<LemmyError>(context, instance, request_counter)
.dereference(context, instance, request_counter)
.await?,
))
}

View file

@ -2,7 +2,7 @@ use crate::{
objects::{community::ApubCommunity, person::ApubPerson},
protocol::objects::{group::Group, person::Person},
};
use activitypub_federation::{core::inbox::ActorPublicKey, traits::ApubObject};
use activitypub_federation::traits::{Actor, ApubObject};
use chrono::NaiveDateTime;
use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext;
@ -102,11 +102,15 @@ impl ApubObject for UserOrCommunity {
}
}
impl ActorPublicKey for UserOrCommunity {
impl Actor for UserOrCommunity {
fn public_key(&self) -> &str {
match self {
UserOrCommunity::User(p) => p.public_key(),
UserOrCommunity::Community(p) => p.public_key(),
}
}
fn inbox(&self) -> Url {
unimplemented!()
}
}

View file

@ -69,7 +69,7 @@ where
.collect();
for l in links {
let object = ObjectId::<Kind>::new(l)
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await;
if object.is_ok() {
return object.map(|o| o.actor_id().into());

View file

@ -86,7 +86,7 @@ pub(crate) async fn get_apub_community_outbox(
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::<LemmyError>(&outbox_data, local_instance(&context), &mut 0)
.dereference(&outbox_data, local_instance(&context), &mut 0)
.await?;
Ok(create_apub_response(&outbox.into_apub(&outbox_data).await?))
}
@ -104,7 +104,7 @@ pub(crate) async fn get_apub_community_moderators(
let id = ObjectId::new(generate_outbox_url(&community.actor_id)?);
let outbox_data = CommunityContext(community, context.get_ref().clone());
let moderators: ApubCommunityModerators = id
.dereference::<LemmyError>(&outbox_data, local_instance(&context), &mut 0)
.dereference(&outbox_data, local_instance(&context), &mut 0)
.await?;
Ok(create_apub_response(
&moderators.into_apub(&outbox_data).await?,

View file

@ -7,10 +7,10 @@ use crate::{
CONTEXT,
};
use activitypub_federation::{
core::inbox::{receive_activity, ActorPublicKey},
core::inbox::receive_activity,
data::Data,
deser::context::WithContext,
traits::{ActivityHandler, ApubObject},
traits::{ActivityHandler, Actor, ApubObject},
APUB_JSON_CONTENT_TYPE,
};
use actix_web::{web, HttpRequest, HttpResponse};
@ -42,7 +42,7 @@ pub async fn shared_inbox(
receive_lemmy_activity::<SharedInboxActivities, UserOrCommunity>(request, payload, context).await
}
pub async fn receive_lemmy_activity<Activity, Actor>(
pub async fn receive_lemmy_activity<Activity, ActorT>(
request: HttpRequest,
payload: String,
context: web::Data<LemmyContext>,
@ -52,8 +52,8 @@ where
+ DeserializeOwned
+ Send
+ 'static,
Actor: ApubObject<DataType = LemmyContext, Error = LemmyError> + ActorPublicKey + Send + 'static,
for<'de2> <Actor as ApubObject>::ApubType: serde::Deserialize<'de2>,
ActorT: ApubObject<DataType = LemmyContext, Error = LemmyError> + Actor + Send + 'static,
for<'de2> <ActorT as ApubObject>::ApubType: serde::Deserialize<'de2>,
{
let activity_value: Value = serde_json::from_str(&payload)?;
let activity: Activity = serde_json::from_value(activity_value.clone())?;
@ -67,7 +67,7 @@ where
static DATA: OnceCell<Data<LemmyContext>> = OnceCell::new();
let data = DATA.get_or_init(|| Data::new(context.get_ref().clone()));
receive_activity::<Activity, Actor, LemmyContext, LemmyError>(
receive_activity::<Activity, ActorT, LemmyContext>(
request,
activity,
local_instance(&context),

View file

@ -1,6 +1,7 @@
use crate::fetcher::post_or_comment::PostOrComment;
use activitypub_federation::{
core::{inbox::ActorPublicKey, signatures::PublicKey},
core::signatures::PublicKey,
traits::{Actor, ApubObject},
InstanceSettingsBuilder,
LocalInstance,
};
@ -10,7 +11,6 @@ use lemmy_db_schema::{newtypes::DbUrl, source::activity::Activity, utils::DbPool
use lemmy_utils::{error::LemmyError, location_info, settings::structs::Settings};
use lemmy_websocket::LemmyContext;
use once_cell::sync::{Lazy, OnceCell};
use std::env;
use url::{ParseError, Url};
pub mod activities;
@ -33,7 +33,7 @@ fn local_instance(context: &LemmyContext) -> &'static LocalInstance {
let settings = InstanceSettingsBuilder::default()
.http_fetch_retry_limit(context.settings().http_fetch_retry_limit)
.worker_count(context.settings().federation.worker_count)
.testing_send_sync(env::var("APUB_TESTING_SEND_SYNC").is_ok())
.debug(context.settings().federation.debug)
.verify_url_function(|url| check_apub_id_valid(url, &Settings::get()))
.build()
.expect("configure federation");
@ -204,19 +204,11 @@ async fn insert_activity(
/// Common methods provided by ActivityPub actors (community and person). Not all methods are
/// implemented by all actors.
pub trait ActorType: ActorPublicKey {
pub trait ActorType: Actor + ApubObject {
fn actor_id(&self) -> Url;
fn private_key(&self) -> Option<String>;
fn inbox_url(&self) -> Url;
fn shared_inbox_url(&self) -> Option<Url>;
fn shared_inbox_or_inbox_url(&self) -> Url {
self.shared_inbox_url().unwrap_or_else(|| self.inbox_url())
}
fn get_public_key(&self) -> PublicKey {
PublicKey::new_main_key(self.actor_id(), self.public_key().to_string())
}

View file

@ -168,7 +168,7 @@ impl ApubObject for ApubComment {
) -> Result<ApubComment, LemmyError> {
let creator = note
.attributed_to
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let (post, parent_comment_id) = note.get_parents(context, request_counter).await?;

View file

@ -13,8 +13,8 @@ use crate::{
ActorType,
};
use activitypub_federation::{
core::{inbox::ActorPublicKey, object_id::ObjectId},
traits::ApubObject,
core::object_id::ObjectId,
traits::{Actor, ApubObject},
};
use activitystreams_kinds::actor::GroupType;
use chrono::NaiveDateTime;
@ -139,14 +139,14 @@ impl ApubObject for ApubCommunity {
group
.outbox
.dereference::<LemmyError>(&outbox_data, local_instance(context), request_counter)
.dereference(&outbox_data, local_instance(context), request_counter)
.await
.map_err(|e| debug!("{}", e))
.ok();
if let Some(moderators) = &group.moderators {
moderators
.dereference::<LemmyError>(&outbox_data, local_instance(context), request_counter)
.dereference(&outbox_data, local_instance(context), request_counter)
.await
.map_err(|e| debug!("{}", e))
.ok();
@ -158,6 +158,20 @@ impl ApubObject for ApubCommunity {
}
}
impl Actor for ApubCommunity {
fn public_key(&self) -> &str {
&self.public_key
}
fn inbox(&self) -> Url {
self.inbox_url.clone().into()
}
fn shared_inbox(&self) -> Option<Url> {
self.shared_inbox_url.clone().map(|s| s.into())
}
}
impl ActorType for ApubCommunity {
fn actor_id(&self) -> Url {
self.actor_id.to_owned().into()
@ -165,20 +179,6 @@ impl ActorType for ApubCommunity {
fn private_key(&self) -> Option<String> {
self.private_key.to_owned()
}
fn inbox_url(&self) -> Url {
self.inbox_url.clone().into()
}
fn shared_inbox_url(&self) -> Option<Url> {
self.shared_inbox_url.clone().map(|s| s.into())
}
}
impl ActorPublicKey for ApubCommunity {
fn public_key(&self) -> &str {
&self.public_key
}
}
impl ApubCommunity {

View file

@ -10,16 +10,16 @@ use crate::{
ActorType,
};
use activitypub_federation::{
core::{inbox::ActorPublicKey, object_id::ObjectId},
core::object_id::ObjectId,
deser::values::MediaTypeHtml,
traits::ApubObject,
traits::{Actor, ApubObject},
utils::verify_domains_match,
};
use chrono::NaiveDateTime;
use lemmy_api_common::utils::blocking;
use lemmy_db_schema::{
source::site::{Site, SiteForm},
utils::naive_now,
utils::{naive_now, DbPool},
};
use lemmy_utils::{
error::LemmyError,
@ -147,20 +147,16 @@ impl ActorType for ApubSite {
fn private_key(&self) -> Option<String> {
self.private_key.to_owned()
}
fn inbox_url(&self) -> Url {
self.inbox_url.clone().into()
}
fn shared_inbox_url(&self) -> Option<Url> {
None
}
}
impl ActorPublicKey for ApubSite {
impl Actor for ApubSite {
fn public_key(&self) -> &str {
&self.public_key
}
fn inbox(&self) -> Url {
self.inbox_url.clone().into()
}
}
/// Instance actor is at the root path, so we simply need to clear the path and other unnecessary
@ -181,13 +177,23 @@ pub(in crate::objects) async fn fetch_instance_actor_for_object(
// try to fetch the instance actor (to make things like instance rules available)
let instance_id = instance_actor_id_from_url(object_id);
let site = ObjectId::<ApubSite>::new(instance_id.clone())
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await;
if let Err(e) = site {
debug!("Failed to dereference site for {}: {}", instance_id, e);
}
}
pub(crate) async fn remote_instance_inboxes(pool: &DbPool) -> Result<Vec<Url>, LemmyError> {
Ok(
blocking(pool, Site::read_remote_sites)
.await??
.into_iter()
.map(|s| ApubSite::from(s).shared_inbox_or_inbox())
.collect(),
)
}
#[cfg(test)]
pub(crate) mod tests {
use super::*;

View file

@ -13,8 +13,8 @@ use crate::{
ActorType,
};
use activitypub_federation::{
core::{inbox::ActorPublicKey, object_id::ObjectId},
traits::ApubObject,
core::object_id::ObjectId,
traits::{Actor, ApubObject},
utils::verify_domains_match,
};
use chrono::NaiveDateTime;
@ -182,22 +182,22 @@ impl ActorType for ApubPerson {
fn private_key(&self) -> Option<String> {
self.private_key.to_owned()
}
}
fn inbox_url(&self) -> Url {
impl Actor for ApubPerson {
fn public_key(&self) -> &str {
&self.public_key
}
fn inbox(&self) -> Url {
self.inbox_url.clone().into()
}
fn shared_inbox_url(&self) -> Option<Url> {
fn shared_inbox(&self) -> Option<Url> {
self.shared_inbox_url.clone().map(|s| s.into())
}
}
impl ActorPublicKey for ApubPerson {
fn public_key(&self) -> &str {
&self.public_key
}
}
#[cfg(test)]
pub(crate) mod tests {
use super::*;

View file

@ -152,7 +152,7 @@ impl ApubObject for ApubPost {
) -> Result<ApubPost, LemmyError> {
let creator = page
.creator()?
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let community = page.extract_community(context, request_counter).await?;
@ -215,7 +215,7 @@ impl ApubObject for ApubPost {
// read existing, local post if any (for generating mod log)
let old_post = ObjectId::<ApubPost>::new(page.id.clone())
.dereference_local::<LemmyError>(context)
.dereference_local(context)
.await;
let post = blocking(context.pool(), move |conn| Post::upsert(conn, &form)).await??;

View file

@ -90,7 +90,7 @@ impl ApubObject for ApubPrivateMessage {
r#type: ChatMessageType::ChatMessage,
id: ObjectId::new(self.ap_id.clone()),
attributed_to: ObjectId::new(creator.actor_id),
to: ObjectId::new(recipient.actor_id),
to: [ObjectId::new(recipient.actor_id)],
content: markdown_to_html(&self.content),
media_type: Some(MediaTypeHtml::Html),
source: Some(Source::new(self.content.clone())),
@ -112,7 +112,7 @@ impl ApubObject for ApubPrivateMessage {
check_apub_id_valid_with_strictness(note.id.inner(), false, &Settings::get())?;
let person = note
.attributed_to
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
if person.banned {
return Err(LemmyError::from_message("Person is banned from site"));
@ -128,11 +128,10 @@ impl ApubObject for ApubPrivateMessage {
) -> Result<ApubPrivateMessage, LemmyError> {
let creator = note
.attributed_to
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?;
let recipient = note
.to
.dereference::<LemmyError>(context, local_instance(context), request_counter)
let recipient = note.to[0]
.dereference(context, local_instance(context), request_counter)
.await?;
let form = PrivateMessageForm {

View file

@ -13,7 +13,7 @@ use url::Url;
pub struct Report {
pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "deserialize_one")]
pub(crate) to: ObjectId<ApubCommunity>,
pub(crate) to: [ObjectId<ApubCommunity>; 1],
pub(crate) object: ObjectId<PostOrComment>,
pub(crate) summary: String,
#[serde(rename = "type")]

View file

@ -12,7 +12,7 @@ pub struct CreateOrUpdatePrivateMessage {
pub(crate) id: Url,
pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "deserialize_one")]
pub(crate) to: ObjectId<ApubPerson>,
pub(crate) to: [ObjectId<ApubPerson>; 1],
pub(crate) object: ChatMessage,
#[serde(rename = "type")]
pub(crate) kind: CreateOrUpdateType,

View file

@ -21,7 +21,7 @@ pub struct ChatMessage {
pub(crate) id: ObjectId<ApubPrivateMessage>,
pub(crate) attributed_to: ObjectId<ApubPerson>,
#[serde(deserialize_with = "deserialize_one")]
pub(crate) to: ObjectId<ApubPerson>,
pub(crate) to: [ObjectId<ApubPerson>; 1],
pub(crate) content: String,
pub(crate) media_type: Option<MediaTypeHtml>,

View file

@ -56,7 +56,7 @@ impl Note {
let parent = Box::pin(
self
.in_reply_to
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await?,
);
match parent.deref() {

View file

@ -93,7 +93,7 @@ impl Page {
/// Both stickied and locked need to be false on a newly created post (verified in [[CreatePost]].
pub(crate) async fn is_mod_action(&self, context: &LemmyContext) -> Result<bool, LemmyError> {
let old_post = ObjectId::<ApubPost>::new(self.id.clone())
.dereference_local::<LemmyError>(context)
.dereference_local(context)
.await;
let stickied_changed = Page::is_stickied_changed(&old_post, &self.stickied);
@ -139,7 +139,7 @@ impl Page {
if let Some(cid) = iter.next() {
let cid = ObjectId::new(cid.clone());
if let Ok(c) = cid
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await
{
break Ok(c);
@ -154,7 +154,7 @@ impl Page {
.find(|a| a.kind == PersonOrGroupType::Group)
.map(|a| ObjectId::<ApubCommunity>::new(a.id.clone().into_inner()))
.ok_or_else(|| LemmyError::from_message("page does not specify group"))?
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.dereference(context, local_instance(context), request_counter)
.await
}
}

View file

@ -23,7 +23,7 @@ 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 }
activitypub_federation = { version = "0.1.0", 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 }

View file

@ -135,6 +135,10 @@ pub struct FederationConfig {
/// increase it.
#[default(64)]
pub worker_count: u64,
/// Use federation debug mode. Allows connecting to http and localhost urls. Also sends outgoing
/// activities synchronously for easier testing. Do not use in production.
#[default(false)]
pub debug: bool,
}
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]

View file

@ -40,7 +40,6 @@ services:
volumes:
- ./lemmy_alpha.hjson:/config/config.hjson
environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on:
@ -69,7 +68,6 @@ services:
volumes:
- ./lemmy_beta.hjson:/config/config.hjson
environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on:
@ -98,7 +96,6 @@ services:
volumes:
- ./lemmy_gamma.hjson:/config/config.hjson
environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on:
@ -128,7 +125,6 @@ services:
volumes:
- ./lemmy_delta.hjson:/config/config.hjson
environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on:
@ -158,7 +154,6 @@ services:
volumes:
- ./lemmy_epsilon.hjson:/config/config.hjson
environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on:

View file

@ -19,6 +19,7 @@
federation: {
enabled: true
allowed_instances: ["lemmy-beta","lemmy-gamma","lemmy-delta","lemmy-epsilon"]
debug: true
}
captcha: {
enabled: false

View file

@ -18,6 +18,7 @@
federation: {
enabled: true
allowed_instances: ["lemmy-alpha","lemmy-gamma","lemmy-delta","lemmy-epsilon"]
debug: true
}
captcha: {
enabled: false

View file

@ -18,6 +18,7 @@
federation: {
enabled: true
allowed_instances: ["lemmy-beta"]
debug: true
}
captcha: {
enabled: false

View file

@ -18,6 +18,7 @@
federation: {
enabled: true
blocked_instances: ["lemmy-alpha"]
debug: true
}
captcha: {
enabled: false

View file

@ -18,6 +18,7 @@
federation: {
enabled: true
allowed_instances: ["lemmy-alpha","lemmy-beta","lemmy-delta","lemmy-epsilon"]
debug: true
}
captcha: {
enabled: false