From ba6a4c9679c8348945f4f9db570129951543167f Mon Sep 17 00:00:00 2001 From: projectmoon Date: Mon, 22 Mar 2021 15:01:49 +0000 Subject: [PATCH] Update matrix SDK to latest with Room enum 2.0 --- Cargo.lock | 79 ++++++++++++++++++++------------------- src/bot/event_handlers.rs | 20 ++++------ 2 files changed, 47 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6bb2286..1195567 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -777,12 +777,13 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" +checksum = "5dfb77c123b4e2f72a2069aeae0b4b4949cc7e966df277813fc16347e7549737" dependencies = [ "bytes", "http", + "pin-project-lite", ] [[package]] @@ -878,7 +879,7 @@ checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ "cfg-if", "js-sys", - "time 0.2.25", + "time 0.2.26", "wasm-bindgen", "web-sys", ] @@ -906,9 +907,9 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "js-sys" -version = "0.3.48" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc9f84f9b115ce7843d60706df1422a916680bfdfcbdb0447c5614ff9d7e4d78" +checksum = "dc15e39392125075f60c95ba416f5381ff6c3a948ff02ab12464715adf56c821" dependencies = [ "wasm-bindgen", ] @@ -943,9 +944,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.88" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" +checksum = "ba4aede83fc3617411dc6993bc8c70919750c1c257c6ca6a502aed6e0e2394ae" [[package]] name = "lock_api" @@ -1015,7 +1016,7 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] name = "matrix-sdk" version = "0.2.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#31dd031269ad7d91ca9f097e345a7125585efcf6" +source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#382ec01bc3b88427e807ffdfdd7992f67907e999" dependencies = [ "backoff", "dashmap", @@ -1038,7 +1039,7 @@ dependencies = [ [[package]] name = "matrix-sdk-base" version = "0.2.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#31dd031269ad7d91ca9f097e345a7125585efcf6" +source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#382ec01bc3b88427e807ffdfdd7992f67907e999" dependencies = [ "chacha20poly1305", "dashmap", @@ -1061,7 +1062,7 @@ dependencies = [ [[package]] name = "matrix-sdk-common" version = "0.2.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#31dd031269ad7d91ca9f097e345a7125585efcf6" +source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#382ec01bc3b88427e807ffdfdd7992f67907e999" dependencies = [ "async-trait", "futures-locks", @@ -1075,7 +1076,7 @@ dependencies = [ [[package]] name = "matrix-sdk-crypto" version = "0.2.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#31dd031269ad7d91ca9f097e345a7125585efcf6" +source = "git+https://github.com/matrix-org/matrix-rust-sdk?branch=master#382ec01bc3b88427e807ffdfdd7992f67907e999" dependencies = [ "aes-ctr", "aes-gcm", @@ -1126,9 +1127,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mio" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5dede4e2065b3842b8b0af444119f3aa331cc7cc2dd20388bfb0f5d5a38823a" +checksum = "2182a122f3b7f3f5329cb1972cee089ba2459a0a80a56935e6e674f096f8d839" dependencies = [ "libc", "log", @@ -1982,9 +1983,9 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7" +checksum = "cbce6d4507c7e4a3962091436e56e95290cb71fa302d0d270e32130b75fbff27" [[package]] name = "slab" @@ -2027,9 +2028,9 @@ dependencies = [ [[package]] name = "standback" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2beb4d1860a61f571530b3f855a1b538d0200f7871c63331ecd6f17b1f014f8" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" dependencies = [ "version_check", ] @@ -2209,9 +2210,9 @@ dependencies = [ [[package]] name = "time" -version = "0.2.25" +version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1195b046942c221454c2539395f85413b33383a067449d78aab2b7b052a142f7" +checksum = "08a8cbfbf47955132d0202d1662f49b2423ae35862aee471f3ba4b133358f372" dependencies = [ "const_fn", "libc", @@ -2262,9 +2263,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d56477f6ed99e10225f38f9f75f872f29b8b8bd8c0b946f63345bb144e9eeda" +checksum = "134af885d758d645f0f0505c9a8b3f9bf8a348fd822e112ab5248138348f1722" dependencies = [ "autocfg", "bytes", @@ -2303,9 +2304,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec31e5cc6b46e653cf57762f36f71d5e6386391d88a72fd6db4508f8f676fb29" +checksum = "5143d049e85af7fbc36f5454d990e62c2df705b3589f123b71f441b6b59f443f" dependencies = [ "bytes", "futures-core", @@ -2466,9 +2467,9 @@ checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "want" @@ -2494,9 +2495,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7" +checksum = "8fe8f61dba8e5d645a4d8132dc7a0a66861ed5e1045d2c0ed940fab33bac0fbe" dependencies = [ "cfg-if", "serde", @@ -2506,9 +2507,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7d8b6942b8bb3a9b0e73fc79b98095a27de6fa247615e59d096754a3bc2aa8" +checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3" dependencies = [ "bumpalo", "lazy_static", @@ -2521,9 +2522,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e67a5806118af01f0d9045915676b22aaebecf4178ae7021bc171dab0b897ab" +checksum = "73157efb9af26fb564bb59a009afd1c7c334a44db171d280690d0c3faaec3468" dependencies = [ "cfg-if", "js-sys", @@ -2533,9 +2534,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ac38da8ef716661f0f36c0d8320b89028efe10c7c0afde65baffb496ce0d3b" +checksum = "0ef9aa01d36cda046f797c57959ff5f3c615c9cc63997a8d545831ec7976819b" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2543,9 +2544,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc053ec74d454df287b9374ee8abb36ffd5acb95ba87da3ba5b7d3fe20eb401e" +checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d" dependencies = [ "proc-macro2", "quote", @@ -2556,15 +2557,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d6f8ec44822dd71f5f221a5847fb34acd9060535c1211b70a05844c0f6383b1" +checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" [[package]] name = "web-sys" -version = "0.3.48" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec600b26223b2948cedfde2a0aa6756dcf1fef616f43d7b3097aaf53a6c4d92b" +checksum = "59fe19d70f5dacc03f6e46777213facae5ac3801575d56ca6cbd4c93dcd12310" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/src/bot/event_handlers.rs b/src/bot/event_handlers.rs index 75b764c..dddd6dc 100644 --- a/src/bot/event_handlers.rs +++ b/src/bot/event_handlers.rs @@ -11,8 +11,8 @@ use matrix_sdk::{ room::message::{MessageEventContent, MessageType, TextMessageEventContent}, StrippedStateEvent, SyncMessageEvent, SyncStateEvent, }, - room::{Common, Invited, Joined}, - EventHandler, Room, + room::Room, + EventHandler, }; use std::clone::Clone; use std::ops::Sub; @@ -102,7 +102,7 @@ fn should_process_event(db: &Database, room_id: &str, event_id: &str) -> bool { #[async_trait] impl EventHandler for DiceBot { async fn on_room_member(&self, room: Room, event: &SyncStateEvent) { - let room = Common::new(self.client.clone(), room); + //let room = Common::new(self.client.clone(), room); let (room_id, room_display_name) = match room.display_name().await { Ok(display_name) => (room.room_id(), display_name), _ => return, @@ -165,8 +165,8 @@ impl EventHandler for DiceBot { event: &StrippedStateEvent, _: Option, ) { - let room = match Invited::new(self.client.clone(), room) { - Some(invited_room) => invited_room, + let room = match room { + Room::Invited(invited_room) => invited_room, _ => return, }; @@ -174,12 +174,6 @@ impl EventHandler for DiceBot { return; } - // if let Some(user_id) = self.client.user_id().await { - // if event.state_key != user_id { - // return; - // } - // } - info!( "Autojoining room {}", room.display_name().await.ok().unwrap_or_default() @@ -191,8 +185,8 @@ impl EventHandler for DiceBot { } async fn on_room_message(&self, room: Room, event: &SyncMessageEvent) { - let room = match Joined::new(self.client.clone(), room) { - Some(joined_room) => joined_room, + let room = match room { + Room::Joined(joined_room) => joined_room, _ => return, };