From 6efab333f3b063549f9fa463cd55e3b6736e4ea1 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sun, 7 Sep 2025 17:22:58 +0200 Subject: [PATCH] Remove federation functionality and related tests - Deleted the `federation.rs` module and its associated functionality for federating thoughts to followers. - Removed the `well_known.rs` module and its WebFinger discovery functionality. - Eliminated references to federation in the `thought.rs` router and removed the spawning of background tasks for federating thoughts. - Deleted tests related to WebFinger and user inbox interactions in `activitypub.rs`. - Updated `Cargo.toml` to remove the `activitypub_federation` dependency. --- thoughts-backend/Cargo.lock | 698 +----------------- thoughts-backend/api/Cargo.toml | 3 +- thoughts-backend/api/src/federation.rs | 70 -- thoughts-backend/api/src/lib.rs | 1 - thoughts-backend/api/src/routers/mod.rs | 4 +- thoughts-backend/api/src/routers/thought.rs | 8 - .../api/src/routers/well_known.rs | 70 -- thoughts-backend/tests/api/activitypub.rs | 151 ---- thoughts-backend/tests/api/mod.rs | 1 - 9 files changed, 35 insertions(+), 971 deletions(-) delete mode 100644 thoughts-backend/api/src/federation.rs delete mode 100644 thoughts-backend/api/src/routers/well_known.rs delete mode 100644 thoughts-backend/tests/api/activitypub.rs diff --git a/thoughts-backend/Cargo.lock b/thoughts-backend/Cargo.lock index 3851e0d..ec4be89 100644 --- a/thoughts-backend/Cargo.lock +++ b/thoughts-backend/Cargo.lock @@ -2,211 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "activitypub_federation" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b58dd6127cbb797b5626306bebef8ca464fdb38c50f2ed6ecc7a3fcf45d422ec" -dependencies = [ - "activitystreams-kinds", - "actix-web", - "async-trait", - "axum 0.7.9", - "base64", - "bytes", - "chrono", - "derive_builder", - "dyn-clone", - "either", - "enum_delegate", - "futures", - "futures-core", - "http 0.2.12", - "http 1.3.1", - "http-signature-normalization", - "http-signature-normalization-reqwest", - "httpdate", - "itertools", - "moka", - "once_cell", - "pin-project-lite", - "rand 0.8.5", - "regex", - "reqwest", - "reqwest-middleware 0.3.3", - "rsa", - "serde", - "serde_json", - "sha2", - "thiserror 1.0.69", - "tokio", - "tower 0.4.13", - "tracing", - "url", -] - -[[package]] -name = "activitystreams-kinds" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97dfe76efd8c0b113cc3580a6b5f4acba47662e3cfbbfcce081c9ac89798990" -dependencies = [ - "serde", - "url", -] - -[[package]] -name = "actix-codec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" -dependencies = [ - "bitflags", - "bytes", - "futures-core", - "futures-sink", - "memchr", - "pin-project-lite", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "actix-http" -version = "3.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cceded2fb55f3c4b67068fa64962e2ca59614edc5b03167de9ff82ae803da0" -dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-utils", - "base64", - "bitflags", - "bytes", - "bytestring", - "derive_more", - "encoding_rs", - "foldhash", - "futures-core", - "http 0.2.12", - "httparse", - "httpdate", - "itoa", - "language-tags", - "local-channel", - "mime", - "percent-encoding", - "pin-project-lite", - "rand 0.9.1", - "sha1", - "smallvec", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "actix-router" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" -dependencies = [ - "bytestring", - "cfg-if", - "http 0.2.12", - "regex-lite", - "serde", - "tracing", -] - -[[package]] -name = "actix-rt" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92589714878ca59a7626ea19734f0e07a6a875197eec751bb5d3f99e64998c63" -dependencies = [ - "futures-core", - "tokio", -] - -[[package]] -name = "actix-server" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a65064ea4a457eaf07f2fba30b4c695bf43b721790e9530d26cb6f9019ff7502" -dependencies = [ - "actix-rt", - "actix-service", - "actix-utils", - "futures-core", - "futures-util", - "mio", - "socket2", - "tokio", - "tracing", -] - -[[package]] -name = "actix-service" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e46f36bf0e5af44bdc4bdb36fbbd421aa98c79a9bce724e1edeb3894e10dc7f" -dependencies = [ - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "actix-utils" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" -dependencies = [ - "local-waker", - "pin-project-lite", -] - -[[package]] -name = "actix-web" -version = "4.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a597b77b5c6d6a1e1097fddde329a83665e25c5437c696a3a9a4aa514a614dea" -dependencies = [ - "actix-codec", - "actix-http", - "actix-router", - "actix-rt", - "actix-server", - "actix-service", - "actix-utils", - "bytes", - "bytestring", - "cfg-if", - "derive_more", - "encoding_rs", - "foldhash", - "futures-core", - "futures-util", - "impl-more", - "itoa", - "language-tags", - "log", - "mime", - "once_cell", - "pin-project-lite", - "regex-lite", - "serde", - "serde_json", - "serde_urlencoded", - "smallvec", - "socket2", - "time", - "tracing", - "url", -] - [[package]] name = "addr2line" version = "0.24.2" @@ -329,10 +124,9 @@ checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" name = "api" version = "0.1.0" dependencies = [ - "activitypub_federation", "anyhow", "app", - "axum 0.8.4", + "axum", "bcrypt", "dotenvy", "jsonwebtoken", @@ -343,11 +137,10 @@ dependencies = [ "serde", "serde_json", "tokio", - "tower 0.5.2", + "tower", "tower-cookies", "tower-http", "tracing", - "url", "utoipa", "validator", ] @@ -559,53 +352,24 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" -[[package]] -name = "axum" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" -dependencies = [ - "async-trait", - "axum-core 0.4.5", - "bytes", - "futures-util", - "http 1.3.1", - "http-body", - "http-body-util", - "itoa", - "matchit 0.7.3", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "serde_json", - "serde_path_to_error", - "sync_wrapper", - "tower 0.5.2", - "tower-layer", - "tower-service", -] - [[package]] name = "axum" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" dependencies = [ - "axum-core 0.5.2", + "axum-core", "axum-macros", "bytes", "form_urlencoded", "futures-util", - "http 1.3.1", + "http", "http-body", "http-body-util", "hyper", "hyper-util", "itoa", - "matchit 0.8.4", + "matchit", "memchr", "mime", "percent-encoding", @@ -617,32 +381,12 @@ dependencies = [ "serde_urlencoded", "sync_wrapper", "tokio", - "tower 0.5.2", + "tower", "tower-layer", "tower-service", "tracing", ] -[[package]] -name = "axum-core" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http 1.3.1", - "http-body", - "http-body-util", - "mime", - "pin-project-lite", - "rustversion", - "sync_wrapper", - "tower-layer", - "tower-service", -] - [[package]] name = "axum-core" version = "0.5.2" @@ -651,7 +395,7 @@ checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" dependencies = [ "bytes", "futures-core", - "http 1.3.1", + "http", "http-body", "http-body-util", "mime", @@ -844,15 +588,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" -[[package]] -name = "bytestring" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e465647ae23b2823b0753f50decb2d5a86d2bb2cac04788fafd1f80e45378e5f" -dependencies = [ - "bytes", -] - [[package]] name = "cc" version = "1.2.27" @@ -1030,24 +765,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-queue" version = "0.3.12" @@ -1146,58 +863,6 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "derive_builder" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "derive_builder_macro" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" -dependencies = [ - "derive_builder_core", - "syn 2.0.104", -] - -[[package]] -name = "derive_more" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", - "unicode-xid", -] - [[package]] name = "diesel" version = "2.2.11" @@ -1273,7 +938,7 @@ dependencies = [ name = "doc" version = "0.1.0" dependencies = [ - "axum 0.8.4", + "axum", "models", "tracing", "utoipa", @@ -1301,12 +966,6 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "dyn-clone" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" - [[package]] name = "either" version = "1.15.0" @@ -1325,30 +984,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "enum_delegate" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8ea75f31022cba043afe037940d73684327e915f88f62478e778c3de914cd0a" -dependencies = [ - "enum_delegate_lib", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "enum_delegate_lib" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e1f6c3800b304a6be0012039e2a45a322a093539c45ab818d9e6895a39c90fe" -dependencies = [ - "proc-macro2", - "quote", - "rand 0.8.5", - "syn 1.0.109", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -1487,7 +1122,6 @@ checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", - "futures-executor", "futures-io", "futures-sink", "futures-task", @@ -1580,7 +1214,6 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ - "futures-channel", "futures-core", "futures-io", "futures-macro", @@ -1592,20 +1225,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generator" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "605183a538e3e2a9c1038635cc5c2d194e2ee8fd0d1b66b8349fad7dbacce5a2" -dependencies = [ - "cc", - "cfg-if", - "libc", - "log", - "rustversion", - "windows", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -1678,7 +1297,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.3.1", + "http", "indexmap", "slab", "tokio", @@ -1724,7 +1343,7 @@ dependencies = [ "base64", "bytes", "headers-core", - "http 1.3.1", + "http", "httpdate", "mime", "sha1", @@ -1736,7 +1355,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" dependencies = [ - "http 1.3.1", + "http", ] [[package]] @@ -1790,17 +1409,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http" version = "1.3.1" @@ -1819,7 +1427,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.3.1", + "http", ] [[package]] @@ -1830,7 +1438,7 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", "futures-core", - "http 1.3.1", + "http", "http-body", "pin-project-lite", ] @@ -1841,32 +1449,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" -[[package]] -name = "http-signature-normalization" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b95e3149194de5f3f9d5225bcc6a8677979f8ff8ce39c85654730ad4824f101e" -dependencies = [ - "httpdate", -] - -[[package]] -name = "http-signature-normalization-reqwest" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8822f7eab343cae1ce3bd3b6d0b9b58c72adaf3463627cfe150f8f5406f27aa" -dependencies = [ - "async-trait", - "base64", - "http-signature-normalization", - "httpdate", - "reqwest", - "reqwest-middleware 0.3.3", - "sha2", - "thiserror 1.0.69", - "tokio", -] - [[package]] name = "httparse" version = "1.10.1" @@ -1889,7 +1471,7 @@ dependencies = [ "futures-channel", "futures-util", "h2", - "http 1.3.1", + "http", "http-body", "httparse", "httpdate", @@ -1906,7 +1488,7 @@ version = "0.27.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ - "http 1.3.1", + "http", "hyper", "hyper-util", "rustls", @@ -1944,7 +1526,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "http 1.3.1", + "http", "http-body", "hyper", "ipnet", @@ -2096,12 +1678,6 @@ dependencies = [ "icu_properties", ] -[[package]] -name = "impl-more" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a5a9a0ff0086c7a148acb942baaabeadf9504d10400b5a05645853729b9cd2" - [[package]] name = "indexmap" version = "2.10.0" @@ -2155,15 +1731,6 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.15" @@ -2204,12 +1771,6 @@ dependencies = [ "log", ] -[[package]] -name = "language-tags" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" - [[package]] name = "lazy_static" version = "1.5.0" @@ -2263,23 +1824,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" -[[package]] -name = "local-channel" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" -dependencies = [ - "futures-core", - "futures-sink", - "local-waker", -] - -[[package]] -name = "local-waker" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" - [[package]] name = "lock_api" version = "0.4.13" @@ -2299,19 +1843,6 @@ dependencies = [ "value-bag", ] -[[package]] -name = "loom" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" -dependencies = [ - "cfg-if", - "generator", - "scoped-tls", - "tracing", - "tracing-subscriber", -] - [[package]] name = "lru-slab" version = "0.1.2" @@ -2327,12 +1858,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matchit" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" - [[package]] name = "matchit" version = "0.8.4" @@ -2396,7 +1921,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", - "log", "wasi 0.11.1+wasi-snapshot-preview1", "windows-sys 0.59.0", ] @@ -2414,28 +1938,6 @@ dependencies = [ "validator", ] -[[package]] -name = "moka" -version = "0.12.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9321642ca94a4282428e6ea4af8cc2ca4eac48ac7a6a4ea8f33f76d0ce70926" -dependencies = [ - "async-lock", - "crossbeam-channel", - "crossbeam-epoch", - "crossbeam-utils", - "event-listener 5.4.0", - "futures-util", - "loom", - "parking_lot", - "portable-atomic", - "rustc_version", - "smallvec", - "tagptr", - "thiserror 1.0.69", - "uuid", -] - [[package]] name = "native-tls" version = "0.2.14" @@ -2788,12 +2290,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "portable-atomic" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" - [[package]] name = "postgres-protocol" version = "0.6.8" @@ -3109,12 +2605,6 @@ dependencies = [ "regex-syntax 0.8.5", ] -[[package]] -name = "regex-lite" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943f41321c63ef1c92fd763bfe054d2668f7f225a5c29f0105903dc2fc04ba30" - [[package]] name = "regex-syntax" version = "0.6.29" @@ -3146,9 +2636,8 @@ dependencies = [ "bytes", "encoding_rs", "futures-core", - "futures-util", "h2", - "http 1.3.1", + "http", "http-body", "http-body-util", "hyper", @@ -3171,33 +2660,16 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls", - "tokio-util", - "tower 0.5.2", + "tower", "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams", "web-sys", "webpki-roots 1.0.1", ] -[[package]] -name = "reqwest-middleware" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562ceb5a604d3f7c885a792d42c199fd8af239d0a51b2fa6a78aafa092452b04" -dependencies = [ - "anyhow", - "async-trait", - "http 1.3.1", - "reqwest", - "serde", - "thiserror 1.0.69", - "tower-service", -] - [[package]] name = "reqwest-middleware" version = "0.4.2" @@ -3206,7 +2678,7 @@ checksum = "57f17d28a6e6acfe1733fe24bcd30774d13bffa4b8a22535b4c8c98423088d4e" dependencies = [ "anyhow", "async-trait", - "http 1.3.1", + "http", "reqwest", "serde", "thiserror 1.0.69", @@ -3338,15 +2810,6 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - [[package]] name = "rustix" version = "1.0.7" @@ -3434,12 +2897,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - [[package]] name = "scopeguard" version = "1.2.0" @@ -3672,7 +3129,6 @@ version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ - "indexmap", "itoa", "memchr", "ryu", @@ -3747,10 +3203,10 @@ dependencies = [ "anyhow", "async-trait", "headers", - "http 1.3.1", + "http", "percent-encoding", "reqwest", - "reqwest-middleware 0.4.2", + "reqwest-middleware", "serde", "serde_json", "shuttle-common", @@ -3765,7 +3221,7 @@ version = "0.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf1e9636f7f77bb6d1eb9e0e19352eb8cbaf11109fdbf5148cabd8d28190161" dependencies = [ - "axum 0.8.4", + "axum", "shuttle-runtime", ] @@ -3788,7 +3244,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33df336332f0052b047470b321709f70475a8f4d94909d23bc67d448aad15454" dependencies = [ "chrono", - "http 1.3.1", + "http", "semver", "serde", "serde_json", @@ -4293,12 +3749,6 @@ dependencies = [ "libc", ] -[[package]] -name = "tagptr" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" - [[package]] name = "tap" version = "1.0.1" @@ -4364,7 +3814,7 @@ version = "0.1.0" dependencies = [ "api", "app", - "axum 0.8.4", + "axum", "doc", "http-body-util", "models", @@ -4577,17 +4027,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tower" version = "0.5.2" @@ -4610,10 +4049,10 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "151b5a3e3c45df17466454bb74e9ecedecc955269bdedbf4d150dfa393b55a36" dependencies = [ - "axum-core 0.5.2", + "axum-core", "cookie", "futures-util", - "http 1.3.1", + "http", "parking_lot", "pin-project-lite", "tower-layer", @@ -4630,7 +4069,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http 1.3.1", + "http", "http-body", "http-body-util", "http-range-header", @@ -4642,7 +4081,7 @@ dependencies = [ "pin-project-lite", "tokio", "tokio-util", - "tower 0.5.2", + "tower", "tower-layer", "tower-service", "tracing", @@ -4749,7 +4188,7 @@ checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13" dependencies = [ "bytes", "data-encoding", - "http 1.3.1", + "http", "httparse", "log", "rand 0.9.1", @@ -4821,12 +4260,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "untrusted" version = "0.9.0" @@ -4867,11 +4300,11 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" name = "utils" version = "0.1.0" dependencies = [ - "axum 0.8.4", + "axum", "migration", "sea-orm", "tokio", - "tower 0.5.2", + "tower", "uuid", ] @@ -4906,7 +4339,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59559e1509172f6b26c1cdbc7247c4ddd1ac6560fe94b584f81ee489b141f719" dependencies = [ - "axum 0.8.4", + "axum", "serde", "serde_json", "utoipa", @@ -4918,7 +4351,7 @@ version = "9.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d047458f1b5b65237c2f6dc6db136945667f40a7668627b3490b9513a3d43a55" dependencies = [ - "axum 0.8.4", + "axum", "base64", "mime_guess", "regex", @@ -5113,19 +4546,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "wasm-streams" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" -dependencies = [ - "futures-util", - "js-sys", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "web-sys" version = "0.3.77" @@ -5206,28 +4626,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.61.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" -dependencies = [ - "windows-collections", - "windows-core", - "windows-future", - "windows-link", - "windows-numerics", -] - -[[package]] -name = "windows-collections" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" -dependencies = [ - "windows-core", -] - [[package]] name = "windows-core" version = "0.61.2" @@ -5241,17 +4639,6 @@ dependencies = [ "windows-strings", ] -[[package]] -name = "windows-future" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" -dependencies = [ - "windows-core", - "windows-link", - "windows-threading", -] - [[package]] name = "windows-implement" version = "0.60.0" @@ -5280,16 +4667,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" -[[package]] -name = "windows-numerics" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" -dependencies = [ - "windows-core", - "windows-link", -] - [[package]] name = "windows-registry" version = "0.5.3" @@ -5402,15 +4779,6 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] -[[package]] -name = "windows-threading" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" -dependencies = [ - "windows-link", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" diff --git a/thoughts-backend/api/Cargo.toml b/thoughts-backend/api/Cargo.toml index 9385935..1017f4b 100644 --- a/thoughts-backend/api/Cargo.toml +++ b/thoughts-backend/api/Cargo.toml @@ -38,6 +38,5 @@ tower-http = { version = "0.6.6", features = ["fs", "cors"] } tower-cookies = "0.11.0" anyhow = "1.0.98" dotenvy = "0.15.7" -activitypub_federation = "0.6.5" -url = "2.5.7" + [dev-dependencies] diff --git a/thoughts-backend/api/src/federation.rs b/thoughts-backend/api/src/federation.rs deleted file mode 100644 index 8bb2dae..0000000 --- a/thoughts-backend/api/src/federation.rs +++ /dev/null @@ -1,70 +0,0 @@ -use app::{ - persistence::{follow, user}, - state::AppState, -}; -use models::domains::thought; -use serde_json::json; - -// This function handles pushing a new thought to all followers. -pub async fn federate_thought( - state: AppState, - thought: thought::Model, - author: models::domains::user::Model, -) { - // Find all followers of the author - let follower_ids = match follow::get_follower_ids(&state.conn, author.id).await { - Ok(ids) => ids, - Err(e) => { - tracing::error!("Failed to get followers for federation: {}", e); - return; - } - }; - - if follower_ids.is_empty() { - println!("No followers to federate to for user {}", author.username); - return; - } - - let thought_url = format!("{}/thoughts/{}", &state.base_url, thought.id); - let author_url = format!("{}/users/{}", &state.base_url, author.username); - - // Construct the "Create" activity containing the "Note" object - let activity = json!({ - "@context": "https://www.w3.org/ns/activitystreams", - "id": format!("{}/activity", thought_url), - "type": "Create", - "actor": author_url, - "object": { - "id": thought_url, - "type": "Note", - "attributedTo": author_url, - "content": thought.content, - "published": thought.created_at.to_rfc3339(), - "to": ["https://www.w3.org/ns/activitystreams#Public"], - "cc": [format!("{}/followers", author_url)] - } - }); - - // Get the inbox URLs for all followers - // In a real federated app, you would store remote users' full inbox URLs. - // For now, we assume followers are local and construct their inbox URLs. - let followers = match user::get_users_by_ids(&state.conn, follower_ids).await { - Ok(users) => users, - Err(e) => { - tracing::error!("Failed to get follower user objects: {}", e); - return; - } - }; - - let client = reqwest::Client::new(); - for follower in followers { - let inbox_url = format!("{}/users/{}/inbox", &state.base_url, follower.username); - tracing::info!("Federating post {} to {}", thought.id, inbox_url); - - let res = client.post(&inbox_url).json(&activity).send().await; - - if let Err(e) = res { - tracing::error!("Failed to federate to {}: {}", inbox_url, e); - } - } -} diff --git a/thoughts-backend/api/src/lib.rs b/thoughts-backend/api/src/lib.rs index 12a96f9..ceba9b9 100644 --- a/thoughts-backend/api/src/lib.rs +++ b/thoughts-backend/api/src/lib.rs @@ -1,6 +1,5 @@ mod error; mod extractor; -mod federation; mod init; mod validation; diff --git a/thoughts-backend/api/src/routers/mod.rs b/thoughts-backend/api/src/routers/mod.rs index ef77fa1..9c2895e 100644 --- a/thoughts-backend/api/src/routers/mod.rs +++ b/thoughts-backend/api/src/routers/mod.rs @@ -9,9 +9,8 @@ pub mod search; pub mod tag; pub mod thought; pub mod user; -pub mod well_known; -use crate::routers::{auth::create_auth_router, well_known::create_well_known_router}; +use crate::routers::auth::create_auth_router; use app::state::AppState; use root::create_root_router; use tower_http::cors::CorsLayer; @@ -24,7 +23,6 @@ pub fn create_router(state: AppState) -> Router { Router::new() .merge(create_root_router()) - .nest("/.well-known", create_well_known_router()) .nest("/auth", create_auth_router()) .nest("/users", create_user_router()) .nest("/thoughts", create_thought_router()) diff --git a/thoughts-backend/api/src/routers/thought.rs b/thoughts-backend/api/src/routers/thought.rs index 31a4cd7..2fc4082 100644 --- a/thoughts-backend/api/src/routers/thought.rs +++ b/thoughts-backend/api/src/routers/thought.rs @@ -20,7 +20,6 @@ use sea_orm::prelude::Uuid; use crate::{ error::ApiError, extractor::{AuthUser, Json, OptionalAuthUser, Valid}, - federation, models::{ApiErrorResponse, ParamsErrorResponse}, }; @@ -77,13 +76,6 @@ async fn thoughts_post( .await? .ok_or(UserError::NotFound)?; // Should not happen if auth is valid - // Spawn a background task to handle federation without blocking the response - tokio::spawn(federation::federate_thought( - state.clone(), - thought.clone(), - author.clone(), - )); - let schema = ThoughtSchema::from_models(&thought, &author); Ok((StatusCode::CREATED, Json(schema))) } diff --git a/thoughts-backend/api/src/routers/well_known.rs b/thoughts-backend/api/src/routers/well_known.rs deleted file mode 100644 index c92adb7..0000000 --- a/thoughts-backend/api/src/routers/well_known.rs +++ /dev/null @@ -1,70 +0,0 @@ -use app::state::AppState; -use axum::{ - extract::{Query, State}, - response::{IntoResponse, Json}, -}; -use serde::{Deserialize, Serialize}; -use url::Url; - -#[derive(Deserialize)] -pub struct WebFingerQuery { - resource: String, -} - -#[derive(Serialize)] -pub struct WebFingerLink { - rel: String, - #[serde(rename = "type")] - type_: String, - href: Url, -} - -#[derive(Serialize)] -pub struct WebFingerResponse { - subject: String, - links: Vec, -} - -pub async fn webfinger( - State(state): State, - Query(query): Query, -) -> Result { - if let Some((scheme, account_info)) = query.resource.split_once(':') { - if scheme != "acct" { - return Err(( - axum::http::StatusCode::BAD_REQUEST, - "Invalid resource scheme", - )); - } - - let account_parts: Vec<&str> = account_info.split('@').collect(); - let username = account_parts[0]; - - let user = match app::persistence::user::get_user_by_username(&state.conn, username).await { - Ok(Some(user)) => user, - _ => return Err((axum::http::StatusCode::NOT_FOUND, "User not found")), - }; - - let user_url = Url::parse(&format!("{}/users/{}", &state.base_url, user.username)).unwrap(); - - let response = WebFingerResponse { - subject: query.resource, - links: vec![WebFingerLink { - rel: "self".to_string(), - type_: "application/activity+json".to_string(), - href: user_url, - }], - }; - - Ok(Json(response)) - } else { - Err(( - axum::http::StatusCode::BAD_REQUEST, - "Invalid resource format", - )) - } -} - -pub fn create_well_known_router() -> axum::Router { - axum::Router::new().route("/webfinger", axum::routing::get(webfinger)) -} diff --git a/thoughts-backend/tests/api/activitypub.rs b/thoughts-backend/tests/api/activitypub.rs deleted file mode 100644 index 1325bb2..0000000 --- a/thoughts-backend/tests/api/activitypub.rs +++ /dev/null @@ -1,151 +0,0 @@ -use crate::api::main::{create_user_with_password, setup}; -use axum::http::{header, StatusCode}; -use http_body_util::BodyExt; -use serde_json::{json, Value}; -use utils::testing::{ - make_get_request, make_jwt_request, make_post_request, make_request_with_headers, -}; - -#[tokio::test] -async fn test_webfinger_discovery() { - let app = setup().await; - create_user_with_password(&app.db, "testuser", "password123", "testuser@example.com").await; - - // 1. Valid WebFinger lookup for existing user - let url = "/.well-known/webfinger?resource=acct:testuser@localhost:3000"; - let response = make_get_request(app.router.clone(), url, None).await; - assert_eq!(response.status(), StatusCode::OK); - let body = response.into_body().collect().await.unwrap().to_bytes(); - let v: Value = serde_json::from_slice(&body).unwrap(); - assert_eq!(v["subject"], "acct:testuser@localhost:3000"); - assert_eq!( - v["links"][0]["href"], - "http://localhost:3000/users/testuser" - ); - - // 2. WebFinger lookup for a non-existent user - let response = make_get_request( - app.router.clone(), - "/.well-known/webfinger?resource=acct:nobody@localhost:3000", - None, - ) - .await; - assert_eq!(response.status(), StatusCode::NOT_FOUND); -} - -#[tokio::test] -async fn test_user_actor_endpoint() { - let app = setup().await; - create_user_with_password(&app.db, "testuser", "password123", "testuser@example.com").await; - - let response = make_request_with_headers( - app.router.clone(), - "/users/testuser", - "GET", - None, - vec![( - header::ACCEPT, - "application/activity+json, application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", - )], - ).await; - - assert_eq!(response.status(), StatusCode::OK); - let content_type = response.headers().get(header::CONTENT_TYPE).unwrap(); - assert_eq!(content_type, "application/activity+json"); - - let body = response.into_body().collect().await.unwrap().to_bytes(); - let v: Value = serde_json::from_slice(&body).unwrap(); - assert_eq!(v["type"], "Person"); - assert_eq!(v["preferredUsername"], "testuser"); - assert_eq!(v["id"], "http://localhost:3000/users/testuser"); -} - -#[tokio::test] -async fn test_user_inbox_follow() { - let app = setup().await; - // user1 will be followed - let user1 = - create_user_with_password(&app.db, "user1", "password123", "user1@example.com").await; - // user2 will be the follower - let user2 = - create_user_with_password(&app.db, "user2", "password123", "user2@example.com").await; - - // Construct a follow activity from user2, targeting user1 - let follow_activity = json!({ - "@context": "https://www.w3.org/ns/activitystreams", - "id": "http://localhost:3000/some-unique-id", - "type": "Follow", - "actor": "http://localhost:3000/users/user2", // The actor is user2 - "object": "http://localhost:3000/users/user1" - }) - .to_string(); - - // POST the activity to user1's inbox - let response = make_post_request( - app.router.clone(), - "/users/user1/inbox", - follow_activity, - None, - ) - .await; - - assert_eq!(response.status(), StatusCode::ACCEPTED); - - // Verify that user2 is now following user1 in the database - let followers = app::persistence::follow::get_following_ids(&app.db, user2.id) - .await - .unwrap(); - assert!( - followers.contains(&user1.id), - "User2 should be following user1" - ); - - let following = app::persistence::follow::get_following_ids(&app.db, user1.id) - .await - .unwrap(); - assert!( - !following.contains(&user2.id), - "User1 should now be followed by user2" - ); - assert!(following.is_empty(), "User1 should not be following anyone"); -} - -#[tokio::test] -async fn test_user_outbox_get() { - let app = setup().await; - create_user_with_password(&app.db, "testuser", "password123", "testuser@example.com").await; - let token = super::main::login_user(app.router.clone(), "testuser", "password123").await; - - // Create a thought first - let thought_body = json!({ "content": "This is a federated thought!" }).to_string(); - make_jwt_request( - app.router.clone(), - "/thoughts", - "POST", - Some(thought_body), - &token, - ) - .await; - - // Now, fetch the outbox - let response = make_request_with_headers( - app.router.clone(), - "/users/testuser/outbox", - "GET", - None, - vec![(header::ACCEPT, "application/activity+json")], - ) - .await; - - assert_eq!(response.status(), StatusCode::OK); - let body = response.into_body().collect().await.unwrap().to_bytes(); - let v: Value = serde_json::from_slice(&body).unwrap(); - - assert_eq!(v["type"], "OrderedCollection"); - assert_eq!(v["totalItems"], 1); - assert_eq!(v["orderedItems"][0]["type"], "Create"); - assert_eq!( - v["orderedItems"][0]["object"]["content"], - "This is a federated thought!" - ); -} diff --git a/thoughts-backend/tests/api/mod.rs b/thoughts-backend/tests/api/mod.rs index 9285b4a..31c3edd 100644 --- a/thoughts-backend/tests/api/mod.rs +++ b/thoughts-backend/tests/api/mod.rs @@ -1,4 +1,3 @@ -mod activitypub; mod api_key; mod auth; mod feed;