Remove remaining usages of old activitystreams library

This commit is contained in:
Felix Ableitner 2020-07-16 23:40:34 +02:00
parent 269844fa8c
commit 45fb473a81
13 changed files with 425 additions and 557 deletions

275
server/Cargo.lock generated vendored
View file

@ -111,9 +111,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-files" name = "actix-files"
version = "0.3.0-alpha.1" version = "0.3.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b32e0fdd5998c2712549cbc39dff46c8754d55e3dd9f4d017d9e28de30cac6" checksum = "627f597ad98061816766201db8afc7444752992f2919b2e60f53a7fa27f01aed"
dependencies = [ dependencies = [
"actix-http", "actix-http",
"actix-service", "actix-service",
@ -132,9 +132,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-http" name = "actix-http"
version = "2.0.0-alpha.4" version = "2.0.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd7ea0568480d199952a51de70271946da57c33cc0e8b83f54383e70958dff21" checksum = "33f501768e82e8548763b7f55309e2f8bcc7f9f4273c75b47af99ac2b2581f37"
dependencies = [ dependencies = [
"actix-codec", "actix-codec",
"actix-connect", "actix-connect",
@ -147,6 +147,7 @@ dependencies = [
"bitflags", "bitflags",
"brotli2", "brotli2",
"bytes", "bytes",
"cookie",
"copyless", "copyless",
"derive_more", "derive_more",
"either", "either",
@ -160,6 +161,7 @@ dependencies = [
"http", "http",
"httparse", "httparse",
"indexmap", "indexmap",
"itoa",
"language-tags", "language-tags",
"lazy_static", "lazy_static",
"log", "log",
@ -171,7 +173,7 @@ dependencies = [
"serde 1.0.114", "serde 1.0.114",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"sha-1", "sha-1 0.9.1",
"slab", "slab",
"time 0.2.16", "time 0.2.16",
] ]
@ -260,16 +262,16 @@ dependencies = [
[[package]] [[package]]
name = "actix-threadpool" name = "actix-threadpool"
version = "0.3.2" 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 = "91164716d956745c79dcea5e66d2aa04506549958accefcede5368c70f2fd4ff" checksum = "d209f04d002854b9afd3743032a27b066158817965bf5d036824d19ac2cc0e30"
dependencies = [ dependencies = [
"derive_more", "derive_more",
"futures-channel", "futures-channel",
"lazy_static", "lazy_static",
"log", "log",
"num_cpus", "num_cpus",
"parking_lot 0.10.2", "parking_lot 0.11.0",
"threadpool", "threadpool",
] ]
@ -313,9 +315,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-web" name = "actix-web"
version = "3.0.0-alpha.3" version = "3.0.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bd6df56ec5f9a1a0d8335f156f36e1e8f76dbd736fa0cc0f6bc3a69be1e6124" checksum = "9125c29b7d9911bfdb4d0d4d8f1cf4fee4f21515cf2a405a423c30c245364297"
dependencies = [ dependencies = [
"actix-codec", "actix-codec",
"actix-http", "actix-http",
@ -353,24 +355,25 @@ dependencies = [
[[package]] [[package]]
name = "actix-web-actors" name = "actix-web-actors"
version = "3.0.0-alpha.1" version = "3.0.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b5efeb3907582f9c724ce27be093ab8aafabd97be828bc6750c0d467f5e1aa3" checksum = "55ef22b33c49a28dda61866d5573c5b8ceb080a099cd59e7371b78b48bbf1bc0"
dependencies = [ dependencies = [
"actix", "actix",
"actix-codec", "actix-codec",
"actix-http", "actix-http",
"actix-web", "actix-web",
"bytes", "bytes",
"futures", "futures-channel",
"futures-core",
"pin-project", "pin-project",
] ]
[[package]] [[package]]
name = "actix-web-codegen" name = "actix-web-codegen"
version = "0.2.2" version = "0.3.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a71bf475cbe07281d0b3696abb48212db118e7e23219f13596ce865235ff5766" checksum = "df9679f5b1f4c819de08b63b0a61a131b2fdc30b367c2c208984fda8eaa07fa0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -390,24 +393,18 @@ dependencies = [
[[package]] [[package]]
name = "addr2line" name = "addr2line"
version = "0.12.2" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "602d785912f476e480434627e8732e6766b760c045bbf897d9dfaa9f4fbd399c" checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
dependencies = [ dependencies = [
"gimli", "gimli",
] ]
[[package]] [[package]]
name = "adler" name = "adler"
version = "0.2.2" 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 = "ccc9a9dd069569f212bc4330af9f17c4afb5e8ce185e83dbb14f1349dda18b10" checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
[[package]]
name = "adler32"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d"
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
@ -481,9 +478,9 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]] [[package]]
name = "awc" name = "awc"
version = "2.0.0-alpha.2" version = "2.0.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7038a9747cd5159b9f0550895eaf865c0143baa7e4eee834e9294d0a7e0e4be" checksum = "374057b508d4083208996be82141891c2e14c8885f45991b21c1621200ab6df3"
dependencies = [ dependencies = [
"actix-codec", "actix-codec",
"actix-http", "actix-http",
@ -505,14 +502,14 @@ dependencies = [
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.49" version = "0.3.50"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05100821de9e028f12ae3d189176b41ee198341eb8f369956407fea2f5cc666c" checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293"
dependencies = [ dependencies = [
"addr2line", "addr2line",
"cfg-if", "cfg-if",
"libc", "libc",
"miniz_oxide 0.3.7", "miniz_oxide",
"object", "object",
"rustc-demangle", "rustc-demangle",
] ]
@ -590,7 +587,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
dependencies = [ dependencies = [
"generic-array 0.14.2", "generic-array 0.14.3",
] ]
[[package]] [[package]]
@ -599,7 +596,7 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa136449e765dc7faa244561ccae839c394048667929af599b5d931ebe7b7f10" checksum = "fa136449e765dc7faa244561ccae839c394048667929af599b5d931ebe7b7f10"
dependencies = [ dependencies = [
"generic-array 0.14.2", "generic-array 0.14.3",
] ]
[[package]] [[package]]
@ -642,6 +639,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "buf-min"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6ae7069aad07c7cdefe6a22a671f00650728bd2331a4cc62e1e5d0becdf9ca4"
dependencies = [
"bytes",
]
[[package]] [[package]]
name = "bufstream" name = "bufstream"
version = "0.1.4" version = "0.1.4"
@ -668,12 +674,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "0.5.5" version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "118cf036fbb97d0816e3c34b2d7a1e8cfc60f68fcf63d550ddbe9bd5f59c213b" checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
dependencies = [
"loom",
]
[[package]] [[package]]
name = "bytestring" name = "bytestring"
@ -686,9 +689,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.57" version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe" checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -698,9 +701,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.12" version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0fee792e164f78f5fe0c296cc2eb3688a2ca2b70cdff33040922d298203f0c4" checksum = "c74d84029116787153e02106bf53e66828452a4b325cc8652b788b5967c0a0b6"
dependencies = [ dependencies = [
"num-integer", "num-integer",
"num-traits 0.2.12", "num-traits 0.2.12",
@ -770,6 +773,16 @@ dependencies = [
"serde-hjson", "serde-hjson",
] ]
[[package]]
name = "cookie"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca761767cf3fa9068cc893ec8c247a22d0fd0535848e65640c0548bd1f8bbb36"
dependencies = [
"percent-encoding",
"time 0.2.16",
]
[[package]] [[package]]
name = "copyless" name = "copyless"
version = "0.1.5" version = "0.1.5"
@ -794,9 +807,9 @@ checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]] [[package]]
name = "cpuid-bool" name = "cpuid-bool"
version = "0.1.0" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d375c433320f6c5057ae04a04376eef4d04ce2801448cf8863a78da99107be4" checksum = "ec6763c20301ab0dc67051d1b6f4cc9132ad9e6eddcb1f10c6c53ea6d6ae2183"
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
@ -950,7 +963,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [ dependencies = [
"generic-array 0.14.2", "generic-array 0.14.3",
] ]
[[package]] [[package]]
@ -1142,7 +1155,7 @@ dependencies = [
"cfg-if", "cfg-if",
"crc32fast", "crc32fast",
"libc", "libc",
"miniz_oxide 0.4.0", "miniz_oxide",
] ]
[[package]] [[package]]
@ -1292,19 +1305,6 @@ dependencies = [
"byteorder", "byteorder",
] ]
[[package]]
name = "generator"
version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "add72f17bb81521258fcc8a7a3245b1e184e916bfbe34f0ea89558f440df5c68"
dependencies = [
"cc",
"libc",
"log",
"rustc_version",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.12.3" version = "0.12.3"
@ -1316,9 +1316,9 @@ dependencies = [
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.14.2" version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac746a5f3bbfdadd6106868134545e684693d54d9d44f6e9588a7d54af0bf980" checksum = "60fb4bb6bba52f78a471264d9a3b7d026cc0af47b22cd2cffbc0b787ca003e63"
dependencies = [ dependencies = [
"typenum", "typenum",
"version_check 0.9.2", "version_check 0.9.2",
@ -1337,15 +1337,15 @@ dependencies = [
[[package]] [[package]]
name = "gimli" name = "gimli"
version = "0.21.0" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.2.5" version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff" checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53"
dependencies = [ dependencies = [
"bytes", "bytes",
"fnv", "fnv",
@ -1354,10 +1354,10 @@ dependencies = [
"futures-util", "futures-util",
"http", "http",
"indexmap", "indexmap",
"log",
"slab", "slab",
"tokio", "tokio",
"tokio-util 0.3.1", "tokio-util 0.3.1",
"tracing",
] ]
[[package]] [[package]]
@ -1371,9 +1371,9 @@ dependencies = [
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.14" version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909" checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -1481,9 +1481,9 @@ dependencies = [
[[package]] [[package]]
name = "instant" name = "instant"
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 = "69da7ce1490173c2bf4d26bc8be429aaeeaf4cce6c4b970b7949651fa17655fe" checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
[[package]] [[package]]
name = "iovec" name = "iovec"
@ -1523,9 +1523,9 @@ checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.41" version = "0.3.42"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4b9172132a62451e56142bff9afc91c8e4a4500aa5b847da36815b63bfda916" checksum = "52732a3d3ad72c58ad2dc70624f9c17b46ecd0943b9a4f1ee37c4c18c5d983e2"
dependencies = [ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
@ -1585,7 +1585,6 @@ dependencies = [
name = "lemmy_server" name = "lemmy_server"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"activitystreams",
"activitystreams-ext", "activitystreams-ext",
"activitystreams-new", "activitystreams-new",
"actix", "actix",
@ -1693,9 +1692,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.71" version = "0.2.72"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
@ -1724,33 +1723,22 @@ dependencies = [
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de302ce1fe7482db13738fbaf2e21cfb06a986b89c0bf38d88abf16681aada4e" checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c"
dependencies = [ dependencies = [
"scopeguard", "scopeguard",
] ]
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.8" version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "loom"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ecc775857611e1df29abba5c41355cdf540e7e9d4acfdf0f355eefee82330b7"
dependencies = [
"cfg-if",
"generator",
"scoped-tls",
]
[[package]] [[package]]
name = "lru-cache" name = "lru-cache"
version = "0.1.2" version = "0.1.2"
@ -1827,15 +1815,6 @@ dependencies = [
"unicase", "unicase",
] ]
[[package]]
name = "miniz_oxide"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435"
dependencies = [
"adler32",
]
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.4.0" version = "0.4.0"
@ -2060,7 +2039,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733"
dependencies = [ dependencies = [
"instant", "instant",
"lock_api 0.4.0", "lock_api 0.4.1",
"parking_lot_core 0.8.0", "parking_lot_core 0.8.0",
] ]
@ -2150,7 +2129,7 @@ checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
dependencies = [ dependencies = [
"maplit", "maplit",
"pest", "pest",
"sha-1", "sha-1 0.8.2",
] ]
[[package]] [[package]]
@ -2187,9 +2166,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.17" version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
@ -2434,9 +2413,9 @@ dependencies = [
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.1.56" version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]] [[package]]
name = "regex" name = "regex"
@ -2559,12 +2538,6 @@ dependencies = [
"parking_lot 0.11.0", "parking_lot 0.11.0",
] ]
[[package]]
name = "scoped-tls"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28"
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.1.0" version = "1.1.0"
@ -2703,6 +2676,19 @@ dependencies = [
"opaque-debug 0.2.3", "opaque-debug 0.2.3",
] ]
[[package]]
name = "sha-1"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770"
dependencies = [
"block-buffer 0.9.0",
"cfg-if",
"cpuid-bool",
"digest 0.9.0",
"opaque-debug 0.3.0",
]
[[package]] [[package]]
name = "sha1" name = "sha1"
version = "0.6.0" version = "0.6.0"
@ -2734,9 +2720,9 @@ dependencies = [
[[package]] [[package]]
name = "simple_asn1" name = "simple_asn1"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b25ecba7165254f0c97d6c22a64b1122a03634b18d20a34daf21e18f892e618" checksum = "692ca13de57ce0613a363c8c2f1de925adebc81b04c923ac60c5488bb44abe4b"
dependencies = [ dependencies = [
"chrono", "chrono",
"num-bigint", "num-bigint",
@ -2751,9 +2737,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.4.0" 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 = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f"
[[package]] [[package]]
name = "socket2" name = "socket2"
@ -2869,9 +2855,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.33" version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3076,6 +3062,26 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "tracing"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e2a2de6b0d5cbb13fc21193a2296888eaab62b6044479aafb3c54c01c29fcd"
dependencies = [
"cfg-if",
"log",
"tracing-core",
]
[[package]]
name = "tracing-core"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94ae75f0d28ae10786f3b1895c55fe72e79928fd5ccdebb5438c75e93fec178f"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "trust-dns-proto" name = "trust-dns-proto"
version = "0.19.5" version = "0.19.5"
@ -3251,18 +3257,19 @@ dependencies = [
[[package]] [[package]]
name = "v_escape" name = "v_escape"
version = "0.7.4" version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "660b101c07b5d0863deb9e7fb3138777e858d6d2a79f9e6049a27d1cc77c6da6" checksum = "b66158ce426982197fd44266d68125fd4000f1d42f5ee33ef02b500b4b6b0024"
dependencies = [ dependencies = [
"buf-min",
"v_escape_derive", "v_escape_derive",
] ]
[[package]] [[package]]
name = "v_escape_derive" name = "v_escape_derive"
version = "0.5.6" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2ca2a14bc3fc5b64d188b087a7d3a927df87b152e941ccfbc66672e20c467ae" checksum = "cae7cffca0b1f9af9b20610f6fdeee9ffcce61417b5ad186a5d482dc904e24cd"
dependencies = [ dependencies = [
"nom 4.2.3", "nom 4.2.3",
"proc-macro2", "proc-macro2",
@ -3272,9 +3279,9 @@ dependencies = [
[[package]] [[package]]
name = "v_htmlescape" name = "v_htmlescape"
version = "0.4.5" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e33e939c0d8cf047514fb6ba7d5aac78bc56677a6938b2ee67000b91f2e97e41" checksum = "f5fd25529cb2f78527b5ee507bcfb357b26d057b5e480853c26d49a4ead5c629"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"v_escape", "v_escape",
@ -3312,9 +3319,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.64" version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2" checksum = "f3edbcc9536ab7eababcc6d2374a0b7bfe13a2b6d562c5e07f370456b1a8f33d"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"wasm-bindgen-macro", "wasm-bindgen-macro",
@ -3322,9 +3329,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-backend" name = "wasm-bindgen-backend"
version = "0.2.64" version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df" checksum = "89ed2fb8c84bfad20ea66b26a3743f3e7ba8735a69fe7d95118c33ec8fc1244d"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"lazy_static", "lazy_static",
@ -3337,9 +3344,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.64" version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8" checksum = "eb071268b031a64d92fc6cf691715ca5a40950694d8f683c5bb43db7c730929e"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@ -3347,9 +3354,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.64" version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75" checksum = "cf592c807080719d1ff2f245a687cbadb3ed28b2077ed7084b47aba8b691f2c6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3360,15 +3367,15 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.64" version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae" checksum = "72b6c0220ded549d63860c78c38f3bcc558d1ca3f4efa74942c536ddbbb55e87"
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.41" version = "0.3.42"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "863539788676619aac1a23e2df3655e96b32b0e05eb72ca34ba045ad573c625d" checksum = "8be2398f326b7ba09815d0b403095f34dd708579220d099caae89be0b32137b2"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",

1
server/Cargo.toml vendored
View file

@ -18,7 +18,6 @@ lemmy_db = { path = "./lemmy_db" }
diesel = "1.4.4" diesel = "1.4.4"
diesel_migrations = "1.4.0" diesel_migrations = "1.4.0"
dotenv = "0.15.0" dotenv = "0.15.0"
activitystreams = "0.6.2"
activitystreams-new = { git = "https://git.asonix.dog/asonix/activitystreams-sketch" } activitystreams-new = { git = "https://git.asonix.dog/asonix/activitystreams-sketch" }
activitystreams-ext = { git = "https://git.asonix.dog/asonix/activitystreams-ext" } activitystreams-ext = { git = "https://git.asonix.dog/asonix/activitystreams-ext" }
bcrypt = "0.8.0" bcrypt = "0.8.0"

View file

@ -1,46 +1,29 @@
use crate::{ use crate::{
apub::{ apub::{
community::do_announce, extensions::signatures::sign, insert_activity, is_apub_id_valid, community::do_announce,
extensions::signatures::sign,
insert_activity,
is_apub_id_valid,
ActorType, ActorType,
}, },
request::retry_custom, request::retry_custom,
DbPool, LemmyError, DbPool,
LemmyError,
}; };
use activitystreams::{context, object::properties::ObjectProperties, public, Activity, Base}; use activitystreams_new::base::AnyBase;
use actix_web::client::Client; use actix_web::client::Client;
use lemmy_db::{community::Community, user::User_}; use lemmy_db::{community::Community, user::User_};
use log::debug; use log::debug;
use serde::Serialize;
use std::fmt::Debug;
use url::Url; use url::Url;
pub fn populate_object_props( pub async fn send_activity_to_community(
props: &mut ObjectProperties,
addressed_ccs: Vec<String>,
object_id: &str,
) -> Result<(), LemmyError> {
props
.set_context_xsd_any_uri(context())?
// TODO: the activity needs a seperate id from the object
.set_id(object_id)?
// TODO: should to/cc go on the Create, or on the Post? or on both?
// TODO: handle privacy on the receiving side (at least ignore anything thats not public)
.set_to_xsd_any_uri(public())?
.set_many_cc_xsd_any_uris(addressed_ccs)?;
Ok(())
}
pub async fn send_activity_to_community<A>(
creator: &User_, creator: &User_,
community: &Community, community: &Community,
to: Vec<String>, to: Vec<String>,
activity: A, activity: AnyBase,
client: &Client, client: &Client,
pool: &DbPool, pool: &DbPool,
) -> Result<(), LemmyError> ) -> Result<(), LemmyError> {
where
A: Activity + Base + Serialize + Debug + Clone + Send + 'static,
{
insert_activity(creator.id, activity.clone(), true, pool).await?; insert_activity(creator.id, activity.clone(), true, pool).await?;
// if this is a local community, we need to do an announce from the community instead // if this is a local community, we need to do an announce from the community instead
@ -54,15 +37,12 @@ where
} }
/// Send an activity to a list of recipients, using the correct headers etc. /// Send an activity to a list of recipients, using the correct headers etc.
pub async fn send_activity<A>( pub async fn send_activity(
client: &Client, client: &Client,
activity: &A, activity: &AnyBase,
actor: &dyn ActorType, actor: &dyn ActorType,
to: Vec<String>, to: Vec<String>,
) -> Result<(), LemmyError> ) -> Result<(), LemmyError> {
where
A: Serialize,
{
let activity = serde_json::to_string(&activity)?; let activity = serde_json::to_string(&activity)?;
debug!("Sending activitypub activity {} to {:?}", activity, to); debug!("Sending activitypub activity {} to {:?}", activity, to);

View file

@ -1,16 +1,25 @@
use crate::{ use crate::{
apub::{ apub::{
activities::send_activity_to_community, activities::send_activity_to_community,
create_apub_response, create_apub_tombstone_response, create_tombstone, fetch_webfinger_url, create_apub_response,
create_apub_tombstone_response,
create_tombstone,
fetch_webfinger_url,
fetcher::{ fetcher::{
get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post, get_or_fetch_and_insert_remote_comment,
get_or_fetch_and_insert_remote_post,
get_or_fetch_and_upsert_remote_user, get_or_fetch_and_upsert_remote_user,
}, },
ActorType, ApubLikeableType, ApubObjectType, FromApub, ToApub, ActorType,
ApubLikeableType,
ApubObjectType,
FromApub,
ToApub,
}, },
blocking, blocking,
routes::DbPoolParam, routes::DbPoolParam,
DbPool, LemmyError, DbPool,
LemmyError,
}; };
use activitystreams_new::{ use activitystreams_new::{
activity::{Create, Delete, Dislike, Like, Remove, Undo, Update}, activity::{Create, Delete, Dislike, Like, Remove, Undo, Update},
@ -207,7 +216,15 @@ impl ApubObjectType for Comment {
// Set the mention tags // Set the mention tags
.set_many_tags(maa.get_tags()?); .set_many_tags(maa.get_tags()?);
send_activity_to_community(&creator, &community, maa.inboxes, create, client, pool).await?; send_activity_to_community(
&creator,
&community,
maa.inboxes,
create.into_any_base()?,
client,
pool,
)
.await?;
Ok(()) Ok(())
} }
@ -239,7 +256,15 @@ impl ApubObjectType for Comment {
// Set the mention tags // Set the mention tags
.set_many_tags(maa.get_tags()?); .set_many_tags(maa.get_tags()?);
send_activity_to_community(&creator, &community, maa.inboxes, update, client, pool).await?; send_activity_to_community(
&creator,
&community,
maa.inboxes,
update.into_any_base()?,
client,
pool,
)
.await?;
Ok(()) Ok(())
} }
@ -269,7 +294,7 @@ impl ApubObjectType for Comment {
&creator, &creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
delete, delete.into_any_base()?,
client, client,
pool, pool,
) )
@ -314,7 +339,7 @@ impl ApubObjectType for Comment {
&creator, &creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
undo, undo.into_any_base()?,
client, client,
pool, pool,
) )
@ -348,7 +373,7 @@ impl ApubObjectType for Comment {
&mod_, &mod_,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
remove, remove.into_any_base()?,
client, client,
pool, pool,
) )
@ -392,7 +417,7 @@ impl ApubObjectType for Comment {
&mod_, &mod_,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
undo, undo.into_any_base()?,
client, client,
pool, pool,
) )
@ -430,7 +455,7 @@ impl ApubLikeableType for Comment {
&creator, &creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
like, like.into_any_base()?,
client, client,
pool, pool,
) )
@ -465,7 +490,7 @@ impl ApubLikeableType for Comment {
&creator, &creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
dislike, dislike.into_any_base()?,
client, client,
pool, pool,
) )
@ -510,7 +535,7 @@ impl ApubLikeableType for Comment {
&creator, &creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
undo, undo.into_any_base()?,
client, client,
pool, pool,
) )

View file

@ -1,21 +1,28 @@
use crate::{ use crate::{
apub::{ apub::{
activities::{populate_object_props, send_activity}, activities::send_activity,
create_apub_response, create_apub_tombstone_response, create_tombstone, create_apub_response,
create_apub_tombstone_response,
create_tombstone,
extensions::group_extensions::GroupExtension, extensions::group_extensions::GroupExtension,
fetcher::get_or_fetch_and_upsert_remote_user, fetcher::get_or_fetch_and_upsert_remote_user,
get_shared_inbox, insert_activity, ActorType, FromApub, GroupExt, ToApub, get_shared_inbox,
insert_activity,
ActorType,
FromApub,
GroupExt,
ToApub,
}, },
blocking, blocking,
routes::DbPoolParam, routes::DbPoolParam,
DbPool, LemmyError, DbPool,
LemmyError,
}; };
use activitystreams::{activity::Announce, Activity, Base, BaseBox};
use activitystreams_ext::Ext2; use activitystreams_ext::Ext2;
use activitystreams_new::{ use activitystreams_new::{
activity::{Accept, Delete, Follow, Remove, Undo}, activity::{Accept, Announce, Delete, Follow, Remove, Undo},
actor::{kind::GroupType, ApActor, Endpoints, Group}, actor::{kind::GroupType, ApActor, Endpoints, Group},
base::BaseExt, base::{AnyBase, BaseExt},
collection::UnorderedCollection, collection::UnorderedCollection,
context, context,
object::Tombstone, object::Tombstone,
@ -32,8 +39,8 @@ use lemmy_db::{
user::User_, user::User_,
}; };
use lemmy_utils::convert_datetime; use lemmy_utils::convert_datetime;
use serde::{Deserialize, Serialize}; use serde::Deserialize;
use std::{fmt::Debug, str::FromStr}; use std::str::FromStr;
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct CommunityQuery { pub struct CommunityQuery {
@ -142,7 +149,7 @@ impl ActorType for Community {
insert_activity(self.creator_id, accept.clone(), true, pool).await?; insert_activity(self.creator_id, accept.clone(), true, pool).await?;
send_activity(client, &accept, self, vec![to]).await?; send_activity(client, &accept.into_any_base()?, self, vec![to]).await?;
Ok(()) Ok(())
} }
@ -170,7 +177,7 @@ impl ActorType for Community {
// Note: For an accept, since it was automatic, no one pushed a button, // Note: For an accept, since it was automatic, no one pushed a button,
// the community was the actor. // the community was the actor.
// But for delete, the creator is the actor, and does the signing // But for delete, the creator is the actor, and does the signing
send_activity(client, &delete, creator, inboxes).await?; send_activity(client, &delete.into_any_base()?, creator, inboxes).await?;
Ok(()) Ok(())
} }
@ -208,7 +215,7 @@ impl ActorType for Community {
// Note: For an accept, since it was automatic, no one pushed a button, // Note: For an accept, since it was automatic, no one pushed a button,
// the community was the actor. // the community was the actor.
// But for delete, the creator is the actor, and does the signing // But for delete, the creator is the actor, and does the signing
send_activity(client, &undo, creator, inboxes).await?; send_activity(client, &undo.into_any_base()?, creator, inboxes).await?;
Ok(()) Ok(())
} }
@ -236,7 +243,7 @@ impl ActorType for Community {
// Note: For an accept, since it was automatic, no one pushed a button, // Note: For an accept, since it was automatic, no one pushed a button,
// the community was the actor. // the community was the actor.
// But for delete, the creator is the actor, and does the signing // But for delete, the creator is the actor, and does the signing
send_activity(client, &remove, mod_, inboxes).await?; send_activity(client, &remove.into_any_base()?, mod_, inboxes).await?;
Ok(()) Ok(())
} }
@ -273,7 +280,7 @@ impl ActorType for Community {
// Note: For an accept, since it was automatic, no one pushed a button, // Note: For an accept, since it was automatic, no one pushed a button,
// the community was the actor. // the community was the actor.
// But for remove , the creator is the actor, and does the signing // But for remove , the creator is the actor, and does the signing
send_activity(client, &undo, mod_, inboxes).await?; send_activity(client, &undo.into_any_base()?, mod_, inboxes).await?;
Ok(()) Ok(())
} }
@ -413,26 +420,20 @@ pub async fn get_apub_community_followers(
Ok(create_apub_response(&collection)) Ok(create_apub_response(&collection))
} }
pub async fn do_announce<A>( pub async fn do_announce(
activity: A, activity: AnyBase,
community: &Community, community: &Community,
sender: &dyn ActorType, sender: &dyn ActorType,
client: &Client, client: &Client,
pool: &DbPool, pool: &DbPool,
) -> Result<HttpResponse, LemmyError> ) -> Result<HttpResponse, LemmyError> {
where let id = format!("{}/announce/{}", community.actor_id, uuid::Uuid::new_v4());
A: Activity + Base + Serialize + Debug, let mut announce = Announce::new(community.actor_id.to_owned(), activity);
{
let mut announce = Announce::default();
populate_object_props(
&mut announce.object_props,
vec![community.get_followers_url()],
&format!("{}/announce/{}", community.actor_id, uuid::Uuid::new_v4()),
)?;
announce announce
.announce_props .set_context(context())
.set_actor_xsd_any_uri(community.actor_id.to_owned())? .set_id(XsdAnyUri::from_str(&id)?)
.set_object_base_box(BaseBox::from_concrete(activity)?)?; .set_to(public())
.set_many_ccs(vec![community.get_followers_url()]);
insert_activity(community.creator_id, announce.clone(), true, pool).await?; insert_activity(community.creator_id, announce.clone(), true, pool).await?;
@ -443,7 +444,7 @@ where
// this seems to be the "easiest" stable alternative for remove_item() // this seems to be the "easiest" stable alternative for remove_item()
to.retain(|x| *x != sender.get_shared_inbox_url()); to.retain(|x| *x != sender.get_shared_inbox_url());
send_activity(client, &announce, community, to).await?; send_activity(client, &announce.into_any_base()?, community, to).await?;
Ok(HttpResponse::Ok().finish()) Ok(HttpResponse::Ok().finish())
} }

View file

@ -2,7 +2,8 @@ use crate::{
apub::{ apub::{
extensions::signatures::verify, extensions::signatures::verify,
fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user}, fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
insert_activity, ActorType, insert_activity,
ActorType,
}, },
blocking, blocking,
routes::{ChatServerParam, DbPoolParam}, routes::{ChatServerParam, DbPoolParam},

View file

@ -4,7 +4,8 @@ use crate::{
blocking, blocking,
request::{retry, RecvError}, request::{retry, RecvError},
routes::nodeinfo::{NodeInfo, NodeInfoWellKnown}, routes::nodeinfo::{NodeInfo, NodeInfoWellKnown},
DbPool, LemmyError, DbPool,
LemmyError,
}; };
use activitystreams_new::{base::BaseExt, object::Note, prelude::*, primitives::XsdAnyUri}; use activitystreams_new::{base::BaseExt, object::Note, prelude::*, primitives::XsdAnyUri};
use actix_web::client::Client; use actix_web::client::Client;
@ -20,7 +21,9 @@ use lemmy_db::{
post_view::PostView, post_view::PostView,
user::{UserForm, User_}, user::{UserForm, User_},
user_view::UserView, user_view::UserView,
Crud, Joinable, SearchType, Crud,
Joinable,
SearchType,
}; };
use lemmy_utils::get_apub_protocol_string; use lemmy_utils::get_apub_protocol_string;
use log::debug; use log::debug;

View file

@ -19,7 +19,8 @@ use crate::{
blocking, blocking,
request::{retry, RecvError}, request::{retry, RecvError},
routes::webfinger::WebFingerResponse, routes::webfinger::WebFingerResponse,
DbPool, LemmyError, DbPool,
LemmyError,
}; };
use activitystreams_ext::{Ext1, Ext2}; use activitystreams_ext::{Ext1, Ext2};
use activitystreams_new::{ use activitystreams_new::{

View file

@ -1,14 +1,22 @@
use crate::{ use crate::{
apub::{ apub::{
activities::send_activity_to_community, activities::send_activity_to_community,
create_apub_response, create_apub_tombstone_response, create_tombstone, create_apub_response,
create_apub_tombstone_response,
create_tombstone,
extensions::page_extension::PageExtension, extensions::page_extension::PageExtension,
fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user}, fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
ActorType, ApubLikeableType, ApubObjectType, FromApub, PageExt, ToApub, ActorType,
ApubLikeableType,
ApubObjectType,
FromApub,
PageExt,
ToApub,
}, },
blocking, blocking,
routes::DbPoolParam, routes::DbPoolParam,
DbPool, LemmyError, DbPool,
LemmyError,
}; };
use activitystreams_ext::Ext1; use activitystreams_ext::Ext1;
use activitystreams_new::{ use activitystreams_new::{
@ -275,7 +283,7 @@ impl ApubObjectType for Post {
creator, creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
create, create.into_any_base()?,
client, client,
pool, pool,
) )
@ -308,7 +316,7 @@ impl ApubObjectType for Post {
creator, creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
update, update.into_any_base()?,
client, client,
pool, pool,
) )
@ -339,7 +347,7 @@ impl ApubObjectType for Post {
creator, creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
delete, delete.into_any_base()?,
client, client,
pool, pool,
) )
@ -380,7 +388,7 @@ impl ApubObjectType for Post {
creator, creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
undo, undo.into_any_base()?,
client, client,
pool, pool,
) )
@ -411,7 +419,7 @@ impl ApubObjectType for Post {
mod_, mod_,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
remove, remove.into_any_base()?,
client, client,
pool, pool,
) )
@ -451,7 +459,7 @@ impl ApubObjectType for Post {
mod_, mod_,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
undo, undo.into_any_base()?,
client, client,
pool, pool,
) )
@ -486,7 +494,7 @@ impl ApubLikeableType for Post {
&creator, &creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
like, like.into_any_base()?,
client, client,
pool, pool,
) )
@ -518,7 +526,7 @@ impl ApubLikeableType for Post {
&creator, &creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
dislike, dislike.into_any_base()?,
client, client,
pool, pool,
) )
@ -560,7 +568,7 @@ impl ApubLikeableType for Post {
&creator, &creator,
&community, &community,
vec![community.get_shared_inbox_url()], vec![community.get_shared_inbox_url()],
undo, undo.into_any_base()?,
client, client,
pool, pool,
) )

View file

@ -1,9 +1,16 @@
use crate::{ use crate::{
apub::{ apub::{
activities::send_activity, create_tombstone, fetcher::get_or_fetch_and_upsert_remote_user, activities::send_activity,
insert_activity, ApubObjectType, FromApub, ToApub, create_tombstone,
fetcher::get_or_fetch_and_upsert_remote_user,
insert_activity,
ApubObjectType,
FromApub,
ToApub,
}, },
blocking, DbPool, LemmyError, blocking,
DbPool,
LemmyError,
}; };
use activitystreams_new::{ use activitystreams_new::{
activity::{Create, Delete, Undo, Update}, activity::{Create, Delete, Undo, Update},
@ -127,7 +134,7 @@ impl ApubObjectType for PrivateMessage {
insert_activity(creator.id, create.clone(), true, pool).await?; insert_activity(creator.id, create.clone(), true, pool).await?;
send_activity(client, &create, creator, vec![to]).await?; send_activity(client, &create.into_any_base()?, creator, vec![to]).await?;
Ok(()) Ok(())
} }
@ -153,7 +160,7 @@ impl ApubObjectType for PrivateMessage {
insert_activity(creator.id, update.clone(), true, pool).await?; insert_activity(creator.id, update.clone(), true, pool).await?;
send_activity(client, &update, creator, vec![to]).await?; send_activity(client, &update.into_any_base()?, creator, vec![to]).await?;
Ok(()) Ok(())
} }
@ -178,7 +185,7 @@ impl ApubObjectType for PrivateMessage {
insert_activity(creator.id, delete.clone(), true, pool).await?; insert_activity(creator.id, delete.clone(), true, pool).await?;
send_activity(client, &delete, creator, vec![to]).await?; send_activity(client, &delete.into_any_base()?, creator, vec![to]).await?;
Ok(()) Ok(())
} }
@ -212,7 +219,7 @@ impl ApubObjectType for PrivateMessage {
insert_activity(creator.id, undo.clone(), true, pool).await?; insert_activity(creator.id, undo.clone(), true, pool).await?;
send_activity(client, &undo, creator, vec![to]).await?; send_activity(client, &undo.into_any_base()?, creator, vec![to]).await?;
Ok(()) Ok(())
} }

View file

@ -8,10 +8,15 @@ use crate::{
community::do_announce, community::do_announce,
extensions::signatures::verify, extensions::signatures::verify,
fetcher::{ fetcher::{
get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post, get_or_fetch_and_insert_remote_comment,
get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user, get_or_fetch_and_insert_remote_post,
get_or_fetch_and_upsert_remote_community,
get_or_fetch_and_upsert_remote_user,
}, },
insert_activity, FromApub, GroupExt, PageExt, insert_activity,
FromApub,
GroupExt,
PageExt,
}, },
blocking, blocking,
routes::{ChatServerParam, DbPoolParam}, routes::{ChatServerParam, DbPoolParam},
@ -19,13 +24,16 @@ use crate::{
server::{SendComment, SendCommunityRoomMessage, SendPost}, server::{SendComment, SendCommunityRoomMessage, SendPost},
UserOperation, UserOperation,
}, },
DbPool, LemmyError, DbPool,
LemmyError,
}; };
use activitystreams::{ use activitystreams_new::{
activity::{Announce, Create, Delete, Dislike, Like, Remove, Undo, Update}, activity::{Announce, Create, Delete, Dislike, Like, Remove, Undo, Update},
Activity, Base, BaseBox, base::AnyBase,
object::Note,
prelude::{ExtendsExt, *},
primitives::XsdAnyUri,
}; };
use activitystreams_new::{object::Note, primitives::XsdAnyUri};
use actix_web::{client::Client, web, HttpRequest, HttpResponse}; use actix_web::{client::Client, web, HttpRequest, HttpResponse};
use lemmy_db::{ use lemmy_db::{
comment::{Comment, CommentForm, CommentLike, CommentLikeForm}, comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
@ -35,7 +43,8 @@ use lemmy_db::{
naive_now, naive_now,
post::{Post, PostForm, PostLike, PostLikeForm}, post::{Post, PostForm, PostLike, PostLikeForm},
post_view::PostView, post_view::PostView,
Crud, Likeable, Crud,
Likeable,
}; };
use lemmy_utils::scrape_text_for_mentions; use lemmy_utils::scrape_text_for_mentions;
use log::debug; use log::debug;
@ -43,7 +52,7 @@ use serde::{Deserialize, Serialize};
use std::fmt::Debug; use std::fmt::Debug;
#[serde(untagged)] #[serde(untagged)]
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub enum SharedAcceptedObjects { pub enum SharedAcceptedObjects {
Create(Box<Create>), Create(Box<Create>),
Update(Box<Update>), Update(Box<Update>),
@ -56,47 +65,50 @@ pub enum SharedAcceptedObjects {
} }
impl SharedAcceptedObjects { impl SharedAcceptedObjects {
fn object(&self) -> Option<&BaseBox> { // TODO: these shouldnt be necessary anymore
fn object(&self) -> Option<AnyBase> {
match self { match self {
SharedAcceptedObjects::Create(c) => c.create_props.get_object_base_box(), SharedAcceptedObjects::Create(c) => c.object().to_owned().one(),
SharedAcceptedObjects::Update(u) => u.update_props.get_object_base_box(), SharedAcceptedObjects::Update(u) => u.object().to_owned().one(),
SharedAcceptedObjects::Like(l) => l.like_props.get_object_base_box(), SharedAcceptedObjects::Like(l) => l.object().to_owned().one(),
SharedAcceptedObjects::Dislike(d) => d.dislike_props.get_object_base_box(), SharedAcceptedObjects::Dislike(d) => d.object().to_owned().one(),
SharedAcceptedObjects::Delete(d) => d.delete_props.get_object_base_box(), SharedAcceptedObjects::Delete(d) => d.object().to_owned().one(),
SharedAcceptedObjects::Undo(d) => d.undo_props.get_object_base_box(), SharedAcceptedObjects::Undo(d) => d.object().to_owned().one(),
SharedAcceptedObjects::Remove(r) => r.remove_props.get_object_base_box(), SharedAcceptedObjects::Remove(r) => r.object().to_owned().one(),
SharedAcceptedObjects::Announce(a) => a.announce_props.get_object_base_box(), SharedAcceptedObjects::Announce(a) => a.object().to_owned().one(),
} }
} }
fn sender(&self) -> XsdAnyUri { fn sender(&self) -> XsdAnyUri {
let uri = match self { let uri = match self {
SharedAcceptedObjects::Create(c) => c.create_props.get_actor_xsd_any_uri(), SharedAcceptedObjects::Create(c) => c.actor.to_owned().single_xsd_any_uri(),
SharedAcceptedObjects::Update(u) => u.update_props.get_actor_xsd_any_uri(), SharedAcceptedObjects::Update(u) => u.actor.to_owned().single_xsd_any_uri(),
SharedAcceptedObjects::Like(l) => l.like_props.get_actor_xsd_any_uri(), SharedAcceptedObjects::Like(l) => l.actor.to_owned().single_xsd_any_uri(),
SharedAcceptedObjects::Dislike(d) => d.dislike_props.get_actor_xsd_any_uri(), SharedAcceptedObjects::Dislike(d) => d.actor.to_owned().single_xsd_any_uri(),
SharedAcceptedObjects::Delete(d) => d.delete_props.get_actor_xsd_any_uri(), SharedAcceptedObjects::Delete(d) => d.actor.to_owned().single_xsd_any_uri(),
SharedAcceptedObjects::Undo(d) => d.undo_props.get_actor_xsd_any_uri(), SharedAcceptedObjects::Undo(d) => d.actor.to_owned().single_xsd_any_uri(),
SharedAcceptedObjects::Remove(r) => r.remove_props.get_actor_xsd_any_uri(), SharedAcceptedObjects::Remove(r) => r.actor.to_owned().single_xsd_any_uri(),
SharedAcceptedObjects::Announce(a) => a.announce_props.get_actor_xsd_any_uri(), SharedAcceptedObjects::Announce(a) => a.actor.to_owned().single_xsd_any_uri(),
}; };
uri.unwrap().clone() uri.unwrap()
} }
fn cc(&self) -> String { fn cc(&self) -> String {
// TODO: there is probably an easier way to do this let cc = match self {
let oprops = match self { SharedAcceptedObjects::Create(c) => c.cc().to_owned(),
SharedAcceptedObjects::Create(c) => &c.object_props, SharedAcceptedObjects::Update(u) => u.cc().to_owned(),
SharedAcceptedObjects::Update(u) => &u.object_props, SharedAcceptedObjects::Like(l) => l.cc().to_owned(),
SharedAcceptedObjects::Like(l) => &l.object_props, SharedAcceptedObjects::Dislike(d) => d.cc().to_owned(),
SharedAcceptedObjects::Dislike(d) => &d.object_props, SharedAcceptedObjects::Delete(d) => d.cc().to_owned(),
SharedAcceptedObjects::Delete(d) => &d.object_props, SharedAcceptedObjects::Undo(d) => d.cc().to_owned(),
SharedAcceptedObjects::Undo(d) => &d.object_props, SharedAcceptedObjects::Remove(r) => r.cc().to_owned(),
SharedAcceptedObjects::Remove(r) => &r.object_props, SharedAcceptedObjects::Announce(a) => a.cc().to_owned(),
SharedAcceptedObjects::Announce(a) => &a.object_props,
}; };
oprops cc.unwrap()
.get_many_cc_xsd_any_uris() .clone()
.many()
.unwrap() .unwrap()
.next() .first()
.unwrap()
.as_xsd_any_uri()
.unwrap() .unwrap()
.to_string() .to_string()
} }
@ -117,9 +129,8 @@ pub async fn shared_inbox(
let json = serde_json::to_string(&activity)?; let json = serde_json::to_string(&activity)?;
debug!("Shared inbox received activity: {}", json); debug!("Shared inbox received activity: {}", json);
let object = activity.object().cloned().unwrap(); let sender = &activity.to_owned().sender();
let sender = &activity.sender(); let cc = activity.to_owned().cc();
let cc = &activity.cc();
// TODO: this is hacky, we should probably send the community id directly somehow // TODO: this is hacky, we should probably send the community id directly somehow
let to = cc.replace("/followers", ""); let to = cc.replace("/followers", "");
@ -132,74 +143,75 @@ pub async fn shared_inbox(
} }
} }
match (activity, object.kind()) { let object = activity.object().unwrap();
match (activity, object.kind_str()) {
(SharedAcceptedObjects::Create(c), Some("Page")) => { (SharedAcceptedObjects::Create(c), Some("Page")) => {
receive_create_post((*c).clone(), client, pool, chat_server).await?; receive_create_post((*c).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Create>(*c, &to, sender, client, pool).await announce_activity_if_valid(c.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Update(u), Some("Page")) => { (SharedAcceptedObjects::Update(u), Some("Page")) => {
receive_update_post((*u).clone(), client, pool, chat_server).await?; receive_update_post((*u).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Update>(*u, &to, sender, client, pool).await announce_activity_if_valid(u.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Like(l), Some("Page")) => { (SharedAcceptedObjects::Like(l), Some("Page")) => {
receive_like_post((*l).clone(), client, pool, chat_server).await?; receive_like_post((*l).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Like>(*l, &to, sender, client, pool).await announce_activity_if_valid(l.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Dislike(d), Some("Page")) => { (SharedAcceptedObjects::Dislike(d), Some("Page")) => {
receive_dislike_post((*d).clone(), client, pool, chat_server).await?; receive_dislike_post((*d).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Dislike>(*d, &to, sender, client, pool).await announce_activity_if_valid(d.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Delete(d), Some("Page")) => { (SharedAcceptedObjects::Delete(d), Some("Page")) => {
receive_delete_post((*d).clone(), client, pool, chat_server).await?; receive_delete_post((*d).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Delete>(*d, &to, sender, client, pool).await announce_activity_if_valid(d.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Remove(r), Some("Page")) => { (SharedAcceptedObjects::Remove(r), Some("Page")) => {
receive_remove_post((*r).clone(), client, pool, chat_server).await?; receive_remove_post((*r).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Remove>(*r, &to, sender, client, pool).await announce_activity_if_valid(r.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Create(c), Some("Note")) => { (SharedAcceptedObjects::Create(c), Some("Note")) => {
receive_create_comment((*c).clone(), client, pool, chat_server).await?; receive_create_comment((*c).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Create>(*c, &to, sender, client, pool).await announce_activity_if_valid(c.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Update(u), Some("Note")) => { (SharedAcceptedObjects::Update(u), Some("Note")) => {
receive_update_comment((*u).clone(), client, pool, chat_server).await?; receive_update_comment((*u).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Update>(*u, &to, sender, client, pool).await announce_activity_if_valid(u.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Like(l), Some("Note")) => { (SharedAcceptedObjects::Like(l), Some("Note")) => {
receive_like_comment((*l).clone(), client, pool, chat_server).await?; receive_like_comment((*l).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Like>(*l, &to, sender, client, pool).await announce_activity_if_valid(l.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Dislike(d), Some("Note")) => { (SharedAcceptedObjects::Dislike(d), Some("Note")) => {
receive_dislike_comment((*d).clone(), client, pool, chat_server).await?; receive_dislike_comment((*d).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Dislike>(*d, &to, sender, client, pool).await announce_activity_if_valid(d.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Delete(d), Some("Note")) => { (SharedAcceptedObjects::Delete(d), Some("Note")) => {
receive_delete_comment((*d).clone(), client, pool, chat_server).await?; receive_delete_comment((*d).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Delete>(*d, &to, sender, client, pool).await announce_activity_if_valid(d.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Remove(r), Some("Note")) => { (SharedAcceptedObjects::Remove(r), Some("Note")) => {
receive_remove_comment((*r).clone(), client, pool, chat_server).await?; receive_remove_comment((*r).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Remove>(*r, &to, sender, client, pool).await announce_activity_if_valid(r.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Delete(d), Some("Group")) => { (SharedAcceptedObjects::Delete(d), Some("Group")) => {
receive_delete_community((*d).clone(), client, pool, chat_server).await?; receive_delete_community((*d).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Delete>(*d, &to, sender, client, pool).await announce_activity_if_valid(d.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Remove(r), Some("Group")) => { (SharedAcceptedObjects::Remove(r), Some("Group")) => {
receive_remove_community((*r).clone(), client, pool, chat_server).await?; receive_remove_community((*r).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Remove>(*r, &to, sender, client, pool).await announce_activity_if_valid(r.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Undo(u), Some("Delete")) => { (SharedAcceptedObjects::Undo(u), Some("Delete")) => {
receive_undo_delete((*u).clone(), client, pool, chat_server).await?; receive_undo_delete((*u).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Undo>(*u, &to, sender, client, pool).await announce_activity_if_valid(u.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Undo(u), Some("Remove")) => { (SharedAcceptedObjects::Undo(u), Some("Remove")) => {
receive_undo_remove((*u).clone(), client, pool, chat_server).await?; receive_undo_remove((*u).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Undo>(*u, &to, sender, client, pool).await announce_activity_if_valid(u.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Undo(u), Some("Like")) => { (SharedAcceptedObjects::Undo(u), Some("Like")) => {
receive_undo_like((*u).clone(), client, pool, chat_server).await?; receive_undo_like((*u).clone(), client, pool, chat_server).await?;
announce_activity_if_valid::<Undo>(*u, &to, sender, client, pool).await announce_activity_if_valid(u.into_any_base()?, &to, sender, client, pool).await
} }
(SharedAcceptedObjects::Announce(a), _) => receive_announce(a, client, pool, chat_server).await, (SharedAcceptedObjects::Announce(a), _) => receive_announce(a, client, pool, chat_server).await,
(a, _) => receive_unhandled_activity(a), (a, _) => receive_unhandled_activity(a),
@ -207,16 +219,13 @@ pub async fn shared_inbox(
} }
// TODO: should pass in sender as ActorType, but thats a bit tricky in shared_inbox() // TODO: should pass in sender as ActorType, but thats a bit tricky in shared_inbox()
async fn announce_activity_if_valid<A>( async fn announce_activity_if_valid(
activity: A, activity: AnyBase,
community_uri: &str, community_uri: &str,
sender: &XsdAnyUri, sender: &XsdAnyUri,
client: &Client, client: &Client,
pool: &DbPool, pool: &DbPool,
) -> Result<HttpResponse, LemmyError> ) -> Result<HttpResponse, LemmyError> {
where
A: Activity + Base + Serialize + Debug,
{
let community_uri = community_uri.to_owned(); let community_uri = community_uri.to_owned();
let community = blocking(pool, move |conn| { let community = blocking(pool, move |conn| {
Community::read_from_actor_id(conn, &community_uri) Community::read_from_actor_id(conn, &community_uri)
@ -238,71 +247,60 @@ async fn receive_announce(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let object = announce let object = announce.to_owned().object.one().unwrap();
.announce_props
.get_object_base_box()
.unwrap()
.to_owned();
// TODO: too much copy paste // TODO: too much copy paste
match object.kind() { match object.kind_str() {
Some("Create") => { Some("Create") => {
let create = object.into_concrete::<Create>()?; let create = Create::from_any_base(object)?.unwrap();
let inner_object = create.create_props.get_object_base_box().unwrap(); match create.object.as_single_kind_str() {
match inner_object.kind() {
Some("Page") => receive_create_post(create, client, pool, chat_server).await, Some("Page") => receive_create_post(create, client, pool, chat_server).await,
Some("Note") => receive_create_comment(create, client, pool, chat_server).await, Some("Note") => receive_create_comment(create, client, pool, chat_server).await,
_ => receive_unhandled_activity(announce), _ => receive_unhandled_activity(announce),
} }
} }
Some("Update") => { Some("Update") => {
let update = object.into_concrete::<Update>()?; let update = Update::from_any_base(object)?.unwrap();
let inner_object = update.update_props.get_object_base_box().unwrap(); match update.object.as_single_kind_str() {
match inner_object.kind() {
Some("Page") => receive_update_post(update, client, pool, chat_server).await, Some("Page") => receive_update_post(update, client, pool, chat_server).await,
Some("Note") => receive_update_comment(update, client, pool, chat_server).await, Some("Note") => receive_update_comment(update, client, pool, chat_server).await,
_ => receive_unhandled_activity(announce), _ => receive_unhandled_activity(announce),
} }
} }
Some("Like") => { Some("Like") => {
let like = object.into_concrete::<Like>()?; let like = Like::from_any_base(object)?.unwrap();
let inner_object = like.like_props.get_object_base_box().unwrap(); match like.object.as_single_kind_str() {
match inner_object.kind() {
Some("Page") => receive_like_post(like, client, pool, chat_server).await, Some("Page") => receive_like_post(like, client, pool, chat_server).await,
Some("Note") => receive_like_comment(like, client, pool, chat_server).await, Some("Note") => receive_like_comment(like, client, pool, chat_server).await,
_ => receive_unhandled_activity(announce), _ => receive_unhandled_activity(announce),
} }
} }
Some("Dislike") => { Some("Dislike") => {
let dislike = object.into_concrete::<Dislike>()?; let dislike = Dislike::from_any_base(object)?.unwrap();
let inner_object = dislike.dislike_props.get_object_base_box().unwrap(); match dislike.object.as_single_kind_str() {
match inner_object.kind() {
Some("Page") => receive_dislike_post(dislike, client, pool, chat_server).await, Some("Page") => receive_dislike_post(dislike, client, pool, chat_server).await,
Some("Note") => receive_dislike_comment(dislike, client, pool, chat_server).await, Some("Note") => receive_dislike_comment(dislike, client, pool, chat_server).await,
_ => receive_unhandled_activity(announce), _ => receive_unhandled_activity(announce),
} }
} }
Some("Delete") => { Some("Delete") => {
let delete = object.into_concrete::<Delete>()?; let delete = Delete::from_any_base(object)?.unwrap();
let inner_object = delete.delete_props.get_object_base_box().unwrap(); match delete.object.as_single_kind_str() {
match inner_object.kind() {
Some("Page") => receive_delete_post(delete, client, pool, chat_server).await, Some("Page") => receive_delete_post(delete, client, pool, chat_server).await,
Some("Note") => receive_delete_comment(delete, client, pool, chat_server).await, Some("Note") => receive_delete_comment(delete, client, pool, chat_server).await,
_ => receive_unhandled_activity(announce), _ => receive_unhandled_activity(announce),
} }
} }
Some("Remove") => { Some("Remove") => {
let remove = object.into_concrete::<Remove>()?; let remove = Remove::from_any_base(object)?.unwrap();
let inner_object = remove.remove_props.get_object_base_box().unwrap(); match remove.object.as_single_kind_str() {
match inner_object.kind() {
Some("Page") => receive_remove_post(remove, client, pool, chat_server).await, Some("Page") => receive_remove_post(remove, client, pool, chat_server).await,
Some("Note") => receive_remove_comment(remove, client, pool, chat_server).await, Some("Note") => receive_remove_comment(remove, client, pool, chat_server).await,
_ => receive_unhandled_activity(announce), _ => receive_unhandled_activity(announce),
} }
} }
Some("Undo") => { Some("Undo") => {
let undo = object.into_concrete::<Undo>()?; let undo = Undo::from_any_base(object)?.unwrap();
let inner_object = undo.undo_props.get_object_base_box().unwrap(); match undo.object.as_single_kind_str() {
match inner_object.kind() {
Some("Delete") => receive_undo_delete(undo, client, pool, chat_server).await, Some("Delete") => receive_undo_delete(undo, client, pool, chat_server).await,
Some("Remove") => receive_undo_remove(undo, client, pool, chat_server).await, Some("Remove") => receive_undo_remove(undo, client, pool, chat_server).await,
Some("Like") => receive_undo_like(undo, client, pool, chat_server).await, Some("Like") => receive_undo_like(undo, client, pool, chat_server).await,
@ -327,15 +325,9 @@ async fn receive_create_post(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let page = create let page = PageExt::from_any_base(create.object.to_owned().one().unwrap())?.unwrap();
.create_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<PageExt>()?;
let user_uri = create.create_props.get_actor_xsd_any_uri().unwrap(); let user_uri = create.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -369,15 +361,9 @@ async fn receive_create_comment(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let note = create let note = Note::from_any_base(create.object.to_owned().one().unwrap())?.unwrap();
.create_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Note>()?;
let user_uri = create.create_props.get_actor_xsd_any_uri().unwrap(); let user_uri = create.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -424,15 +410,9 @@ async fn receive_update_post(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let page = update let page = PageExt::from_any_base(update.object.to_owned().one().unwrap())?.unwrap();
.update_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<PageExt>()?;
let user_uri = update.update_props.get_actor_xsd_any_uri().unwrap(); let user_uri = update.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -466,15 +446,9 @@ async fn receive_like_post(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let page = like let page = PageExt::from_any_base(like.object.to_owned().one().unwrap())?.unwrap();
.like_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<PageExt>()?;
let user_uri = like.like_props.get_actor_xsd_any_uri().unwrap(); let user_uri = like.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -517,15 +491,9 @@ async fn receive_dislike_post(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let page = dislike let page = PageExt::from_any_base(dislike.object.to_owned().one().unwrap())?.unwrap();
.dislike_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<PageExt>()?;
let user_uri = dislike.dislike_props.get_actor_xsd_any_uri().unwrap(); let user_uri = dislike.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -568,15 +536,9 @@ async fn receive_update_comment(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let note = update let note = Note::from_any_base(update.object.to_owned().one().unwrap())?.unwrap();
.update_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Note>()?;
let user_uri = update.update_props.get_actor_xsd_any_uri().unwrap(); let user_uri = update.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -623,15 +585,9 @@ async fn receive_like_comment(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let note = like let note = Note::from_any_base(like.object.to_owned().one().unwrap())?.unwrap();
.like_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Note>()?;
let user_uri = like.like_props.get_actor_xsd_any_uri().unwrap(); let user_uri = like.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -681,15 +637,9 @@ async fn receive_dislike_comment(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let note = dislike let note = Note::from_any_base(dislike.object.to_owned().one().unwrap())?.unwrap();
.dislike_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Note>()?;
let user_uri = dislike.dislike_props.get_actor_xsd_any_uri().unwrap(); let user_uri = dislike.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -739,15 +689,9 @@ async fn receive_delete_community(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let user_uri = delete.delete_props.get_actor_xsd_any_uri().unwrap(); let user_uri = delete.actor.to_owned().single_xsd_any_uri().unwrap();
let group = delete let group = GroupExt::from_any_base(delete.object.to_owned().one().unwrap())?.unwrap();
.delete_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<GroupExt>()?;
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -812,15 +756,9 @@ async fn receive_remove_community(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let mod_uri = remove.remove_props.get_actor_xsd_any_uri().unwrap(); let mod_uri = remove.actor.to_owned().single_xsd_any_uri().unwrap();
let group = remove let group = GroupExt::from_any_base(remove.object.to_owned().one().unwrap())?.unwrap();
.remove_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<GroupExt>()?;
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?; let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?;
@ -885,15 +823,9 @@ async fn receive_delete_post(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let user_uri = delete.delete_props.get_actor_xsd_any_uri().unwrap(); let user_uri = delete.actor.to_owned().single_xsd_any_uri().unwrap();
let page = delete let page = PageExt::from_any_base(delete.object.to_owned().one().unwrap())?.unwrap();
.delete_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<PageExt>()?;
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -947,15 +879,9 @@ async fn receive_remove_post(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let mod_uri = remove.remove_props.get_actor_xsd_any_uri().unwrap(); let mod_uri = remove.actor.to_owned().single_xsd_any_uri().unwrap();
let page = remove let page = PageExt::from_any_base(remove.object.to_owned().one().unwrap())?.unwrap();
.remove_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<PageExt>()?;
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?; let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?;
@ -1009,15 +935,9 @@ async fn receive_delete_comment(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let user_uri = delete.delete_props.get_actor_xsd_any_uri().unwrap(); let user_uri = delete.actor.to_owned().single_xsd_any_uri().unwrap();
let note = delete let note = Note::from_any_base(delete.object.to_owned().one().unwrap())?.unwrap();
.delete_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Note>()?;
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -1073,15 +993,9 @@ async fn receive_remove_comment(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let mod_uri = remove.remove_props.get_actor_xsd_any_uri().unwrap(); let mod_uri = remove.actor.to_owned().single_xsd_any_uri().unwrap();
let note = remove let note = Note::from_any_base(remove.object.to_owned().one().unwrap())?.unwrap();
.remove_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Note>()?;
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?; let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?;
@ -1137,22 +1051,9 @@ async fn receive_undo_delete(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let delete = undo let delete = Delete::from_any_base(undo.object.to_owned().one().unwrap())?.unwrap();
.undo_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Delete>()?;
let type_ = delete
.delete_props
.get_object_base_box()
.to_owned()
.unwrap()
.kind()
.unwrap();
let type_ = delete.object.as_single_kind_str().unwrap();
match type_ { match type_ {
"Note" => receive_undo_delete_comment(delete, client, pool, chat_server).await, "Note" => receive_undo_delete_comment(delete, client, pool, chat_server).await,
"Page" => receive_undo_delete_post(delete, client, pool, chat_server).await, "Page" => receive_undo_delete_post(delete, client, pool, chat_server).await,
@ -1167,22 +1068,9 @@ async fn receive_undo_remove(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let remove = undo let remove = Remove::from_any_base(undo.object.to_owned().one().unwrap())?.unwrap();
.undo_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Remove>()?;
let type_ = remove
.remove_props
.get_object_base_box()
.to_owned()
.unwrap()
.kind()
.unwrap();
let type_ = remove.object.as_single_kind_str().unwrap();
match type_ { match type_ {
"Note" => receive_undo_remove_comment(remove, client, pool, chat_server).await, "Note" => receive_undo_remove_comment(remove, client, pool, chat_server).await,
"Page" => receive_undo_remove_post(remove, client, pool, chat_server).await, "Page" => receive_undo_remove_post(remove, client, pool, chat_server).await,
@ -1197,15 +1085,9 @@ async fn receive_undo_delete_comment(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let user_uri = delete.delete_props.get_actor_xsd_any_uri().unwrap(); let user_uri = delete.actor.to_owned().single_xsd_any_uri().unwrap();
let note = delete let note = Note::from_any_base(delete.object.to_owned().one().unwrap())?.unwrap();
.delete_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Note>()?;
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -1261,15 +1143,9 @@ async fn receive_undo_remove_comment(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let mod_uri = remove.remove_props.get_actor_xsd_any_uri().unwrap(); let mod_uri = remove.actor.to_owned().single_xsd_any_uri().unwrap();
let note = remove let note = Note::from_any_base(remove.object.to_owned().one().unwrap())?.unwrap();
.remove_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Note>()?;
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?; let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?;
@ -1325,15 +1201,9 @@ async fn receive_undo_delete_post(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let user_uri = delete.delete_props.get_actor_xsd_any_uri().unwrap(); let user_uri = delete.actor.to_owned().single_xsd_any_uri().unwrap();
let page = delete let page = PageExt::from_any_base(delete.object.to_owned().one().unwrap())?.unwrap();
.delete_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<PageExt>()?;
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -1387,15 +1257,9 @@ async fn receive_undo_remove_post(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let mod_uri = remove.remove_props.get_actor_xsd_any_uri().unwrap(); let mod_uri = remove.actor.to_owned().single_xsd_any_uri().unwrap();
let page = remove let page = PageExt::from_any_base(remove.object.to_owned().one().unwrap())?.unwrap();
.remove_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<PageExt>()?;
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?; let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?;
@ -1449,15 +1313,9 @@ async fn receive_undo_delete_community(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let user_uri = delete.delete_props.get_actor_xsd_any_uri().unwrap(); let user_uri = delete.actor.to_owned().single_xsd_any_uri().unwrap();
let group = delete let group = GroupExt::from_any_base(delete.object.to_owned().one().unwrap())?.unwrap();
.delete_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<GroupExt>()?;
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -1522,15 +1380,9 @@ async fn receive_undo_remove_community(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let mod_uri = remove.remove_props.get_actor_xsd_any_uri().unwrap(); let mod_uri = remove.actor.to_owned().single_xsd_any_uri().unwrap();
let group = remove let group = GroupExt::from_any_base(remove.object.to_owned().one().unwrap())?.unwrap();
.remove_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<GroupExt>()?;
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?; let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, client, pool).await?;
@ -1595,22 +1447,9 @@ async fn receive_undo_like(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let like = undo let like = Like::from_any_base(undo.object.to_owned().one().unwrap())?.unwrap();
.undo_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Like>()?;
let type_ = like
.like_props
.get_object_base_box()
.to_owned()
.unwrap()
.kind()
.unwrap();
let type_ = like.object.as_single_kind_str().unwrap();
match type_ { match type_ {
"Note" => receive_undo_like_comment(like, client, pool, chat_server).await, "Note" => receive_undo_like_comment(like, client, pool, chat_server).await,
"Page" => receive_undo_like_post(like, client, pool, chat_server).await, "Page" => receive_undo_like_post(like, client, pool, chat_server).await,
@ -1624,15 +1463,9 @@ async fn receive_undo_like_comment(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let note = like let note = Note::from_any_base(like.object.to_owned().one().unwrap())?.unwrap();
.like_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<Note>()?;
let user_uri = like.like_props.get_actor_xsd_any_uri().unwrap(); let user_uri = like.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
@ -1678,15 +1511,9 @@ async fn receive_undo_like_post(
pool: &DbPool, pool: &DbPool,
chat_server: ChatServerParam, chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> { ) -> Result<HttpResponse, LemmyError> {
let page = like let page = PageExt::from_any_base(like.object.to_owned().one().unwrap())?.unwrap();
.like_props
.get_object_base_box()
.to_owned()
.unwrap()
.to_owned()
.into_concrete::<PageExt>()?;
let user_uri = like.like_props.get_actor_xsd_any_uri().unwrap(); let user_uri = like.actor.to_owned().single_xsd_any_uri().unwrap();
let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?; let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;

View file

@ -1,12 +1,18 @@
use crate::{ use crate::{
api::claims::Claims, api::claims::Claims,
apub::{ apub::{
activities::send_activity, create_apub_response, insert_activity, ActorType, FromApub, activities::send_activity,
PersonExt, ToApub, create_apub_response,
insert_activity,
ActorType,
FromApub,
PersonExt,
ToApub,
}, },
blocking, blocking,
routes::DbPoolParam, routes::DbPoolParam,
DbPool, LemmyError, DbPool,
LemmyError,
}; };
use activitystreams_ext::Ext1; use activitystreams_ext::Ext1;
use activitystreams_new::{ use activitystreams_new::{
@ -105,7 +111,7 @@ impl ActorType for User_ {
insert_activity(self.id, follow.clone(), true, pool).await?; insert_activity(self.id, follow.clone(), true, pool).await?;
send_activity(client, &follow, self, vec![to]).await?; send_activity(client, &follow.into_any_base()?, self, vec![to]).await?;
Ok(()) Ok(())
} }
@ -129,7 +135,7 @@ impl ActorType for User_ {
insert_activity(self.id, undo.clone(), true, pool).await?; insert_activity(self.id, undo.clone(), true, pool).await?;
send_activity(client, &undo, self, vec![to]).await?; send_activity(client, &undo.into_any_base()?, self, vec![to]).await?;
Ok(()) Ok(())
} }

View file

@ -3,12 +3,14 @@ use crate::{
apub::{ apub::{
extensions::signatures::verify, extensions::signatures::verify,
fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user}, fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
insert_activity, FromApub, insert_activity,
FromApub,
}, },
blocking, blocking,
routes::{ChatServerParam, DbPoolParam}, routes::{ChatServerParam, DbPoolParam},
websocket::{server::SendUserRoomMessage, UserOperation}, websocket::{server::SendUserRoomMessage, UserOperation},
DbPool, LemmyError, DbPool,
LemmyError,
}; };
use activitystreams_new::{ use activitystreams_new::{
activity::{Accept, Create, Delete, Undo, Update}, activity::{Accept, Create, Delete, Undo, Update},
@ -22,7 +24,8 @@ use lemmy_db::{
private_message::{PrivateMessage, PrivateMessageForm}, private_message::{PrivateMessage, PrivateMessageForm},
private_message_view::PrivateMessageView, private_message_view::PrivateMessageView,
user::User_, user::User_,
Crud, Followable, Crud,
Followable,
}; };
use log::debug; use log::debug;
use serde::Deserialize; use serde::Deserialize;