From 729e425e328f96fd0b21bb2cd3861f410cd9407e Mon Sep 17 00:00:00 2001 From: asonix Date: Thu, 21 May 2020 16:24:56 -0500 Subject: [PATCH] Fully lean on activitystreams-new --- Cargo.lock | 483 ++++++++++++++++++++----------------- Cargo.toml | 7 +- src/apub.rs | 183 +++----------- src/data/actor.rs | 11 +- src/data/media.rs | 2 +- src/data/node.rs | 2 +- src/data/state.rs | 2 +- src/db.rs | 2 +- src/error.rs | 18 +- src/jobs/apub/announce.rs | 14 +- src/jobs/apub/follow.rs | 49 ++-- src/jobs/apub/forward.rs | 14 +- src/jobs/apub/mod.rs | 39 ++- src/jobs/apub/reject.rs | 2 +- src/jobs/apub/undo.rs | 8 +- src/jobs/deliver.rs | 2 +- src/jobs/deliver_many.rs | 2 +- src/jobs/instance.rs | 2 +- src/jobs/nodeinfo.rs | 2 +- src/middleware/verifier.rs | 2 +- src/notify.rs | 2 +- src/requests.rs | 2 +- src/routes/actor.rs | 73 +++--- src/routes/inbox.rs | 129 ++++++---- templates/admin.rs.html | 2 +- templates/info.rs.html | 2 +- templates/instance.rs.html | 2 +- 27 files changed, 514 insertions(+), 544 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac6bc84..4c2194d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,14 +2,14 @@ # It is not intended for manual editing. [[package]] name = "activitystreams" -version = "0.5.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae98a55a86fc3150f278b225644cd46b5359f4d75067eae6dc3a52b409c537fb" +checksum = "464cb473bfb402b857cc15b1153974c203a43f1485da4dda15cd17a738548958" dependencies = [ "activitystreams-derive", "chrono", "mime", - "serde 1.0.106", + "serde 1.0.110", "serde_json", "thiserror", "url", @@ -17,15 +17,36 @@ dependencies = [ [[package]] name = "activitystreams-derive" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20d0384ae423a1df266f216e351ce9b40e8d369467d9242c086121154b4327dd" +checksum = "c39ba5929399e9f921055bac76dd8f47419fa5b6b6da1ac4c1e82b94ed0ac7b4" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "activitystreams-ext" +version = "0.1.0" +source = "git+https://git.asonix.dog/asonix/activitystreams-ext#4e89c6eaaa23075e9d320c09ee68bcddec728cb6" +dependencies = [ + "activitystreams-new", + "serde 1.0.110", + "serde_json", +] + +[[package]] +name = "activitystreams-new" +version = "0.1.0" +source = "git+https://git.asonix.dog/asonix/activitystreams-sketch#ffc8faf82522ce7801b783077731809a37fbaa36" +dependencies = [ + "activitystreams", + "serde 1.0.110", + "serde_json", + "typed-builder", +] + [[package]] name = "actix-codec" version = "0.2.0" @@ -43,9 +64,9 @@ dependencies = [ [[package]] name = "actix-connect" -version = "2.0.0-alpha.2" +version = "2.0.0-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b97accbe63a89df4022addc06f25f61341eb86d4295b2cb4cc0ab01d8309336" +checksum = "2551ed85d5e157c13f8f523cdb13a6292d948049eb2dc2072bbee3ec350399a2" dependencies = [ "actix-codec", "actix-rt", @@ -53,7 +74,7 @@ dependencies = [ "actix-utils", "derive_more", "either", - "futures", + "futures-util", "http", "log", "rustls", @@ -65,9 +86,9 @@ dependencies = [ [[package]] name = "actix-http" -version = "2.0.0-alpha.2" +version = "2.0.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65f194bcd786457b736d6b04ba7501af31e9961d24567dfcb3dc4cffc149cbdb" +checksum = "fd7ea0568480d199952a51de70271946da57c33cc0e8b83f54383e70958dff21" dependencies = [ "actix-codec", "actix-connect", @@ -76,7 +97,7 @@ dependencies = [ "actix-threadpool", "actix-tls", "actix-utils", - "base64 0.11.0", + "base64 0.12.1", "bitflags", "brotli2", "bytes", @@ -84,7 +105,6 @@ dependencies = [ "derive_more", "either", "encoding_rs", - "failure", "flate2", "futures-channel", "futures-core", @@ -102,19 +122,19 @@ dependencies = [ "pin-project", "rand", "regex", - "serde 1.0.106", + "serde 1.0.110", "serde_json", "serde_urlencoded", "sha-1", "slab", - "time 0.2.10", + "time 0.2.16", ] [[package]] name = "actix-macros" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21705adc76bbe4bc98434890e73a89cd00c6015e5704a60bb6eea6c3b72316b6" +checksum = "a60f9ba7c4e6df97f3aacb14bb5c0cd7d98a49dcbaed0d7f292912ad9a6a3ed2" dependencies = [ "quote", "syn", @@ -130,40 +150,42 @@ dependencies = [ "http", "log", "regex", - "serde 1.0.106", + "serde 1.0.110", ] [[package]] name = "actix-rt" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20066d9200ef8d441ac156c76dd36c3f1e9a15976c34e69ae97f7f570b331882" +checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227" dependencies = [ "actix-macros", "actix-threadpool", "copyless", "futures-channel", "futures-util", + "smallvec", "tokio", ] [[package]] name = "actix-server" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "582a7173c281a4f46b5aa168a11e7f37183dcb71177a39312cc2264da7a632c9" +checksum = "e6d74b464215a473c973a2d7d03a69cc10f4ce1f4b38a7659c5193dc5c675630" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-utils", - "futures", + "futures-channel", + "futures-util", "log", "mio", "mio-uds", - "net2", "num_cpus", "slab", + "socket2", ] [[package]] @@ -178,24 +200,23 @@ dependencies = [ [[package]] name = "actix-testing" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48494745b72d0ea8ff0cf874aaf9b622a3ee03d7081ee0c04edea4f26d32c911" +checksum = "47239ca38799ab74ee6a8a94d1ce857014b2ac36f242f70f3f75a66f691e791c" dependencies = [ "actix-macros", "actix-rt", "actix-server", "actix-service", - "futures", "log", - "net2", + "socket2", ] [[package]] name = "actix-threadpool" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4082192601de5f303013709ff84d81ca6a1bc4af7fb24f367a500a23c6e84e" +checksum = "91164716d956745c79dcea5e66d2aa04506549958accefcede5368c70f2fd4ff" dependencies = [ "derive_more", "futures-channel", @@ -246,9 +267,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "3.0.0-alpha.1" +version = "3.0.0-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e6d4c344acb10ceb89ba0d0bb6bf67fea56cd68444b1166d78d218e0f06013" +checksum = "8bd6df56ec5f9a1a0d8335f156f36e1e8f76dbd736fa0cc0f6bc3a69be1e6124" dependencies = [ "actix-codec", "actix-http", @@ -266,18 +287,21 @@ dependencies = [ "bytes", "derive_more", "encoding_rs", - "futures", + "futures-channel", + "futures-core", + "futures-util", "fxhash", "log", "mime", - "net2", "pin-project", "regex", "rustls", - "serde 1.0.106", + "serde 1.0.110", "serde_json", "serde_urlencoded", - "time 0.2.10", + "socket2", + "time 0.2.16", + "tinyvec", "url", ] @@ -300,11 +324,20 @@ checksum = "abb66d471f2af5a9ea7b48ea4456f117c56cd1b2348e52ae8d3bc95cddeebf4c" dependencies = [ "actix-http", "actix-web", - "serde 1.0.106", + "serde 1.0.110", "serde_derive", "thiserror", ] +[[package]] +name = "addr2line" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a49806b9dadc843c61e7c97e72490ad7f7220ae249012fbda9ad0609457c0543" +dependencies = [ + "gimli", +] + [[package]] name = "adler32" version = "1.0.4" @@ -355,9 +388,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.28" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff" +checksum = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f" [[package]] name = "arc-swap" @@ -376,9 +409,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da71fef07bc806586090247e971229289f64c210a278ee5ae419314eb386b31d" +checksum = "26c4f3195085c36ea8d24d32b2f828d23296a9370a28aa39d111f6f16bef9f3b" dependencies = [ "proc-macro2", "quote", @@ -410,15 +443,15 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" [[package]] name = "awc" -version = "2.0.0-alpha.1" +version = "2.0.0-alpha.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18faab57a9a1e4c59e38a998784bc3d9b4fdd9464faed77feb6046cc67b95e17" +checksum = "a7038a9747cd5159b9f0550895eaf865c0143baa7e4eee834e9294d0a7e0e4be" dependencies = [ "actix-codec", "actix-http", "actix-rt", "actix-service", - "base64 0.11.0", + "base64 0.12.1", "bytes", "derive_more", "futures-core", @@ -427,7 +460,7 @@ dependencies = [ "percent-encoding", "rand", "rustls", - "serde 1.0.106", + "serde 1.0.110", "serde_json", "serde_urlencoded", ] @@ -456,7 +489,7 @@ dependencies = [ "log", "num_cpus", "rand", - "serde 1.0.106", + "serde 1.0.110", "serde_json", "thiserror", "tokio", @@ -475,7 +508,7 @@ dependencies = [ "chrono", "futures", "log", - "serde 1.0.106", + "serde 1.0.110", "serde_json", "thiserror", "tokio", @@ -484,26 +517,17 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.46" +version = "0.3.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e" +checksum = "0df2f85c8a2abbe3b7d7e748052fdd9b76a0458fdeb16ad4223f5eca78c7c130" dependencies = [ - "backtrace-sys", + "addr2line", "cfg-if", "libc", + "object", "rustc-demangle", ] -[[package]] -name = "backtrace-sys" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78848718ee1255a2485d1309ad9cdecfc2e7d0362dd11c6829364c6b35ae1bc7" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "base-x" version = "0.2.6" @@ -518,15 +542,15 @@ checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" [[package]] name = "base64" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5ca2cd0adc3f48f9e9ea5a6bbdf9ccc0bfade884847e484d452414c7ccffb3" +checksum = "53d1ccbaf7d9ec9537465a97bf19edc1a4e158ecb49fc16178202238c569cc42" [[package]] name = "bit-vec" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4523a10839ffae575fb08aa3423026c8cb4687eef43952afb956229d4f246f7" +checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3" [[package]] name = "bitflags" @@ -577,9 +601,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.2.1" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" +checksum = "5356f1d23ee24a1f785a56d1d1a5f0fd5b0f6a0c0fb2412ce11da71649ab78f6" [[package]] name = "byte-tools" @@ -616,9 +640,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.52" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" +checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" [[package]] name = "cfg-if" @@ -634,15 +658,15 @@ checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" dependencies = [ "num-integer", "num-traits 0.2.11", - "serde 1.0.106", + "serde 1.0.110", "time 0.1.43", ] [[package]] name = "clap" -version = "2.33.0" +version = "2.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" dependencies = [ "ansi_term", "atty", @@ -671,7 +695,7 @@ dependencies = [ "lazy_static", "nom", "rust-ini", - "serde 1.0.106", + "serde 1.0.110", "serde-hjson", "serde_json", "toml", @@ -754,7 +778,7 @@ dependencies = [ "config", "crossbeam-queue", "num_cpus", - "serde 1.0.106", + "serde 1.0.110", "tokio", ] @@ -769,16 +793,16 @@ dependencies = [ "deadpool", "futures", "log", - "serde 1.0.106", + "serde 1.0.110", "tokio", "tokio-postgres", ] [[package]] name = "derive_more" -version = "0.99.5" +version = "0.99.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2323f3f47db9a0e77ce7a300605d8d2098597fc451ed1a97bb1f6411bb550a7" +checksum = "2127768764f1556535c01b5326ef94bd60ff08dcfbdc544d53e69ed155610f5d" dependencies = [ "proc-macro2", "quote", @@ -820,9 +844,9 @@ checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" [[package]] name = "encoding_rs" -version = "0.8.22" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28" +checksum = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" dependencies = [ "cfg-if", ] @@ -854,9 +878,9 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" +checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" dependencies = [ "backtrace", "failure_derive", @@ -864,9 +888,9 @@ dependencies = [ [[package]] name = "failure_derive" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" +checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2", "quote", @@ -900,9 +924,9 @@ dependencies = [ [[package]] name = "fnv" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fuchsia-zircon" @@ -932,9 +956,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780" +checksum = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613" dependencies = [ "futures-channel", "futures-core", @@ -947,9 +971,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" +checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" dependencies = [ "futures-core", "futures-sink", @@ -957,15 +981,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" +checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" [[package]] name = "futures-executor" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" +checksum = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314" dependencies = [ "futures-core", "futures-task", @@ -974,15 +998,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" +checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" [[package]] name = "futures-macro" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" +checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -992,21 +1016,24 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6" +checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" [[package]] name = "futures-task" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" +checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +dependencies = [ + "once_cell", +] [[package]] name = "futures-util" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" +checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" dependencies = [ "futures-channel", "futures-core", @@ -1015,6 +1042,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", + "pin-project", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -1051,10 +1079,16 @@ dependencies = [ ] [[package]] -name = "h2" -version = "0.2.4" +name = "gimli" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "377038bf3c89d18d6ca1431e7a5027194fbd724ca10592b9487ede5e8e144f42" +checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" + +[[package]] +name = "h2" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff" dependencies = [ "bytes", "fnv", @@ -1090,9 +1124,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d737e0f947a1864e93d33fdef4af8445a00d1ed8dc0c8ddb73139ea6abf15" +checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" dependencies = [ "libc", ] @@ -1161,7 +1195,7 @@ checksum = "9994f5cd15a70a4ae0e1a6e40e42912e897f5a77f43e0e81fe8efdd7ad3c53ae" dependencies = [ "actix-http", "actix-web", - "base64 0.12.0", + "base64 0.12.1", "bytes", "chrono", "futures", @@ -1217,9 +1251,9 @@ dependencies = [ [[package]] name = "ipconfig" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" +checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" dependencies = [ "socket2", "widestring", @@ -1244,9 +1278,9 @@ checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" [[package]] name = "js-sys" -version = "0.3.37" +version = "0.3.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" +checksum = "fa5a448de267e7358beaf4a5d849518fe9a0c13fce7afd44b06e68550e5562a7" dependencies = [ "wasm-bindgen", ] @@ -1291,9 +1325,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" +checksum = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f" [[package]] name = "libm" @@ -1313,9 +1347,9 @@ dependencies = [ [[package]] name = "linked-hash-map" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" +checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" [[package]] name = "lock_api" @@ -1337,9 +1371,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0609345ddee5badacf857d4f547e0e5a2e987db77085c24cd887f73573a04237" +checksum = "348b828e43d7d1d7a247a6ece0c041d95fb0e34d5496bb4c308428face25df6b" dependencies = [ "hashbrown", ] @@ -1350,7 +1384,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" dependencies = [ - "linked-hash-map 0.5.2", + "linked-hash-map 0.5.3", ] [[package]] @@ -1374,7 +1408,7 @@ dependencies = [ "log", "phf", "phf_codegen", - "serde 1.0.106", + "serde 1.0.110", "serde_derive", "serde_json", "string_cache", @@ -1435,9 +1469,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" dependencies = [ "cfg-if", "fuchsia-zircon", @@ -1454,9 +1488,9 @@ dependencies = [ [[package]] name = "mio-uds" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" dependencies = [ "iovec", "libc", @@ -1477,9 +1511,9 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.33" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" dependencies = [ "cfg-if", "libc", @@ -1534,7 +1568,7 @@ dependencies = [ "num-iter", "num-traits 0.2.11", "rand", - "serde 1.0.106", + "serde 1.0.110", "smallvec", "zeroize", ] @@ -1599,6 +1633,18 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" + +[[package]] +name = "once_cell" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -1686,18 +1732,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.9" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f6a7f5eee6292c559c793430c55c00aea9d3b3d1905e855806ca4d7253426a2" +checksum = "edc93aeee735e60ecb40cf740eb319ff23eab1c5748abfdb5c180e4ce49f7791" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "0.4.9" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8988430ce790d8682672117bc06dda364c0be32d3abd738234f19f3240bad99a" +checksum = "e58db2081ba5b4c93bd6be09c40fd36cb9193a8336c384f3b40012e531aa7e40" dependencies = [ "proc-macro2", "quote", @@ -1706,9 +1752,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" +checksum = "f7505eeebd78492e0f6108f7171c4948dbb120ee8119d9d77d0afa5469bef67f" [[package]] name = "pin-utils" @@ -1722,7 +1768,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f611afe4d1407ebe7f3ced1ffc66f730fac1b1c13085e230a8cdcb921e97710" dependencies = [ - "base64 0.12.0", + "base64 0.12.1", "byteorder", "bytes", "fallible-iterator", @@ -1744,16 +1790,16 @@ dependencies = [ "chrono", "fallible-iterator", "postgres-protocol", - "serde 1.0.106", + "serde 1.0.110", "serde_json", "uuid", ] [[package]] name = "ppv-lite86" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" [[package]] name = "precomputed-hash" @@ -1811,9 +1857,9 @@ checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" [[package]] name = "proc-macro2" -version = "1.0.10" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" +checksum = "53f5ffe53a6b28e37c9c1ce74893477864d64f74778a93a4beb43c8fa167f639" dependencies = [ "unicode-xid", ] @@ -1826,9 +1872,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.3" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" dependencies = [ "proc-macro2", ] @@ -1912,7 +1958,8 @@ checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" name = "relay" version = "0.1.0" dependencies = [ - "activitystreams", + "activitystreams-ext", + "activitystreams-new", "actix-rt", "actix-web", "actix-webfinger", @@ -1920,7 +1967,7 @@ dependencies = [ "anyhow", "async-trait", "background-jobs", - "base64 0.12.0", + "base64 0.12.1", "bytes", "config", "deadpool", @@ -1939,7 +1986,7 @@ dependencies = [ "rsa-magic-public-key", "rsa-pem", "ructe", - "serde 1.0.106", + "serde 1.0.110", "serde_json", "sha2", "structopt", @@ -1962,13 +2009,13 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.12" +version = "0.16.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c" +checksum = "703516ae74571f24b465b4a1431e81e2ad51336cb0ded733a55a1aa3eccac196" dependencies = [ "cc", - "lazy_static", "libc", + "once_cell", "spin", "untrusted", "web-sys", @@ -2042,7 +2089,7 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f615d1e172dcc01a7cd78c7f77f21a5669c6de4341548ad2e7764e9045d06657" dependencies = [ - "base64 0.12.0", + "base64 0.12.1", "bytecount", "itertools", "md5", @@ -2085,17 +2132,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "rustversion" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3bba175698996010c4f6dce5e7f173b6eb781fce25d2cfc45e27091ce0b79f6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "ryu" version = "1.0.4" @@ -2141,9 +2177,9 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" [[package]] name = "serde" -version = "1.0.106" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" +checksum = "99e7b308464d16b56eba9964e4972a3eee817760ab60d88c3f86e1fecb08204c" dependencies = [ "serde_derive", ] @@ -2163,9 +2199,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.106" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" +checksum = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984" dependencies = [ "proc-macro2", "quote", @@ -2174,13 +2210,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.51" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" +checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2" dependencies = [ "itoa", "ryu", - "serde 1.0.106", + "serde 1.0.110", ] [[package]] @@ -2200,7 +2236,7 @@ checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" dependencies = [ "dtoa", "itoa", - "serde 1.0.106", + "serde 1.0.110", "url", ] @@ -2282,9 +2318,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "standback" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898341a519ec30272f8665dd05fb00156254310e99df3dc1e0cb096883d8656c" +checksum = "47e4b8c631c998468961a9ea159f064c5c8499b95b5e4a34b77849d45949d540" [[package]] name = "static_assertions" @@ -2314,7 +2350,7 @@ checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" dependencies = [ "proc-macro2", "quote", - "serde 1.0.106", + "serde 1.0.110", "serde_derive", "syn", ] @@ -2328,7 +2364,7 @@ dependencies = [ "base-x", "proc-macro2", "quote", - "serde 1.0.106", + "serde 1.0.110", "serde_derive", "serde_json", "sha1", @@ -2351,7 +2387,7 @@ dependencies = [ "new_debug_unreachable", "phf_shared", "precomputed-hash", - "serde 1.0.106", + "serde 1.0.110", ] [[package]] @@ -2420,9 +2456,9 @@ checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" [[package]] name = "syn" -version = "1.0.18" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" +checksum = "95b5f192649e48a5302a13f2feb224df883b98933222369e4b3b0fe2a5447269" dependencies = [ "proc-macro2", "quote", @@ -2483,18 +2519,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b3d3d2ff68104100ab257bb6bb0cb26c901abe4bd4ba15961f3bf867924012" +checksum = "5976891d6950b4f68477850b5b9e5aa64d955961466f9e174363f573e54e8ca7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca972988113b7715266f91250ddb98070d033c62a011fa0fcc57434a649310dd" +checksum = "ab81dbd1cd69cd2ce22ecfbdd3bdb73334ba25350649408cc6c085f46d89573d" dependencies = [ "proc-macro2", "quote", @@ -2512,9 +2548,9 @@ dependencies = [ [[package]] name = "threadpool" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8dae184447c15d5a6916d973c642aec485105a13cd238192a6927ae3e077d66" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" dependencies = [ "num_cpus", ] @@ -2531,16 +2567,16 @@ dependencies = [ [[package]] name = "time" -version = "0.2.10" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cacbd5ebf7b211db6d9500b8b033c20b6e333a68368a9e8d3a1d073bb1f0a12a" +checksum = "3a51cadc5b1eec673a685ff7c33192ff7b7603d0b75446fb354939ee615acb15" dependencies = [ "cfg-if", "libc", - "rustversion", "standback", "stdweb", "time-macros", + "version_check", "winapi 0.3.8", ] @@ -2568,10 +2604,16 @@ dependencies = [ ] [[package]] -name = "tokio" -version = "0.2.19" +name = "tinyvec" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d9c43f1bb96970e153bcbae39a65e249ccb942bd9d36dbdf086024920417c9c" +checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" + +[[package]] +name = "tokio" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" dependencies = [ "bytes", "fnv", @@ -2590,9 +2632,9 @@ dependencies = [ [[package]] name = "tokio-postgres" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524da2f17264514c854ac770177bdb810f0db7e706ae69f143d6e6828e3c4fe3" +checksum = "d56010a704311361b7c9e870aaa4ddffaf9f2db89cbcf3e14773ac8a14469c9c" dependencies = [ "async-trait", "byteorder", @@ -2612,9 +2654,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4adb8b3e5f86b707f1b54e7c15b6de52617a823608ccda98a15d3a24222f265a" +checksum = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4" dependencies = [ "futures-core", "rustls", @@ -2656,14 +2698,14 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" dependencies = [ - "serde 1.0.106", + "serde 1.0.110", ] [[package]] name = "trust-dns-proto" -version = "0.19.4" +version = "0.19.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e7e47e6ab54e6a011f88dbffd6d2953c628a116850174d81463e472031381d" +checksum = "cdd7061ba6f4d4d9721afedffbfd403f20f39a4301fee1b70d6fcd09cca69f28" dependencies = [ "async-trait", "backtrace", @@ -2681,9 +2723,9 @@ dependencies = [ [[package]] name = "trust-dns-resolver" -version = "0.19.4" +version = "0.19.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631e8078bf7bb595a0f7aac4ab7d7cf617535adb3c50ecbca7c2c30ef33c3c15" +checksum = "0f23cdfdc3d8300b3c50c9e84302d3bd6d860fb9529af84ace6cf9665f181b77" dependencies = [ "backtrace", "cfg-if", @@ -2705,7 +2747,18 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4189890526f0168710b6ee65ceaedf1460c48a14318ceec933cb26baa492096a" dependencies = [ - "linked-hash-map 0.5.2", + "linked-hash-map 0.5.3", +] + +[[package]] +name = "typed-builder" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fc4459191c621a53ef6c6ca5642e6e0e5ccc61f3e5b8ad6b6ab5317f0200fb" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -2752,9 +2805,9 @@ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] name = "untrusted" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" @@ -2780,14 +2833,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" dependencies = [ "rand", - "serde 1.0.106", + "serde 1.0.110", ] [[package]] name = "vec_map" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" @@ -2803,9 +2856,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasm-bindgen" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f" +checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2813,9 +2866,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd" +checksum = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94" dependencies = [ "bumpalo", "lazy_static", @@ -2828,9 +2881,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" +checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2838,9 +2891,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" +checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" dependencies = [ "proc-macro2", "quote", @@ -2851,15 +2904,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" +checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad" [[package]] name = "web-sys" -version = "0.3.37" +version = "0.3.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb" +checksum = "8bc359e5dd3b46cb9687a051d50a2fdd228e4ba7cf6fcf861a5365c3d671a642" dependencies = [ "js-sys", "wasm-bindgen", @@ -2970,14 +3023,14 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" dependencies = [ - "linked-hash-map 0.5.2", + "linked-hash-map 0.5.3", ] [[package]] name = "yasna" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a563d10ead87e2d798e357d44f40f495ad70bcee4d5c0d3f77a5b1b7376645d9" +checksum = "0de7bff972b4f2a06c85f6d8454b09df153af7e3a4ec2aac81db1b105b684ddb" dependencies = [ "bit-vec", "num-bigint", diff --git a/Cargo.toml b/Cargo.toml index 9ae691a..7c0ca0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,10 +14,11 @@ build = "src/build.rs" [dependencies] anyhow = "1.0" -actix-rt = "1.0.0" -actix-web = { version = "3.0.0-alpha.1", features = ["rustls"] } +actix-rt = "1.1.1" +actix-web = { version = "3.0.0-alpha.2", features = ["rustls"] } actix-webfinger = "0.3.0-alpha.6" -activitystreams = "0.5.0" +activitystreams-new = { git = "https://git.asonix.dog/asonix/activitystreams-sketch" } +activitystreams-ext = { git = "https://git.asonix.dog/asonix/activitystreams-ext" } ammonia = "3.1.0" async-trait = "0.1.24" background-jobs = "0.8.0-alpha.2" diff --git a/src/apub.rs b/src/apub.rs index deafc07..9877c02 100644 --- a/src/apub.rs +++ b/src/apub.rs @@ -1,15 +1,14 @@ -use activitystreams::{ - actor::Actor, - ext::Extension, - object::{Object, ObjectBox}, +use activitystreams_ext::{Ext1, UnparsedExtension}; +use activitystreams_new::{ + activity::ActorAndObject, + actor::{Actor, ApActor}, primitives::XsdAnyUri, - Base, BaseBox, PropRefs, + unparsed::UnparsedMutExt, }; -use std::collections::HashMap; #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "camelCase")] -pub struct PublicKey { +pub struct PublicKeyInner { pub id: XsdAnyUri, pub owner: XsdAnyUri, pub public_key_pem: String, @@ -17,21 +16,8 @@ pub struct PublicKey { #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "camelCase")] -pub struct PublicKeyExtension { - pub public_key: PublicKey, -} - -#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, PropRefs)] -#[serde(rename_all = "camelCase")] -#[prop_refs(Object)] -pub struct AnyExistingObject { - pub id: XsdAnyUri, - - #[serde(rename = "type")] - pub kind: String, - - #[serde(flatten)] - ext: HashMap, +pub struct PublicKey { + pub public_key: PublicKeyInner, } #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, serde::Deserialize, serde::Serialize)] @@ -47,141 +33,32 @@ pub enum ValidTypes { Update, } -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] -#[serde(untagged)] -#[serde(rename_all = "camelCase")] -pub enum ValidObjects { - Id(XsdAnyUri), - Object(AnyExistingObject), +#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, serde::Deserialize, serde::Serialize)] +#[serde(rename_all = "PascalCase")] +pub enum UndoTypes { + Follow, + Announce, + Create, } -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] -#[serde(rename_all = "camelCase")] -pub struct AcceptedObjects { - pub id: XsdAnyUri, +pub type AcceptedUndoObjects = ActorAndObject; +pub type AcceptedActivities = ActorAndObject; +pub type AcceptedActors = Ext1>, PublicKey>; - #[serde(rename = "type")] - pub kind: ValidTypes, +impl UnparsedExtension for PublicKey +where + U: UnparsedMutExt, +{ + type Error = serde_json::Error; - pub actor: XsdAnyUri, + fn try_from_unparsed(unparsed_mut: &mut U) -> Result { + Ok(PublicKey { + public_key: unparsed_mut.remove("publicKey")?, + }) + } - pub object: ValidObjects, - - #[serde(flatten)] - ext: HashMap, -} - -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] -#[serde(rename_all = "camelCase")] -pub struct AcceptedActors { - pub id: XsdAnyUri, - - #[serde(rename = "type")] - pub kind: String, - - pub inbox: XsdAnyUri, - - pub endpoints: Endpoints, - - pub public_key: PublicKey, -} - -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Endpoints { - shared_inbox: Option, -} - -impl PublicKey { - pub fn into_ext(self) -> PublicKeyExtension { - self.into() - } -} - -impl From for PublicKeyExtension { - fn from(public_key: PublicKey) -> Self { - PublicKeyExtension { public_key } - } -} - -impl Extension for PublicKeyExtension where T: Actor {} - -impl ValidObjects { - pub fn id(&self) -> &XsdAnyUri { - match self { - ValidObjects::Id(ref id) => id, - ValidObjects::Object(ref obj) => &obj.id, - } - } - - pub fn kind(&self) -> Option<&str> { - match self { - ValidObjects::Id(_) => None, - ValidObjects::Object(AnyExistingObject { kind, .. }) => Some(kind), - } - } - - pub fn is_kind(&self, query_kind: &str) -> bool { - match self { - ValidObjects::Id(_) => false, - ValidObjects::Object(AnyExistingObject { kind, .. }) => kind == query_kind, - } - } - - pub fn is(&self, uri: &XsdAnyUri) -> bool { - match self { - ValidObjects::Id(id) => id == uri, - ValidObjects::Object(AnyExistingObject { id, .. }) => id == uri, - } - } - - pub fn child_object_id(&self) -> Option { - match self { - ValidObjects::Id(_) => None, - ValidObjects::Object(AnyExistingObject { ext, .. }) => { - if let Some(o) = ext.get("object") { - if let Ok(child_uri) = serde_json::from_value::(o.clone()) { - return Some(child_uri); - } - } - - None - } - } - } - - pub fn child_object_is(&self, uri: &XsdAnyUri) -> bool { - if let Some(child_object_id) = self.child_object_id() { - return *uri == child_object_id; - } - false - } - - pub fn child_actor_id(&self) -> Option { - match self { - ValidObjects::Id(_) => None, - ValidObjects::Object(AnyExistingObject { ext, .. }) => { - if let Some(o) = ext.get("actor") { - if let Ok(child_uri) = serde_json::from_value::(o.clone()) { - return Some(child_uri); - } - } - - None - } - } - } - - pub fn child_actor_is(&self, uri: &XsdAnyUri) -> bool { - if let Some(child_actor_id) = self.child_actor_id() { - return *uri == child_actor_id; - } - false - } -} - -impl AcceptedActors { - pub fn inbox(&self) -> &XsdAnyUri { - self.endpoints.shared_inbox.as_ref().unwrap_or(&self.inbox) + fn try_into_unparsed(self, unparsed_mut: &mut U) -> Result<(), Self::Error> { + unparsed_mut.insert("publicKey", self.public_key)?; + Ok(()) } } diff --git a/src/data/actor.rs b/src/data/actor.rs index a0ac989..35676d0 100644 --- a/src/data/actor.rs +++ b/src/data/actor.rs @@ -1,5 +1,5 @@ use crate::{apub::AcceptedActors, db::Db, error::MyError, requests::Requests}; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::{prelude::*, primitives::XsdAnyUri}; use log::error; use std::{collections::HashSet, sync::Arc, time::Duration}; use tokio::sync::RwLock; @@ -61,7 +61,8 @@ impl ActorCache { let accepted_actor = requests.fetch::(id.as_str()).await?; let input_host = id.as_url().host(); - let actor_host = accepted_actor.id.as_url().host(); + let accepted_actor_id = accepted_actor.id().ok_or(MyError::MissingId)?; + let actor_host = accepted_actor_id.as_url().host(); let inbox_host = accepted_actor.inbox().as_url().host(); if input_host != actor_host { @@ -81,9 +82,9 @@ impl ActorCache { let inbox = accepted_actor.inbox().clone(); let actor = Actor { - id: accepted_actor.id, - public_key: accepted_actor.public_key.public_key_pem, - public_key_id: accepted_actor.public_key.id, + id: accepted_actor_id.clone(), + public_key: accepted_actor.ext_one.public_key.public_key_pem, + public_key_id: accepted_actor.ext_one.public_key.id, inbox, }; diff --git a/src/data/media.rs b/src/data/media.rs index 69166f4..587b8e3 100644 --- a/src/data/media.rs +++ b/src/data/media.rs @@ -1,5 +1,5 @@ use crate::{db::Db, error::MyError}; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use bytes::Bytes; use futures::join; use lru::LruCache; diff --git a/src/data/node.rs b/src/data/node.rs index 566a863..faad264 100644 --- a/src/data/node.rs +++ b/src/data/node.rs @@ -1,5 +1,5 @@ use crate::{db::Db, error::MyError}; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use log::{debug, error}; use std::{ collections::{HashMap, HashSet}, diff --git a/src/data/state.rs b/src/data/state.rs index afbaa96..81de917 100644 --- a/src/data/state.rs +++ b/src/data/state.rs @@ -5,7 +5,7 @@ use crate::{ error::MyError, requests::Requests, }; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use actix_rt::{ spawn, time::{interval_at, Instant}, diff --git a/src/db.rs b/src/db.rs index 046e69a..cc199f2 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,5 +1,5 @@ use crate::error::MyError; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use deadpool_postgres::{Manager, Pool}; use log::{info, warn}; use rsa::RSAPrivateKey; diff --git a/src/error.rs b/src/error.rs index 97063f5..0395b59 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,4 @@ -use activitystreams::primitives::XsdAnyUriError; +use activitystreams_new::primitives::XsdAnyUriError; use actix_web::{ error::{BlockingError, ResponseError}, http::StatusCode, @@ -96,6 +96,18 @@ pub enum MyError { #[error("Response has invalid status code, {0}")] Status(StatusCode), + #[error("Expected an Object, found something else")] + ObjectFormat, + + #[error("Expected a single object, found array")] + ObjectCount, + + #[error("Input is missing a 'type' field")] + MissingKind, + + #[error("Input is missing a 'id' field")] + MissingId, + #[error("URI is missing domain field")] Domain, @@ -112,7 +124,9 @@ impl ResponseError for MyError { | MyError::BadActor(_, _) => StatusCode::FORBIDDEN, MyError::NotSubscribed(_) => StatusCode::UNAUTHORIZED, MyError::Duplicate => StatusCode::ACCEPTED, - MyError::Kind(_) => StatusCode::BAD_REQUEST, + MyError::Kind(_) | MyError::MissingKind | MyError::MissingId | MyError::ObjectCount => { + StatusCode::BAD_REQUEST + } _ => StatusCode::INTERNAL_SERVER_ERROR, } } diff --git a/src/jobs/apub/announce.rs b/src/jobs/apub/announce.rs index b71d3b1..1825b0e 100644 --- a/src/jobs/apub/announce.rs +++ b/src/jobs/apub/announce.rs @@ -7,7 +7,7 @@ use crate::{ DeliverMany, JobState, }, }; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::{activity::Announce as AsAnnounce, primitives::XsdAnyUri}; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; @@ -41,13 +41,11 @@ fn generate_announce( config: &Config, activity_id: &XsdAnyUri, object_id: &XsdAnyUri, -) -> Result { - let mut announce = activitystreams::activity::Announce::default(); - - announce - .announce_props - .set_object_xsd_any_uri(object_id.clone())? - .set_actor_xsd_any_uri(config.generate_url(UrlKind::Actor))?; +) -> Result { + let announce = AsAnnounce::new( + config.generate_url(UrlKind::Actor).parse::()?, + object_id.clone(), + ); prepare_activity( announce, diff --git a/src/jobs/apub/follow.rs b/src/jobs/apub/follow.rs index 3d20890..1c13315 100644 --- a/src/jobs/apub/follow.rs +++ b/src/jobs/apub/follow.rs @@ -1,23 +1,27 @@ use crate::{ - apub::AcceptedObjects, + apub::AcceptedActivities, config::{Config, UrlKind}, data::Actor, error::MyError, jobs::{apub::prepare_activity, Deliver, JobState}, }; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::{ + activity::{Accept as AsAccept, Follow as AsFollow}, + prelude::*, + primitives::XsdAnyUri, +}; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct Follow { is_listener: bool, - input: AcceptedObjects, + input: AcceptedActivities, actor: Actor, } impl Follow { - pub fn new(is_listener: bool, input: AcceptedObjects, actor: Actor) -> Self { + pub fn new(is_listener: bool, input: AcceptedActivities, actor: Actor) -> Self { Follow { is_listener, input, @@ -32,7 +36,7 @@ impl Follow { let my_id: XsdAnyUri = state.config.generate_url(UrlKind::Actor).parse()?; // if following relay directly, not just following 'public', followback - if self.input.object.is(&my_id) && !state.actors.is_following(&self.actor.id).await { + if self.input.object_is(&my_id) && !state.actors.is_following(&self.actor.id).await { let follow = generate_follow(&state.config, &self.actor.id, &my_id)?; state .job_server @@ -41,7 +45,12 @@ impl Follow { state.actors.follower(&self.actor).await?; - let accept = generate_accept_follow(&state.config, &self.actor.id, &self.input.id, &my_id)?; + let accept = generate_accept_follow( + &state.config, + &self.actor.id, + self.input.id().ok_or(MyError::MissingId)?, + &my_id, + )?; state .job_server @@ -55,13 +64,8 @@ fn generate_follow( config: &Config, actor_id: &XsdAnyUri, my_id: &XsdAnyUri, -) -> Result { - let mut follow = activitystreams::activity::Follow::default(); - - follow - .follow_props - .set_object_xsd_any_uri(actor_id.clone())? - .set_actor_xsd_any_uri(my_id.clone())?; +) -> Result { + let follow = AsFollow::new(my_id.clone(), actor_id.clone()); prepare_activity( follow, @@ -76,23 +80,12 @@ fn generate_accept_follow( actor_id: &XsdAnyUri, input_id: &XsdAnyUri, my_id: &XsdAnyUri, -) -> Result { - let mut accept = activitystreams::activity::Accept::default(); +) -> Result { + let mut follow = AsFollow::new(actor_id.clone(), my_id.clone()); - accept - .accept_props - .set_actor_xsd_any_uri(my_id.clone())? - .set_object_base_box({ - let mut follow = activitystreams::activity::Follow::default(); + follow.set_id(input_id.clone()); - follow.object_props.set_id(input_id.clone())?; - follow - .follow_props - .set_object_xsd_any_uri(my_id.clone())? - .set_actor_xsd_any_uri(actor_id.clone())?; - - follow - })?; + let accept = AsAccept::new(my_id.clone(), follow.into_any_base()?); prepare_activity( accept, diff --git a/src/jobs/apub/forward.rs b/src/jobs/apub/forward.rs index c6d8aed..b22e860 100644 --- a/src/jobs/apub/forward.rs +++ b/src/jobs/apub/forward.rs @@ -1,24 +1,30 @@ use crate::{ - apub::AcceptedObjects, + apub::AcceptedActivities, data::Actor, + error::MyError, jobs::{apub::get_inboxes, DeliverMany, JobState}, }; +use activitystreams_new::prelude::*; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct Forward { - input: AcceptedObjects, + input: AcceptedActivities, actor: Actor, } impl Forward { - pub fn new(input: AcceptedObjects, actor: Actor) -> Self { + pub fn new(input: AcceptedActivities, actor: Actor) -> Self { Forward { input, actor } } async fn perform(self, state: JobState) -> Result<(), anyhow::Error> { - let object_id = self.input.object.id(); + let object_id = self + .input + .object() + .as_single_id() + .ok_or(MyError::MissingId)?; let inboxes = get_inboxes(&state.state, &self.actor, object_id).await?; diff --git a/src/jobs/apub/mod.rs b/src/jobs/apub/mod.rs index 7d1bd85..be83a94 100644 --- a/src/jobs/apub/mod.rs +++ b/src/jobs/apub/mod.rs @@ -3,8 +3,12 @@ use crate::{ data::{Actor, State}, error::MyError, }; -use activitystreams::{ - context, object::properties::ObjectProperties, primitives::XsdAnyUri, security, +use activitystreams_new::{ + activity::{Follow as AsFollow, Undo as AsUndo}, + context, + prelude::*, + primitives::XsdAnyUri, + security, }; use std::convert::TryInto; @@ -30,19 +34,18 @@ async fn get_inboxes( Ok(state.listeners_without(&actor.inbox, &domain).await) } -fn prepare_activity( +fn prepare_activity( mut t: T, id: impl TryInto, to: impl TryInto, ) -> Result where - T: AsMut, + T: ObjectExt + BaseExt, MyError: From + From, { - t.as_mut() - .set_id(id.try_into()?)? - .set_many_to_xsd_any_uris(vec![to.try_into()?])? - .set_many_context_xsd_any_uris(vec![context(), security()])?; + t.set_id(id.try_into()?) + .set_many_tos(vec![to.try_into()?]) + .set_many_contexts(vec![context(), security()]); Ok(t) } @@ -51,24 +54,12 @@ fn generate_undo_follow( config: &Config, actor_id: &XsdAnyUri, my_id: &XsdAnyUri, -) -> Result { - let mut undo = activitystreams::activity::Undo::default(); +) -> Result { + let mut follow = AsFollow::new(my_id.clone(), actor_id.clone()); - undo.undo_props - .set_actor_xsd_any_uri(my_id.clone())? - .set_object_base_box({ - let mut follow = activitystreams::activity::Follow::default(); + follow.set_id(config.generate_url(UrlKind::Activity).parse()?); - follow - .object_props - .set_id(config.generate_url(UrlKind::Activity))?; - follow - .follow_props - .set_actor_xsd_any_uri(actor_id.clone())? - .set_object_xsd_any_uri(actor_id.clone())?; - - follow - })?; + let undo = AsUndo::new(my_id.clone(), follow.into_any_base()?); prepare_activity(undo, config.generate_url(UrlKind::Actor), actor_id.clone()) } diff --git a/src/jobs/apub/reject.rs b/src/jobs/apub/reject.rs index 977164e..ae9379d 100644 --- a/src/jobs/apub/reject.rs +++ b/src/jobs/apub/reject.rs @@ -3,7 +3,7 @@ use crate::{ data::Actor, jobs::{apub::generate_undo_follow, Deliver, JobState}, }; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; diff --git a/src/jobs/apub/undo.rs b/src/jobs/apub/undo.rs index d013c63..510e825 100644 --- a/src/jobs/apub/undo.rs +++ b/src/jobs/apub/undo.rs @@ -1,21 +1,21 @@ use crate::{ - apub::AcceptedObjects, + apub::AcceptedActivities, config::UrlKind, data::Actor, jobs::{apub::generate_undo_follow, Deliver, JobState}, }; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct Undo { - input: AcceptedObjects, + input: AcceptedActivities, actor: Actor, } impl Undo { - pub fn new(input: AcceptedObjects, actor: Actor) -> Self { + pub fn new(input: AcceptedActivities, actor: Actor) -> Self { Undo { input, actor } } diff --git a/src/jobs/deliver.rs b/src/jobs/deliver.rs index 95ad1ec..33397c6 100644 --- a/src/jobs/deliver.rs +++ b/src/jobs/deliver.rs @@ -1,5 +1,5 @@ use crate::{error::MyError, jobs::JobState}; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use anyhow::Error; use background_jobs::{ActixJob, Backoff}; use std::{future::Future, pin::Pin}; diff --git a/src/jobs/deliver_many.rs b/src/jobs/deliver_many.rs index 977faa1..73f1112 100644 --- a/src/jobs/deliver_many.rs +++ b/src/jobs/deliver_many.rs @@ -2,7 +2,7 @@ use crate::{ error::MyError, jobs::{Deliver, JobState}, }; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use anyhow::Error; use background_jobs::ActixJob; use futures::future::{ready, Ready}; diff --git a/src/jobs/instance.rs b/src/jobs/instance.rs index f272c91..4de7713 100644 --- a/src/jobs/instance.rs +++ b/src/jobs/instance.rs @@ -1,5 +1,5 @@ use crate::{config::UrlKind, jobs::JobState}; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use anyhow::Error; use background_jobs::ActixJob; use futures::join; diff --git a/src/jobs/nodeinfo.rs b/src/jobs/nodeinfo.rs index c833771..6e4436f 100644 --- a/src/jobs/nodeinfo.rs +++ b/src/jobs/nodeinfo.rs @@ -1,5 +1,5 @@ use crate::jobs::JobState; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use anyhow::Error; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; diff --git a/src/middleware/verifier.rs b/src/middleware/verifier.rs index 9b7c9fe..5d25e39 100644 --- a/src/middleware/verifier.rs +++ b/src/middleware/verifier.rs @@ -1,5 +1,5 @@ use crate::{data::ActorCache, error::MyError, requests::Requests}; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use actix_web::web; use http_signature_normalization_actix::{prelude::*, verify::DeprecatedAlgorithm}; use log::error; diff --git a/src/notify.rs b/src/notify.rs index 51e83ae..5dd0c87 100644 --- a/src/notify.rs +++ b/src/notify.rs @@ -3,7 +3,7 @@ use crate::{ db::listen, jobs::{JobServer, QueryInstance, QueryNodeinfo}, }; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use actix_rt::{spawn, time::delay_for}; use futures::stream::{poll_fn, StreamExt}; use log::{debug, error, warn}; diff --git a/src/requests.rs b/src/requests.rs index 7a820dd..077de5e 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -1,5 +1,5 @@ use crate::error::MyError; -use activitystreams::primitives::XsdAnyUri; +use activitystreams_new::primitives::XsdAnyUri; use actix_web::{client::Client, http::header::Date}; use bytes::Bytes; use http_signature_normalization_actix::prelude::*; diff --git a/src/routes/actor.rs b/src/routes/actor.rs index 018fdb9..5a267c0 100644 --- a/src/routes/actor.rs +++ b/src/routes/actor.rs @@ -1,13 +1,17 @@ use crate::{ - apub::PublicKey, + apub::{PublicKey, PublicKeyInner}, config::{Config, UrlKind}, data::State, error::MyError, routes::ok, }; -use activitystreams::{ - actor::Application, context, endpoint::EndpointProperties, ext::Extensible, - object::properties::ObjectProperties, security, +use activitystreams_ext::Ext1; +use activitystreams_new::{ + actor::{ApActor, Application, Endpoints}, + context, + prelude::*, + primitives::{XsdAnyUri, XsdString}, + security, }; use actix_web::{web, Responder}; use rsa_pem::KeyExt; @@ -16,33 +20,42 @@ pub async fn route( state: web::Data, config: web::Data, ) -> Result { - let mut application = Application::full(); - let mut endpoint = EndpointProperties::default(); - - endpoint.set_shared_inbox(config.generate_url(UrlKind::Inbox))?; - - let props: &mut ObjectProperties = application.as_mut(); - props - .set_id(config.generate_url(UrlKind::Actor))? - .set_summary_xsd_string("AodeRelay bot")? - .set_name_xsd_string("AodeRelay")? - .set_url_xsd_any_uri(config.generate_url(UrlKind::Actor))? - .set_many_context_xsd_any_uris(vec![context(), security()])?; + let mut application = Ext1::new( + ApActor::new( + config.generate_url(UrlKind::Inbox).parse()?, + config.generate_url(UrlKind::Outbox).parse()?, + Application::new(), + ), + PublicKey { + public_key: PublicKeyInner { + id: config.generate_url(UrlKind::MainKey).parse()?, + owner: config.generate_url(UrlKind::Actor).parse()?, + public_key_pem: state.public_key.to_pem_pkcs8()?, + }, + }, + ); application - .extension - .set_preferred_username("relay")? - .set_followers(config.generate_url(UrlKind::Followers))? - .set_following(config.generate_url(UrlKind::Following))? - .set_inbox(config.generate_url(UrlKind::Inbox))? - .set_outbox(config.generate_url(UrlKind::Outbox))? - .set_endpoints(endpoint)?; + .set_id(config.generate_url(UrlKind::Actor).parse()?) + .set_summary(XsdString::from("AodeRelay bot")) + .set_name(XsdString::from("AodeRelay")) + .set_url(config.generate_url(UrlKind::Actor).parse::()?) + .set_many_contexts(vec![context(), security()]) + .set_preferred_username("relay".into()) + .set_followers( + config + .generate_url(UrlKind::Followers) + .parse::()?, + ) + .set_following( + config + .generate_url(UrlKind::Following) + .parse::()?, + ) + .set_endpoints(Endpoints { + shared_inbox: Some(config.generate_url(UrlKind::Inbox).parse::()?), + ..Default::default() + }); - let public_key = PublicKey { - id: config.generate_url(UrlKind::MainKey).parse()?, - owner: config.generate_url(UrlKind::Actor).parse()?, - public_key_pem: state.public_key.to_pem_pkcs8()?, - }; - - Ok(ok(application.extend(public_key.into_ext()))) + Ok(ok(application)) } diff --git a/src/routes/inbox.rs b/src/routes/inbox.rs index b39b33a..6e73370 100644 --- a/src/routes/inbox.rs +++ b/src/routes/inbox.rs @@ -1,5 +1,5 @@ use crate::{ - apub::{AcceptedObjects, ValidTypes}, + apub::{AcceptedActivities, AcceptedUndoObjects, UndoTypes, ValidTypes}, config::{Config, UrlKind}, data::{Actor, ActorCache, State}, error::MyError, @@ -8,7 +8,13 @@ use crate::{ requests::Requests, routes::accepted, }; -use activitystreams::{primitives::XsdAnyUri, public}; +use activitystreams_new::{ + activity, + base::AnyBase, + prelude::*, + primitives::{OneOrMany, XsdAnyUri}, + public, +}; use actix_web::{web, HttpResponse}; use futures::join; use http_signature_normalization_actix::prelude::{DigestVerified, SignatureVerified}; @@ -20,12 +26,18 @@ pub async fn route( config: web::Data, client: web::Data, jobs: web::Data, - input: web::Json, + input: web::Json, verified: Option<(SignatureVerified, DigestVerified)>, ) -> Result { let input = input.into_inner(); - let actor = actors.get(&input.actor, &client).await?.into_inner(); + let actor = actors + .get( + input.actor().as_single_id().ok_or(MyError::MissingId)?, + &client, + ) + .await? + .into_inner(); let (is_blocked, is_whitelisted, is_listener) = join!( state.is_blocked(&actor.id), @@ -41,7 +53,7 @@ pub async fn route( return Err(MyError::Whitelist(actor.id.to_string())); } - if !is_listener && !valid_without_listener(&input) { + if !is_listener && !valid_without_listener(&input)? { return Err(MyError::NotSubscribed(actor.inbox.to_string())); } @@ -59,7 +71,7 @@ pub async fn route( } } - match input.kind { + match input.kind().ok_or(MyError::MissingKind)? { ValidTypes::Accept => handle_accept(&config, input).await?, ValidTypes::Reject => handle_reject(&config, &jobs, input, actor).await?, ValidTypes::Announce | ValidTypes::Create => { @@ -73,26 +85,39 @@ pub async fn route( Ok(accepted(serde_json::json!({}))) } -fn valid_without_listener(input: &AcceptedObjects) -> bool { - match input.kind { - ValidTypes::Follow => true, - ValidTypes::Undo if input.object.is_kind("Follow") => true, - _ => false, +fn valid_without_listener(input: &AcceptedActivities) -> Result { + match input.kind() { + Some(ValidTypes::Follow) => Ok(true), + Some(ValidTypes::Undo) => Ok(single_object(input.object())?.is_kind("Follow")), + _ => Ok(false), } } -async fn handle_accept(config: &Config, input: AcceptedObjects) -> Result<(), MyError> { - if !input.object.is_kind("Follow") { - return Err(MyError::Kind( - input.object.kind().unwrap_or("unknown").to_owned(), - )); - } +fn kind_str(base: &AnyBase) -> Result<&str, MyError> { + base.kind_str().ok_or(MyError::MissingKind) +} - if !input - .object - .child_actor_is(&config.generate_url(UrlKind::Actor).parse()?) +fn id_string(id: Option<&XsdAnyUri>) -> Result { + id.map(|s| s.to_string()).ok_or(MyError::MissingId) +} + +fn single_object(o: &OneOrMany) -> Result<&AnyBase, MyError> { + o.as_one().ok_or(MyError::ObjectCount) +} + +async fn handle_accept(config: &Config, input: AcceptedActivities) -> Result<(), MyError> { + let follow = if let Ok(Some(follow)) = + activity::Follow::from_any_base(single_object(input.object())?.clone()) { - return Err(MyError::WrongActor(input.object.id().to_string())); + follow + } else { + return Err(MyError::Kind( + kind_str(single_object(input.object())?)?.to_owned(), + )); + }; + + if !follow.actor_is(&config.generate_url(UrlKind::Actor).parse()?) { + return Err(MyError::WrongActor(id_string(follow.id())?)); } Ok(()) @@ -101,20 +126,23 @@ async fn handle_accept(config: &Config, input: AcceptedObjects) -> Result<(), My async fn handle_reject( config: &Config, jobs: &JobServer, - input: AcceptedObjects, + input: AcceptedActivities, actor: Actor, ) -> Result<(), MyError> { - if !input.object.is_kind("Follow") { - return Err(MyError::Kind( - input.object.kind().unwrap_or("unknown").to_owned(), - )); - } - - if !input - .object - .child_actor_is(&config.generate_url(UrlKind::Actor).parse()?) + let follow = if let Ok(Some(follow)) = + activity::Follow::from_any_base(single_object(input.object())?.clone()) { - return Err(MyError::WrongActor(input.object.id().to_string())); + follow + } else { + return Err(MyError::Kind( + kind_str(single_object(input.object())?)?.to_owned(), + )); + }; + + if !follow.actor_is(&config.generate_url(UrlKind::Actor).parse()?) { + return Err(MyError::WrongActor( + follow.id().map(|s| s.to_string()).unwrap_or(String::new()), + )); } jobs.queue(Reject(actor))?; @@ -125,34 +153,27 @@ async fn handle_reject( async fn handle_undo( config: &Config, jobs: &JobServer, - input: AcceptedObjects, + input: AcceptedActivities, actor: Actor, is_listener: bool, ) -> Result<(), MyError> { - match input.object.kind() { - Some("Follow") | Some("Announce") | Some("Create") => (), - _ => { - return Err(MyError::Kind( - input.object.kind().unwrap_or("unknown").to_owned(), - )); - } - } + let any_base = single_object(input.object())?.clone(); + let undone_object = + AcceptedUndoObjects::from_any_base(any_base)?.ok_or(MyError::ObjectFormat)?; - if !input.object.is_kind("Follow") { + if !undone_object.is_kind(&UndoTypes::Follow) { if is_listener { jobs.queue(Forward::new(input, actor))?; return Ok(()); } else { - return Err(MyError::Kind( - input.object.kind().unwrap_or("unknown").to_owned(), - )); + return Err(MyError::NotSubscribed(id_string(input.id())?)); } } let my_id: XsdAnyUri = config.generate_url(UrlKind::Actor).parse()?; - if !input.object.child_object_is(&my_id) && !input.object.child_object_is(&public()) { - return Err(MyError::WrongActor(input.object.id().to_string())); + if !undone_object.object_is(&my_id) && !undone_object.object_is(&public()) { + return Err(MyError::WrongActor(id_string(undone_object.id())?)); } if !is_listener { @@ -165,7 +186,7 @@ async fn handle_undo( async fn handle_forward( jobs: &JobServer, - input: AcceptedObjects, + input: AcceptedActivities, actor: Actor, ) -> Result<(), MyError> { jobs.queue(Forward::new(input, actor))?; @@ -176,10 +197,10 @@ async fn handle_forward( async fn handle_announce( state: &State, jobs: &JobServer, - input: AcceptedObjects, + input: AcceptedActivities, actor: Actor, ) -> Result<(), MyError> { - let object_id = input.object.id(); + let object_id = input.object().as_single_id().ok_or(MyError::MissingId)?; if state.is_cached(object_id).await { return Err(MyError::Duplicate); @@ -193,14 +214,16 @@ async fn handle_announce( async fn handle_follow( config: &Config, jobs: &JobServer, - input: AcceptedObjects, + input: AcceptedActivities, actor: Actor, is_listener: bool, ) -> Result<(), MyError> { let my_id: XsdAnyUri = config.generate_url(UrlKind::Actor).parse()?; - if !input.object.is(&my_id) && !input.object.is(&public()) { - return Err(MyError::WrongActor(input.object.id().to_string())); + if !input.object_is(&my_id) && !input.object_is(&public()) { + return Err(MyError::WrongActor(id_string( + input.object().as_single_id(), + )?)); } jobs.queue(Follow::new(is_listener, input, actor))?; diff --git a/templates/admin.rs.html b/templates/admin.rs.html index ffb570d..4f781b8 100644 --- a/templates/admin.rs.html +++ b/templates/admin.rs.html @@ -1,5 +1,5 @@ @use crate::data::Contact; -@use activitystreams::primitives::XsdAnyUri; +@use activitystreams_new::primitives::XsdAnyUri; @(contact: &Contact, base: &XsdAnyUri) diff --git a/templates/info.rs.html b/templates/info.rs.html index 3ac1e4c..a953fc6 100644 --- a/templates/info.rs.html +++ b/templates/info.rs.html @@ -1,5 +1,5 @@ @use crate::data::Info; -@use activitystreams::primitives::XsdAnyUri; +@use activitystreams_new::primitives::XsdAnyUri; @(info: &Info, base: &XsdAnyUri) diff --git a/templates/instance.rs.html b/templates/instance.rs.html index 29082c9..5300d76 100644 --- a/templates/instance.rs.html +++ b/templates/instance.rs.html @@ -1,5 +1,5 @@ @use crate::{data::{Contact, Instance}, templates::admin}; -@use activitystreams::primitives::XsdAnyUri; +@use activitystreams_new::primitives::XsdAnyUri; @(instance: &Instance, software: Option<&str>, contact: Option<&Contact>, base: &XsdAnyUri)