Extract Activitypub logic into separate library (#2288)

* Create example for apub lib

* some rewriting of apub lib

* Add LocalInstance struct for apub lib to avoid using Lemmy Settings

* Move ActorType trait to lemmy_apub, because its not needed in library

* Use reqwest_retry instead of custom impl, dont specify timeout on every send()

* Some improvements to example

* Moved inbox handling to library

* bug fixes

* Move context and serde helpers into library

* wip: example changes

* Add lemmy_utils feature to build only LemmyError

* Rename to activitypub_federation

* Remove lemmy_utils dep from activitypub_federation using generic error type

* Finish activitypub example

* Cleanup and fix tests

* Reorganize library files

* Remove ApubObject.to_tombstone()

* Extract activitypub library into separate git repository
This commit is contained in:
Nutomic 2022-06-02 14:33:41 +00:00 committed by GitHub
parent 1bd57ee5ca
commit a2a594b763
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
199 changed files with 1481 additions and 2234 deletions

489
Cargo.lock generated
View file

@ -2,6 +2,46 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 3
[[package]]
name = "activitypub_federation"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b34a144dc98c419543690aa8f182d8675ebe0610775982b8fdee84a00f70fe"
dependencies = [
"activitypub_federation_derive",
"actix-web",
"anyhow",
"async-trait",
"background-jobs",
"base64",
"chrono",
"derive_builder 0.11.2",
"http",
"http-signature-normalization-actix",
"http-signature-normalization-reqwest",
"once_cell",
"openssl",
"reqwest",
"reqwest-middleware",
"serde",
"serde_json",
"sha2",
"thiserror",
"tracing",
"url",
]
[[package]]
name = "activitypub_federation_derive"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a2aaf58676b669d3b0dedf6bbb44fa518b5a6657b2959561d77899c668dec2a"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
]
[[package]] [[package]]
name = "activitystreams-kinds" name = "activitystreams-kinds"
version = "0.2.1" version = "0.2.1"
@ -94,8 +134,8 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6"
dependencies = [ dependencies = [
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -245,9 +285,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7525bedf54704abb1d469e88d7e7e9226df73778798a69cea5022d53b2ae91bc" checksum = "7525bedf54704abb1d469e88d7e7e9226df73778798a69cea5022d53b2ae91bc"
dependencies = [ dependencies = [
"actix-router", "actix-router",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -256,9 +296,9 @@ 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 = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -349,9 +389,9 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -360,9 +400,9 @@ version = "0.1.53"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600" checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -372,7 +412,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21fb6a0b39c6517edafe46f8137e53c51742425a4dae1c73ee12264a37ad7541" checksum = "21fb6a0b39c6517edafe46f8137e53c51742425a4dae1c73ee12264a37ad7541"
dependencies = [ dependencies = [
"chrono", "chrono",
"derive_builder", "derive_builder 0.10.2",
"diligent-date-parser", "diligent-date-parser",
"never", "never",
"quick-xml", "quick-xml",
@ -801,6 +841,16 @@ dependencies = [
"darling_macro 0.13.1", "darling_macro 0.13.1",
] ]
[[package]]
name = "darling"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4529658bdda7fd6769b8614be250cdcfc3aeb0ee72fe66f9e41e5e5eb73eac02"
dependencies = [
"darling_core 0.14.1",
"darling_macro 0.14.1",
]
[[package]] [[package]]
name = "darling_core" name = "darling_core"
version = "0.12.4" version = "0.12.4"
@ -809,10 +859,10 @@ checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36"
dependencies = [ dependencies = [
"fnv", "fnv",
"ident_case", "ident_case",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"strsim", "strsim",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -823,10 +873,24 @@ checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324"
dependencies = [ dependencies = [
"fnv", "fnv",
"ident_case", "ident_case",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"strsim", "strsim",
"syn 1.0.90", "syn 1.0.95",
]
[[package]]
name = "darling_core"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "649c91bc01e8b1eac09fb91e8dbc7d517684ca6be8ebc75bb9cafc894f9fdb6f"
dependencies = [
"fnv",
"ident_case",
"proc-macro2 1.0.39",
"quote 1.0.18",
"strsim",
"syn 1.0.95",
] ]
[[package]] [[package]]
@ -836,8 +900,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a" checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a"
dependencies = [ dependencies = [
"darling_core 0.12.4", "darling_core 0.12.4",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -847,8 +911,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b"
dependencies = [ dependencies = [
"darling_core 0.13.1", "darling_core 0.13.1",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
]
[[package]]
name = "darling_macro"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddfc69c5bfcbd2fc09a0f38451d2daf0e372e367986a83906d1b0dbc88134fb5"
dependencies = [
"darling_core 0.14.1",
"quote 1.0.18",
"syn 1.0.95",
] ]
[[package]] [[package]]
@ -866,7 +941,16 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30" checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30"
dependencies = [ dependencies = [
"derive_builder_macro", "derive_builder_macro 0.10.2",
]
[[package]]
name = "derive_builder"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3"
dependencies = [
"derive_builder_macro 0.11.2",
] ]
[[package]] [[package]]
@ -876,9 +960,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5" checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5"
dependencies = [ dependencies = [
"darling 0.12.4", "darling 0.12.4",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
]
[[package]]
name = "derive_builder_core"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4"
dependencies = [
"darling 0.14.1",
"proc-macro2 1.0.39",
"quote 1.0.18",
"syn 1.0.95",
] ]
[[package]] [[package]]
@ -887,8 +983,18 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73" checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73"
dependencies = [ dependencies = [
"derive_builder_core", "derive_builder_core 0.10.2",
"syn 1.0.90", "syn 1.0.95",
]
[[package]]
name = "derive_builder_macro"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68"
dependencies = [
"derive_builder_core 0.11.2",
"syn 1.0.95",
] ]
[[package]] [[package]]
@ -898,10 +1004,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
dependencies = [ dependencies = [
"convert_case", "convert_case",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"rustc_version", "rustc_version",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -946,9 +1052,9 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -1009,12 +1115,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "dissimilar"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31ad93652f40969dead8d4bf897a41e9462095152eb21c56e5830537e41179dd"
[[package]] [[package]]
name = "doku" name = "doku"
version = "0.11.0" version = "0.11.0"
@ -1032,9 +1132,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "603fe9f91b4d0e11036df029aeaeffa90b8f97e700104d5d24abb053bf9ba858" checksum = "603fe9f91b4d0e11036df029aeaeffa90b8f97e700104d5d24abb053bf9ba858"
dependencies = [ dependencies = [
"darling 0.13.1", "darling 0.13.1",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -1286,9 +1386,9 @@ version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -1362,12 +1462,6 @@ dependencies = [
"wasi 0.10.0+wasi-snapshot-preview1", "wasi 0.10.0+wasi-snapshot-preview1",
] ]
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.3.12" version = "0.3.12"
@ -1484,9 +1578,9 @@ dependencies = [
"log", "log",
"mac", "mac",
"markup5ever", "markup5ever",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -1764,6 +1858,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
name = "lemmy_api" name = "lemmy_api"
version = "0.16.5" version = "0.16.5"
dependencies = [ dependencies = [
"activitypub_federation",
"actix-web", "actix-web",
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1774,7 +1869,6 @@ dependencies = [
"diesel", "diesel",
"lemmy_api_common", "lemmy_api_common",
"lemmy_apub", "lemmy_apub",
"lemmy_apub_lib",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views", "lemmy_db_views",
"lemmy_db_views_actor", "lemmy_db_views_actor",
@ -1815,12 +1909,12 @@ dependencies = [
name = "lemmy_api_crud" name = "lemmy_api_crud"
version = "0.16.5" version = "0.16.5"
dependencies = [ dependencies = [
"activitypub_federation",
"actix-web", "actix-web",
"async-trait", "async-trait",
"bcrypt", "bcrypt",
"lemmy_api_common", "lemmy_api_common",
"lemmy_apub", "lemmy_apub",
"lemmy_apub_lib",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views", "lemmy_db_views",
"lemmy_db_views_actor", "lemmy_db_views_actor",
@ -1837,6 +1931,7 @@ dependencies = [
name = "lemmy_apub" name = "lemmy_apub"
version = "0.16.5" version = "0.16.5"
dependencies = [ dependencies = [
"activitypub_federation",
"activitystreams-kinds", "activitystreams-kinds",
"actix", "actix",
"actix-rt", "actix-rt",
@ -1852,7 +1947,6 @@ dependencies = [
"http-signature-normalization-actix", "http-signature-normalization-actix",
"itertools", "itertools",
"lemmy_api_common", "lemmy_api_common",
"lemmy_apub_lib",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views", "lemmy_db_views",
"lemmy_db_views_actor", "lemmy_db_views_actor",
@ -1873,53 +1967,16 @@ dependencies = [
"uuid", "uuid",
] ]
[[package]]
name = "lemmy_apub_lib"
version = "0.16.5"
dependencies = [
"actix-web",
"anyhow",
"async-trait",
"background-jobs",
"base64",
"chrono",
"diesel",
"http",
"http-signature-normalization-actix",
"http-signature-normalization-reqwest",
"lemmy_apub_lib_derive",
"lemmy_utils",
"once_cell",
"openssl",
"reqwest",
"reqwest-middleware",
"serde",
"serde_json",
"sha2",
"tracing",
"url",
]
[[package]]
name = "lemmy_apub_lib_derive"
version = "0.16.5"
dependencies = [
"proc-macro2 1.0.36",
"quote 1.0.17",
"syn 1.0.90",
"trybuild",
]
[[package]] [[package]]
name = "lemmy_db_schema" name = "lemmy_db_schema"
version = "0.16.5" version = "0.16.5"
dependencies = [ dependencies = [
"activitypub_federation",
"bcrypt", "bcrypt",
"chrono", "chrono",
"diesel", "diesel",
"diesel-derive-newtype", "diesel-derive-newtype",
"diesel_migrations", "diesel_migrations",
"lemmy_apub_lib",
"lemmy_utils", "lemmy_utils",
"once_cell", "once_cell",
"regex", "regex",
@ -1992,6 +2049,7 @@ dependencies = [
name = "lemmy_server" name = "lemmy_server"
version = "0.16.5" version = "0.16.5"
dependencies = [ dependencies = [
"activitypub_federation",
"actix", "actix",
"actix-web", "actix-web",
"clokwerk", "clokwerk",
@ -2003,7 +2061,6 @@ dependencies = [
"lemmy_api_common", "lemmy_api_common",
"lemmy_api_crud", "lemmy_api_crud",
"lemmy_apub", "lemmy_apub",
"lemmy_apub_lib",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_routes", "lemmy_routes",
"lemmy_utils", "lemmy_utils",
@ -2013,6 +2070,7 @@ dependencies = [
"parking_lot 0.12.0", "parking_lot 0.12.0",
"reqwest", "reqwest",
"reqwest-middleware", "reqwest-middleware",
"reqwest-retry",
"reqwest-tracing", "reqwest-tracing",
"serde", "serde",
"tracing", "tracing",
@ -2258,9 +2316,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c" checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c"
dependencies = [ dependencies = [
"migrations_internals", "migrations_internals",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -2663,9 +2721,9 @@ checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
dependencies = [ dependencies = [
"pest", "pest",
"pest_meta", "pest_meta",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -2761,9 +2819,9 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -2824,9 +2882,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [ dependencies = [
"proc-macro-error-attr", "proc-macro-error-attr",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
"version_check", "version_check",
] ]
@ -2836,8 +2894,8 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"version_check", "version_check",
] ]
@ -2847,16 +2905,16 @@ version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [ dependencies = [
"unicode-xid 0.1.0", "unicode-xid",
] ]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.36" version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
dependencies = [ dependencies = [
"unicode-xid 0.2.2", "unicode-ident",
] ]
[[package]] [[package]]
@ -2897,9 +2955,9 @@ checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"itertools", "itertools",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -2942,11 +3000,11 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.17" version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58" checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
] ]
[[package]] [[package]]
@ -3148,9 +3206,9 @@ dependencies = [
[[package]] [[package]]
name = "reqwest-middleware" name = "reqwest-middleware"
version = "0.1.5" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b58621b8223cfc85b63d38b8d335c69b96a666d9b7561aa30a3b070ce1df31c" checksum = "69539cea4148dce683bec9dc95be3f0397a9bb2c248a49c8296a9d21659a8cdd"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -3162,6 +3220,26 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "reqwest-retry"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce246a729eaa6aff5e215aee42845bf5fed9893cc6cd51aeeb712f34e04dd9f3"
dependencies = [
"anyhow",
"async-trait",
"chrono",
"futures",
"http",
"hyper",
"reqwest",
"reqwest-middleware",
"retry-policies",
"task-local-extensions",
"tokio",
"tracing",
]
[[package]] [[package]]
name = "reqwest-tracing" name = "reqwest-tracing"
version = "0.2.1" version = "0.2.1"
@ -3178,6 +3256,17 @@ dependencies = [
"tracing-opentelemetry 0.16.0", "tracing-opentelemetry 0.16.0",
] ]
[[package]]
name = "retry-policies"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47f9e19b18c6cdd796cc70aea8a9ea5ee7b813be611c6589e3624fcdbfd05f9d"
dependencies = [
"anyhow",
"chrono",
"rand 0.8.5",
]
[[package]] [[package]]
name = "rgb" name = "rgb"
version = "0.8.32" version = "0.8.32"
@ -3210,8 +3299,8 @@ checksum = "6f697b8b3f19bee20f30dc87213d05ce091c43bc733ab1bfc98b0e5cdd9943f3"
dependencies = [ dependencies = [
"convert_case", "convert_case",
"lazy_static", "lazy_static",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"regex", "regex",
"tinyjson", "tinyjson",
] ]
@ -3229,7 +3318,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36e19e299f301be17927a7c05b8fa1c621e3227e6c3a0da65492701642901ff7" checksum = "36e19e299f301be17927a7c05b8fa1c621e3227e6c3a0da65492701642901ff7"
dependencies = [ dependencies = [
"atom_syndication", "atom_syndication",
"derive_builder", "derive_builder 0.10.2",
"never", "never",
"quick-xml", "quick-xml",
] ]
@ -3366,9 +3455,9 @@ version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -3413,9 +3502,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12e47be9471c72889ebafb5e14d5ff930d89ae7a67bbdb5f8abb564f845a927e" checksum = "12e47be9471c72889ebafb5e14d5ff930d89ae7a67bbdb5f8abb564f845a927e"
dependencies = [ dependencies = [
"darling 0.13.1", "darling 0.13.1",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -3436,10 +3525,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2881bccd7d60fb32dfa3d7b3136385312f8ad75e2674aab2852867a09790cae8" checksum = "2881bccd7d60fb32dfa3d7b3136385312f8ad75e2674aab2852867a09790cae8"
dependencies = [ dependencies = [
"proc-macro-error", "proc-macro-error",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"rustversion", "rustversion",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -3536,9 +3625,9 @@ 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 = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -3585,8 +3674,8 @@ checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988"
dependencies = [ dependencies = [
"phf_generator 0.10.0", "phf_generator 0.10.0",
"phf_shared 0.10.0", "phf_shared 0.10.0",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
] ]
[[package]] [[package]]
@ -3608,10 +3697,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef"
dependencies = [ dependencies = [
"heck 0.4.0", "heck 0.4.0",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"rustversion", "rustversion",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -3622,18 +3711,18 @@ checksum = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
dependencies = [ dependencies = [
"proc-macro2 0.4.30", "proc-macro2 0.4.30",
"quote 0.6.13", "quote 0.6.13",
"unicode-xid 0.1.0", "unicode-xid",
] ]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.90" version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f" checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"unicode-xid 0.2.2", "unicode-ident",
] ]
[[package]] [[package]]
@ -3676,33 +3765,24 @@ dependencies = [
"utf-8", "utf-8",
] ]
[[package]]
name = "termcolor"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.30" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.30" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -3768,9 +3848,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.17.0" version = "1.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" checksum = "4903bf0427cf68dddd5aa6a93220756f8be0c34fcfa9f5e6191e103e15a31395"
dependencies = [ dependencies = [
"bytes", "bytes",
"libc", "libc",
@ -3803,9 +3883,9 @@ version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -3868,15 +3948,6 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "toml"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "tonic" name = "tonic"
version = "0.6.2" version = "0.6.2"
@ -3914,10 +3985,10 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757" checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"prost-build", "prost-build",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -3984,9 +4055,9 @@ version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b" checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
] ]
[[package]] [[package]]
@ -4080,22 +4151,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "trybuild"
version = "1.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ae8c4cee9b97b861a6e3be1d5acb6f50a86bbb68b1f3a896db8342fb6d0f94c"
dependencies = [
"dissimilar",
"glob",
"once_cell",
"serde",
"serde_derive",
"serde_json",
"termcolor",
"toml",
]
[[package]] [[package]]
name = "twoway" name = "twoway"
version = "0.2.2" version = "0.2.2"
@ -4145,6 +4200,12 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f"
[[package]]
name = "unicode-ident"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
[[package]] [[package]]
name = "unicode-normalization" name = "unicode-normalization"
version = "0.1.19" version = "0.1.19"
@ -4172,12 +4233,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]] [[package]]
name = "unicode_categories" name = "unicode_categories"
version = "0.1.1" version = "0.1.1"
@ -4295,9 +4350,9 @@ dependencies = [
"bumpalo", "bumpalo",
"lazy_static", "lazy_static",
"log", "log",
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -4319,7 +4374,7 @@ version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01"
dependencies = [ dependencies = [
"quote 1.0.17", "quote 1.0.18",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
] ]
@ -4329,9 +4384,9 @@ version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc"
dependencies = [ dependencies = [
"proc-macro2 1.0.36", "proc-macro2 1.0.39",
"quote 1.0.17", "quote 1.0.18",
"syn 1.0.90", "syn 1.0.95",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]

View file

@ -23,8 +23,6 @@ members = [
"crates/api", "crates/api",
"crates/api_crud", "crates/api_crud",
"crates/api_common", "crates/api_common",
"crates/apub_lib",
"crates/apub_lib_derive",
"crates/apub", "crates/apub",
"crates/utils", "crates/utils",
"crates/db_schema", "crates/db_schema",
@ -39,12 +37,12 @@ members = [
lemmy_api = { version = "=0.16.5", path = "./crates/api" } lemmy_api = { version = "=0.16.5", path = "./crates/api" }
lemmy_api_crud = { version = "=0.16.5", path = "./crates/api_crud" } lemmy_api_crud = { version = "=0.16.5", path = "./crates/api_crud" }
lemmy_apub = { version = "=0.16.5", path = "./crates/apub" } lemmy_apub = { version = "=0.16.5", path = "./crates/apub" }
lemmy_apub_lib = { version = "=0.16.5", path = "./crates/apub_lib" }
lemmy_utils = { version = "=0.16.5", path = "./crates/utils" } lemmy_utils = { version = "=0.16.5", path = "./crates/utils" }
lemmy_db_schema = { version = "=0.16.5", path = "./crates/db_schema" } 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"
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"] }
@ -62,6 +60,7 @@ reqwest-tracing = "0.2.1"
clokwerk = "0.3.5" clokwerk = "0.3.5"
doku = "0.11.0" doku = "0.11.0"
parking_lot = "0.12.0" parking_lot = "0.12.0"
reqwest-retry = "0.1.5"
console-subscriber = { version = "0.1.3", optional = true } console-subscriber = { version = "0.1.3", optional = true }
opentelemetry = { version = "0.17.0", features = ["rt-tokio"], optional = true } opentelemetry = { version = "0.17.0", features = ["rt-tokio"], optional = true }
opentelemetry-otlp = { version = "0.10.0", optional = true } opentelemetry-otlp = { version = "0.10.0", optional = true }

View file

@ -170,10 +170,10 @@ test('Remove a comment from admin and community on the same instance', async ()
}); });
test('Remove a comment from admin and community on different instance', async () => { test('Remove a comment from admin and community on different instance', async () => {
let alphaUser = await registerUser(alpha); let alpha_user = await registerUser(alpha);
let newAlphaApi: API = { let newAlphaApi: API = {
client: alpha.client, client: alpha.client,
auth: alphaUser.jwt, auth: alpha_user.jwt,
}; };
// New alpha user creates a community, post, and comment. // New alpha user creates a community, post, and comment.

View file

@ -290,17 +290,17 @@ test('Enforce site ban for federated user', async () => {
// create a test user // create a test user
let alphaUserJwt = await registerUser(alpha); let alphaUserJwt = await registerUser(alpha);
expect(alphaUserJwt).toBeDefined(); expect(alphaUserJwt).toBeDefined();
let alphaUser: API = { let alpha_user: API = {
client: alpha.client, client: alpha.client,
auth: alphaUserJwt.jwt, auth: alphaUserJwt.jwt,
}; };
let alphaUserActorId = (await getSite(alphaUser)).my_user.local_user_view.person.actor_id; let alphaUserActorId = (await getSite(alpha_user)).my_user.local_user_view.person.actor_id;
expect(alphaUserActorId).toBeDefined(); expect(alphaUserActorId).toBeDefined();
let alphaPerson = (await resolvePerson(alphaUser, alphaUserActorId)).person; let alphaPerson = (await resolvePerson(alpha_user, alphaUserActorId)).person;
expect(alphaPerson).toBeDefined(); expect(alphaPerson).toBeDefined();
// alpha makes post in beta community, it federates to beta instance // alpha makes post in beta community, it federates to beta instance
let postRes1 = await createPost(alphaUser, betaCommunity.community.id); let postRes1 = await createPost(alpha_user, betaCommunity.community.id);
let searchBeta1 = await searchPostLocal(beta, postRes1.post_view.post); let searchBeta1 = await searchPostLocal(beta, postRes1.post_view.post);
expect(searchBeta1.posts[0]).toBeDefined(); expect(searchBeta1.posts[0]).toBeDefined();
@ -321,7 +321,7 @@ test('Enforce site ban for federated user', async () => {
expect(unBanAlpha.banned).toBe(false); expect(unBanAlpha.banned).toBe(false);
// alpha makes new post in beta community, it federates // alpha makes new post in beta community, it federates
let postRes2 = await createPost(alphaUser, betaCommunity.community.id); let postRes2 = await createPost(alpha_user, betaCommunity.community.id);
let searchBeta3 = await searchPostLocal(beta, postRes2.post_view.post); let searchBeta3 = await searchPostLocal(beta, postRes2.post_view.post);
expect(searchBeta3.posts[0]).toBeDefined(); expect(searchBeta3.posts[0]).toBeDefined();

View file

@ -14,7 +14,6 @@ doctest = false
[dependencies] [dependencies]
lemmy_apub = { version = "=0.16.5", path = "../apub" } lemmy_apub = { version = "=0.16.5", path = "../apub" }
lemmy_apub_lib = { version = "=0.16.5", path = "../apub_lib" }
lemmy_utils = { version = "=0.16.5", path = "../utils" } lemmy_utils = { version = "=0.16.5", path = "../utils" }
lemmy_db_schema = { version = "=0.16.5", path = "../db_schema", features = ["full"] } lemmy_db_schema = { version = "=0.16.5", path = "../db_schema", features = ["full"] }
lemmy_db_views = { version = "=0.16.5", path = "../db_views", features = ["full"] } lemmy_db_views = { version = "=0.16.5", path = "../db_views", features = ["full"] }
@ -22,6 +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"
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

@ -17,7 +17,7 @@ use lemmy_db_schema::{
traits::Likeable, traits::Likeable,
}; };
use lemmy_db_views::structs::{CommentView, LocalUserView}; use lemmy_db_views::structs::{CommentView, LocalUserView};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperation}; use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperation};
use std::convert::TryInto; use std::convert::TryInto;

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_schema::source::comment::Comment; use lemmy_db_schema::source::comment::Comment;
use lemmy_db_views::structs::CommentView; use lemmy_db_views::structs::CommentView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -9,7 +9,7 @@ use lemmy_db_schema::{
traits::Saveable, traits::Saveable,
}; };
use lemmy_db_views::structs::CommentView; use lemmy_db_views::structs::CommentView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -1,17 +1,17 @@
use crate::Perform; use crate::Perform;
use activitypub_federation::core::object_id::ObjectId;
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_api_common::{ use lemmy_api_common::{
comment::{CommentReportResponse, CreateCommentReport}, comment::{CommentReportResponse, CreateCommentReport},
utils::{blocking, check_community_ban, get_local_user_view_from_jwt}, utils::{blocking, check_community_ban, get_local_user_view_from_jwt},
}; };
use lemmy_apub::protocol::activities::community::report::Report; use lemmy_apub::protocol::activities::community::report::Report;
use lemmy_apub_lib::object_id::ObjectId;
use lemmy_db_schema::{ use lemmy_db_schema::{
source::comment_report::{CommentReport, CommentReportForm}, source::comment_report::{CommentReport, CommentReportForm},
traits::Reportable, traits::Reportable,
}; };
use lemmy_db_views::structs::{CommentReportView, CommentView}; use lemmy_db_views::structs::{CommentReportView, CommentView};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation};
/// Creates a comment report and notifies the moderators of the community /// Creates a comment report and notifies the moderators of the community

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, get_local_user_view_from_jwt}, utils::{blocking, get_local_user_view_from_jwt},
}; };
use lemmy_db_views::comment_report_view::CommentReportQueryBuilder; use lemmy_db_views::comment_report_view::CommentReportQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
/// Lists comment reports for a community if an id is supplied /// Lists comment reports for a community if an id is supplied

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_schema::{source::comment_report::CommentReport, traits::Reportable}; use lemmy_db_schema::{source::comment_report::CommentReport, traits::Reportable};
use lemmy_db_views::structs::CommentReportView; use lemmy_db_views::structs::CommentReportView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation};
/// Resolves or unresolves a comment report and notifies the moderators of the community /// Resolves or unresolves a comment report and notifies the moderators of the community

View file

@ -17,7 +17,7 @@ use lemmy_db_schema::{
traits::{Crud, Joinable}, traits::{Crud, Joinable},
}; };
use lemmy_db_views_actor::structs::CommunityModeratorView; use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -24,7 +24,7 @@ use lemmy_db_schema::{
traits::{Bannable, Crud, Followable}, traits::{Bannable, Crud, Followable},
}; };
use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_db_views_actor::structs::PersonViewSafe;
use lemmy_utils::{utils::naive_from_unix, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, utils::naive_from_unix, ConnectionId};
use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -13,7 +13,7 @@ use lemmy_db_schema::{
traits::{Blockable, Crud, Followable}, traits::{Blockable, Crud, Followable},
}; };
use lemmy_db_views_actor::structs::CommunityView; use lemmy_db_views_actor::structs::CommunityView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -21,7 +21,7 @@ use lemmy_db_schema::{
traits::{Crud, Followable}, traits::{Crud, Followable},
}; };
use lemmy_db_views_actor::structs::CommunityView; use lemmy_db_views_actor::structs::CommunityView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -13,7 +13,7 @@ use lemmy_db_schema::{
traits::Crud, traits::Crud,
utils::naive_now, utils::naive_now,
}; };
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -13,7 +13,7 @@ use lemmy_db_schema::{
traits::{Crud, Joinable}, traits::{Crud, Joinable},
}; };
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView, PersonViewSafe}; use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView, PersonViewSafe};
use lemmy_utils::{location_info, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, location_info, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
// TODO: we dont do anything for federation here, it should be updated the next time the community // TODO: we dont do anything for federation here, it should be updated the next time the community

View file

@ -1,7 +1,7 @@
use actix_web::{web, web::Data}; use actix_web::{web, web::Data};
use captcha::Captcha; use captcha::Captcha;
use lemmy_api_common::{comment::*, community::*, person::*, post::*, site::*, websocket::*}; use lemmy_api_common::{comment::*, community::*, person::*, post::*, site::*, websocket::*};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation}; use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation};
use serde::Deserialize; use serde::Deserialize;

View file

@ -12,7 +12,7 @@ use lemmy_db_schema::{
traits::Crud, traits::Crud,
}; };
use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_db_views_actor::structs::PersonViewSafe;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -17,7 +17,7 @@ use lemmy_db_schema::{
traits::Crud, traits::Crud,
}; };
use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_db_views_actor::structs::PersonViewSafe;
use lemmy_utils::{utils::naive_from_unix, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, utils::naive_from_unix, ConnectionId};
use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -9,7 +9,7 @@ use lemmy_db_schema::{
traits::Blockable, traits::Blockable,
}; };
use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_db_views_actor::structs::PersonViewSafe;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
utils::{blocking, get_local_user_view_from_jwt, password_length_check}, utils::{blocking, get_local_user_view_from_jwt, password_length_check},
}; };
use lemmy_db_schema::source::local_user::LocalUser; use lemmy_db_schema::source::local_user::LocalUser;
use lemmy_utils::{claims::Claims, ConnectionId, LemmyError}; use lemmy_utils::{claims::Claims, error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -8,7 +8,7 @@ use lemmy_db_schema::source::{
local_user::LocalUser, local_user::LocalUser,
password_reset_request::PasswordResetRequest, password_reset_request::PasswordResetRequest,
}; };
use lemmy_utils::{claims::Claims, ConnectionId, LemmyError}; use lemmy_utils::{claims::Claims, error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -4,7 +4,7 @@ use captcha::{gen, Difficulty};
use chrono::Duration; use chrono::Duration;
use lemmy_api_common::person::{CaptchaResponse, GetCaptcha, GetCaptchaResponse}; use lemmy_api_common::person::{CaptchaResponse, GetCaptcha, GetCaptchaResponse};
use lemmy_db_schema::utils::naive_now; use lemmy_db_schema::utils::naive_now;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{messages::CaptchaItem, LemmyContext}; use lemmy_websocket::{messages::CaptchaItem, LemmyContext};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, get_local_user_view_from_jwt, is_admin}, utils::{blocking, get_local_user_view_from_jwt, is_admin},
}; };
use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_db_views_actor::structs::PersonViewSafe;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -7,7 +7,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_schema::source::site::Site; use lemmy_db_schema::source::site::Site;
use lemmy_db_views::structs::LocalUserView; use lemmy_db_views::structs::LocalUserView;
use lemmy_utils::{claims::Claims, ConnectionId, LemmyError}; use lemmy_utils::{claims::Claims, error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, get_local_user_view_from_jwt}, utils::{blocking, get_local_user_view_from_jwt},
}; };
use lemmy_db_views_actor::person_mention_view::PersonMentionQueryBuilder; use lemmy_db_views_actor::person_mention_view::PersonMentionQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, get_local_user_view_from_jwt}, utils::{blocking, get_local_user_view_from_jwt},
}; };
use lemmy_db_views::comment_view::CommentQueryBuilder; use lemmy_db_views::comment_view::CommentQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -10,7 +10,7 @@ use lemmy_db_schema::source::{
private_message::PrivateMessage, private_message::PrivateMessage,
}; };
use lemmy_db_views::comment_view::CommentQueryBuilder; use lemmy_db_views::comment_view::CommentQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_schema::{source::person_mention::PersonMention, traits::Crud}; use lemmy_db_schema::{source::person_mention::PersonMention, traits::Crud};
use lemmy_db_views_actor::structs::PersonMentionView; use lemmy_db_views_actor::structs::PersonMentionView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_views::structs::{CommentView, PrivateMessageView}; use lemmy_db_views::structs::{CommentView, PrivateMessageView};
use lemmy_db_views_actor::structs::PersonMentionView; use lemmy_db_views_actor::structs::PersonMentionView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, get_local_user_view_from_jwt}, utils::{blocking, get_local_user_view_from_jwt},
}; };
use lemmy_db_views::structs::{CommentReportView, PostReportView}; use lemmy_db_views::structs::{CommentReportView, PostReportView};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, send_password_reset_email}, utils::{blocking, send_password_reset_email},
}; };
use lemmy_db_views::structs::LocalUserView; use lemmy_db_views::structs::LocalUserView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -15,9 +15,9 @@ use lemmy_db_schema::{
}; };
use lemmy_utils::{ use lemmy_utils::{
claims::Claims, claims::Claims,
error::LemmyError,
utils::{is_valid_display_name, is_valid_matrix_id}, utils::{is_valid_display_name, is_valid_matrix_id},
ConnectionId, ConnectionId,
LemmyError,
}; };
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;

View file

@ -12,7 +12,7 @@ use lemmy_db_schema::{
traits::Crud, traits::Crud,
}; };
use lemmy_db_views::structs::LocalUserView; use lemmy_db_views::structs::LocalUserView;
use lemmy_utils::LemmyError; use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -4,7 +4,7 @@ use lemmy_api_common::{
post::{GetSiteMetadata, GetSiteMetadataResponse}, post::{GetSiteMetadata, GetSiteMetadataResponse},
request::fetch_site_metadata, request::fetch_site_metadata,
}; };
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -23,7 +23,7 @@ use lemmy_db_schema::{
source::post::{Post, PostLike, PostLikeForm}, source::post::{Post, PostLike, PostLikeForm},
traits::{Crud, Likeable}, traits::{Crud, Likeable},
}; };
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation}; use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -21,7 +21,7 @@ use lemmy_db_schema::{
}, },
traits::Crud, traits::Crud,
}; };
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation}; use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, get_local_user_view_from_jwt, mark_post_as_read, mark_post_as_unread}, utils::{blocking, get_local_user_view_from_jwt, mark_post_as_read, mark_post_as_unread},
}; };
use lemmy_db_views::structs::PostView; use lemmy_db_views::structs::PostView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -9,7 +9,7 @@ use lemmy_db_schema::{
traits::Saveable, traits::Saveable,
}; };
use lemmy_db_views::structs::PostView; use lemmy_db_views::structs::PostView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -21,7 +21,7 @@ use lemmy_db_schema::{
}, },
traits::Crud, traits::Crud,
}; };
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation}; use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -1,17 +1,17 @@
use crate::Perform; use crate::Perform;
use activitypub_federation::core::object_id::ObjectId;
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_api_common::{ use lemmy_api_common::{
post::{CreatePostReport, PostReportResponse}, post::{CreatePostReport, PostReportResponse},
utils::{blocking, check_community_ban, get_local_user_view_from_jwt}, utils::{blocking, check_community_ban, get_local_user_view_from_jwt},
}; };
use lemmy_apub::protocol::activities::community::report::Report; use lemmy_apub::protocol::activities::community::report::Report;
use lemmy_apub_lib::object_id::ObjectId;
use lemmy_db_schema::{ use lemmy_db_schema::{
source::post_report::{PostReport, PostReportForm}, source::post_report::{PostReport, PostReportForm},
traits::Reportable, traits::Reportable,
}; };
use lemmy_db_views::structs::{PostReportView, PostView}; use lemmy_db_views::structs::{PostReportView, PostView};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation};
/// Creates a post report and notifies the moderators of the community /// Creates a post report and notifies the moderators of the community

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, get_local_user_view_from_jwt}, utils::{blocking, get_local_user_view_from_jwt},
}; };
use lemmy_db_views::post_report_view::PostReportQueryBuilder; use lemmy_db_views::post_report_view::PostReportQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
/// Lists post reports for a community if an id is supplied /// Lists post reports for a community if an id is supplied

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_schema::{source::post_report::PostReport, traits::Reportable}; use lemmy_db_schema::{source::post_report::PostReport, traits::Reportable};
use lemmy_db_views::structs::PostReportView; use lemmy_db_views::structs::PostReportView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation};
/// Resolves or unresolves a post report and notifies the moderators of the community /// Resolves or unresolves a post report and notifies the moderators of the community

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, get_local_user_view_from_jwt}, utils::{blocking, get_local_user_view_from_jwt},
}; };
use lemmy_db_schema::{source::private_message::PrivateMessage, traits::Crud}; use lemmy_db_schema::{source::private_message::PrivateMessage, traits::Crud};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperation}; use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -4,7 +4,7 @@ use lemmy_api_common::{
site::{GetSiteConfig, GetSiteConfigResponse}, site::{GetSiteConfig, GetSiteConfigResponse},
utils::{get_local_user_view_from_jwt, is_admin}, utils::{get_local_user_view_from_jwt, is_admin},
}; };
use lemmy_utils::{settings::structs::Settings, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, settings::structs::Settings, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -4,7 +4,7 @@ use lemmy_api_common::{
site::{GetSiteConfigResponse, SaveSiteConfig}, site::{GetSiteConfigResponse, SaveSiteConfig},
utils::{get_local_user_view_from_jwt, is_admin}, utils::{get_local_user_view_from_jwt, is_admin},
}; };
use lemmy_utils::{settings::structs::Settings, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, settings::structs::Settings, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -13,7 +13,7 @@ use lemmy_db_schema::{
}; };
use lemmy_db_views::structs::SiteView; use lemmy_db_views::structs::SiteView;
use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_db_views_actor::structs::PersonViewSafe;
use lemmy_utils::{version, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, version, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -17,7 +17,7 @@ use lemmy_db_views_moderator::structs::{
ModStickyPostView, ModStickyPostView,
ModTransferCommunityView, ModTransferCommunityView,
}; };
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -13,7 +13,7 @@ use lemmy_db_schema::{
utils::diesel_option_overwrite, utils::diesel_option_overwrite,
}; };
use lemmy_db_views::structs::{LocalUserView, RegistrationApplicationView}; use lemmy_db_views::structs::{LocalUserView, RegistrationApplicationView};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_schema::source::site::Site; use lemmy_db_schema::source::site::Site;
use lemmy_db_views::registration_application_view::RegistrationApplicationQueryBuilder; use lemmy_db_views::registration_application_view::RegistrationApplicationQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
/// Lists registration applications, filterable by undenied only. /// Lists registration applications, filterable by undenied only.

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_schema::source::site::Site; use lemmy_db_schema::source::site::Site;
use lemmy_db_views::structs::RegistrationApplicationView; use lemmy_db_views::structs::RegistrationApplicationView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -9,7 +9,7 @@ use lemmy_apub::fetcher::search::{search_by_apub_id, SearchableObjects};
use lemmy_db_schema::{newtypes::PersonId, utils::DbPool}; use lemmy_db_schema::{newtypes::PersonId, utils::DbPool};
use lemmy_db_views::structs::{CommentView, PostView}; use lemmy_db_views::structs::{CommentView, PostView};
use lemmy_db_views_actor::structs::{CommunityView, PersonViewSafe}; use lemmy_db_views_actor::structs::{CommunityView, PersonViewSafe};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -11,7 +11,7 @@ use lemmy_db_views_actor::{
community_view::CommunityQueryBuilder, community_view::CommunityQueryBuilder,
person_view::PersonQueryBuilder, person_view::PersonQueryBuilder,
}; };
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -1,7 +1,7 @@
use crate::Perform; use crate::Perform;
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_api_common::{utils::get_local_user_view_from_jwt, websocket::*}; use lemmy_api_common::{utils::get_local_user_view_from_jwt, websocket::*};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{ use lemmy_websocket::{
messages::{JoinCommunityRoom, JoinModRoom, JoinPostRoom, JoinUserRoom}, messages::{JoinCommunityRoom, JoinModRoom, JoinPostRoom, JoinUserRoom},
LemmyContext, LemmyContext,

View file

@ -1,6 +1,6 @@
use crate::post::SiteMetadata; use crate::post::SiteMetadata;
use encoding::{all::encodings, DecoderTrap}; use encoding::{all::encodings, DecoderTrap};
use lemmy_utils::{settings::structs::Settings, version::VERSION, LemmyError, REQWEST_TIMEOUT}; use lemmy_utils::{error::LemmyError, settings::structs::Settings, version::VERSION};
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC}; use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use reqwest_middleware::ClientWithMiddleware; use reqwest_middleware::ClientWithMiddleware;
use serde::Deserialize; use serde::Deserialize;
@ -15,11 +15,7 @@ pub async fn fetch_site_metadata(
url: &Url, url: &Url,
) -> Result<SiteMetadata, LemmyError> { ) -> Result<SiteMetadata, LemmyError> {
info!("Fetching site metadata for url: {}", url); info!("Fetching site metadata for url: {}", url);
let response = client let response = client.get(url.as_str()).send().await?;
.get(url.as_str())
.timeout(REQWEST_TIMEOUT)
.send()
.await?;
// Can't use .text() here, because it only checks the content header, not the actual bytes // Can't use .text() here, because it only checks the content header, not the actual bytes
// https://github.com/LemmyNet/lemmy/issues/1964 // https://github.com/LemmyNet/lemmy/issues/1964
@ -122,11 +118,7 @@ pub(crate) async fn fetch_pictrs(
utf8_percent_encode(image_url.as_str(), NON_ALPHANUMERIC) // TODO this might not be needed utf8_percent_encode(image_url.as_str(), NON_ALPHANUMERIC) // TODO this might not be needed
); );
let response = client let response = client.get(&fetch_url).send().await?;
.get(&fetch_url)
.timeout(REQWEST_TIMEOUT)
.send()
.await?;
let response: PictrsResponse = response.json().await.map_err(LemmyError::from)?; let response: PictrsResponse = response.json().await.map_err(LemmyError::from)?;
@ -195,11 +187,7 @@ pub async fn fetch_site_data(
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Result<(), LemmyError> { async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Result<(), LemmyError> {
let response = client let response = client.get(url.as_str()).send().await?;
.get(url.as_str())
.timeout(REQWEST_TIMEOUT)
.send()
.await?;
if response if response
.headers() .headers()
.get("Content-Type") .get("Content-Type")

View file

@ -28,9 +28,9 @@ use lemmy_db_views_actor::structs::{
use lemmy_utils::{ use lemmy_utils::{
claims::Claims, claims::Claims,
email::{send_email, translations::Lang}, email::{send_email, translations::Lang},
error::LemmyError,
settings::structs::Settings, settings::structs::Settings,
utils::generate_random_string, utils::generate_random_string,
LemmyError,
}; };
use rosetta_i18n::{Language, LanguageId}; use rosetta_i18n::{Language, LanguageId};
use tracing::warn; use tracing::warn;

View file

@ -9,13 +9,13 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
[dependencies] [dependencies]
lemmy_apub = { version = "=0.16.5", path = "../apub" } lemmy_apub = { version = "=0.16.5", path = "../apub" }
lemmy_apub_lib = { version = "=0.16.5", path = "../apub_lib" }
lemmy_utils = { version = "=0.16.5", path = "../utils" } lemmy_utils = { version = "=0.16.5", path = "../utils" }
lemmy_db_schema = { version = "=0.16.5", path = "../db_schema", features = ["full"] } lemmy_db_schema = { version = "=0.16.5", path = "../db_schema", features = ["full"] }
lemmy_db_views = { version = "=0.16.5", path = "../db_views", features = ["full"] } lemmy_db_views = { 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"
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

@ -26,9 +26,9 @@ use lemmy_db_schema::{
}; };
use lemmy_db_views::structs::CommentView; use lemmy_db_views::structs::CommentView;
use lemmy_utils::{ use lemmy_utils::{
error::LemmyError,
utils::{remove_slurs, scrape_text_for_mentions}, utils::{remove_slurs, scrape_text_for_mentions},
ConnectionId, ConnectionId,
LemmyError,
}; };
use lemmy_websocket::{ use lemmy_websocket::{
send::{send_comment_ws_message, send_local_notifs}, send::{send_comment_ws_message, send_local_notifs},

View file

@ -10,7 +10,7 @@ use lemmy_db_schema::{
traits::Crud, traits::Crud,
}; };
use lemmy_db_views::structs::CommentView; use lemmy_db_views::structs::CommentView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{ use lemmy_websocket::{
send::{send_comment_ws_message, send_local_notifs}, send::{send_comment_ws_message, send_local_notifs},
LemmyContext, LemmyContext,

View file

@ -7,7 +7,7 @@ use lemmy_api_common::{
use lemmy_apub::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity}; use lemmy_apub::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity};
use lemmy_db_schema::{source::community::Community, traits::DeleteableOrRemoveable}; use lemmy_db_schema::{source::community::Community, traits::DeleteableOrRemoveable};
use lemmy_db_views::comment_view::CommentQueryBuilder; use lemmy_db_views::comment_view::CommentQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -5,7 +5,7 @@ use lemmy_api_common::{
utils::{blocking, check_private_instance, get_local_user_view_from_jwt_opt}, utils::{blocking, check_private_instance, get_local_user_view_from_jwt_opt},
}; };
use lemmy_db_views::structs::CommentView; use lemmy_db_views::structs::CommentView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -15,7 +15,7 @@ use lemmy_db_schema::{
traits::Crud, traits::Crud,
}; };
use lemmy_db_views::structs::CommentView; use lemmy_db_views::structs::CommentView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{ use lemmy_websocket::{
send::{send_comment_ws_message, send_local_notifs}, send::{send_comment_ws_message, send_local_notifs},
LemmyContext, LemmyContext,

View file

@ -16,9 +16,9 @@ use lemmy_apub::protocol::activities::{
use lemmy_db_schema::source::comment::Comment; use lemmy_db_schema::source::comment::Comment;
use lemmy_db_views::structs::CommentView; use lemmy_db_views::structs::CommentView;
use lemmy_utils::{ use lemmy_utils::{
error::LemmyError,
utils::{remove_slurs, scrape_text_for_mentions}, utils::{remove_slurs, scrape_text_for_mentions},
ConnectionId, ConnectionId,
LemmyError,
}; };
use lemmy_websocket::{ use lemmy_websocket::{
send::{send_comment_ws_message, send_local_notifs}, send::{send_comment_ws_message, send_local_notifs},

View file

@ -1,4 +1,5 @@
use crate::PerformCrud; use crate::PerformCrud;
use activitypub_federation::core::{object_id::ObjectId, signatures::generate_actor_keypair};
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_api_common::{ use lemmy_api_common::{
community::{CommunityResponse, CreateCommunity}, community::{CommunityResponse, CreateCommunity},
@ -12,7 +13,6 @@ use lemmy_apub::{
objects::community::ApubCommunity, objects::community::ApubCommunity,
EndpointType, EndpointType,
}; };
use lemmy_apub_lib::object_id::ObjectId;
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{
community::{ community::{
@ -30,10 +30,9 @@ use lemmy_db_schema::{
}; };
use lemmy_db_views_actor::structs::CommunityView; use lemmy_db_views_actor::structs::CommunityView;
use lemmy_utils::{ use lemmy_utils::{
apub::generate_actor_keypair, error::LemmyError,
utils::{check_slurs, check_slurs_opt, is_valid_actor_name}, utils::{check_slurs, check_slurs_opt, is_valid_actor_name},
ConnectionId, ConnectionId,
LemmyError,
}; };
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
@ -77,7 +76,9 @@ 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.dereference_local(context).await; let community_dupe = community_actor_id_wrapped
.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

@ -7,7 +7,7 @@ use lemmy_api_common::{
use lemmy_apub::activities::deletion::{send_apub_delete_in_community, DeletableObjects}; use lemmy_apub::activities::deletion::{send_apub_delete_in_community, DeletableObjects};
use lemmy_db_schema::source::community::Community; use lemmy_db_schema::source::community::Community;
use lemmy_db_views_actor::structs::CommunityModeratorView; use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_schema::traits::DeleteableOrRemoveable; use lemmy_db_schema::traits::DeleteableOrRemoveable;
use lemmy_db_views_actor::community_view::CommunityQueryBuilder; use lemmy_db_views_actor::community_view::CommunityQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -13,7 +13,7 @@ use lemmy_db_schema::{
traits::DeleteableOrRemoveable, traits::DeleteableOrRemoveable,
}; };
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView}; use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{messages::GetCommunityUsersOnline, LemmyContext}; use lemmy_websocket::{messages::GetCommunityUsersOnline, LemmyContext};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -12,7 +12,7 @@ use lemmy_db_schema::{
}, },
traits::Crud, traits::Crud,
}; };
use lemmy_utils::{utils::naive_from_unix, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, utils::naive_from_unix, ConnectionId};
use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -12,7 +12,7 @@ use lemmy_db_schema::{
utils::{diesel_option_overwrite_to_url, naive_now}, utils::{diesel_option_overwrite_to_url, naive_now},
}; };
use lemmy_db_views_actor::structs::CommunityModeratorView; use lemmy_db_views_actor::structs::CommunityModeratorView;
use lemmy_utils::{utils::check_slurs_opt, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, utils::check_slurs_opt, ConnectionId};
use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -1,6 +1,6 @@
use actix_web::{web, web::Data}; use actix_web::{web, web::Data};
use lemmy_api_common::{comment::*, community::*, person::*, post::*, site::*}; use lemmy_api_common::{comment::*, community::*, person::*, post::*, site::*};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperationCrud};
use serde::Deserialize; use serde::Deserialize;

View file

@ -27,6 +27,7 @@ use lemmy_db_schema::{
}; };
use lemmy_db_views_actor::structs::CommunityView; use lemmy_db_views_actor::structs::CommunityView;
use lemmy_utils::{ use lemmy_utils::{
error::LemmyError,
utils::{ utils::{
check_slurs, check_slurs,
check_slurs_opt, check_slurs_opt,
@ -35,7 +36,6 @@ use lemmy_utils::{
is_valid_post_title, is_valid_post_title,
}, },
ConnectionId, ConnectionId,
LemmyError,
}; };
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
use tracing::{warn, Instrument}; use tracing::{warn, Instrument};

View file

@ -14,7 +14,7 @@ use lemmy_db_schema::{
source::{community::Community, post::Post}, source::{community::Community, post::Post},
traits::Crud, traits::Crud,
}; };
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -11,7 +11,7 @@ use lemmy_db_schema::{
ListingType, ListingType,
}; };
use lemmy_db_views::post_view::PostQueryBuilder; use lemmy_db_views::post_view::PostQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use std::str::FromStr; use std::str::FromStr;

View file

@ -7,7 +7,7 @@ use lemmy_api_common::{
use lemmy_db_schema::traits::DeleteableOrRemoveable; use lemmy_db_schema::traits::DeleteableOrRemoveable;
use lemmy_db_views::{comment_view::CommentQueryBuilder, structs::PostView}; use lemmy_db_views::{comment_view::CommentQueryBuilder, structs::PostView};
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView}; use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{messages::GetPostUsersOnline, LemmyContext}; use lemmy_websocket::{messages::GetPostUsersOnline, LemmyContext};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -13,7 +13,7 @@ use lemmy_db_schema::{
}, },
traits::Crud, traits::Crud,
}; };
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -19,9 +19,9 @@ use lemmy_db_schema::{
utils::naive_now, utils::naive_now,
}; };
use lemmy_utils::{ use lemmy_utils::{
error::LemmyError,
utils::{check_slurs_opt, clean_optional_text, clean_url_params, is_valid_post_title}, utils::{check_slurs_opt, clean_optional_text, clean_url_params, is_valid_post_title},
ConnectionId, ConnectionId,
LemmyError,
}; };
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};

View file

@ -23,7 +23,7 @@ use lemmy_db_schema::{
traits::Crud, traits::Crud,
}; };
use lemmy_db_views::structs::LocalUserView; use lemmy_db_views::structs::LocalUserView;
use lemmy_utils::{utils::remove_slurs, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, utils::remove_slurs, ConnectionId};
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_apub::activities::deletion::send_apub_delete_private_message; use lemmy_apub::activities::deletion::send_apub_delete_private_message;
use lemmy_db_schema::{source::private_message::PrivateMessage, traits::Crud}; use lemmy_db_schema::{source::private_message::PrivateMessage, traits::Crud};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
}; };
use lemmy_db_schema::traits::DeleteableOrRemoveable; use lemmy_db_schema::traits::DeleteableOrRemoveable;
use lemmy_db_views::private_message_view::PrivateMessageQueryBuilder; use lemmy_db_views::private_message_view::PrivateMessageQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -9,7 +9,7 @@ use lemmy_apub::protocol::activities::{
CreateOrUpdateType, CreateOrUpdateType,
}; };
use lemmy_db_schema::{source::private_message::PrivateMessage, traits::Crud}; use lemmy_db_schema::{source::private_message::PrivateMessage, traits::Crud};
use lemmy_utils::{utils::remove_slurs, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, utils::remove_slurs, ConnectionId};
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -1,4 +1,5 @@
use crate::PerformCrud; use crate::PerformCrud;
use activitypub_federation::core::signatures::generate_actor_keypair;
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_api_common::{ use lemmy_api_common::{
site::{CreateSite, SiteResponse}, site::{CreateSite, SiteResponse},
@ -13,11 +14,10 @@ use lemmy_db_schema::{
}; };
use lemmy_db_views::structs::SiteView; use lemmy_db_views::structs::SiteView;
use lemmy_utils::{ use lemmy_utils::{
apub::generate_actor_keypair, error::LemmyError,
settings::structs::Settings, settings::structs::Settings,
utils::{check_slurs, check_slurs_opt}, utils::{check_slurs, check_slurs_opt},
ConnectionId, ConnectionId,
LemmyError,
}; };
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use url::Url; use url::Url;

View file

@ -13,7 +13,7 @@ use lemmy_db_views_actor::structs::{
PersonBlockView, PersonBlockView,
PersonViewSafe, PersonViewSafe,
}; };
use lemmy_utils::{version, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, version, ConnectionId};
use lemmy_websocket::{messages::GetUsersOnline, LemmyContext}; use lemmy_websocket::{messages::GetUsersOnline, LemmyContext};
use tracing::info; use tracing::info;

View file

@ -14,7 +14,7 @@ use lemmy_db_schema::{
ListingType, ListingType,
}; };
use lemmy_db_views::structs::SiteView; use lemmy_db_views::structs::SiteView;
use lemmy_utils::{utils::check_slurs_opt, ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, utils::check_slurs_opt, ConnectionId};
use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperationCrud}; use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperationCrud};
use std::{default::Default, str::FromStr}; use std::{default::Default, str::FromStr};

View file

@ -1,4 +1,5 @@
use crate::PerformCrud; use crate::PerformCrud;
use activitypub_federation::core::signatures::generate_actor_keypair;
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_api_common::{ use lemmy_api_common::{
person::{LoginResponse, Register}, person::{LoginResponse, Register},
@ -33,11 +34,10 @@ use lemmy_db_schema::{
use lemmy_db_views::structs::LocalUserView; use lemmy_db_views::structs::LocalUserView;
use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_db_views_actor::structs::PersonViewSafe;
use lemmy_utils::{ use lemmy_utils::{
apub::generate_actor_keypair,
claims::Claims, claims::Claims,
error::LemmyError,
utils::{check_slurs, is_valid_actor_name}, utils::{check_slurs, is_valid_actor_name},
ConnectionId, ConnectionId,
LemmyError,
}; };
use lemmy_websocket::{messages::CheckCaptcha, LemmyContext}; use lemmy_websocket::{messages::CheckCaptcha, LemmyContext};

View file

@ -6,7 +6,7 @@ use lemmy_api_common::{
utils::{delete_user_account, get_local_user_view_from_jwt}, utils::{delete_user_account, get_local_user_view_from_jwt},
}; };
use lemmy_apub::protocol::activities::deletion::delete_user::DeleteUser; use lemmy_apub::protocol::activities::deletion::delete_user::DeleteUser;
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -8,7 +8,7 @@ use lemmy_apub::{fetcher::resolve_actor_identifier, objects::person::ApubPerson}
use lemmy_db_schema::source::person::Person; use lemmy_db_schema::source::person::Person;
use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder}; use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder};
use lemmy_db_views_actor::structs::{CommunityModeratorView, PersonViewSafe}; use lemmy_db_views_actor::structs::{CommunityModeratorView, PersonViewSafe};
use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View file

@ -14,12 +14,12 @@ doctest = false
[dependencies] [dependencies]
lemmy_utils = { version = "=0.16.5", path = "../utils" } lemmy_utils = { version = "=0.16.5", path = "../utils" }
lemmy_apub_lib = { version = "=0.16.5", path = "../apub_lib" }
lemmy_db_schema = { version = "=0.16.5", path = "../db_schema", features = ["full"] } lemmy_db_schema = { version = "=0.16.5", path = "../db_schema", features = ["full"] }
lemmy_db_views = { version = "=0.16.5", path = "../db_views", features = ["full"] } lemmy_db_views = { 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"
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,8 +1,6 @@
{ {
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha", "actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
"to": [ "to": "http://enterprise.lemmy.ml/c/main",
"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,16 +1,12 @@
{ {
"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": [ "to": "http://ds9.lemmy.ml/u/lemmy_alpha",
"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": [ "to": "http://ds9.lemmy.ml/u/lemmy_alpha",
"http://ds9.lemmy.ml/u/lemmy_alpha"
],
"content": "hello", "content": "hello",
"mediaType": "text/html", "mediaType": "text/html",
"source": { "source": {

View file

@ -2,9 +2,7 @@
"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": [ "to": "https://queer.hacktivis.me/users/lanodan",
"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

@ -4,25 +4,26 @@ use crate::{
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,
verify_activity,
verify_is_public, verify_is_public,
verify_mod_action, verify_mod_action,
verify_person_in_community, verify_person_in_community,
}, },
activity_lists::AnnouncableActivities, activity_lists::AnnouncableActivities,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::block::block_user::BlockUser, protocol::activities::block::block_user::BlockUser,
ActorType,
};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::ActivityHandler,
utils::verify_domains_match,
}; };
use activitystreams_kinds::{activity::BlockType, public}; use activitystreams_kinds::{activity::BlockType, public};
use anyhow::anyhow; use anyhow::anyhow;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use lemmy_api_common::utils::{blocking, remove_user_data, remove_user_data_in_community}; use lemmy_api_common::utils::{blocking, remove_user_data, remove_user_data_in_community};
use lemmy_apub_lib::{
data::Data,
object_id::ObjectId,
traits::{ActivityHandler, ActorType},
verify::verify_domains_match,
};
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{
community::{ community::{
@ -36,8 +37,9 @@ use lemmy_db_schema::{
}, },
traits::{Bannable, Crud, Followable}, traits::{Bannable, Crud, Followable},
}; };
use lemmy_utils::{settings::structs::Settings, utils::convert_datetime, LemmyError}; use lemmy_utils::{error::LemmyError, settings::structs::Settings, utils::convert_datetime};
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use url::Url;
impl BlockUser { impl BlockUser {
pub(in crate::activities::block) async fn new( pub(in crate::activities::block) async fn new(
@ -106,6 +108,15 @@ impl BlockUser {
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl ActivityHandler for BlockUser { impl ActivityHandler for BlockUser {
type DataType = LemmyContext; type DataType = LemmyContext;
type Error = LemmyError;
fn id(&self) -> &Url {
&self.id
}
fn actor(&self) -> &Url {
self.actor.inner()
}
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn verify( async fn verify(
@ -114,10 +125,9 @@ impl ActivityHandler for BlockUser {
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
verify_is_public(&self.to, &self.cc)?; verify_is_public(&self.to, &self.cc)?;
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
match self match self
.target .target
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(context, local_instance(context), request_counter)
.await? .await?
{ {
SiteOrCommunity::Site(site) => { SiteOrCommunity::Site(site) => {
@ -155,15 +165,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(context, context.client(), request_counter) .dereference::<LemmyError>(context, local_instance(context), request_counter)
.await?; .await?;
let blocked_person = self let blocked_person = self
.object .object
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(context, local_instance(context), request_counter)
.await?; .await?;
let target = self let target = self
.target .target
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(context, local_instance(context), request_counter)
.await?; .await?;
match target { match target {
SiteOrCommunity::Site(_site) => { SiteOrCommunity::Site(_site) => {
@ -242,7 +252,7 @@ impl GetCommunity for BlockUser {
) -> Result<ApubCommunity, LemmyError> { ) -> Result<ApubCommunity, LemmyError> {
let target = self let target = self
.target .target
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(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,15 +1,13 @@
use crate::{ use crate::{
objects::{community::ApubCommunity, instance::ApubSite, person::ApubPerson}, objects::{community::ApubCommunity, instance::ApubSite, person::ApubPerson},
protocol::objects::{group::Group, instance::Instance}, protocol::objects::{group::Group, instance::Instance},
ActorType,
}; };
use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use lemmy_api_common::utils::blocking; use lemmy_api_common::utils::blocking;
use lemmy_apub_lib::{
object_id::ObjectId,
traits::{ActorType, ApubObject},
};
use lemmy_db_schema::{source::site::Site, utils::DbPool}; use lemmy_db_schema::{source::site::Site, utils::DbPool};
use lemmy_utils::LemmyError; use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use serde::Deserialize; use serde::Deserialize;
use url::Url; use url::Url;
@ -35,7 +33,7 @@ impl ApubObject for SiteOrCommunity {
type DataType = LemmyContext; type DataType = LemmyContext;
type ApubType = InstanceOrGroup; type ApubType = InstanceOrGroup;
type DbType = (); type DbType = ();
type TombstoneType = (); type Error = LemmyError;
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
fn last_refreshed_at(&self) -> Option<NaiveDateTime> { fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
@ -70,10 +68,6 @@ impl ApubObject for SiteOrCommunity {
unimplemented!() unimplemented!()
} }
fn to_tombstone(&self) -> Result<Self::TombstoneType, LemmyError> {
unimplemented!()
}
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn verify( async fn verify(
apub: &Self::ApubType, apub: &Self::ApubType,

View file

@ -4,21 +4,22 @@ use crate::{
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,
verify_activity,
verify_is_public, verify_is_public,
}, },
activity_lists::AnnouncableActivities, activity_lists::AnnouncableActivities,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser}, protocol::activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
ActorType,
};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::ActivityHandler,
utils::verify_domains_match,
}; };
use activitystreams_kinds::{activity::UndoType, public}; use activitystreams_kinds::{activity::UndoType, public};
use lemmy_api_common::utils::blocking; use lemmy_api_common::utils::blocking;
use lemmy_apub_lib::{
data::Data,
object_id::ObjectId,
traits::{ActivityHandler, ActorType},
verify::verify_domains_match,
};
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{
community::{CommunityPersonBan, CommunityPersonBanForm}, community::{CommunityPersonBan, CommunityPersonBanForm},
@ -27,8 +28,9 @@ use lemmy_db_schema::{
}, },
traits::{Bannable, Crud}, traits::{Bannable, Crud},
}; };
use lemmy_utils::LemmyError; use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use url::Url;
impl UndoBlockUser { impl UndoBlockUser {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
@ -72,6 +74,15 @@ impl UndoBlockUser {
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl ActivityHandler for UndoBlockUser { impl ActivityHandler for UndoBlockUser {
type DataType = LemmyContext; type DataType = LemmyContext;
type Error = LemmyError;
fn id(&self) -> &Url {
&self.id
}
fn actor(&self) -> &Url {
self.actor.inner()
}
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn verify( async fn verify(
@ -80,7 +91,6 @@ impl ActivityHandler for UndoBlockUser {
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
verify_is_public(&self.to, &self.cc)?; verify_is_public(&self.to, &self.cc)?;
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
verify_domains_match(self.actor.inner(), self.object.actor.inner())?; verify_domains_match(self.actor.inner(), self.object.actor.inner())?;
self.object.verify(context, request_counter).await?; self.object.verify(context, request_counter).await?;
Ok(()) Ok(())
@ -92,20 +102,21 @@ impl ActivityHandler for UndoBlockUser {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let instance = local_instance(context);
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(context, context.client(), request_counter) .dereference::<LemmyError>(context, instance, request_counter)
.await?; .await?;
let blocked_person = self let blocked_person = self
.object .object
.object .object
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(context, instance, request_counter)
.await?; .await?;
match self match self
.object .object
.target .target
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(context, instance, request_counter)
.await? .await?
{ {
SiteOrCommunity::Site(_site) => { SiteOrCommunity::Site(_site) => {

View file

@ -6,7 +6,6 @@ use crate::{
send_activity_in_community, send_activity_in_community,
}, },
generate_activity_id, generate_activity_id,
verify_activity,
verify_add_remove_moderator_target, verify_add_remove_moderator_target,
verify_is_public, verify_is_public,
verify_mod_action, verify_mod_action,
@ -14,16 +13,14 @@ use crate::{
}, },
activity_lists::AnnouncableActivities, activity_lists::AnnouncableActivities,
generate_moderators_url, generate_moderators_url,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::add_mod::AddMod, protocol::activities::community::add_mod::AddMod,
ActorType,
}; };
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
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_apub_lib::{
data::Data,
object_id::ObjectId,
traits::{ActivityHandler, ActorType},
};
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{
community::{CommunityModerator, CommunityModeratorForm}, community::{CommunityModerator, CommunityModeratorForm},
@ -31,8 +28,9 @@ use lemmy_db_schema::{
}, },
traits::{Crud, Joinable}, traits::{Crud, Joinable},
}; };
use lemmy_utils::LemmyError; use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use url::Url;
impl AddMod { impl AddMod {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
@ -66,6 +64,15 @@ impl AddMod {
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl ActivityHandler for AddMod { impl ActivityHandler for AddMod {
type DataType = LemmyContext; type DataType = LemmyContext;
type Error = LemmyError;
fn id(&self) -> &Url {
&self.id
}
fn actor(&self) -> &Url {
self.actor.inner()
}
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn verify( async fn verify(
@ -74,7 +81,6 @@ impl ActivityHandler for AddMod {
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
verify_is_public(&self.to, &self.cc)?; verify_is_public(&self.to, &self.cc)?;
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
let community = self.get_community(context, request_counter).await?; let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?; verify_person_in_community(&self.actor, &community, context, request_counter).await?;
verify_mod_action( verify_mod_action(
@ -98,7 +104,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(context, context.client(), request_counter) .dereference::<LemmyError>(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
@ -121,7 +127,7 @@ impl ActivityHandler for AddMod {
// write mod log // write mod log
let actor = self let actor = self
.actor .actor
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(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

@ -1,23 +1,20 @@
use crate::{ use crate::{
activities::{generate_activity_id, send_lemmy_activity, verify_activity, verify_is_public}, activities::{generate_activity_id, send_lemmy_activity, verify_is_public},
activity_lists::AnnouncableActivities, activity_lists::AnnouncableActivities,
http::ActivityCommonFields,
insert_activity, insert_activity,
objects::community::ApubCommunity, objects::community::ApubCommunity,
protocol::{ protocol::{
activities::{community::announce::AnnounceActivity, CreateOrUpdateType}, activities::{community::announce::AnnounceActivity, CreateOrUpdateType},
IdOrNestedObject, IdOrNestedObject,
}, },
ActorType,
}; };
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
use activitystreams_kinds::{activity::AnnounceType, public}; use activitystreams_kinds::{activity::AnnounceType, public};
use lemmy_apub_lib::{ use lemmy_utils::error::LemmyError;
data::Data,
object_id::ObjectId,
traits::{ActivityHandler, ActorType},
};
use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use tracing::debug; use tracing::debug;
use url::Url;
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
pub(crate) trait GetCommunity { pub(crate) trait GetCommunity {
@ -90,15 +87,23 @@ impl AnnounceActivity {
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl ActivityHandler for AnnounceActivity { impl ActivityHandler for AnnounceActivity {
type DataType = LemmyContext; type DataType = LemmyContext;
type Error = LemmyError;
fn id(&self) -> &Url {
&self.id
}
fn actor(&self) -> &Url {
self.actor.inner()
}
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn verify( async fn verify(
&self, &self,
context: &Data<LemmyContext>, _context: &Data<LemmyContext>,
_request_counter: &mut i32, _request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
verify_is_public(&self.to, &self.cc)?; verify_is_public(&self.to, &self.cc)?;
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
Ok(()) Ok(())
} }
@ -118,14 +123,12 @@ impl ActivityHandler for AnnounceActivity {
AnnouncableActivities::Page(_) => {} AnnouncableActivities::Page(_) => {}
_ => { _ => {
let object_value = serde_json::to_value(&object)?; let object_value = serde_json::to_value(&object)?;
let object_data: ActivityCommonFields = serde_json::from_value(object_value.to_owned())?;
let insert = let insert =
insert_activity(&object_data.id, object_value, false, true, context.pool()).await?; insert_activity(object.id(), object_value, false, true, context.pool()).await?;
if !insert { if !insert {
debug!( debug!(
"Received duplicate activity in announce {}", "Received duplicate activity in announce {}",
object_data.id.to_string() object.id().to_string()
); );
return Ok(()); return Ok(());
} }

View file

@ -1,11 +1,13 @@
use crate::{ use crate::{
activities::send_lemmy_activity, activities::send_lemmy_activity,
activity_lists::AnnouncableActivities, activity_lists::AnnouncableActivities,
local_instance,
objects::community::ApubCommunity, objects::community::ApubCommunity,
protocol::activities::community::announce::AnnounceActivity, protocol::activities::community::announce::AnnounceActivity,
ActorType,
}; };
use lemmy_apub_lib::{object_id::ObjectId, traits::ActorType}; use activitypub_federation::core::object_id::ObjectId;
use lemmy_utils::LemmyError; use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use url::Url; use url::Url;
@ -42,6 +44,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(context, context.client(), request_counter) .dereference::<LemmyError>(context, local_instance(context), request_counter)
.await .await
} }

View file

@ -6,7 +6,6 @@ use crate::{
send_activity_in_community, send_activity_in_community,
}, },
generate_activity_id, generate_activity_id,
verify_activity,
verify_add_remove_moderator_target, verify_add_remove_moderator_target,
verify_is_public, verify_is_public,
verify_mod_action, verify_mod_action,
@ -14,16 +13,14 @@ use crate::{
}, },
activity_lists::AnnouncableActivities, activity_lists::AnnouncableActivities,
generate_moderators_url, generate_moderators_url,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::remove_mod::RemoveMod, protocol::activities::community::remove_mod::RemoveMod,
ActorType,
}; };
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
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_apub_lib::{
data::Data,
object_id::ObjectId,
traits::{ActivityHandler, ActorType},
};
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{
community::{CommunityModerator, CommunityModeratorForm}, community::{CommunityModerator, CommunityModeratorForm},
@ -31,8 +28,9 @@ use lemmy_db_schema::{
}, },
traits::{Crud, Joinable}, traits::{Crud, Joinable},
}; };
use lemmy_utils::LemmyError; use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
use url::Url;
impl RemoveMod { impl RemoveMod {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
@ -66,6 +64,15 @@ impl RemoveMod {
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl ActivityHandler for RemoveMod { impl ActivityHandler for RemoveMod {
type DataType = LemmyContext; type DataType = LemmyContext;
type Error = LemmyError;
fn id(&self) -> &Url {
&self.id
}
fn actor(&self) -> &Url {
self.actor.inner()
}
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn verify( async fn verify(
@ -74,7 +81,6 @@ impl ActivityHandler for RemoveMod {
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
verify_is_public(&self.to, &self.cc)?; verify_is_public(&self.to, &self.cc)?;
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
let community = self.get_community(context, request_counter).await?; let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?; verify_person_in_community(&self.actor, &community, context, request_counter).await?;
verify_mod_action( verify_mod_action(
@ -98,7 +104,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(context, context.client(), request_counter) .dereference::<LemmyError>(context, local_instance(context), request_counter)
.await?; .await?;
let form = CommunityModeratorForm { let form = CommunityModeratorForm {
@ -113,7 +119,7 @@ impl ActivityHandler for RemoveMod {
// write mod log // write mod log
let actor = self let actor = self
.actor .actor
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(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

@ -1,21 +1,14 @@
use crate::{ use crate::{
activities::{ activities::{generate_activity_id, send_lemmy_activity, verify_person_in_community},
generate_activity_id, local_instance,
send_lemmy_activity,
verify_activity,
verify_person_in_community,
},
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::report::Report, protocol::activities::community::report::Report,
ActorType,
PostOrComment, PostOrComment,
}; };
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
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_apub_lib::{
data::Data,
object_id::ObjectId,
traits::{ActivityHandler, ActorType},
};
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{
comment_report::{CommentReport, CommentReportForm}, comment_report::{CommentReport, CommentReportForm},
@ -24,8 +17,9 @@ use lemmy_db_schema::{
traits::Reportable, traits::Reportable,
}; };
use lemmy_db_views::structs::{CommentReportView, PostReportView}; use lemmy_db_views::structs::{CommentReportView, PostReportView};
use lemmy_utils::LemmyError; use lemmy_utils::error::LemmyError;
use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation};
use url::Url;
impl Report { impl Report {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
@ -36,7 +30,9 @@ impl Report {
reason: String, reason: String,
context: &LemmyContext, context: &LemmyContext,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let community = community_id.dereference_local(context).await?; let community = community_id
.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(),
@ -44,7 +40,7 @@ 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,
@ -66,6 +62,15 @@ impl Report {
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl ActivityHandler for Report { impl ActivityHandler for Report {
type DataType = LemmyContext; type DataType = LemmyContext;
type Error = LemmyError;
fn id(&self) -> &Url {
&self.id
}
fn actor(&self) -> &Url {
self.actor.inner()
}
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn verify( async fn verify(
@ -73,9 +78,9 @@ impl ActivityHandler for Report {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
verify_activity(&self.id, self.actor.inner(), &context.settings())?; let community = self
let community = self.to[0] .to
.dereference(context, context.client(), 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(())
@ -89,11 +94,11 @@ impl ActivityHandler for Report {
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let actor = self let actor = self
.actor .actor
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(context, local_instance(context), request_counter)
.await?; .await?;
match self match self
.object .object
.dereference(context, context.client(), request_counter) .dereference::<LemmyError>(context, local_instance(context), request_counter)
.await? .await?
{ {
PostOrComment::Post(post) => { PostOrComment::Post(post) => {

View file

@ -2,28 +2,30 @@ use crate::{
activities::{ activities::{
community::{announce::GetCommunity, send_activity_in_community}, community::{announce::GetCommunity, send_activity_in_community},
generate_activity_id, generate_activity_id,
verify_activity,
verify_is_public, verify_is_public,
verify_mod_action, verify_mod_action,
verify_person_in_community, verify_person_in_community,
}, },
activity_lists::AnnouncableActivities, activity_lists::AnnouncableActivities,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::update::UpdateCommunity, protocol::activities::community::update::UpdateCommunity,
ActorType,
};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
traits::{ActivityHandler, ApubObject},
}; };
use activitystreams_kinds::{activity::UpdateType, public}; use activitystreams_kinds::{activity::UpdateType, public};
use lemmy_api_common::utils::blocking; use lemmy_api_common::utils::blocking;
use lemmy_apub_lib::{
data::Data,
object_id::ObjectId,
traits::{ActivityHandler, ActorType, ApubObject},
};
use lemmy_db_schema::{ use lemmy_db_schema::{
source::community::{Community, CommunityForm}, source::community::{Community, CommunityForm},
traits::Crud, traits::Crud,
}; };
use lemmy_utils::LemmyError; use lemmy_utils::error::LemmyError;
use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud};
use url::Url;
impl UpdateCommunity { impl UpdateCommunity {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
@ -54,6 +56,15 @@ impl UpdateCommunity {
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl ActivityHandler for UpdateCommunity { impl ActivityHandler for UpdateCommunity {
type DataType = LemmyContext; type DataType = LemmyContext;
type Error = LemmyError;
fn id(&self) -> &Url {
&self.id
}
fn actor(&self) -> &Url {
self.actor.inner()
}
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn verify( async fn verify(
@ -62,7 +73,6 @@ impl ActivityHandler for UpdateCommunity {
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
verify_is_public(&self.to, &self.cc)?; verify_is_public(&self.to, &self.cc)?;
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
let community = self.get_community(context, request_counter).await?; let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?; verify_person_in_community(&self.actor, &community, context, request_counter).await?;
verify_mod_action( verify_mod_action(
@ -129,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(context, context.client(), request_counter) .dereference::<LemmyError>(context, local_instance(context), request_counter)
.await .await
} }
} }

Some files were not shown because too many files have changed in this diff Show more