From d2881ee3f744083ab73a96b1a594714640b0a0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mina=20Gali=C4=87?= Date: Sat, 23 May 2020 23:32:10 +0200 Subject: [PATCH] add async/.await until all our errors are the same: that our Connection is not Send-safe. --- Cargo.lock | 334 +++++++++++++++++++++------------------ plume-models/src/lib.rs | 6 + src/api/mod.rs | 1 + src/inbox.rs | 3 +- src/routes/blogs.rs | 26 +-- src/routes/comments.rs | 17 +- src/routes/errors.rs | 12 +- src/routes/posts.rs | 7 +- src/routes/reshares.rs | 4 +- src/routes/session.rs | 8 +- src/routes/user.rs | 30 ++-- src/routes/well_known.rs | 20 ++- 12 files changed, 264 insertions(+), 204 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 742772d8..777f02f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,9 +31,9 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65608fdeae5eb05485d5b71a3d2242d76b2b7413608c196d47eb4dff3eed7b85" dependencies = [ - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[package]] @@ -62,6 +62,15 @@ dependencies = [ "serde_json", ] +[[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" @@ -70,9 +79,9 @@ checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" [[package]] name = "ahash" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c251dce3391a07b43218ca070203ecb8f9f520d35ab71312296a59dbceab154" +checksum = "2f3e0bf23f51883cce372d5d5892211236856e4bb37fb942e1eb135ee0f146e3" [[package]] name = "aho-corasick" @@ -147,13 +156,13 @@ checksum = "719b48039ffac1564f67d70162109ba9341125cee0096a540e478355b3c724a7" [[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 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[package]] @@ -218,13 +227,14 @@ 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", ] @@ -300,9 +310,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.50.1" +version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0e5a5f74b2bafe0b39379f616b5975e08bcaca4e779c078d5c31324147e9ba" +checksum = "c72a978d268b1d70b0e963217e60fdabd9523a941457a6c42a7315d15c7e89e5" dependencies = [ "bitflags 1.2.1", "cexpr", @@ -310,13 +320,14 @@ dependencies = [ "clang-sys", "clap", "env_logger", - "fxhash", "lazy_static", + "lazycell", "log 0.4.8", "peeking_take_while", - "proc-macro2 0.4.30", - "quote 0.6.13", + "proc-macro2 1.0.15", + "quote 1.0.6", "regex", + "rustc-hash", "shlex", "which", ] @@ -395,9 +406,9 @@ checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" [[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 = "bytecount" @@ -425,9 +436,9 @@ checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" [[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 = "census" @@ -437,11 +448,11 @@ checksum = "641317709904ba3c1ad137cb5d88ec9d8c03c07de087b2cff5e84ec565c7e299" [[package]] name = "cexpr" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" +checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" dependencies = [ - "nom 4.2.3", + "nom 5.1.1", ] [[package]] @@ -476,9 +487,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "0.28.1" +version = "0.29.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" +checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" dependencies = [ "glob", "libc", @@ -487,9 +498,9 @@ dependencies = [ [[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", @@ -746,7 +757,7 @@ version = "0.3.0" source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089" dependencies = [ "devise_core", - "quote 1.0.4", + "quote 1.0.6", ] [[package]] @@ -755,9 +766,9 @@ version = "0.3.0" source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089" dependencies = [ "bitflags 1.2.1", - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[package]] @@ -793,9 +804,9 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" dependencies = [ - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[package]] @@ -930,18 +941,18 @@ checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" [[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", ] [[package]] name = "env_logger" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" dependencies = [ "atty", "humantime", @@ -956,7 +967,7 @@ version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" dependencies = [ - "backtrace 0.3.46", + "backtrace 0.3.48", "version_check 0.9.1", ] @@ -977,7 +988,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" dependencies = [ - "backtrace 0.3.46", + "backtrace 0.3.48", "failure_derive", ] @@ -987,9 +998,9 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", "synstructure", ] @@ -1028,9 +1039,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 = "foreign-types" @@ -1125,9 +1136,9 @@ checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" [[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", @@ -1140,9 +1151,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", @@ -1150,9 +1161,9 @@ 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-cpupool" @@ -1166,9 +1177,9 @@ dependencies = [ [[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", @@ -1177,39 +1188,42 @@ 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 0.5.15", - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[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 1.4.0", +] [[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", @@ -1218,21 +1232,13 @@ dependencies = [ "futures-sink", "futures-task", "memchr", + "pin-project", "pin-utils", "proc-macro-hack 0.5.15", "proc-macro-nested", "slab", ] -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder 1.3.4", -] - [[package]] name = "generic-array" version = "0.12.3" @@ -1286,6 +1292,12 @@ name = "gettext-utils" version = "0.1.0" source = "git+https://github.com/Plume-org/gettext-macros/?rev=a7c605f7edd6bfbfbfe7778026bfefd88d82db10#a7c605f7edd6bfbfbfe7778026bfefd88d82db10" +[[package]] +name = "gimli" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" + [[package]] name = "glob" version = "0.3.0" @@ -1384,9 +1396,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4" +checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" dependencies = [ "libc", ] @@ -1668,9 +1680,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 = "libloading" @@ -1838,9 +1850,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c" dependencies = [ "migrations_internals", - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[package]] @@ -2116,6 +2128,12 @@ 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 = "0.2.4" @@ -2127,9 +2145,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b" +checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" [[package]] name = "onig" @@ -2145,9 +2163,9 @@ dependencies = [ [[package]] name = "onig_sys" -version = "69.2.0" +version = "69.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a8d4efbf5f59cece01f539305191485b651acb3785b9d5eef05749f0496514e" +checksum = "3814583fad89f3c60ae0701d80e87e1fd3028741723deda72d0d4a0ecf0cb0db" dependencies = [ "bindgen", "cc", @@ -2365,22 +2383,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.13" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c3bfbfb5bb42f99498c7234bbd768c220eb0cea6818259d0d18a1aa3d2595d" +checksum = "edc93aeee735e60ecb40cf740eb319ff23eab1c5748abfdb5c180e4ce49f7791" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "0.4.13" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccbf6449dcfb18562c015526b085b8df1aa3cdab180af8ec2ebd300a3bd28f63" +checksum = "e58db2081ba5b4c93bd6be09c40fd36cb9193a8336c384f3b40012e531aa7e40" dependencies = [ - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[package]] @@ -2421,6 +2439,7 @@ version = "0.4.0" dependencies = [ "activitypub", "askama_escape", + "async-trait", "atom_syndication", "chrono", "clap", @@ -2455,7 +2474,7 @@ dependencies = [ "tokio", "validator", "validator_derive", - "webfinger", + "webfinger 0.5.0 (git+https://github.com/Plume-org/webfinger?rev=4e8f12810c4a7ba7a07bbcb722cd265fdff512b6)", ] [[package]] @@ -2539,7 +2558,7 @@ dependencies = [ "diesel", "diesel-derive-newtype", "diesel_migrations", - "futures 0.3.4", + "futures 0.3.5", "glob", "guid-create", "heck", @@ -2562,15 +2581,15 @@ dependencies = [ "tokio", "url 2.1.1", "walkdir", - "webfinger", + "webfinger 0.5.0 (git+https://github.com/Plume-org/webfinger?rev=update-deps)", "whatlang", ] [[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 = "pq-sys" @@ -2643,9 +2662,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.12" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319" +checksum = "70a50b9351bfa8d65a7d93ce712dc63d2fd15ddbf2c36990fc7cac344859c04f" dependencies = [ "unicode-xid 0.2.0", ] @@ -2712,11 +2731,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c1f4b0efa5fc5e8ceb705136bfee52cfdb6a4e3509f770b478cd6ed434232a7" +checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" dependencies = [ - "proc-macro2 1.0.12", + "proc-macro2 1.0.15", ] [[package]] @@ -2995,7 +3014,7 @@ checksum = "703516ae74571f24b465b4a1431e81e2ad51336cb0ded733a55a1aa3eccac196" dependencies = [ "cc", "libc", - "once_cell 1.3.1", + "once_cell 1.4.0", "spin", "untrusted", "web-sys", @@ -3011,7 +3030,7 @@ dependencies = [ "atty", "base16", "base64 0.11.0", - "futures 0.3.4", + "futures 0.3.5", "futures-util", "log 0.4.8", "memchr", @@ -3034,7 +3053,7 @@ source = "git+https://github.com/SergioBenitez/Rocket?rev=async#78c8ac8ccdbe85ab dependencies = [ "devise", "indexmap", - "quote 1.0.4", + "quote 1.0.6", "rocket_http", "version_check 0.9.1", "yansi 0.5.0", @@ -3134,6 +3153,12 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -3166,9 +3191,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039c25b130bd8c1321ee2d7de7fde2659fa9c2744e4bb29711cfc852ea53cd19" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ "lazy_static", "winapi 0.3.8", @@ -3214,9 +3239,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "security-framework" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f331b9025654145cd425b9ded0caf8f5ae0df80d418b326e2dc1c3dc5eb0620" +checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" dependencies = [ "bitflags 1.2.1", "core-foundation", @@ -3252,29 +3277,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[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", ] [[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 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[package]] name = "serde_json" -version = "1.0.52" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7894c8ed05b7a3a279aeb79025fdec1d3158080b75b98a08faf2806bb799edd" +checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2" dependencies = [ "itoa", "ryu", @@ -3325,9 +3350,9 @@ checksum = "83695fde96cbe9e08f0e4eb96b1b56fdbd44f2098ee27462dda964c7745fddc7" dependencies = [ "bitflags 1.2.1", "itertools", - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[package]] @@ -3338,9 +3363,9 @@ checksum = "e63e6744142336dfb606fe2b068afa2e1cca1ee6a5d8377277a92945d81fa331" dependencies = [ "bitflags 1.2.1", "itertools", - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", ] [[package]] @@ -3488,8 +3513,8 @@ checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" dependencies = [ "phf_generator", "phf_shared", - "proc-macro2 1.0.12", - "quote 1.0.4", + "proc-macro2 1.0.15", + "quote 1.0.6", "string_cache_shared", ] @@ -3562,12 +3587,12 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.19" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e5aa70697bb26ee62214ae3288465ecec0000f05182f039b477001f08f5ae7" +checksum = "95b5f192649e48a5302a13f2feb224df883b98933222369e4b3b0fe2a5447269" dependencies = [ - "proc-macro2 1.0.12", - "quote 1.0.4", + "proc-macro2 1.0.15", + "quote 1.0.6", "unicode-xid 0.2.0", ] @@ -3586,9 +3611,9 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" dependencies = [ - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", "unicode-xid 0.2.0", ] @@ -3749,9 +3774,9 @@ dependencies = [ [[package]] name = "tokio" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c1d570eb1a36f0345a5ce9c6c6e665b70b73d11236912c0b477616aeec47b1" +checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" dependencies = [ "bytes", "fnv", @@ -4068,9 +4093,9 @@ dependencies = [ "bumpalo", "lazy_static", "log 0.4.8", - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", "wasm-bindgen-shared", ] @@ -4092,7 +4117,7 @@ version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" dependencies = [ - "quote 1.0.4", + "quote 1.0.6", "wasm-bindgen-macro-support", ] @@ -4102,9 +4127,9 @@ version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" dependencies = [ - "proc-macro2 1.0.12", - "quote 1.0.4", - "syn 1.0.19", + "proc-macro2 1.0.15", + "quote 1.0.6", + "syn 1.0.23", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4125,6 +4150,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webfinger" +version = "0.5.0" +source = "git+https://github.com/Plume-org/webfinger?rev=4e8f12810c4a7ba7a07bbcb722cd265fdff512b6#4e8f12810c4a7ba7a07bbcb722cd265fdff512b6" +dependencies = [ + "async-trait", + "reqwest", + "serde", +] + [[package]] name = "webfinger" version = "0.5.0" @@ -4136,20 +4171,19 @@ dependencies = [ [[package]] name = "whatlang" -version = "0.7.4" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eb4694f7385e63fab02bb374e8ab39bffb5c25c2bce68a9b18c51cfd554e69a" +checksum = "3437a8cc85accfcd03f291a2d2a6ae8400fa78ad6f2b6aa6c38d2badb6e378e9" dependencies = [ "hashbrown", ] [[package]] name = "which" -version = "2.0.1" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" +checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" dependencies = [ - "failure", "libc", ] diff --git a/plume-models/src/lib.rs b/plume-models/src/lib.rs index f652e6df..6e6810a1 100644 --- a/plume-models/src/lib.rs +++ b/plume-models/src/lib.rs @@ -76,6 +76,12 @@ impl From for Error { } } +impl From for std::option::NoneError { + fn from(_: Error) -> Self { + std::option::NoneError + } +} + impl From for Error { fn from(_: url::ParseError) -> Self { Error::Url diff --git a/src/api/mod.rs b/src/api/mod.rs index f13f5615..3ff09276 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -66,6 +66,7 @@ pub struct OAuthRequest { } #[get("/oauth2?")] +#[rocket::async_trait(?Send)] pub async fn oauth( query: Form, rockets: PlumeRocket, diff --git a/src/inbox.rs b/src/inbox.rs index 92dba541..1e554194 100644 --- a/src/inbox.rs +++ b/src/inbox.rs @@ -11,7 +11,7 @@ use rocket_contrib::json::*; use serde::Deserialize; use tokio::io::AsyncReadExt; -pub fn handle_incoming( +pub async fn handle_incoming( rockets: PlumeRocket, data: SignedJson, headers: Headers<'_>, @@ -32,6 +32,7 @@ pub fn handle_incoming( // maybe we just know an old key? actor .refetch(conn) + .await .and_then(|_| User::get(conn, actor.id)) .and_then(|u| { if verify_http_headers(&u, &headers.0, &sig).is_secure() || act.clone().verify(&u) { diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index 0fb3d3bb..2891463e 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -19,10 +19,14 @@ use plume_models::{ }; #[get("/~/?", rank = 2)] -pub fn details(name: String, page: Option, rockets: PlumeRocket) -> Result { +pub async fn details( + name: String, + page: Option, + rockets: PlumeRocket, +) -> Result { let page = page.unwrap_or_default(); let conn = &*rockets.conn; - let blog = Blog::find_by_fqn(&rockets, &name)?; + let blog = Blog::find_by_fqn(&rockets, &name).await?; let posts = Post::blog_page(conn, &blog, page.limits())?; let articles_count = Post::count_for_blog(conn, &blog)?; let authors = &blog.list_authors(conn)?; @@ -43,7 +47,7 @@ pub async fn activity_details( rockets: PlumeRocket, _ap: ApRequest, ) -> Option> { - let blog = Blog::find_by_fqn(&rockets, &name).await?.ok()?; + let blog = Blog::find_by_fqn(&rockets, &name).await?; Some(ActivityStream::new(blog.to_activity(&*rockets.conn).ok()?)) } @@ -83,7 +87,7 @@ fn valid_slug(title: &str) -> Result<(), ValidationError> { } #[post("/blogs/new", data = "
")] -pub fn create(form: LenientForm, rockets: PlumeRocket) -> RespondOrRedirect { +pub async fn create(form: LenientForm, rockets: PlumeRocket) -> RespondOrRedirect { let slug = utils::make_actor_id(&form.title); let conn = &*rockets.conn; let intl = &rockets.intl.catalog; @@ -143,9 +147,11 @@ pub fn create(form: LenientForm, rockets: PlumeRocket) -> RespondOr } #[post("/~//delete")] -pub fn delete(name: String, rockets: PlumeRocket) -> RespondOrRedirect { +pub async fn delete(name: String, rockets: PlumeRocket) -> RespondOrRedirect { let conn = &*rockets.conn; - let blog = Blog::find_by_fqn(&rockets, &name).expect("blog::delete: blog not found"); + let blog = Blog::find_by_fqn(&rockets, &name) + .await + .expect("blog::delete: blog not found"); if rockets .user @@ -348,9 +354,10 @@ pub async fn outbox( name: String, rockets: PlumeRocket, ) -> Option> { - let blog = Blog::find_by_fqn(&rockets, &name).await?.ok()?; + let blog = Blog::find_by_fqn(&rockets, &name).await?; Some(blog.outbox(&*rockets.conn).ok()?) } + #[allow(unused_variables)] #[get("/~//outbox?")] pub async fn outbox_page( @@ -358,12 +365,13 @@ pub async fn outbox_page( page: Page, rockets: PlumeRocket, ) -> Option> { - let blog = Blog::find_by_fqn(&rockets, &name).await?.ok()?; + let blog = Blog::find_by_fqn(&rockets, &name).await?; Some(blog.outbox_page(&*rockets.conn, page.limits()).ok()?) } + #[get("/~//atom.xml")] pub async fn atom_feed(name: String, rockets: PlumeRocket) -> Option> { - let blog = Blog::find_by_fqn(&rockets, &name).await?.ok()?; + let blog = Blog::find_by_fqn(&rockets, &name).await?; let conn = &*rockets.conn; let entries = Post::get_recents_for_blog(&*conn, &blog, 15).ok()?; let uri = Instance::get_local() diff --git a/src/routes/comments.rs b/src/routes/comments.rs index 99ef6e57..ce05abbc 100644 --- a/src/routes/comments.rs +++ b/src/routes/comments.rs @@ -28,7 +28,7 @@ pub struct NewCommentForm { } #[post("/~///comment", data = "")] -pub fn create( +pub async fn create( blog_name: String, slug: String, form: LenientForm, @@ -39,9 +39,7 @@ pub fn create( let blog = Blog::find_by_fqn(&rockets, &blog_name) .await .expect("comments::create: blog error"); - let post = Post::find_by_slug(&*conn, &slug, blog.id) - .await - .expect("comments::create: post error"); + let post = Post::find_by_slug(&*conn, &slug, blog.id).expect("comments::create: post error"); form.validate() .map(|_| { let (html, mentions, _hashtags) = utils::md_to_html( @@ -70,6 +68,7 @@ pub fn create( .expect("comments::create: insert error"); let new_comment = comm .create_activity(&rockets) + .await .expect("comments::create: activity error"); // save mentions @@ -77,6 +76,7 @@ pub fn create( Mention::from_activity( &*conn, &Mention::build_activity(&rockets, &ment) + .await .expect("comments::create: build mention error"), comm.id, false, @@ -185,8 +185,9 @@ pub fn activity_pub( _ap: ApRequest, rockets: PlumeRocket, ) -> Option> { - Comment::get(&*rockets.conn, id) - .and_then(|c| c.to_activity(&rockets)) - .ok() - .map(ActivityStream::new) + let c = match Comment::get(&*rockets.conn, id) { + Ok(c) => c.to_activity(&rockets).await.ok(), + Err(_) => None, + }; + c.map(ActivityStream::new) } diff --git a/src/routes/errors.rs b/src/routes/errors.rs index 02d6883b..039fd0d5 100644 --- a/src/routes/errors.rs +++ b/src/routes/errors.rs @@ -41,20 +41,20 @@ impl<'r> Responder<'r> for ErrorPage { } #[catch(404)] -pub fn not_found(req: &Request<'_>) -> Ructe { - let rockets = req.guard::().unwrap(); +pub async fn not_found(req: &Request<'_>) -> Ructe { + let rockets = req.guard::().await.unwrap(); render!(errors::not_found(&rockets.to_context())) } #[catch(422)] -pub fn unprocessable_entity(req: &Request<'_>) -> Ructe { - let rockets = req.guard::().unwrap(); +pub async fn unprocessable_entity(req: &Request<'_>) -> Ructe { + let rockets = req.guard::().await.unwrap(); render!(errors::unprocessable_entity(&rockets.to_context())) } #[catch(500)] -pub fn server_error(req: &Request<'_>) -> Ructe { - let rockets = req.guard::().unwrap(); +pub async fn server_error(req: &Request<'_>) -> Ructe { + let rockets = req.guard::().await.unwrap(); render!(errors::server_error(&rockets.to_context())) } diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 84658d40..16329d9b 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -304,11 +304,11 @@ pub async fn update( if post.published { post.update_mentions( + &conn, mentions .into_iter() .filter_map(|m| Mention::build_activity(&rockets, &m).await.ok()) .collect(), - &conn, ) .expect("post::update: mentions error"); } @@ -645,9 +645,10 @@ pub async fn remote_interact_post( let target = Blog::find_by_fqn(&rockets, &blog_name) .await .and_then(|blog| Post::find_by_slug(&rockets.conn, &slug, blog.id))?; - if let Some(uri) = User::fetch_remote_interact_uri(&remote.remote) + if let uri = User::fetch_remote_interact_uri(&remote.remote) .await - .map(|uri| uri.replace("{uri}", format!("{}", target.ap_url)).ok()) + .map(|uri| uri.replace("{uri}", &format!("{}", target.ap_url))) + .unwrap() { Ok(Redirect::to(uri).into()) } else { diff --git a/src/routes/reshares.rs b/src/routes/reshares.rs index 9fe63650..1a427f4e 100644 --- a/src/routes/reshares.rs +++ b/src/routes/reshares.rs @@ -10,14 +10,14 @@ use plume_models::{ }; #[post("/~///reshare")] -pub fn create( +pub async fn create( blog: String, slug: String, user: User, rockets: PlumeRocket, ) -> Result { let conn = &*rockets.conn; - let b = Blog::find_by_fqn(&rockets, &blog)?; + let b = Blog::find_by_fqn(&rockets, &blog).await?; let post = Post::find_by_slug(&*conn, &slug, b.id)?; if !user.has_reshared(&*conn, &post)? { diff --git a/src/routes/session.rs b/src/routes/session.rs index 4d79f6f4..5f65ddf8 100644 --- a/src/routes/session.rs +++ b/src/routes/session.rs @@ -42,14 +42,16 @@ pub struct LoginForm { } #[post("/login", data = "")] -pub fn create( +pub async fn create( form: LenientForm, mut cookies: Cookies<'_>, rockets: PlumeRocket, ) -> RespondOrRedirect { let conn = &*rockets.conn; - let user = User::find_by_email(&*conn, &form.email_or_name) - .or_else(|_| User::find_by_fqn(&rockets, &form.email_or_name)); + let user = match User::find_by_email(&*conn, &form.email_or_name) { + Ok(user) => Ok(user), + Err(_) => User::find_by_fqn(&rockets, &form.email_or_name).await, + }; let mut errors = match form.validate() { Ok(_) => ValidationErrors::new(), Err(e) => e, diff --git a/src/routes/user.rs b/src/routes/user.rs index 2a43289e..eca17a68 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -50,7 +50,7 @@ pub async fn details( update_conn: DbConn, ) -> Result { let conn = &*rockets.conn; - let user = User::find_by_fqn(&rockets, &name)?; + let user = User::find_by_fqn(&rockets, &name).await?; let recents = Post::get_recents_for_author(&*conn, &user, 6)?; let reshares = Reshare::get_recents_for_author(&*conn, &user, 6)?; let worker = &rockets.worker; @@ -149,7 +149,7 @@ pub fn dashboard_auth(i18n: I18n) -> Flash { } #[post("/@//follow")] -pub fn follow( +pub async fn follow( name: String, user: User, rockets: PlumeRocket, @@ -193,7 +193,7 @@ pub fn follow( } #[post("/@//follow", data = "", rank = 2)] -pub fn follow_not_connected( +pub async fn follow_not_connected( rockets: PlumeRocket, name: String, remote_form: Option>, @@ -205,14 +205,14 @@ pub fn follow_not_connected( .await .ok() .and_then(|uri| { - uri.replace( + Some(uri.replace( "{uri}", - format!( + &format!( "{}@{}", target.fqn, target.get_instance(&rockets.conn).ok()?.public_domain ), - ) + )) }) { Ok(Redirect::to(uri).into()) @@ -270,14 +270,14 @@ pub fn follow_auth(name: String, i18n: I18n) -> Flash { #[get("/@//followers?", rank = 2)] pub async fn followers( - String, + name: String, page: Option, rockets: PlumeRocket, ) -> Result { let conn = &*rockets.conn; let page = page.unwrap_or_default(); - let user = User::find_by_fqn(&rockets, &name).await?; - let followers_count = user.count_followers(&*; + let user: User = User::find_by_fqn(&rockets, &name).await?; + let followers_count = user.count_followers(&conn); Ok(render!(users::followers( &rockets.to_context(), @@ -296,7 +296,7 @@ pub async fn followers( } #[get("/@//followed?", rank = 2)] -pub fn followed( +pub async fn followed( name: String, page: Option, rockets: PlumeRocket, @@ -328,8 +328,8 @@ pub async fn activity_details( rockets: PlumeRocket, _ap: ApRequest, ) -> Option> { - let user = User::find_by_fqn(&rockets, &name).await?.ok()?; - Some(ActivityStream::new(user.to_activity(&*roonn).ok()?)) + let user: User = User::find_by_fqn(&rockets, &name).await?; + Some(ActivityStream::new(user.to_activity(&*rockets.conn).ok()?)) } #[get("/users/new")] @@ -595,7 +595,7 @@ pub async fn inbox( User::find_by_fqn(&rockets, &name) .await .map_err(|_| status::BadRequest(Some("User not found")))?; - inbox::handle_incoming(rockets, data, headers) + inbox::handle_incoming(rockets, data, headers).await } #[get("/@//followers", rank = 1)] @@ -604,7 +604,7 @@ pub async fn ap_followers( rockets: PlumeRocket, _ap: ApRequest, ) -> Option> { - let user = User::find_by_fqn(&rockets, &name).await?.ok()?; + let user = User::find_by_fqn(&rockets, &name).await?; let followers = user .get_followers(&*rockets.conn) .ok()? @@ -626,7 +626,7 @@ pub async fn ap_followers( #[get("/@//atom.xml")] pub async fn atom_feed(name: String, rockets: PlumeRocket) -> Option> { let conn = &*rockets.conn; - let author = User::find_by_fqn(&rockets, &name).await?.ok()?; + let author = User::find_by_fqn(&rockets, &name).await?; let entries = Post::get_recents_for_author(conn, &author, 15).ok()?; let uri = Instance::get_local() .ok()? diff --git a/src/routes/well_known.rs b/src/routes/well_known.rs index 80aa0916..fe1c7e19 100644 --- a/src/routes/well_known.rs +++ b/src/routes/well_known.rs @@ -1,3 +1,4 @@ +use async_trait; use rocket::http::ContentType; use rocket::response::Content; use serde_json; @@ -43,12 +44,14 @@ pub fn host_meta() -> String { struct WebfingerResolver; -impl Resolver for WebfingerResolver { - fn instance_domain<'a>(&self) -> &'a str { +#[async_trait::async_trait] +impl AsyncResolver for WebfingerResolver { + type Repo = PlumeRocket; + async fn instance_domain<'a>(&self) -> &'a str { CONFIG.base_url.as_str() } - fn find( + async fn find( &self, prefix: Prefix, acct: String, @@ -66,9 +69,9 @@ impl Resolver for WebfingerResolver { Prefix::Custom(_) => Err(ResolverError::NotFound), } } - fn endpoint( + async fn endpoint( &self, - resource: impl Into, + resource: impl Into + 'async_trait, resource_repo: PlumeRocket, ) -> Result { let resource = resource.into(); @@ -80,7 +83,9 @@ impl Resolver for WebfingerResolver { let user = parsed_res.next().ok_or(ResolverError::InvalidResource)?; let domain = parsed_res.next().ok_or(ResolverError::InvalidResource)?; if domain == webfinger.instance_domain() { - webfinger.find(res_prefix, user.to_string(), resource_repo) + webfinger + .find(res_prefix, user.to_string(), resource_repo) + .await } else { Err(ResolverError::WrongDomain) } @@ -88,8 +93,9 @@ impl Resolver for WebfingerResolver { } #[get("/.well-known/webfinger?")] -pub fn webfinger(resource: String, rockets: PlumeRocket) -> Content { +pub async fn webfinger(resource: String, rockets: PlumeRocket) -> Content { match WebfingerResolver::endpoint(resource, rockets) + .await .and_then(|wf| serde_json::to_string(&wf).map_err(|_| ResolverError::NotFound)) { Ok(wf) => Content(ContentType::new("application", "jrd+json"), wf),