From 1b0003ff1b851c2db9e00ad670b0aa213394e159 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Fri, 29 Jan 2021 22:35:07 +0000 Subject: [PATCH] Upgrade to Matrix SDK latest (Store Rewrite) and Tokio 1.0 This upgrade introduces a handful of breaking changes in the Rust Matrix SDK. - Some types have disappeared and changed name. - Some functions are no longer async. - Room display name now has a Result type instead of just returning the value. - Client state store has breaking changes (not really a big deal). This required introduction of a new type to store room information that we are interested in on the context struct. This new RoomContext is required mostly due to unit tests, because it is no longer possible to instantiate the Room type in the Matrix SDK. --- Cargo.lock | 1309 +++++++++++------------------------- Cargo.toml | 2 +- src/bin/dicebot-cmd.rs | 19 +- src/bot.rs | 18 +- src/bot/event_handlers.rs | 131 ++-- src/cofd/dice.rs | 21 +- src/commands.rs | 15 +- src/commands/management.rs | 10 +- src/commands/variables.rs | 8 +- src/context.rs | 20 +- src/cthulhu/dice.rs | 15 +- src/dice.rs | 2 +- src/error.rs | 3 + src/logic.rs | 11 +- src/matrix.rs | 20 +- 15 files changed, 551 insertions(+), 1053 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 58c5fdb..c197ca5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,18 +6,18 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] name = "aes" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd2bc6d3f370b5666245ff421e231cba4353df936e26986d2918e61a8fd6aef6" +checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" dependencies = [ - "aes-soft 0.5.0", - "aesni 0.8.0", - "block-cipher", + "aes-soft", + "aesni", + "cipher", ] [[package]] @@ -26,36 +26,26 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7729c3cde54d67063be556aeac75a81330d802f0259500ca40cb52967f975763" dependencies = [ - "aes-soft 0.6.4", - "aesni 0.10.0", + "aes-soft", + "aesni", "cipher", "ctr", ] [[package]] name = "aes-gcm" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0301c9e9c443494d970a07885e8cf3e587bae8356a1d5abd0999068413f7205f" +checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" dependencies = [ "aead", "aes", - "block-cipher", + "cipher", + "ctr", "ghash", "subtle", ] -[[package]] -name = "aes-soft" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63dd91889c49327ad7ef3b500fd1109dbd3c509a03db0d4a9ce413b79f575cb6" -dependencies = [ - "block-cipher", - "byteorder", - "opaque-debug 0.3.0", -] - [[package]] name = "aes-soft" version = "0.6.4" @@ -63,17 +53,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" dependencies = [ "cipher", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6fe808308bb07d393e2ea47780043ec47683fcf19cf5efc8ca51c50cc8c68a" -dependencies = [ - "block-cipher", - "opaque-debug 0.3.0", + "opaque-debug", ] [[package]] @@ -83,33 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" dependencies = [ "cipher", - "opaque-debug 0.3.0", -] - -[[package]] -name = "ahash" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" -dependencies = [ - "const-random", -] - -[[package]] -name = "ahash" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" - -[[package]] -name = "ahash" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75b7e6a93ecd6dbd2c225154d0fa7f86205574ecaa6c87429fb5f66ee677c44" -dependencies = [ - "getrandom 0.2.1", - "lazy_static", - "version_check", + "opaque-debug", ] [[package]] @@ -139,6 +93,27 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f093eed78becd229346bf859eec0aa4dd7ddde0757287b2b4107a1f09c80002" +[[package]] +name = "async-stream" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3670df70cbc01729f901f94c887814b3c68db038aad1329a418bae178bc5295c" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3548b8efc9f8e8a5a0a2808c5bd8451a9031b9e5b879a79590304ae928b0a70" +dependencies = [ + "proc-macro2 1.0.24", + "quote 1.0.8", + "syn 1.0.60", +] + [[package]] name = "async-trait" version = "0.1.42" @@ -147,16 +122,7 @@ checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", -] - -[[package]] -name = "atoi" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616896e05fc0e2649463a93a15183c6a16bf03413a7af88ef1285ddedfa9cda5" -dependencies = [ - "num-traits", + "syn 1.0.60", ] [[package]] @@ -176,7 +142,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -219,18 +185,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "bitvec" -version = "0.19.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ba35e9565969edb811639dbebfe34edc0368e472c5018474c8eb2543397f81" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "blake2b_simd" version = "0.5.11" @@ -242,86 +196,32 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.3", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "block-cipher" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f337a3e6da609650eb74e02bc9fac7b735049f7623ab12f2e4c719316fcc7e80" -dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", + "generic-array", ] [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +checksum = "f07aa6688c702439a1be0307b6a94dffe1168569e45b9500c1372bc580740d59" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "bytes" -version = "0.5.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" - -[[package]] -name = "bytes" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1f8e949d755f9d79112b5bb46938e0ef9d3804a0b16dfab13aafcaa5f0fa72" - -[[package]] -name = "cargo_metadata" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83f95cf4bf0dda0ac2e65371ae7215d0dce3c187613a9dbf23aaa9374186f97a" -dependencies = [ - "semver 0.11.0", - "semver-parser 0.10.0", - "serde", - "serde_json", -] +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" [[package]] name = "cc" @@ -341,6 +241,29 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chacha20" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed8738f14471a99f0e316c327e68fc82a3611cc2895fcb604b89eedaf8f39d95" +dependencies = [ + "cipher", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1fc18e6d90c40164bf6c317476f2a98f04661e310e79830366b7e914c58a8e" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + [[package]] name = "chronicle-dicebot" version = "0.7.0" @@ -357,7 +280,7 @@ dependencies = [ "log", "matrix-sdk", "memmem", - "nom 5.1.2", + "nom", "phf", "rand 0.7.3", "serde", @@ -375,7 +298,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -398,41 +321,19 @@ dependencies = [ [[package]] name = "combine" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01199925a18b00193570e3d70cfe57dcb647eb167c29851983e76fc39e2fee39" +checksum = "cc4369b5e4c0cddf64ad8981c0111e7df4f7078f4d6ba98fb31f2e17c4c57b7e" dependencies = [ - "bytes 1.0.0", + "bytes", "memchr", ] -[[package]] -name = "const-random" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f590d95d011aa80b063ffe3253422ed5aa462af4e9867d43ce8337562bac77c4" -dependencies = [ - "const-random-macro", - "proc-macro-hack", -] - -[[package]] -name = "const-random-macro" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "615f6e27d000a2bffbc7f2f6a8669179378fa27ee4d0a509e985dfc0a7defb40" -dependencies = [ - "getrandom 0.2.1", - "lazy_static", - "proc-macro-hack", - "tiny-keccak", -] - [[package]] name = "const_fn" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" [[package]] name = "constant_time_eq" @@ -477,16 +378,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - [[package]] name = "crossbeam-epoch" version = "0.9.1" @@ -501,16 +392,6 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "crossbeam-queue" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6cb3c7f5b8e51bc3ebb73a2327ad4abdbd119dc13223f14f961d2f38486756" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.8.1" @@ -522,19 +403,13 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - [[package]] name = "crypto-mac" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" dependencies = [ - "generic-array 0.14.4", + "generic-array", "subtle", ] @@ -549,31 +424,21 @@ dependencies = [ [[package]] name = "dashmap" -version = "3.11.10" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f260e2fc850179ef410018660006951c1b55b79e8087e87111a2c388994b9b5" +checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" dependencies = [ - "ahash 0.3.8", - "cfg-if 0.1.10", + "cfg-if 1.0.0", "num_cpus", ] -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.3", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -593,7 +458,7 @@ checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" dependencies = [ "libc", "redox_users", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -602,12 +467,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" -[[package]] -name = "dotenv" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" - [[package]] name = "either" version = "1.6.1" @@ -636,12 +495,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "fnv" version = "1.0.7" @@ -680,7 +533,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" dependencies = [ "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -689,33 +542,11 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "funty" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" - [[package]] name = "futures" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0" +checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" dependencies = [ "futures-channel", "futures-core", @@ -728,9 +559,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" +checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" dependencies = [ "futures-core", "futures-sink", @@ -738,15 +569,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" +checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" [[package]] name = "futures-executor" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65" +checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" dependencies = [ "futures-core", "futures-task", @@ -755,9 +586,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb" +checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" [[package]] name = "futures-locks" @@ -770,27 +601,27 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" +checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" dependencies = [ "proc-macro-hack", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] name = "futures-sink" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" +checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" [[package]] name = "futures-task" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" +checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" dependencies = [ "once_cell", ] @@ -807,9 +638,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" +checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" dependencies = [ "futures-channel", "futures-core", @@ -818,7 +649,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project 1.0.2", + "pin-project-lite", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -834,15 +665,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.4" @@ -860,21 +682,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] name = "getrandom" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if 1.0.0", + "js-sys", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi 0.10.2+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -883,7 +705,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" dependencies = [ - "opaque-debug 0.3.0", + "opaque-debug", "polyval", ] @@ -902,11 +724,11 @@ dependencies = [ [[package]] name = "h2" -version = "0.2.7" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" +checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" dependencies = [ - "bytes 0.5.6", + "bytes", "fnv", "futures-core", "futures-sink", @@ -925,43 +747,16 @@ name = "hashbrown" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" -dependencies = [ - "ahash 0.4.7", -] - -[[package]] -name = "hashlink" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d99cf782f0dc4372d26846bec3de7804ceb5df083c2d4462c0b8d2330e894fa8" -dependencies = [ - "hashbrown", -] - -[[package]] -name = "heck" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" -dependencies = [ - "unicode-segmentation", -] [[package]] name = "hermit-abi" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] -[[package]] -name = "hex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" - [[package]] name = "hmac" version = "0.10.1" @@ -969,27 +764,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", - "digest 0.9.0", + "digest", ] [[package]] name = "http" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84129d298a6d57d246960ff8eb831ca4af3f96d29e2e28848dae275408658e26" +checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" dependencies = [ - "bytes 0.5.6", + "bytes", "fnv", "itoa", ] [[package]] name = "http-body" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" dependencies = [ - "bytes 0.5.6", + "bytes", "http", ] @@ -1016,11 +811,11 @@ dependencies = [ [[package]] name = "hyper" -version = "0.13.9" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ad767baac13b44d4529fcf58ba2cd0995e36e7b435bc5b039de6f47e880dbf" +checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe" dependencies = [ - "bytes 0.5.6", + "bytes", "futures-channel", "futures-core", "futures-util", @@ -1030,7 +825,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project 1.0.2", + "pin-project 1.0.4", "socket2", "tokio", "tower-service", @@ -1040,15 +835,15 @@ dependencies = [ [[package]] name = "hyper-tls" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes 0.5.6", + "bytes", "hyper", "native-tls", "tokio", - "tokio-tls", + "tokio-native-tls", ] [[package]] @@ -1094,15 +889,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - [[package]] name = "ipnet" version = "2.3.0" @@ -1126,32 +912,22 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "js-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" dependencies = [ "wasm-bindgen", ] [[package]] name = "js_int" -version = "0.1.9" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96797f53235a1d6dc985f244a69de54b04c45b7e0e357a35c85a45a847d92f2" +checksum = "fcae89e078a96b781b38f36225bb3a174b8f6e905dfec550dd16a13539c82acc" dependencies = [ "serde", ] -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -1173,20 +949,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.81" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" - -[[package]] -name = "libsqlite3-sys" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d31059f22935e6c31830db5249ba2b7ecd54fd73a9909286f0a67aa55c2fbd" -dependencies = [ - "cc", - "pkg-config", - "vcpkg", -] +checksum = "1cca32fa0182e8c0989459524dc356b8f2b5c10f1b9eb521b7d182c03cf8c5ff" [[package]] name = "lock_api" @@ -1199,11 +964,11 @@ dependencies = [ [[package]] name = "log" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", ] [[package]] @@ -1220,16 +985,15 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] name = "matrix-sdk" -version = "0.1.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#9245b2a89a9cd61038379a51423abe8f7fc71a82" +version = "0.2.0" +source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#b66c666997cbcf32071d24ffe2484a215de8d0e4" dependencies = [ - "async-trait", "dashmap", + "futures", "futures-timer", "http", "matrix-sdk-base", "matrix-sdk-common", - "matrix-sdk-common-macros", "mime", "reqwest", "serde_json", @@ -1243,15 +1007,21 @@ dependencies = [ [[package]] name = "matrix-sdk-base" -version = "0.1.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#9245b2a89a9cd61038379a51423abe8f7fc71a82" +version = "0.2.0" +source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#b66c666997cbcf32071d24ffe2484a215de8d0e4" dependencies = [ - "async-trait", + "chacha20poly1305", + "dashmap", + "futures", + "hmac", "matrix-sdk-common", - "matrix-sdk-common-macros", "matrix-sdk-crypto", + "pbkdf2", + "rand 0.8.3", "serde", "serde_json", + "sha2", + "sled", "thiserror", "tokio", "tracing", @@ -1260,52 +1030,40 @@ dependencies = [ [[package]] name = "matrix-sdk-common" -version = "0.1.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#9245b2a89a9cd61038379a51423abe8f7fc71a82" +version = "0.2.0" +source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#b66c666997cbcf32071d24ffe2484a215de8d0e4" dependencies = [ - "assign", + "async-trait", "futures-locks", "instant", - "js_int", "ruma", + "serde", "tokio", "uuid", ] -[[package]] -name = "matrix-sdk-common-macros" -version = "0.1.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#9245b2a89a9cd61038379a51423abe8f7fc71a82" -dependencies = [ - "quote 1.0.8", - "syn 1.0.57", -] - [[package]] name = "matrix-sdk-crypto" -version = "0.1.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#9245b2a89a9cd61038379a51423abe8f7fc71a82" +version = "0.2.0" +source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#b66c666997cbcf32071d24ffe2484a215de8d0e4" dependencies = [ "aes-ctr", "aes-gcm", - "async-trait", "atomic", "base64", "byteorder", "dashmap", - "getrandom 0.2.1", + "getrandom 0.2.2", "hmac", "matrix-sdk-common", - "matrix-sdk-common-macros", "olm-rs", "pbkdf2", "serde", "serde_json", "sha2", - "sqlx", + "sled", "thiserror", "tracing", - "url", "zeroize", ] @@ -1336,68 +1094,17 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "mime_guess" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "mio" -version = "0.6.23" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7" dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", "libc", "log", - "miow 0.2.2", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-named-pipes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" -dependencies = [ - "log", - "mio", - "miow 0.3.6", - "winapi 0.3.9", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", + "miow", + "ntapi", + "winapi", ] [[package]] @@ -1407,7 +1114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ "socket2", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1428,17 +1135,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "net2" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - [[package]] name = "nom" version = "5.1.2" @@ -1451,24 +1147,12 @@ dependencies = [ ] [[package]] -name = "nom" -version = "6.0.1" +name = "ntapi" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88034cfd6b4a0d54dd14f4a507eceee36c0b70e5a02236c4e4df571102be17f0" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" dependencies = [ - "bitvec", - "lexical-core", - "memchr", - "version_check", -] - -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg 1.0.1", + "winapi", ] [[package]] @@ -1487,7 +1171,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daab4abdd728e5e77ec15888fc12688c0b821c81fca621f1bb28dbe489cbc404" dependencies = [ - "getrandom 0.2.1", + "getrandom 0.2.2", "olm-sys", "serde", "serde_json", @@ -1509,12 +1193,6 @@ version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -1574,9 +1252,9 @@ dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall", + "redox_syscall 0.1.57", "smallvec", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1600,49 +1278,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.57", -] - -[[package]] -name = "pest_meta" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" -dependencies = [ - "maplit", - "pest", - "sha-1", -] - [[package]] name = "phf" version = "0.7.24" @@ -1696,11 +1331,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" +checksum = "95b70b68509f17aa2857863b6fa00bf21fc93674c7a8893de2f469f6aa7ca2f2" dependencies = [ - "pin-project-internal 1.0.2", + "pin-project-internal 1.0.4", ] [[package]] @@ -1711,31 +1346,25 @@ checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] name = "pin-project-internal" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" +checksum = "caa25a6393f22ce819b0f50e0be89287292fda8d425be38ee0ca14c4931d9e71" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] name = "pin-project-lite" -version = "0.1.11" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" - -[[package]] -name = "pin-project-lite" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" [[package]] name = "pin-utils" @@ -1749,6 +1378,16 @@ version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +[[package]] +name = "poly1305" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b7456bc1ad2d4cf82b3a016be4c2ac48daf11bf990c1603ebd447fe6f30fca8" +dependencies = [ + "cpuid-bool 0.2.0", + "universal-hash", +] + [[package]] name = "polyval" version = "0.4.5" @@ -1756,7 +1395,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" dependencies = [ "cpuid-bool 0.2.0", - "opaque-debug 0.3.0", + "opaque-debug", "universal-hash", ] @@ -1783,9 +1422,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" @@ -1829,12 +1468,6 @@ dependencies = [ "proc-macro2 1.0.24", ] -[[package]] -name = "radium" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" - [[package]] name = "rand" version = "0.6.5" @@ -1851,7 +1484,7 @@ dependencies = [ "rand_os", "rand_pcg", "rand_xorshift", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1867,6 +1500,18 @@ dependencies = [ "rand_hc 0.2.0", ] +[[package]] +name = "rand" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.1", + "rand_hc 0.3.0", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -1887,6 +1532,16 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.1", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1911,6 +1566,15 @@ dependencies = [ "getrandom 0.1.16", ] +[[package]] +name = "rand_core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" +dependencies = [ + "getrandom 0.2.2", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -1929,6 +1593,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.1", +] + [[package]] name = "rand_isaac" version = "0.1.1" @@ -1946,7 +1619,7 @@ checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" dependencies = [ "libc", "rand_core 0.4.2", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1960,7 +1633,7 @@ dependencies = [ "libc", "rand_core 0.4.2", "rdrand", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1997,6 +1670,15 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_syscall" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.3.5" @@ -2004,15 +1686,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ "getrandom 0.1.16", - "redox_syscall", + "redox_syscall 0.1.57", "rust-argon2", ] [[package]] name = "regex" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", @@ -2022,9 +1704,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "remove_dir_all" @@ -2032,17 +1714,17 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] name = "reqwest" -version = "0.10.10" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c" +checksum = "fd281b1030aa675fb90aa994d07187645bb3c8fc756ca766e7c3070b439de9de" dependencies = [ "base64", - "bytes 0.5.6", + "bytes", "encoding_rs", "futures-core", "futures-util", @@ -2055,14 +1737,13 @@ dependencies = [ "lazy_static", "log", "mime", - "mime_guess", "native-tls", "percent-encoding", - "pin-project-lite 0.2.0", + "pin-project-lite", "serde", "serde_urlencoded", "tokio", - "tokio-tls", + "tokio-native-tls", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -2072,8 +1753,8 @@ dependencies = [ [[package]] name = "ruma" -version = "0.0.1" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.0.2" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "assign", "js_int", @@ -2088,8 +1769,8 @@ dependencies = [ [[package]] name = "ruma-api" -version = "0.17.0-alpha.1" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.17.0-alpha.2" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "http", "percent-encoding", @@ -2103,19 +1784,19 @@ dependencies = [ [[package]] name = "ruma-api-macros" -version = "0.17.0-alpha.1" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.17.0-alpha.2" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] name = "ruma-client-api" -version = "0.10.0-alpha.1" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.10.0-alpha.2" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "assign", "http", @@ -2133,8 +1814,8 @@ dependencies = [ [[package]] name = "ruma-common" -version = "0.2.0" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.3.0-alpha.1" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "js_int", "maplit", @@ -2146,8 +1827,8 @@ dependencies = [ [[package]] name = "ruma-events" -version = "0.22.0-alpha.1" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.22.0-alpha.2" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "js_int", "ruma-common", @@ -2160,19 +1841,19 @@ dependencies = [ [[package]] name = "ruma-events-macros" -version = "0.22.0-alpha.1" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.22.0-alpha.2" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] name = "ruma-federation-api" -version = "0.0.3" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.1.0-alpha.1" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "js_int", "ruma-api", @@ -2186,40 +1867,37 @@ dependencies = [ [[package]] name = "ruma-identifiers" -version = "0.17.4" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.18.0-alpha.1" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "paste", "ruma-identifiers-macros", "ruma-identifiers-validation", "ruma-serde", + "ruma-serde-macros", "serde", - "strum", ] [[package]] name = "ruma-identifiers-macros" -version = "0.17.4" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.18.0-alpha.1" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", "ruma-identifiers-validation", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] name = "ruma-identifiers-validation" -version = "0.1.1" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" -dependencies = [ - "serde", -] +version = "0.2.0" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" [[package]] name = "ruma-serde" -version = "0.2.3" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.3.0" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "form_urlencoded", "itoa", @@ -2231,13 +1909,13 @@ dependencies = [ [[package]] name = "ruma-serde-macros" -version = "0.2.0" -source = "git+https://github.com/ruma/ruma?rev=e8882fe8142d7b55ed4c8ccc6150946945f9e237#e8882fe8142d7b55ed4c8ccc6150946945f9e237" +version = "0.3.0" +source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -2258,7 +1936,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver 0.9.0", + "semver", ] [[package]] @@ -2274,7 +1952,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ "lazy_static", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2312,17 +1990,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0", -] - -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser 0.10.0", - "serde", + "semver-parser", ] [[package]] @@ -2331,16 +1999,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "semver-parser" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e012c6c5380fb91897ba7b9261a0f565e624e869d42fe1a1d03fa0d68a083d5" -dependencies = [ - "pest", - "pest_derive", -] - [[package]] name = "send_wrapper" version = "0.4.0" @@ -2349,22 +2007,22 @@ checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" [[package]] name = "serde" -version = "1.0.118" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.118" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -2390,18 +2048,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha-1" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - [[package]] name = "sha1" version = "0.6.0" @@ -2414,11 +2060,11 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if 1.0.0", "cpuid-bool 0.1.2", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", + "opaque-debug", ] [[package]] @@ -2460,9 +2106,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a55ca5f3b68e41c979bf8c46a6f1da892ca4db8f94023ce0bd32407573b1ac0" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" @@ -2472,99 +2118,7 @@ checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ "cfg-if 1.0.0", "libc", - "winapi 0.3.9", -] - -[[package]] -name = "sqlformat" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74c70f0235b9925cbb106c52af1a28b5ea4885a8b851e328b8562e257a389c2d" -dependencies = [ - "lazy_static", - "maplit", - "nom 6.0.1", - "regex", - "unicode_categories", -] - -[[package]] -name = "sqlx" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1a98f9bf17b690f026b6fec565293a995b46dfbd6293debcb654dcffd2d1b34" -dependencies = [ - "sqlx-core", - "sqlx-macros", -] - -[[package]] -name = "sqlx-core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36bb6a2ca3345a86493bc3b71eabc2c6c16a8bb1aa476cf5303bee27f67627d7" -dependencies = [ - "ahash 0.6.2", - "atoi", - "bitflags", - "byteorder", - "bytes 0.5.6", - "crossbeam-channel", - "crossbeam-queue", - "crossbeam-utils", - "either", - "futures-channel", - "futures-core", - "futures-util", - "hashlink", - "hex", - "itoa", - "libc", - "libsqlite3-sys", - "log", - "memchr", - "once_cell", - "parking_lot", - "percent-encoding", - "smallvec", - "sqlformat", - "sqlx-rt", - "stringprep", - "thiserror", - "url", - "whoami", -] - -[[package]] -name = "sqlx-macros" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5ada8b3b565331275ce913368565a273a74faf2a34da58c4dc010ce3286844" -dependencies = [ - "cargo_metadata", - "dotenv", - "either", - "futures", - "heck", - "lazy_static", - "proc-macro2 1.0.24", - "quote 1.0.8", - "sqlx-core", - "sqlx-rt", - "syn 1.0.57", - "url", -] - -[[package]] -name = "sqlx-rt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63fc5454c9dd7aaea3a0eeeb65ca40d06d0d8e7413a8184f7c3a3ffa5056190b" -dependencies = [ - "native-tls", - "once_cell", - "tokio", - "tokio-native-tls", + "winapi", ] [[package]] @@ -2606,7 +2160,7 @@ dependencies = [ "quote 1.0.8", "serde", "serde_derive", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -2622,7 +2176,7 @@ dependencies = [ "serde_derive", "serde_json", "sha1", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -2631,37 +2185,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" -[[package]] -name = "stringprep" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "strum" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89a286a7e3b5720b9a477b23253bc50debac207c8d21505f8e70b36792f11b5" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.19.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e61bb0be289045cb80bfce000512e32d09f8337e54c186725da381377ad1f8d5" -dependencies = [ - "heck", - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.57", -] - [[package]] name = "subtle" version = "2.4.0" @@ -2681,9 +2204,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.57" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4211ce9909eb971f111059df92c45640aad50a619cf55cd76476be803c4c68e6" +checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", @@ -2698,28 +2221,22 @@ checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", "unicode-xid 0.2.1", ] -[[package]] -name = "tap" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e" - [[package]] name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "rand 0.7.3", - "redox_syscall", + "rand 0.8.3", + "redox_syscall 0.2.4", "remove_dir_all", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2748,23 +2265,23 @@ checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "d8208a331e1cb318dd5bd76951d2b8fc48ca38a69f5f4e4af1b6a9f8c6236915" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] name = "time" -version = "0.2.23" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcdaeea317915d59b2b4cd3b5efcd156c309108664277793f5351700c02ce98b" +checksum = "1195b046942c221454c2539395f85413b33383a067449d78aab2b7b052a142f7" dependencies = [ "const_fn", "libc", @@ -2772,7 +2289,7 @@ dependencies = [ "stdweb", "time-macros", "version_check", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2795,23 +2312,14 @@ dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", "standback", - "syn 1.0.57", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", + "syn 1.0.60", ] [[package]] name = "tinyvec" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" dependencies = [ "tinyvec_macros", ] @@ -2824,71 +2332,70 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "0.2.24" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48" +checksum = "8efab2086f17abcddb8f756117665c958feee6b2e39974c2f1600592ab3a4195" dependencies = [ - "bytes 0.5.6", - "fnv", - "futures-core", - "iovec", - "lazy_static", + "autocfg 1.0.1", + "bytes", "libc", "memchr", "mio", - "mio-named-pipes", - "mio-uds", "num_cpus", - "pin-project-lite 0.1.11", + "once_cell", + "parking_lot", + "pin-project-lite", "signal-hook-registry", - "slab", "tokio-macros", - "winapi 0.3.9", + "winapi", ] [[package]] name = "tokio-macros" -version = "0.2.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" +checksum = "42517d2975ca3114b22a16192634e8241dc5cc1f130be194645970cc1c371494" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] name = "tokio-native-tls" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd608593a919a8e05a7d1fc6df885e40f6a88d3a70a3a7eff23ff27964eda069" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" dependencies = [ "native-tls", "tokio", ] [[package]] -name = "tokio-tls" -version = "0.3.1" +name = "tokio-stream" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" +checksum = "76066865172052eb8796c686f0b441a93df8b08d40a950b062ffb9a426f00edd" dependencies = [ - "native-tls", + "futures-core", + "pin-project-lite", "tokio", ] [[package]] name = "tokio-util" -version = "0.3.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +checksum = "feb971a26599ffd28066d387f109746df178eff14d5ea1e235015c5601967a4b" dependencies = [ - "bytes 0.5.6", + "async-stream", + "bytes", "futures-core", "futures-sink", "log", - "pin-project-lite 0.1.11", + "pin-project-lite", "tokio", + "tokio-stream", ] [[package]] @@ -2902,9 +2409,9 @@ dependencies = [ [[package]] name = "tower-service" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" @@ -2913,8 +2420,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" dependencies = [ "cfg-if 1.0.0", - "log", - "pin-project-lite 0.2.0", + "pin-project-lite", "tracing-attributes", "tracing-core", ] @@ -2927,7 +2433,7 @@ checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -2961,21 +2467,6 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" -[[package]] -name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - [[package]] name = "unicode-bidi" version = "0.3.4" @@ -2994,12 +2485,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" - [[package]] name = "unicode-xid" version = "0.1.0" @@ -3012,12 +2497,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" -[[package]] -name = "unicode_categories" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" - [[package]] name = "unindent" version = "0.1.7" @@ -3030,7 +2509,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ - "generic-array 0.14.4", + "generic-array", "subtle", ] @@ -3048,11 +2527,11 @@ dependencies = [ [[package]] name = "uuid" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "rand 0.7.3", + "getrandom 0.2.2", "serde", ] @@ -3086,15 +2565,15 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" dependencies = [ "cfg-if 1.0.0", "serde", @@ -3104,24 +2583,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" dependencies = [ "bumpalo", "lazy_static", "log", "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe9756085a84584ee9457a002b7cdfe0bfff169f45d2591d8be1345a6780e35" +checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3131,9 +2610,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" dependencies = [ "quote 1.0.8", "wasm-bindgen-macro-support", @@ -3141,49 +2620,33 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" +checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" [[package]] name = "web-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" dependencies = [ "js-sys", "wasm-bindgen", ] -[[package]] -name = "whoami" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d595b2e146f36183d6a590b8d41568e2bc84c922267f43baf61c956330eeb436" -dependencies = [ - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.9" @@ -3194,12 +2657,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -3212,7 +2669,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -3227,25 +2684,9 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ - "winapi 0.3.9", + "winapi", ] -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "wyz" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" - [[package]] name = "zerocopy" version = "0.3.0" @@ -3263,7 +2704,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d498dbd1fd7beb83c86709ae1c33ca50942889473473d287d56ce4770a18edfb" dependencies = [ "proc-macro2 1.0.24", - "syn 1.0.57", + "syn 1.0.60", "synstructure", ] @@ -3284,6 +2725,6 @@ checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.8", - "syn 1.0.57", + "syn 1.0.60", "synstructure", ] diff --git a/Cargo.toml b/Cargo.toml index 5a99468..7c28ab4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,5 +37,5 @@ version = "1" features = ['derive'] [dependencies.tokio] -version = "0.2" +version = "1.0" features = [ "full" ] \ No newline at end of file diff --git a/src/bin/dicebot-cmd.rs b/src/bin/dicebot-cmd.rs index c9b93da..dbb5954 100644 --- a/src/bin/dicebot-cmd.rs +++ b/src/bin/dicebot-cmd.rs @@ -1,18 +1,8 @@ use chronicle_dicebot::commands; -use chronicle_dicebot::context::Context; +use chronicle_dicebot::context::{Context, RoomContext}; use chronicle_dicebot::db::Database; use chronicle_dicebot::error::BotError; -use matrix_sdk::{ - identifiers::{room_id, user_id}, - Room, -}; - -fn dummy_room() -> Room { - Room::new( - &room_id!("!fakeroomid:example.com"), - &user_id!("@fakeuserid:example.com"), - ) -} +use matrix_sdk::identifiers::room_id; #[tokio::main] async fn main() -> Result<(), BotError> { @@ -26,7 +16,10 @@ async fn main() -> Result<(), BotError> { db: Database::new_temp()?, matrix_client: &matrix_sdk::Client::new("http://example.com") .expect("Could not create matrix client"), - room: &dummy_room(), + room: RoomContext { + id: &room_id!("!fakeroomid:example.com"), + display_name: "fake room", + }, username: "@localuser:example.com", message_body: &input, }; diff --git a/src/bot.rs b/src/bot.rs index 9d2d5c7..516be13 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -1,6 +1,6 @@ use crate::commands::execute_command; use crate::config::*; -use crate::context::Context; +use crate::context::{Context, RoomContext}; use crate::db::Database; use crate::error::BotError; use crate::state::DiceBotState; @@ -13,7 +13,7 @@ use matrix_sdk::{ room::message::{MessageEventContent, NoticeMessageEventContent}, AnyMessageEventContent, }, - Client, ClientConfig, JsonStore, Room, SyncSettings, + Client, ClientConfig, JoinedRoom, SyncSettings, }; //use matrix_sdk_common_macros::async_trait; use std::clone::Clone; @@ -48,8 +48,8 @@ fn cache_dir() -> Result { /// Creates the matrix client. fn create_client(config: &Config) -> Result { let cache_dir = cache_dir()?; - let store = JsonStore::open(&cache_dir)?; - let client_config = ClientConfig::new().state_store(Box::new(store)); + //let store = JsonStore::open(&cache_dir)?; + let client_config = ClientConfig::new().store_path(cache_dir); let homeserver_url = Url::parse(&config.matrix_homeserver())?; Ok(Client::new_with_config(homeserver_url, client_config)?) @@ -90,7 +90,7 @@ impl DiceBot { let password = &self.config.matrix_password(); //TODO provide a device id from config. - let mut client = self.client.clone(); + let client = self.client.clone(); client .login(username, password, None, Some("matrix dice bot")) .await?; @@ -118,9 +118,9 @@ impl DiceBot { Ok(()) } - async fn execute_commands(&self, room: &Room, sender_username: &str, msg_body: &str) { - let room_name = room.display_name().clone(); - let room_id = room.room_id.clone(); + async fn execute_commands(&self, room: &JoinedRoom, sender_username: &str, msg_body: &str) { + let room_name = room.display_name().await.ok().unwrap_or_default(); + let room_id = room.room_id().clone(); let mut results = Vec::with_capacity(msg_body.lines().count()); @@ -130,7 +130,7 @@ impl DiceBot { let ctx = Context { db: self.db.clone(), matrix_client: &self.client, - room: room, + room: RoomContext::new_with_name(&room, &room_name), username: &sender_username, message_body: &command, }; diff --git a/src/bot/event_handlers.rs b/src/bot/event_handlers.rs index afb725f..f6f323a 100644 --- a/src/bot/event_handlers.rs +++ b/src/bot/event_handlers.rs @@ -11,7 +11,8 @@ use matrix_sdk::{ room::message::{MessageEventContent, TextMessageEventContent}, StrippedStateEvent, SyncMessageEvent, SyncStateEvent, }, - EventEmitter, SyncRoom, + identifiers::RoomId, + EventEmitter, RoomState, }; use std::clone::Clone; use std::ops::Sub; @@ -92,86 +93,112 @@ fn should_process_event(db: &Database, room_id: &str, event_id: &str) -> bool { }) } +/// Convert room state object to the room ID and display name, if +/// possible. We only care about the room if it is a joined or left +/// room. +async fn convert_room_state(state: &RoomState) -> Option<(&RoomId, String)> { + match state { + RoomState::Joined(room) => Some(( + room.room_id(), + room.display_name().await.ok().unwrap_or_default(), + )), + RoomState::Left(room) => Some(( + room.room_id(), + room.display_name().await.ok().unwrap_or_default(), + )), + _ => None, + } +} + /// This event emitter listens for messages with dice rolling commands. /// Originally adapted from the matrix-rust-sdk examples. #[async_trait] impl EventEmitter for DiceBot { - async fn on_room_member(&self, room: SyncRoom, event: &SyncStateEvent) { - if let SyncRoom::Joined(room) | SyncRoom::Left(room) = room { - //Clone to avoid holding lock. - let room = room.read().await.clone(); - let (room_id, username) = (room.room_id.as_str(), &event.state_key); + async fn on_room_member(&self, state: RoomState, event: &SyncStateEvent) { + let (room_id, room_display_name) = match convert_room_state(&state).await { + Some((room_id, room_display_name)) => (room_id, room_display_name), + _ => return, + }; - if !should_process_event(&self.db, room_id, event.event_id.as_str()) { - return; - } + let room_id_str = room_id.as_str(); + let username = &event.state_key; - let event_affects_us = if let Some(our_user_id) = self.client.user_id().await { - event.state_key == our_user_id - } else { - false - }; + if !should_process_event(&self.db, room_id_str, event.event_id.as_str()) { + return; + } - use MembershipChange::*; - let adding_user = match event.membership_change() { - Joined => true, - Banned | Left | Kicked | KickedAndBanned => false, - _ => return, - }; + let event_affects_us = if let Some(our_user_id) = self.client.user_id().await { + event.state_key == our_user_id + } else { + false + }; - let result = if event_affects_us && !adding_user { - info!("Clearing all information for room ID {}", room_id); - self.db.rooms.clear_info(room_id) - } else if event_affects_us && adding_user { - info!("Joined room {}; recording room information", room_id); - record_room_information(&self.client, &self.db, &room, &event.state_key).await - } else if !event_affects_us && adding_user { - info!("Adding user {} to room ID {}", username, room_id); - self.db.rooms.add_user_to_room(username, room_id) - } else if !event_affects_us && !adding_user { - info!("Removing user {} from room ID {}", username, room_id); - self.db.rooms.remove_user_from_room(username, room_id) - } else { - debug!("Ignoring a room member event: {:#?}", event); - Ok(()) - }; + use MembershipChange::*; + let adding_user = match event.membership_change() { + Joined => true, + Banned | Left | Kicked | KickedAndBanned => false, + _ => return, + }; - if let Err(e) = result { - error!("Could not update room information: {}", e.to_string()); - } else { - debug!("Successfully processed room member update."); - } + let result = if event_affects_us && !adding_user { + info!("Clearing all information for room ID {}", room_id); + self.db.rooms.clear_info(room_id_str) + } else if event_affects_us && adding_user { + info!("Joined room {}; recording room information", room_id); + record_room_information( + &self.client, + &self.db, + &room_id, + &room_display_name, + &event.state_key, + ) + .await + } else if !event_affects_us && adding_user { + info!("Adding user {} to room ID {}", username, room_id); + self.db.rooms.add_user_to_room(username, room_id_str) + } else if !event_affects_us && !adding_user { + info!("Removing user {} from room ID {}", username, room_id); + self.db.rooms.remove_user_from_room(username, room_id_str) + } else { + debug!("Ignoring a room member event: {:#?}", event); + Ok(()) + }; + + if let Err(e) = result { + error!("Could not update room information: {}", e.to_string()); + } else { + debug!("Successfully processed room member update."); } } async fn on_stripped_state_member( &self, - room: SyncRoom, + state: RoomState, event: &StrippedStateEvent, _: Option, ) { - if let SyncRoom::Invited(room) = room { + if let RoomState::Invited(room) = state { if let Some(user_id) = self.client.user_id().await { if event.state_key != user_id { return; } } - //Clone to avoid holding lock. - let room = room.read().await.clone(); - info!("Autojoining room {}", room.display_name()); + info!("Autojoining room {}", room.display_name().await); - if let Err(e) = self.client.join_room_by_id(&room.room_id).await { + if let Err(e) = self.client.join_room_by_id(&room.room_id()).await { warn!("Could not join room: {}", e.to_string()) } } } - async fn on_room_message(&self, room: SyncRoom, event: &SyncMessageEvent) { - if let SyncRoom::Joined(room) = room { - //Clone to avoid holding lock. - let room = room.read().await.clone(); - let room_id = room.room_id.as_str(); + async fn on_room_message( + &self, + state: RoomState, + event: &SyncMessageEvent, + ) { + if let RoomState::Joined(room) = state { + let room_id = room.room_id().as_str(); if !should_process_event(&self.db, room_id, event.event_id.as_str()) { return; } diff --git a/src/cofd/dice.rs b/src/cofd/dice.rs index 98143db..6a2a3e5 100644 --- a/src/cofd/dice.rs +++ b/src/cofd/dice.rs @@ -326,12 +326,13 @@ mod tests { use super::*; use crate::db::Database; - /// Create dummy room instance. - fn dummy_room() -> matrix_sdk::Room { - matrix_sdk::Room::new( - &matrix_sdk::identifiers::room_id!("!fakeroomid:example.com"), - &matrix_sdk::identifiers::user_id!("@fakeuserid:example.com"), - ) + macro_rules! dummy_room { + () => { + crate::context::RoomContext { + id: &matrix_sdk::identifiers::room_id!("!fakeroomid:example.com"), + display_name: "displayname", + } + }; } ///Instead of being random, generate a series of numbers we have complete @@ -475,7 +476,7 @@ mod tests { let ctx = Context { db: db, matrix_client: &matrix_sdk::Client::new("http://example.com").unwrap(), - room: &dummy_room(), + room: dummy_room!(), username: "username", message_body: "message", }; @@ -506,7 +507,7 @@ mod tests { let ctx = Context { db: db, matrix_client: &matrix_sdk::Client::new("http://example.com").unwrap(), - room: &dummy_room(), + room: dummy_room!(), username: "username", message_body: "message", }; @@ -536,12 +537,12 @@ mod tests { let ctx = Context { db: db.clone(), matrix_client: &matrix_sdk::Client::new("http://example.com").unwrap(), - room: &dummy_room(), + room: dummy_room!(), username: "username", message_body: "message", }; - let user_and_room = UserAndRoom(&ctx.username, &ctx.room.room_id.as_str()); + let user_and_room = UserAndRoom(&ctx.username, &ctx.room.id.as_str()); db.variables .set_user_variable(&user_and_room, "myvariable", 10) diff --git a/src/commands.rs b/src/commands.rs index 8bb950a..7a45f71 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -78,12 +78,13 @@ pub async fn execute_command(ctx: &Context<'_>) -> CommandResult { mod tests { use super::*; - /// Create a dummy room instance. - fn dummy_room() -> matrix_sdk::Room { - matrix_sdk::Room::new( - &matrix_sdk::identifiers::room_id!("!fakeroomid:example.com"), - &matrix_sdk::identifiers::user_id!("@fakeuserid:example.com"), - ) + macro_rules! dummy_room { + () => { + crate::context::RoomContext { + id: &matrix_sdk::identifiers::room_id!("!fakeroomid:example.com"), + display_name: "displayname", + } + }; } #[tokio::test] @@ -92,7 +93,7 @@ mod tests { let ctx = Context { db: db, matrix_client: &matrix_sdk::Client::new("http://example.com").unwrap(), - room: &dummy_room(), + room: dummy_room!(), username: "myusername", message_body: "!notacommand", }; diff --git a/src/commands/management.rs b/src/commands/management.rs index e71630b..c25ce1e 100644 --- a/src/commands/management.rs +++ b/src/commands/management.rs @@ -19,8 +19,14 @@ impl Command for ResyncCommand { let our_username: Option = ctx.matrix_client.user_id().await; let our_username: &str = our_username.as_ref().map_or("", UserId::as_str); - let result: ResyncResult = - record_room_information(ctx.matrix_client, &ctx.db, &ctx.room, our_username).await; + let result: ResyncResult = record_room_information( + ctx.matrix_client, + &ctx.db, + ctx.room.id, + &ctx.room.display_name, + our_username, + ) + .await; let (plain, html) = match result { Ok(()) => { diff --git a/src/commands/variables.rs b/src/commands/variables.rs index 8e47dbd..7025b2f 100644 --- a/src/commands/variables.rs +++ b/src/commands/variables.rs @@ -13,7 +13,7 @@ impl Command for GetAllVariablesCommand { } async fn execute(&self, ctx: &Context<'_>) -> Execution { - let key = UserAndRoom(&ctx.username, &ctx.room.room_id.as_str()); + let key = UserAndRoom(&ctx.username, &ctx.room.id.as_str()); let result = ctx.db.variables.get_user_variables(&key); let value = match result { @@ -48,7 +48,7 @@ impl Command for GetVariableCommand { async fn execute(&self, ctx: &Context<'_>) -> Execution { let name = &self.0; - let key = UserAndRoom(&ctx.username, &ctx.room.room_id.as_str()); + let key = UserAndRoom(&ctx.username, &ctx.room.id.as_str()); let result = ctx.db.variables.get_user_variable(&key, name); let value = match result { @@ -74,7 +74,7 @@ impl Command for SetVariableCommand { async fn execute(&self, ctx: &Context<'_>) -> Execution { let name = &self.0; let value = self.1; - let key = UserAndRoom(&ctx.username, ctx.room.room_id.as_str()); + let key = UserAndRoom(&ctx.username, ctx.room.id.as_str()); let result = ctx.db.variables.set_user_variable(&key, name, value); let content = match result { @@ -98,7 +98,7 @@ impl Command for DeleteVariableCommand { async fn execute(&self, ctx: &Context<'_>) -> Execution { let name = &self.0; - let key = UserAndRoom(&ctx.username, ctx.room.room_id.as_str()); + let key = UserAndRoom(&ctx.username, ctx.room.id.as_str()); let result = ctx.db.variables.delete_user_variable(&key, name); let value = match result { diff --git a/src/context.rs b/src/context.rs index 7fead4b..0e32264 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,6 +1,7 @@ use crate::db::Database; +use matrix_sdk::identifiers::RoomId; use matrix_sdk::Client; -use matrix_sdk::Room; +use matrix_sdk::JoinedRoom; /// A context carried through the system providing access to things /// like the database. @@ -8,7 +9,22 @@ use matrix_sdk::Room; pub struct Context<'a> { pub db: Database, pub matrix_client: &'a Client, - pub room: &'a Room, + pub room: RoomContext<'a>, pub username: &'a str, pub message_body: &'a str, } + +#[derive(Clone)] +pub struct RoomContext<'a> { + pub id: &'a RoomId, + pub display_name: &'a str, +} + +impl RoomContext<'_> { + pub fn new_with_name<'a>(room: &'a JoinedRoom, display_name: &'a str) -> RoomContext<'a> { + RoomContext { + id: room.room_id(), + display_name, + } + } +} diff --git a/src/cthulhu/dice.rs b/src/cthulhu/dice.rs index 0aeb015..9b45b87 100644 --- a/src/cthulhu/dice.rs +++ b/src/cthulhu/dice.rs @@ -343,12 +343,13 @@ mod tests { use crate::db::Database; use crate::parser::{Amount, Element, Operator}; - /// Create a dummy room instance. - fn dummy_room() -> matrix_sdk::Room { - matrix_sdk::Room::new( - &matrix_sdk::identifiers::room_id!("!fakeroomid:example.com"), - &matrix_sdk::identifiers::user_id!("@fakeuserid:example.com"), - ) + macro_rules! dummy_room { + () => { + crate::context::RoomContext { + id: &matrix_sdk::identifiers::room_id!("!fakeroomid:example.com"), + display_name: "displayname", + } + }; } /// Generate a series of numbers manually for testing. For this @@ -391,7 +392,7 @@ mod tests { let ctx = Context { db: db, matrix_client: &matrix_sdk::Client::new("https://example.com").unwrap(), - room: &dummy_room(), + room: dummy_room!(), username: "username", message_body: "message", }; diff --git a/src/dice.rs b/src/dice.rs index f2e0fba..5489255 100644 --- a/src/dice.rs +++ b/src/dice.rs @@ -9,7 +9,7 @@ use futures::stream::{self, StreamExt, TryStreamExt}; //New hotness pub async fn calculate_dice_amount(amounts: &[Amount], ctx: &Context<'_>) -> Result { let stream = stream::iter(amounts); - let key = UserAndRoom(&ctx.username, ctx.room.room_id.as_str()); + let key = UserAndRoom(&ctx.username, ctx.room.id.as_str()); let variables = &ctx.db.variables.get_user_variables(&key)?; use DiceRollingError::VariableNotFound; diff --git a/src/error.rs b/src/error.rs index 68fcf4b..849866d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -27,6 +27,9 @@ pub enum BotError { #[error("could not parse URL")] UrlParseError(#[from] url::ParseError), + #[error("error in matrix state store: {0}")] + MatrixStateStoreError(#[from] matrix_sdk::StoreError), + #[error("uncategorized matrix SDK error")] MatrixError(#[from] matrix_sdk::Error), diff --git a/src/logic.rs b/src/logic.rs index 8649956..3b03190 100644 --- a/src/logic.rs +++ b/src/logic.rs @@ -1,21 +1,22 @@ use crate::db::errors::DataError; use crate::matrix; use crate::models::RoomInfo; -use matrix_sdk::{self, Client, Room}; +use matrix_sdk::{self, identifiers::RoomId, Client}; /// Record the information about a room, including users in it. pub async fn record_room_information( client: &Client, db: &crate::db::Database, - room: &Room, + room_id: &RoomId, + room_display_name: &str, our_username: &str, ) -> Result<(), DataError> { - let room_id_str = room.room_id.as_str(); - let usernames = matrix::get_users_in_room(&client, &room.room_id).await; + let room_id_str = room_id.as_str(); + let usernames = matrix::get_users_in_room(&client, &room_id).await; let info = RoomInfo { room_id: room_id_str.to_owned(), - room_name: room.display_name(), + room_name: room_display_name.to_owned(), }; // TODO this and the username adding should be one whole diff --git a/src/matrix.rs b/src/matrix.rs index 497f0aa..94e3244 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -1,13 +1,21 @@ -use matrix_sdk::{identifiers::RoomId, Client, Room}; +use matrix_sdk::{identifiers::RoomId, Client}; /// Retrieve a list of users in a given room. pub async fn get_users_in_room(client: &Client, room_id: &RoomId) -> Vec { - if let Some(joined_room) = client.get_joined_room(room_id).await { - let joined_room: Room = joined_room.read().await.clone(); + if let Some(joined_room) = client.get_joined_room(room_id) { joined_room - .joined_members - .keys() - .map(|user_id| format!("@{}:{}", user_id.localpart(), user_id.server_name())) + .joined_members() + .await + .ok() + .unwrap_or_default() + .into_iter() + .map(|member| { + format!( + "@{}:{}", + member.user_id().localpart(), + member.user_id().server_name() + ) + }) .collect() } else { vec![]