From: Dessalines Date: Thu, 2 Apr 2020 19:11:11 +0000 (-0400) Subject: Merge branch 'master' into federation X-Git-Url: http://these/git/readmes/README.ja.md?a=commitdiff_plain;h=31f835db86eb78765191c8beaf16adf3f9fd0f50;p=lemmy.git Merge branch 'master' into federation --- 31f835db86eb78765191c8beaf16adf3f9fd0f50 diff --cc .gitignore index 92377b4b,9f7fa1e3..5e221b03 --- a/.gitignore +++ b/.gitignore @@@ -2,17 -1,10 +2,16 @@@ ansible/inventory ansible/inventory_dev ansible/passwords/ - ansible/vars/ + +# docker build files docker/lemmy_mine.hjson docker/dev/env_deploy.sh +docker/federation-test/volumes +docker/dev/volumes + +# local build files build/ -.idea/ ui/src/translations -docker/dev/volumes -docker/federation-test/volumes + +# ide config +.idea/ diff --cc server/Cargo.lock index 78e7ee1e,2a3bc033..ceb09b75 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@@ -1,69 -1,88 +1,69 @@@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "activitypub" -version = "0.2.0" +name = "activitystreams" - version = "0.5.0-alpha.11" ++version = "0.5.0-alpha.16" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "f0fb876395ae7a1dd1c7d7de38f2cdb583918db16b46ee5b75d2e9bf7af1ef9f" ++checksum = "e7173513c9d586a1157f375835777e3b50498b6b7aab4411a7098b455ba995f0" dependencies = [ - "activitystreams-derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "activitystreams-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "activitystreams-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "activitystreams-derive", + "chrono", + "mime", + "serde 1.0.105", + "serde_json 1.0.50", + "thiserror", + "url", ] [[package]] name = "activitystreams-derive" - version = "0.5.0-alpha.4" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "activitystreams-traits" -version = "0.2.0" ++version = "0.5.0-alpha.8" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "c2bc640808dceb2efac81e6bcb77a7f4e2e76af7fb60e88f966b48123b625d2f" ++checksum = "c7ff4a2be3b67d763e78794f622ef2d53da077521229774837f61963c4067b36" dependencies = [ - "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "activitystreams-types" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "activitystreams-derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "activitystreams-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "actix" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4af87564ff659dee8f9981540cac9418c45e910c8072fdedd643a262a38fcaf" dependencies = [ - "actix-http 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "actix_derive 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.99.3 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-resolver 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-http", + "actix-rt", + "actix_derive", + "bitflags", + "bytes", + "crossbeam-channel", + "derive_more", + "futures", + "lazy_static 1.4.0", + "log", + "parking_lot", + "pin-project", + "smallvec", + "tokio", - "tokio-util", ++ "tokio-util 0.2.0", + "trust-dns-proto", + "trust-dns-resolver", ] [[package]] name = "actix-codec" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e55f0a5c2ca15795035d90c46bd0e73a5123b72f68f12596d6ba5282051380" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "bytes", + "futures-core", + "futures-sink", + "log", + "tokio", - "tokio-util", ++ "tokio-util 0.2.0", ] [[package]] @@@ -371,18 -372,24 +371,27 @@@ dependencies = [[package]] name = "aho-corasick" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3", ] + [[package]] + name = "ansi_term" + version = "0.11.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" + dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ++ "winapi 0.3.8", + ] + [[package]] name = "arc-swap" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d663a8e9a99154b5fb793032533f6328da35e23aac63d5c152279aa8ba356825" [[package]] name = "arrayvec" @@@ -401,13 -406,12 +410,13 @@@ checksum = "71938f30533e4d95a6d17aa5309 [[package]] name = "async-trait" - version = "0.1.26" -version = "0.1.24" ++version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "21a03abb7c9b93ae229356151a083d26218c0358866a2a59d4280c856e9482e6" ++checksum = "bab5c215748dc1ad11a145359b1067107ae0f8ca5e99844fa64067ed5bf198e3" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] @@@ -621,11 -602,18 +630,11 @@@ checksum = "130aac562c0dd69c56b3b1cc8ff [[package]] name = "bytestring" --version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "c2-chacha" -version = "0.2.3" ++version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "fc267467f58ef6cc8874064c62a0423eb0d099362c8a23edd1c6d044f46eead4" ++checksum = "fc7c05fa5172da78a62d9949d662d2ac89d4cc7355d7b49adee5163f1fb3f363" dependencies = [ - "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes", ] [[package]] @@@ -644,23 -630,51 +653,55 @@@ checksum = "4785bdd1c96b2a846b2bd7cc02e name = "chrono" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" dependencies = [ - "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer", + "num-traits 0.2.11", + "serde 1.0.105", + "time", ] + [[package]] + name = "clap" + version = "2.33.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" + dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ++ "ansi_term", ++ "atty", ++ "bitflags", ++ "strsim 0.8.0", ++ "textwrap", ++ "unicode-width", ++ "vec_map", + ] + [[package]] name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", ] + [[package]] + name = "comrak" + version = "0.7.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "e17058cc536cf290563e88787d7b9e6030ce4742943017cc2ffb71f88034021c" + dependencies = [ - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "entities 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "twoway 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "typed-arena 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode_categories 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ++ "clap", ++ "entities", ++ "lazy_static 1.4.0", ++ "pest", ++ "pest_derive", ++ "regex 1.3.6", ++ "twoway", ++ "typed-arena", ++ "unicode_categories", + ] + [[package]] name = "config" version = "0.10.1" @@@ -994,11 -976,15 +1035,17 @@@ checksum = "a246d82be1c9d791c5dfde9a2bd name = "encoding_rs" version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] + [[package]] + name = "entities" + version = "1.0.1" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" + [[package]] name = "enum-as-inner" version = "0.3.2" @@@ -1238,21 -1199,20 +1285,21 @@@ dependencies = [[package]] name = "h2" - version = "0.2.3" -version = "0.2.2" ++version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "7938e6aa2a31df4e21f224dc84704bd31c089a6d1355c535b03667371cccc843" ++checksum = "377038bf3c89d18d6ca1431e7a5027194fbd724ca10592b9487ede5e8e144f42" dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "log", + "slab", + "tokio", - "tokio-util", ++ "tokio-util 0.3.1", ] [[package]] @@@ -1266,11 -1225,10 +1313,11 @@@ dependencies = [[package]] name = "hermit-abi" --version = "0.1.8" ++version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8" ++checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" dependencies = [ - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] @@@ -1475,38 -1412,38 +1522,39 @@@ checksum = "e2abad23fbc42b3700f2f279844 name = "lemmy_server" version = "0.0.1" dependencies = [ - "activitypub 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "actix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-files 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web-actors 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bcrypt 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "comrak 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "config 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "diesel 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "dotenv 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "isahc 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonwebtoken 7.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lettre 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lettre_email 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rss 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strum 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "strum_macros 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "activitystreams", + "actix", + "actix-files", + "actix-rt", + "actix-web", + "actix-web-actors", + "bcrypt", + "chrono", ++ "comrak", + "config", + "diesel", + "diesel_migrations", + "dotenv", + "env_logger", + "failure", + "hjson", + "htmlescape", + "isahc", + "jsonwebtoken", + "lazy_static 1.4.0", + "lettre", + "lettre_email", + "log", + "percent-encoding", + "rand 0.7.3", + "regex 1.3.6", + "rss", + "serde 1.0.105", + "serde_json 1.0.50", + "sha2", + "strum", + "strum_macros", + "url", ] [[package]] @@@ -1620,11 -1547,15 +1668,17 @@@ dependencies = name = "lru-cache" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" dependencies = [ - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.2", ] + [[package]] + name = "maplit" + version = "1.0.2" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "match_cfg" version = "0.1.0" @@@ -1929,8 -1830,46 +1983,51 @@@ dependencies = name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + [[package]] + name = "pest" + version = "2.1.3" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" + dependencies = [ - "ucd-trie 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ++ "ucd-trie", + ] + + [[package]] + name = "pest_derive" + version = "2.1.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" + dependencies = [ - "pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pest_generator 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ++ "pest", ++ "pest_generator", + ] + + [[package]] + name = "pest_generator" + version = "2.1.3" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" + dependencies = [ - "pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pest_meta 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ++ "pest", ++ "pest_meta", ++ "proc-macro2", ++ "quote", ++ "syn", + ] + + [[package]] + name = "pest_meta" + version = "2.1.3" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" + dependencies = [ - "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pest 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ++ "maplit", ++ "pest", ++ "sha-1", + ] + [[package]] name = "pin-project" version = "0.4.8" @@@ -1986,9 -1918,13 +2083,9 @@@ dependencies = [[package]] name = "proc-macro-hack" - version = "0.5.14" -version = "0.5.11" ++version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "fcfdefadc3d57ca21cf17990a28ef4c0f7c61383a28cb7604cf4a18e6ede1420" -dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", -] ++checksum = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" [[package]] name = "proc-macro-nested" @@@ -1998,11 -1933,10 +2095,11 @@@ checksum = "8e946095f9d3ed29ec38de908c2 [[package]] name = "proc-macro2" --version = "1.0.9" ++version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" ++checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid", ] [[package]] @@@ -2363,24 -2259,22 +2460,25 @@@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f [[package]] name = "security-framework" --version = "0.4.1" ++version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "97bbedbe81904398b6ebb054b3e912f99d55807125790f3198ac990d98def5b0" ++checksum = "572dfa3a0785509e7a44b5b4bebcf94d41ba34e9ed9eb9df722545c3b3c4144a" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "core-foundation", + "core-foundation-sys", ++ "libc", + "security-framework-sys", ] [[package]] name = "security-framework-sys" --version = "0.4.1" ++version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "06fd2f23e31ef68dd2328cc383bd493142e46107a3a0e24f7d734e3f3b80fe4c" ++checksum = "8ddb15a5fec93b7021b8a9e96009c5d8d51c15673569f7c0f6b7204e5b7b404f" dependencies = [ - "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys", + "libc", ] [[package]] @@@ -2487,14 -2371,24 +2585,26 @@@ dependencies = name = "serde_urlencoded" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" dependencies = [ - "dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa 0.4.5", + "itoa 0.4.5", + "serde 1.0.105", + "url", ] + [[package]] + name = "sha-1" + version = "0.8.2" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" + dependencies = [ - "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ++ "block-buffer", ++ "digest", ++ "fake-simd", ++ "opaque-debug", + ] + [[package]] name = "sha1" version = "0.6.0" @@@ -2560,14 -2447,13 +2670,14 @@@ checksum = "5c2fb2ec9bcd216a5b0d0ccf31a [[package]] name = "socket2" --version = "0.3.11" ++version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" ++checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.8", ] [[package]] @@@ -2586,8 -2470,12 +2696,14 @@@ checksum = "7f3eb36b47e512f8f1c9e3d10c2 name = "strsim" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c" + [[package]] + name = "strsim" + version = "0.8.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + [[package]] name = "strsim" version = "0.9.3" @@@ -2653,29 -2535,34 +2769,38 @@@ dependencies = name = "termcolor" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" dependencies = [ - "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util", ] + [[package]] + name = "textwrap" + version = "0.11.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" + dependencies = [ - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ++ "unicode-width", + ] + [[package]] name = "thiserror" - version = "1.0.13" -version = "1.0.11" ++version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "e3711fd1c4e75b3eff12ba5c40dba762b6b65c5476e8174c1a664772060c49bf" ++checksum = "f0570dc61221295909abdb95c739f2e74325e14293b2026b0a7e195091ec54ae" dependencies = [ - "thiserror-impl 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl", ] [[package]] name = "thiserror-impl" - version = "1.0.13" -version = "1.0.11" ++version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "ae2b85ba4c9aa32dd3343bd80eb8d22e9b54b7688c17ea3907f236885353b233" ++checksum = "227362df41d566be41a28f64401e07a043157c21c14b9785a0d8e256f940a8fd" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] @@@ -2728,39 -2610,37 +2853,53 @@@ dependencies = [[package]] name = "tokio" --version = "0.2.13" ++version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "0fa5e81d6bc4e67fe889d5783bd2a128ab2e0cfa487e0be16b6a8d177b101616" ++checksum = "619cdb2245c40c42d563089b72e80c5df659513d667a017598439ef7a7b1ffe1" dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes", + "fnv", + "futures-core", + "iovec", + "lazy_static 1.4.0", + "libc", + "memchr 2.3.3", + "mio", + "mio-uds", + "pin-project-lite", + "signal-hook-registry", + "slab", + "winapi 0.3.8", ] [[package]] name = "tokio-util" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + ++[[package]] ++name = "tokio-util" ++version = "0.3.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" + dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", ++ "bytes", ++ "futures-core", ++ "futures-sink", ++ "log", ++ "pin-project-lite", ++ "tokio", + ] + [[package]] name = "toml" version = "0.5.6" @@@ -2794,27 -2672,49 +2933,55 @@@ dependencies = name = "trust-dns-resolver" version = "0.18.0-alpha.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f90b1502b226f8b2514c6d5b37bafa8c200d7ca4102d57dc36ee0f3b7a04a2f" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "resolv-conf 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.18.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "failure", + "futures", + "ipconfig", + "lazy_static 1.4.0", + "log", + "lru-cache", + "resolv-conf", + "smallvec", + "tokio", + "trust-dns-proto", ] + [[package]] + name = "twoway" + version = "0.2.1" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "6b40075910de3a912adbd80b5d8bad6ad10a23eeb1f5bf9d4006839e899ba5bc" + dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unchecked-index 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ++ "memchr 2.3.3", ++ "unchecked-index", + ] + + [[package]] + name = "typed-arena" + version = "1.7.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d" + [[package]] name = "typenum" version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" + [[package]] + name = "ucd-trie" + version = "0.1.3" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + + [[package]] + name = "unchecked-index" + version = "0.2.2" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" + [[package]] name = "unicase" version = "2.6.0" @@@ -2846,14 -2743,22 +3013,26 @@@ dependencies = name = "unicode-segmentation" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + [[package]] + name = "unicode-width" + version = "0.1.7" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" + [[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" + [[package]] + name = "unicode_categories" + version = "0.1.1" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "untrusted" version = "0.7.0" @@@ -2921,8 -2819,12 +3100,14 @@@ dependencies = name = "vcpkg" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" + [[package]] + name = "vec_map" + version = "0.8.1" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" + [[package]] name = "version_check" version = "0.1.5" @@@ -3041,11 -2929,10 +3226,11 @@@ checksum = "ac3b87c63620426dd9b991e5ce0 [[package]] name = "winapi-util" --version = "0.1.3" ++version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" ++checksum = "fa515c5163a99cc82bab70fd3bfdd36d827be85de63737b40fcef2ce084a436e" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] diff --cc server/Cargo.toml index 83dfb43e,5a4fdcec..1455428d --- a/server/Cargo.toml +++ b/server/Cargo.toml @@@ -8,8 -8,8 +8,8 @@@ edition = "2018 diesel = { version = "1.4.2", features = ["postgres","chrono", "r2d2", "64-column-tables"] } diesel_migrations = "1.4.0" dotenv = "0.15.0" - activitystreams = "0.5.0-alpha.10" ++activitystreams = "0.5.0-alpha.16" bcrypt = "0.6.2" -activitypub = "0.2.0" chrono = { version = "0.4.7", features = ["serde"] } failure = "0.1.5" serde_json = { version = "1.0.48", features = ["preserve_order"]} @@@ -34,6 -34,6 +34,7 @@@ rss = "1.9.0 htmlescape = "0.3.1" config = "0.10.1" hjson = "0.8.2" +url = "2.1.1" percent-encoding = "2.1.0" isahc = "0.9" + comrak = "0.7" diff --cc server/src/apub/community.rs index 2f533b97,32f14eeb..d914c08d --- a/server/src/apub/community.rs +++ b/server/src/apub/community.rs @@@ -15,105 -7,103 +15,105 @@@ use activitystreams:: use actix_web::body::Body; use actix_web::web::Path; use actix_web::HttpResponse; +use actix_web::{web, Result}; +use diesel::r2d2::{ConnectionManager, Pool}; +use diesel::PgConnection; +use failure::Error; use serde::Deserialize; -impl Community { - pub fn as_group(&self) -> Group { - let base_url = make_apub_endpoint("c", &self.name); - - let mut group = Group::default(); - - group.object_props.set_context_object(context()).ok(); - group.object_props.set_id_string(base_url.to_string()).ok(); - group - .object_props - .set_name_string(self.name.to_owned()) - .ok(); - group - .object_props - .set_published_utctime(to_datetime_utc(self.published)) - .ok(); - if let Some(updated) = self.updated { - group - .object_props - .set_updated_utctime(to_datetime_utc(updated)) - .ok(); - } - - if let Some(description) = &self.description { - group - .object_props - .set_summary_string(description.to_string()) - .ok(); - } - - group - .ap_actor_props - .set_inbox_string(format!("{}/inbox", &base_url)) - .ok(); - group - .ap_actor_props - .set_outbox_string(format!("{}/outbox", &base_url)) - .ok(); - group - .ap_actor_props - .set_followers_string(format!("{}/followers", &base_url)) - .ok(); +#[derive(Deserialize)] +pub struct CommunityQuery { + community_name: String, +} - group +pub async fn get_apub_community( + info: Path, + db: web::Data>>, +) -> Result, Error> { + let community = Community::read_from_name(&&db.get()?, info.community_name.to_owned())?; + let base_url = make_apub_endpoint(EndpointType::Community, &community.name); + + let mut group = Group::default(); + let oprops: &mut ObjectProperties = group.as_mut(); + + oprops + .set_context_xsd_any_uri(context())? + .set_id(base_url.to_owned())? + .set_name_xsd_string(community.title.to_owned())? + .set_published(convert_datetime(community.published))? + .set_attributed_to_xsd_any_uri(make_apub_endpoint( + EndpointType::User, + &community.creator_id.to_string(), + ))?; + + if let Some(u) = community.updated.to_owned() { + oprops.set_updated(convert_datetime(u))?; + } + if let Some(d) = community.description { + oprops.set_summary_xsd_string(d)?; } - pub fn followers_as_collection(&self) -> UnorderedCollection { - let base_url = make_apub_endpoint("c", &self.name); - - let mut collection = UnorderedCollection::default(); - collection.object_props.set_context_object(context()).ok(); - collection.object_props.set_id_string(base_url).ok(); - - let connection = establish_unpooled_connection(); - //As we are an object, we validated that the community id was valid - let community_followers = CommunityFollowerView::for_community(&connection, self.id).unwrap(); + let mut actor_props = ApActorProperties::default(); - let ap_followers = community_followers - .iter() - .map(|follower| make_apub_endpoint("u", &follower.user_name)) - .collect(); + actor_props + .set_inbox(format!("{}/inbox", &base_url))? + .set_outbox(format!("{}/outbox", &base_url))? + .set_followers(format!("{}/followers", &base_url))?; - collection - .collection_props - .set_items_string_vec(ap_followers) - .unwrap(); - collection - } + Ok(create_apub_response(&group.extend(actor_props))) } -#[derive(Deserialize)] -pub struct CommunityQuery { - community_name: String, -} +pub async fn get_apub_community_followers( + info: Path, + db: web::Data>>, +) -> Result, Error> { + let community = Community::read_from_name(&&db.get()?, info.community_name.to_owned())?; + let base_url = make_apub_endpoint(EndpointType::Community, &community.name); -pub async fn get_apub_community(info: Path) -> HttpResponse { let connection = establish_unpooled_connection(); - - if let Ok(community) = Community::read_from_name(&connection, info.community_name.to_owned()) { - HttpResponse::Ok() - .content_type("application/activity+json") - .body(serde_json::to_string(&community.as_group()).unwrap()) - } else { - HttpResponse::NotFound().finish() - } + //As we are an object, we validated that the community id was valid + let community_followers = + CommunityFollowerView::for_community(&connection, community.id).unwrap(); + + let mut collection = UnorderedCollection::default(); + let oprops: &mut ObjectProperties = collection.as_mut(); + oprops + .set_context_xsd_any_uri(context())? + .set_id(base_url)?; + collection + .collection_props + .set_total_items(community_followers.len() as u64)?; + Ok(create_apub_response(&collection)) } -pub async fn get_apub_community_followers(info: Path) -> HttpResponse { - let connection = establish_unpooled_connection(); +pub async fn get_apub_community_outbox( + info: Path, + db: web::Data>>, +) -> Result, Error> { + let community = Community::read_from_name(&&db.get()?, info.community_name.to_owned())?; + let base_url = make_apub_endpoint(EndpointType::Community, &community.name); - if let Ok(community) = Community::read_from_name(&connection, info.community_name.to_owned()) { - HttpResponse::Ok() - .content_type("application/activity+json") - .body(serde_json::to_string(&community.followers_as_collection()).unwrap()) - } else { - HttpResponse::NotFound().finish() - } + let connection = establish_unpooled_connection(); + //As we are an object, we validated that the community id was valid + let community_posts: Vec = PostQueryBuilder::create(&connection) + .for_community_id(community.id) + .list() + .unwrap(); + + let mut collection = OrderedCollection::default(); + let oprops: &mut ObjectProperties = collection.as_mut(); + oprops + .set_context_xsd_any_uri(context())? + .set_id(base_url)?; + collection + .collection_props - .set_many_items_object_boxs( ++ .set_many_items_base_boxes( + community_posts + .iter() + .map(|c| c.as_page().unwrap()) + .collect(), + )? + .set_total_items(community_posts.len() as u64)?; + + Ok(create_apub_response(&collection)) } diff --cc server/src/apub/puller.rs index 43cc2f8c,00000000..a9ac1086 mode 100644,000000..100644 --- a/server/src/apub/puller.rs +++ b/server/src/apub/puller.rs @@@ -1,230 -1,0 +1,230 @@@ +use crate::api::community::{GetCommunityResponse, ListCommunitiesResponse}; +use crate::api::post::GetPostsResponse; +use crate::apub::get_apub_protocol_string; +use crate::db::community_view::CommunityView; +use crate::db::post_view::PostView; +use crate::naive_now; +use crate::routes::nodeinfo::{NodeInfo, NodeInfoWellKnown}; +use crate::settings::Settings; +use activitystreams::actor::{properties::ApActorProperties, Group}; +use activitystreams::collection::{OrderedCollection, UnorderedCollection}; +use activitystreams::ext::Ext; - use activitystreams::object::ObjectBox; +use activitystreams::object::Page; ++use activitystreams::BaseBox; +use failure::Error; +use isahc::prelude::*; +use log::warn; +use serde::Deserialize; + +fn fetch_node_info(domain: &str) -> Result { + let well_known_uri = format!( + "{}://{}/.well-known/nodeinfo", + get_apub_protocol_string(), + domain + ); + let well_known = fetch_remote_object::(&well_known_uri)?; + Ok(fetch_remote_object::(&well_known.links.href)?) +} + +fn fetch_communities_from_instance(domain: &str) -> Result, Error> { + let node_info = fetch_node_info(domain)?; + if node_info.software.name != "lemmy" { + return Err(format_err!( + "{} is not a Lemmy instance, federation is not supported", + domain + )); + } + + // TODO: follow pagination (seems like page count is missing?) + // TODO: see if there is any standard for discovering remote actors, so we dont have to rely on lemmy apis + let communities_uri = format!( + "http://{}/api/v1/communities/list?sort=Hot&local_only=true", + domain + ); + let communities1 = fetch_remote_object::(&communities_uri)?; + let mut communities2 = communities1.communities; + for c in &mut communities2 { + c.name = format_community_name(&c.name, domain); + } + Ok(communities2) +} + +fn get_remote_community_uri(identifier: &str) -> String { + let x: Vec<&str> = identifier.split('@').collect(); + let name = x[0].replace("!", ""); + let instance = x[1]; + format!("http://{}/federation/c/{}", instance, name) +} + +fn fetch_remote_object(uri: &str) -> Result +where + Response: for<'de> Deserialize<'de>, +{ + if Settings::get().federation.tls_enabled && !uri.starts_with("https") { + return Err(format_err!("Activitypub uri is insecure: {}", uri)); + } + // TODO: should cache responses here when we are in production + // TODO: this function should return a future + let text = isahc::get(uri)?.text()?; + let res: Response = serde_json::from_str(&text)?; + Ok(res) +} + +pub fn get_remote_community_posts(identifier: &str) -> Result { + let community = + fetch_remote_object::>(&get_remote_community_uri(identifier))?; + let outbox_uri = &community.extension.get_outbox().to_string(); + let outbox = fetch_remote_object::(outbox_uri)?; - let items = outbox.collection_props.get_many_items_object_boxs(); ++ let items = outbox.collection_props.get_many_items_base_boxes(); + + let posts: Vec = items + .unwrap() - .map(|obox: &ObjectBox| { ++ .map(|obox: &BaseBox| { + let page: Page = obox.clone().to_concrete::().unwrap(); + PostView { + id: -1, + name: page.object_props.get_name_xsd_string().unwrap().to_string(), + url: page + .object_props + .get_url_xsd_any_uri() + .map(|u| u.to_string()), + body: page + .object_props + .get_content_xsd_string() + .map(|c| c.to_string()), + creator_id: -1, + community_id: -1, + removed: false, + locked: false, + published: page + .object_props + .get_published() + .unwrap() + .as_ref() + .naive_local() + .to_owned(), + updated: page + .object_props + .get_updated() + .map(|u| u.as_ref().to_owned().naive_local()), + deleted: false, + nsfw: false, + stickied: false, + embed_title: None, + embed_description: None, + embed_html: None, + thumbnail_url: None, + banned: false, + banned_from_community: false, + creator_name: "".to_string(), + creator_avatar: None, + community_name: "".to_string(), + community_removed: false, + community_deleted: false, + community_nsfw: false, + number_of_comments: -1, + score: -1, + upvotes: -1, + downvotes: -1, + hot_rank: -1, + newest_activity_time: naive_now(), + user_id: None, + my_vote: None, + subscribed: None, + read: None, + saved: None, + } + }) + .collect(); + Ok(GetPostsResponse { posts }) +} + +pub fn get_remote_community(identifier: &str) -> Result { + let community = + fetch_remote_object::>(&get_remote_community_uri(identifier))?; + let followers_uri = &community.extension.get_followers().unwrap().to_string(); + let outbox_uri = &community.extension.get_outbox().to_string(); + let outbox = fetch_remote_object::(outbox_uri)?; + let followers = fetch_remote_object::(followers_uri)?; + // TODO: this is only for testing until we can call that function from GetPosts + // (once string ids are supported) + //dbg!(get_remote_community_posts(identifier)?); + + Ok(GetCommunityResponse { + moderators: vec![], + admins: vec![], + community: CommunityView { + // TODO: we need to merge id and name into a single thing (stuff like @user@instance.com) + id: 1337, //community.object_props.get_id() + name: identifier.to_string(), + title: community + .as_ref() + .get_name_xsd_string() + .unwrap() + .to_string(), + description: community + .as_ref() + .get_summary_xsd_string() + .map(|s| s.to_string()), + category_id: -1, + creator_id: -1, //community.object_props.get_attributed_to_xsd_any_uri() + removed: false, + published: community + .as_ref() + .get_published() + .unwrap() + .as_ref() + .naive_local() + .to_owned(), + updated: community + .as_ref() + .get_updated() + .map(|u| u.as_ref().to_owned().naive_local()), + deleted: false, + nsfw: false, + creator_name: "".to_string(), + creator_avatar: None, + category_name: "".to_string(), + number_of_subscribers: *followers + .collection_props + .get_total_items() + .unwrap() + .as_ref() as i64, // TODO: need to use the same type + number_of_posts: *outbox.collection_props.get_total_items().unwrap().as_ref() as i64, + number_of_comments: -1, + hot_rank: -1, + user_id: None, + subscribed: None, + }, + online: 0, + }) +} + +pub fn get_following_instances() -> Vec<&'static str> { + Settings::get() + .federation + .followed_instances + .split(',') + .collect() +} + +pub fn get_all_communities() -> Result, Error> { + let mut communities_list: Vec = vec![]; + for instance in &get_following_instances() { + match fetch_communities_from_instance(instance) { + Ok(mut c) => communities_list.append(c.as_mut()), + Err(e) => warn!("Failed to fetch instance list from remote instance: {}", e), + }; + } + Ok(communities_list) +} + +/// If community is on local instance, don't include the @instance part. This is only for displaying +/// to the user and should never be used otherwise. +pub fn format_community_name(name: &str, instance: &str) -> String { + if instance == Settings::get().hostname { + format!("!{}", name) + } else { + format!("!{}@{}", name, instance) + } +} diff --cc server/src/lib.rs index 0012c73f,8257dab9..9f882b7f --- a/server/src/lib.rs +++ b/server/src/lib.rs @@@ -15,9 -16,9 +16,10 @@@ pub extern crate dotenv pub extern crate jsonwebtoken; pub extern crate lettre; pub extern crate lettre_email; +extern crate log; pub extern crate rand; pub extern crate regex; + pub extern crate rss; pub extern crate serde; pub extern crate serde_json; pub extern crate sha2; diff --cc server/src/routes/nodeinfo.rs index abfae1ed,1263cef8..662089b3 --- a/server/src/routes/nodeinfo.rs +++ b/server/src/routes/nodeinfo.rs @@@ -1,5 -1,3 +1,4 @@@ - extern crate lazy_static; +use crate::apub::get_apub_protocol_string; use crate::db::site_view::SiteView; use crate::version; use crate::Settings; diff --cc server/src/settings.rs index 3928f74e,875323e9..29d5966b --- a/server/src/settings.rs +++ b/server/src/settings.rs @@@ -17,9 -17,17 +17,17 @@@ pub struct Settings pub front_end_dir: String, pub rate_limit: RateLimitConfig, pub email: Option, - pub federation_enabled: bool, + pub federation: Federation, } + #[derive(Debug, Deserialize)] + pub struct Setup { + pub admin_username: String, + pub admin_password: String, + pub admin_email: Option, + pub site_name: String, + } + #[derive(Debug, Deserialize)] pub struct RateLimitConfig { pub message: i32,