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

View file

@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -e
export APUB_TESTING_SEND_SYNC=1
export RUST_BACKTRACE=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" 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 # see information. If running number is consistently close to the worker_count, you should
# increase it. # increase it.
worker_count: 64 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: { captcha: {
# Whether captcha is required for signup # 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_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_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" } lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
activitypub_federation = "0.1.0" activitypub_federation = "0.2.0"
diesel = "1.4.8" diesel = "1.4.8"
bcrypt = "0.12.1" bcrypt = "0.12.1"
chrono = { version = "0.4.19", features = ["serde"], default-features = false } 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_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_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" } lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
activitypub_federation = "0.1.0" activitypub_federation = "0.2.0"
bcrypt = "0.12.1" bcrypt = "0.12.1"
serde_json = { version = "1.0.79", features = ["preserve_order"] } serde_json = { version = "1.0.79", features = ["preserve_order"] }
serde = { version = "1.0.136", features = ["derive"] } serde = { version = "1.0.136", features = ["derive"] }

View file

@ -76,9 +76,7 @@ impl PerformCrud for CreateCommunity {
&context.settings().get_protocol_and_hostname(), &context.settings().get_protocol_and_hostname(),
)?; )?;
let community_actor_id_wrapped = ObjectId::<ApubCommunity>::new(community_actor_id.clone()); let community_actor_id_wrapped = ObjectId::<ApubCommunity>::new(community_actor_id.clone());
let community_dupe = community_actor_id_wrapped let community_dupe = community_actor_id_wrapped.dereference_local(context).await;
.dereference_local::<LemmyError>(context)
.await;
if community_dupe.is_ok() { if community_dupe.is_ok() {
return Err(LemmyError::from_message("community_already_exists")); 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_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_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" } lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
activitypub_federation = "0.1.0" activitypub_federation = "0.2.0"
diesel = "1.4.8" diesel = "1.4.8"
activitystreams-kinds = "0.2.1" activitystreams-kinds = "0.2.1"
chrono = { version = "0.4.19", features = ["serde"], default-features = false } chrono = { version = "0.4.19", features = ["serde"], default-features = false }

View file

@ -1,6 +1,8 @@
{ {
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha", "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", "object": "http://enterprise.lemmy.ml/post/7",
"summary": "report this post", "summary": "report this post",
"type": "Flag", "type": "Flag",

View file

@ -1,12 +1,16 @@
{ {
"id": "http://enterprise.lemmy.ml/activities/create/987d05fa-f637-46d7-85be-13d112bc269f", "id": "http://enterprise.lemmy.ml/activities/create/987d05fa-f637-46d7-85be-13d112bc269f",
"actor": "http://enterprise.lemmy.ml/u/lemmy_beta", "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": { "object": {
"type": "ChatMessage", "type": "ChatMessage",
"id": "http://enterprise.lemmy.ml/private_message/1", "id": "http://enterprise.lemmy.ml/private_message/1",
"attributedTo": "http://enterprise.lemmy.ml/u/lemmy_beta", "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", "content": "hello",
"mediaType": "text/html", "mediaType": "text/html",
"source": { "source": {

View file

@ -2,7 +2,9 @@
"id": "https://enterprise.lemmy.ml/private_message/1621", "id": "https://enterprise.lemmy.ml/private_message/1621",
"type": "ChatMessage", "type": "ChatMessage",
"attributedTo": "https://enterprise.lemmy.ml/u/picard", "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", "content": "<p>Hello hello, testing</p>\n",
"mediaType": "text/html", "mediaType": "text/html",
"source": { "source": {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -49,7 +49,7 @@ impl UpdateCommunity {
}; };
let activity = AnnouncableActivities::UpdateCommunity(update); 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> { ) -> Result<ApubCommunity, LemmyError> {
let cid = ObjectId::new(self.object.id.clone()); let cid = ObjectId::new(self.object.id.clone());
cid cid
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await .await
} }
} }

View file

@ -17,7 +17,7 @@ use crate::{
use activitypub_federation::{ use activitypub_federation::{
core::object_id::ObjectId, core::object_id::ObjectId,
data::Data, data::Data,
traits::{ActivityHandler, ApubObject}, traits::{ActivityHandler, Actor, ApubObject},
utils::verify_domains_match, utils::verify_domains_match,
}; };
use activitystreams_kinds::public; use activitystreams_kinds::public;
@ -86,13 +86,13 @@ impl CreateOrUpdateComment {
let mut inboxes = vec![]; let mut inboxes = vec![];
for t in tagged_users { for t in tagged_users {
let person = t let person = t
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
inboxes.push(person.shared_inbox_or_inbox_url()); inboxes.push(person.shared_inbox_or_inbox());
} }
let activity = AnnouncableActivities::CreateOrUpdateComment(create_or_update); 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_id = comment.post_id;
let post = blocking(context.pool(), move |conn| Post::read(conn, post_id)).await??; let post = blocking(context.pool(), move |conn| Post::read(conn, post_id)).await??;
let actor = actor let actor = actor
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
// Note: // Note:

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -7,8 +7,9 @@ use crate::{
CONTEXT, CONTEXT,
}; };
use activitypub_federation::{ use activitypub_federation::{
core::{activity_queue::SendActivity, object_id::ObjectId}, core::{activity_queue::send_activity, object_id::ObjectId},
deser::context::WithContext, deser::context::WithContext,
traits::{ActivityHandler, Actor},
}; };
use activitystreams_kinds::public; use activitystreams_kinds::public;
use anyhow::anyhow; use anyhow::anyhow;
@ -39,7 +40,7 @@ async fn verify_person(
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let person = person_id let person = person_id
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
if person.banned { if person.banned {
let err = anyhow!("Person {} is banned", person_id); let err = anyhow!("Person {} is banned", person_id);
@ -58,7 +59,7 @@ pub(crate) async fn verify_person_in_community(
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let person = person_id let person = person_id
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
if person.banned { if person.banned {
return Err(LemmyError::from_message("Person is banned from site")); return Err(LemmyError::from_message("Person is banned from site"));
@ -91,7 +92,7 @@ pub(crate) async fn verify_mod_action(
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
if community.local { if community.local {
let actor = mod_id let actor = mod_id
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
// Note: this will also return true for admins in addition to mods, but as we dont know about // 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)] #[tracing::instrument(skip_all)]
async fn send_lemmy_activity<T: Serialize>( async fn send_lemmy_activity<Activity, ActorT>(
context: &LemmyContext, context: &LemmyContext,
activity: &T, activity: Activity,
activity_id: &Url, actor: &ActorT,
actor: &dyn ActorType, inbox: Vec<Url>,
inboxes: Vec<Url>,
sensitive: bool, sensitive: bool,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError>
if !context.settings().federation.enabled || inboxes.is_empty() { where
return Ok(()); 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()); 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)?; 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 { send_activity(
activity_id: activity_id.clone(), activity,
actor_public_key: actor.get_public_key(), actor.get_public_key(),
actor_private_key: actor.private_key().expect("actor has private key"), actor.private_key().expect("actor has private key"),
inboxes, inbox,
activity: serialised_activity, local_instance(context),
} )
.send(local_instance(context))
.await?; .await?;
Ok(()) Ok(())

View file

@ -61,7 +61,7 @@ impl UndoVote {
unparsed: Default::default(), unparsed: Default::default(),
}; };
let activity = AnnouncableActivities::UndoVote(undo_vote); 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> { ) -> Result<(), LemmyError> {
let actor = self let actor = self
.actor .actor
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
let object = self let object = self
.object .object
.object .object
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
match object { match object {
PostOrComment::Post(p) => undo_vote_post(actor, &p, context).await, PostOrComment::Post(p) => undo_vote_post(actor, &p, context).await,

View file

@ -60,10 +60,9 @@ impl Vote {
.await?? .await??
.into(); .into();
let vote = Vote::new(object, actor, &community, kind, context)?; let vote = Vote::new(object, actor, &community, kind, context)?;
let vote_id = vote.id.clone();
let activity = AnnouncableActivities::Vote(vote); 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> { ) -> Result<(), LemmyError> {
let actor = self let actor = self
.actor .actor
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
let object = self let object = self
.object .object
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
match object { match object {
PostOrComment::Post(p) => vote_post(&self.kind, actor, &p, context).await, PostOrComment::Post(p) => vote_post(&self.kind, actor, &p, context).await,
@ -126,7 +125,7 @@ impl GetCommunity for Vote {
) -> Result<ApubCommunity, LemmyError> { ) -> Result<ApubCommunity, LemmyError> {
let object = self let object = self
.object .object
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
let cid = match object { let cid = match object {
PostOrComment::Post(p) => p.community_id, PostOrComment::Post(p) => p.community_id,

View file

@ -112,7 +112,7 @@ impl ApubObject for ApubCommunityModerators {
for mod_id in apub.ordered_items { for mod_id in apub.ordered_items {
let mod_id = ObjectId::new(mod_id); let mod_id = ObjectId::new(mod_id);
let mod_user: ApubPerson = 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?; .await?;
if !current_moderators if !current_moderators

View file

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

View file

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

View file

@ -69,7 +69,7 @@ where
.collect(); .collect();
for l in links { for l in links {
let object = ObjectId::<Kind>::new(l) let object = ObjectId::<Kind>::new(l)
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await; .await;
if object.is_ok() { if object.is_ok() {
return object.map(|o| o.actor_id().into()); 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 id = ObjectId::new(generate_outbox_url(&community.actor_id)?);
let outbox_data = CommunityContext(community.into(), context.get_ref().clone()); let outbox_data = CommunityContext(community.into(), context.get_ref().clone());
let outbox: ApubCommunityOutbox = id let outbox: ApubCommunityOutbox = id
.dereference::<LemmyError>(&outbox_data, local_instance(&context), &mut 0) .dereference(&outbox_data, local_instance(&context), &mut 0)
.await?; .await?;
Ok(create_apub_response(&outbox.into_apub(&outbox_data).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 id = ObjectId::new(generate_outbox_url(&community.actor_id)?);
let outbox_data = CommunityContext(community, context.get_ref().clone()); let outbox_data = CommunityContext(community, context.get_ref().clone());
let moderators: ApubCommunityModerators = id let moderators: ApubCommunityModerators = id
.dereference::<LemmyError>(&outbox_data, local_instance(&context), &mut 0) .dereference(&outbox_data, local_instance(&context), &mut 0)
.await?; .await?;
Ok(create_apub_response( Ok(create_apub_response(
&moderators.into_apub(&outbox_data).await?, &moderators.into_apub(&outbox_data).await?,

View file

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

View file

@ -1,6 +1,7 @@
use crate::fetcher::post_or_comment::PostOrComment; use crate::fetcher::post_or_comment::PostOrComment;
use activitypub_federation::{ use activitypub_federation::{
core::{inbox::ActorPublicKey, signatures::PublicKey}, core::signatures::PublicKey,
traits::{Actor, ApubObject},
InstanceSettingsBuilder, InstanceSettingsBuilder,
LocalInstance, 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_utils::{error::LemmyError, location_info, settings::structs::Settings};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use once_cell::sync::{Lazy, OnceCell}; use once_cell::sync::{Lazy, OnceCell};
use std::env;
use url::{ParseError, Url}; use url::{ParseError, Url};
pub mod activities; pub mod activities;
@ -33,7 +33,7 @@ fn local_instance(context: &LemmyContext) -> &'static LocalInstance {
let settings = InstanceSettingsBuilder::default() let settings = InstanceSettingsBuilder::default()
.http_fetch_retry_limit(context.settings().http_fetch_retry_limit) .http_fetch_retry_limit(context.settings().http_fetch_retry_limit)
.worker_count(context.settings().federation.worker_count) .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())) .verify_url_function(|url| check_apub_id_valid(url, &Settings::get()))
.build() .build()
.expect("configure federation"); .expect("configure federation");
@ -204,19 +204,11 @@ async fn insert_activity(
/// Common methods provided by ActivityPub actors (community and person). Not all methods are /// Common methods provided by ActivityPub actors (community and person). Not all methods are
/// implemented by all actors. /// implemented by all actors.
pub trait ActorType: ActorPublicKey { pub trait ActorType: Actor + ApubObject {
fn actor_id(&self) -> Url; fn actor_id(&self) -> Url;
fn private_key(&self) -> Option<String>; 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 { fn get_public_key(&self) -> PublicKey {
PublicKey::new_main_key(self.actor_id(), self.public_key().to_string()) 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> { ) -> Result<ApubComment, LemmyError> {
let creator = note let creator = note
.attributed_to .attributed_to
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
let (post, parent_comment_id) = note.get_parents(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, ActorType,
}; };
use activitypub_federation::{ use activitypub_federation::{
core::{inbox::ActorPublicKey, object_id::ObjectId}, core::object_id::ObjectId,
traits::ApubObject, traits::{Actor, ApubObject},
}; };
use activitystreams_kinds::actor::GroupType; use activitystreams_kinds::actor::GroupType;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
@ -139,14 +139,14 @@ impl ApubObject for ApubCommunity {
group group
.outbox .outbox
.dereference::<LemmyError>(&outbox_data, local_instance(context), request_counter) .dereference(&outbox_data, local_instance(context), request_counter)
.await .await
.map_err(|e| debug!("{}", e)) .map_err(|e| debug!("{}", e))
.ok(); .ok();
if let Some(moderators) = &group.moderators { if let Some(moderators) = &group.moderators {
moderators moderators
.dereference::<LemmyError>(&outbox_data, local_instance(context), request_counter) .dereference(&outbox_data, local_instance(context), request_counter)
.await .await
.map_err(|e| debug!("{}", e)) .map_err(|e| debug!("{}", e))
.ok(); .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 { impl ActorType for ApubCommunity {
fn actor_id(&self) -> Url { fn actor_id(&self) -> Url {
self.actor_id.to_owned().into() self.actor_id.to_owned().into()
@ -165,20 +179,6 @@ impl ActorType for ApubCommunity {
fn private_key(&self) -> Option<String> { fn private_key(&self) -> Option<String> {
self.private_key.to_owned() 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 { impl ApubCommunity {

View file

@ -10,16 +10,16 @@ use crate::{
ActorType, ActorType,
}; };
use activitypub_federation::{ use activitypub_federation::{
core::{inbox::ActorPublicKey, object_id::ObjectId}, core::object_id::ObjectId,
deser::values::MediaTypeHtml, deser::values::MediaTypeHtml,
traits::ApubObject, traits::{Actor, ApubObject},
utils::verify_domains_match, utils::verify_domains_match,
}; };
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use lemmy_api_common::utils::blocking; use lemmy_api_common::utils::blocking;
use lemmy_db_schema::{ use lemmy_db_schema::{
source::site::{Site, SiteForm}, source::site::{Site, SiteForm},
utils::naive_now, utils::{naive_now, DbPool},
}; };
use lemmy_utils::{ use lemmy_utils::{
error::LemmyError, error::LemmyError,
@ -147,20 +147,16 @@ impl ActorType for ApubSite {
fn private_key(&self) -> Option<String> { fn private_key(&self) -> Option<String> {
self.private_key.to_owned() 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 { fn public_key(&self) -> &str {
&self.public_key &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 /// 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) // try to fetch the instance actor (to make things like instance rules available)
let instance_id = instance_actor_id_from_url(object_id); let instance_id = instance_actor_id_from_url(object_id);
let site = ObjectId::<ApubSite>::new(instance_id.clone()) let site = ObjectId::<ApubSite>::new(instance_id.clone())
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await; .await;
if let Err(e) = site { if let Err(e) = site {
debug!("Failed to dereference site for {}: {}", instance_id, e); 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)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use super::*; use super::*;

View file

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

View file

@ -152,7 +152,7 @@ impl ApubObject for ApubPost {
) -> Result<ApubPost, LemmyError> { ) -> Result<ApubPost, LemmyError> {
let creator = page let creator = page
.creator()? .creator()?
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
let community = page.extract_community(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) // read existing, local post if any (for generating mod log)
let old_post = ObjectId::<ApubPost>::new(page.id.clone()) let old_post = ObjectId::<ApubPost>::new(page.id.clone())
.dereference_local::<LemmyError>(context) .dereference_local(context)
.await; .await;
let post = blocking(context.pool(), move |conn| Post::upsert(conn, &form)).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, r#type: ChatMessageType::ChatMessage,
id: ObjectId::new(self.ap_id.clone()), id: ObjectId::new(self.ap_id.clone()),
attributed_to: ObjectId::new(creator.actor_id), 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), content: markdown_to_html(&self.content),
media_type: Some(MediaTypeHtml::Html), media_type: Some(MediaTypeHtml::Html),
source: Some(Source::new(self.content.clone())), 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())?; check_apub_id_valid_with_strictness(note.id.inner(), false, &Settings::get())?;
let person = note let person = note
.attributed_to .attributed_to
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
if person.banned { if person.banned {
return Err(LemmyError::from_message("Person is banned from site")); return Err(LemmyError::from_message("Person is banned from site"));
@ -128,11 +128,10 @@ impl ApubObject for ApubPrivateMessage {
) -> Result<ApubPrivateMessage, LemmyError> { ) -> Result<ApubPrivateMessage, LemmyError> {
let creator = note let creator = note
.attributed_to .attributed_to
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?; .await?;
let recipient = note let recipient = note.to[0]
.to .dereference(context, local_instance(context), request_counter)
.dereference::<LemmyError>(context, local_instance(context), request_counter)
.await?; .await?;
let form = PrivateMessageForm { let form = PrivateMessageForm {

View file

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

View file

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

View file

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

View file

@ -56,7 +56,7 @@ impl Note {
let parent = Box::pin( let parent = Box::pin(
self self
.in_reply_to .in_reply_to
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await?, .await?,
); );
match parent.deref() { 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]]. /// 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> { pub(crate) async fn is_mod_action(&self, context: &LemmyContext) -> Result<bool, LemmyError> {
let old_post = ObjectId::<ApubPost>::new(self.id.clone()) let old_post = ObjectId::<ApubPost>::new(self.id.clone())
.dereference_local::<LemmyError>(context) .dereference_local(context)
.await; .await;
let stickied_changed = Page::is_stickied_changed(&old_post, &self.stickied); let stickied_changed = Page::is_stickied_changed(&old_post, &self.stickied);
@ -139,7 +139,7 @@ impl Page {
if let Some(cid) = iter.next() { if let Some(cid) = iter.next() {
let cid = ObjectId::new(cid.clone()); let cid = ObjectId::new(cid.clone());
if let Ok(c) = cid if let Ok(c) = cid
.dereference::<LemmyError>(context, local_instance(context), request_counter) .dereference(context, local_instance(context), request_counter)
.await .await
{ {
break Ok(c); break Ok(c);
@ -154,7 +154,7 @@ impl Page {
.find(|a| a.kind == PersonOrGroupType::Group) .find(|a| a.kind == PersonOrGroupType::Group)
.map(|a| ObjectId::<ApubCommunity>::new(a.id.clone().into_inner())) .map(|a| ObjectId::<ApubCommunity>::new(a.id.clone().into_inner()))
.ok_or_else(|| LemmyError::from_message("page does not specify group"))? .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 .await
} }
} }

View file

@ -23,7 +23,7 @@ url = { version = "2.2.2", features = ["serde"] }
strum = "0.24.0" strum = "0.24.0"
strum_macros = "0.24.0" strum_macros = "0.24.0"
serde_json = { version = "1.0.79", features = ["preserve_order"], optional = true } 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 } lemmy_utils = { version = "=0.16.5", path = "../utils", optional = true }
bcrypt = { version = "0.12.1", optional = true } bcrypt = { version = "0.12.1", optional = true }
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"], 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. /// increase it.
#[default(64)] #[default(64)]
pub worker_count: u64, 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)] #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]

View file

@ -40,7 +40,6 @@ services:
volumes: volumes:
- ./lemmy_alpha.hjson:/config/config.hjson - ./lemmy_alpha.hjson:/config/config.hjson
environment: environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - 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" - 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: depends_on:
@ -69,7 +68,6 @@ services:
volumes: volumes:
- ./lemmy_beta.hjson:/config/config.hjson - ./lemmy_beta.hjson:/config/config.hjson
environment: environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - 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" - 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: depends_on:
@ -98,7 +96,6 @@ services:
volumes: volumes:
- ./lemmy_gamma.hjson:/config/config.hjson - ./lemmy_gamma.hjson:/config/config.hjson
environment: environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - 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" - 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: depends_on:
@ -128,7 +125,6 @@ services:
volumes: volumes:
- ./lemmy_delta.hjson:/config/config.hjson - ./lemmy_delta.hjson:/config/config.hjson
environment: environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - 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" - 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: depends_on:
@ -158,7 +154,6 @@ services:
volumes: volumes:
- ./lemmy_epsilon.hjson:/config/config.hjson - ./lemmy_epsilon.hjson:/config/config.hjson
environment: environment:
- APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - 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" - 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: depends_on:

View file

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

View file

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

View file

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

View file

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

View file

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