matrix_sdk: bump to latest commit

This commit is contained in:
Antoine Martin 2021-04-10 04:08:42 +02:00
parent 31a7bb029b
commit b0483d90da
5 changed files with 71 additions and 44 deletions

79
Cargo.lock generated
View file

@ -133,6 +133,20 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "backoff"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fe17f59a06fe8b87a6fc8bf53bb70b3aba76d7685f432487a68cd5552853625"
dependencies = [
"futures-core",
"getrandom",
"instant",
"pin-project",
"rand",
"tokio",
]
[[package]] [[package]]
name = "bad-news" name = "bad-news"
version = "0.1.0" version = "0.1.0"
@ -820,6 +834,7 @@ checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown",
"serde",
] ]
[[package]] [[package]]
@ -936,8 +951,9 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
[[package]] [[package]]
name = "matrix-sdk" name = "matrix-sdk"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=b66c666997cbcf32071d24ffe2484a215de8d0e4#b66c666997cbcf32071d24ffe2484a215de8d0e4" source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=b5de20349945afcde13a78f023b906f421bb9764#b5de20349945afcde13a78f023b906f421bb9764"
dependencies = [ dependencies = [
"backoff",
"dashmap", "dashmap",
"futures", "futures",
"futures-timer", "futures-timer",
@ -958,7 +974,7 @@ dependencies = [
[[package]] [[package]]
name = "matrix-sdk-base" name = "matrix-sdk-base"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=b66c666997cbcf32071d24ffe2484a215de8d0e4#b66c666997cbcf32071d24ffe2484a215de8d0e4" source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=b5de20349945afcde13a78f023b906f421bb9764#b5de20349945afcde13a78f023b906f421bb9764"
dependencies = [ dependencies = [
"chacha20poly1305", "chacha20poly1305",
"dashmap", "dashmap",
@ -981,21 +997,23 @@ dependencies = [
[[package]] [[package]]
name = "matrix-sdk-common" name = "matrix-sdk-common"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=b66c666997cbcf32071d24ffe2484a215de8d0e4#b66c666997cbcf32071d24ffe2484a215de8d0e4" source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=b5de20349945afcde13a78f023b906f421bb9764#b5de20349945afcde13a78f023b906f421bb9764"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"futures",
"futures-locks", "futures-locks",
"instant", "instant",
"ruma", "ruma",
"serde", "serde",
"tokio", "tokio",
"uuid", "uuid",
"wasm-bindgen-futures",
] ]
[[package]] [[package]]
name = "matrix-sdk-crypto" name = "matrix-sdk-crypto"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=b66c666997cbcf32071d24ffe2484a215de8d0e4#b66c666997cbcf32071d24ffe2484a215de8d0e4" source = "git+https://github.com/matrix-org/matrix-rust-sdk?rev=b5de20349945afcde13a78f023b906f421bb9764#b5de20349945afcde13a78f023b906f421bb9764"
dependencies = [ dependencies = [
"aes-ctr", "aes-ctr",
"aes-gcm", "aes-gcm",
@ -1003,6 +1021,7 @@ dependencies = [
"base64", "base64",
"byteorder", "byteorder",
"dashmap", "dashmap",
"futures",
"getrandom", "getrandom",
"hmac", "hmac",
"matrix-sdk-common", "matrix-sdk-common",
@ -1302,10 +1321,11 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "0.1.5" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" checksum = "41fdbd1df62156fbc5945f4762632564d7d038153091c3fcf1067f6aef7cff92"
dependencies = [ dependencies = [
"thiserror",
"toml", "toml",
] ]
@ -1485,7 +1505,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.0.2" version = "0.0.2"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -1501,7 +1521,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-api" name = "ruma-api"
version = "0.17.0-alpha.2" version = "0.17.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"http", "http",
"percent-encoding", "percent-encoding",
@ -1516,7 +1536,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-api-macros" name = "ruma-api-macros"
version = "0.17.0-alpha.2" version = "0.17.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
@ -1527,7 +1547,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.10.0-alpha.2" version = "0.10.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"assign", "assign",
"http", "http",
@ -1545,21 +1565,24 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.3.0-alpha.1" version = "0.3.1"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"indexmap",
"js_int", "js_int",
"maplit", "maplit",
"ruma-identifiers", "ruma-identifiers",
"ruma-serde", "ruma-serde",
"serde", "serde",
"serde_json", "serde_json",
"tracing",
"wildmatch",
] ]
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.22.0-alpha.2" version = "0.22.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -1573,7 +1596,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events-macros" name = "ruma-events-macros"
version = "0.22.0-alpha.2" version = "0.22.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
@ -1584,7 +1607,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.1.0-alpha.1" version = "0.1.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-api", "ruma-api",
@ -1598,8 +1621,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers" name = "ruma-identifiers"
version = "0.18.0-alpha.1" version = "0.18.1"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"paste", "paste",
"ruma-identifiers-macros", "ruma-identifiers-macros",
@ -1611,8 +1634,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-macros" name = "ruma-identifiers-macros"
version = "0.18.0-alpha.1" version = "0.18.1"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1622,13 +1645,13 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.2.0" version = "0.2.2"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
[[package]] [[package]]
name = "ruma-serde" name = "ruma-serde"
version = "0.3.0" version = "0.3.1"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"itoa", "itoa",
@ -1640,8 +1663,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-serde-macros" name = "ruma-serde-macros"
version = "0.3.0" version = "0.3.1"
source = "git+https://github.com/ruma/ruma?rev=8c109d3c0a7ec66b352dc82677d30db7cb0723eb#8c109d3c0a7ec66b352dc82677d30db7cb0723eb" source = "git+https://github.com/ruma/ruma?rev=2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25#2f1b9f097930bf7908ca539f2ab7bb0ccf5d8b25"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
@ -2446,6 +2469,12 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "wildmatch"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6c48bd20df7e4ced539c12f570f937c6b4884928a87fee70a479d72f031d4e0"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"

View file

@ -23,4 +23,4 @@ void = "1"
[dependencies.matrix-sdk] [dependencies.matrix-sdk]
git = "https://github.com/matrix-org/matrix-rust-sdk" git = "https://github.com/matrix-org/matrix-rust-sdk"
rev = "b66c666997cbcf32071d24ffe2484a215de8d0e4" rev = "b5de20349945afcde13a78f023b906f421bb9764"

View file

@ -20,7 +20,7 @@
src = ./.; src = ./.;
cargoSha256 = "sha256-thGlVgWeAsBnX8IL4y4pyyUnyGfERugYHU61Te0KEUY="; cargoSha256 = "sha256-dNf/FYhNRu85Q4ZinvFGcJmMRayVdTJ9j28fu9BIinY=";
meta = with pkgs.lib; { meta = with pkgs.lib; {
description = "A Matrix bot, bringer of bad news"; description = "A Matrix bot, bringer of bad news";

View file

@ -4,7 +4,8 @@ use matrix_sdk::{
self, async_trait, self, async_trait,
events::{room::member::MemberEventContent, StrippedStateEvent}, events::{room::member::MemberEventContent, StrippedStateEvent},
identifiers::RoomId, identifiers::RoomId,
Client, EventEmitter, RoomState, room::Room,
Client, EventHandler,
}; };
use tokio::time::sleep; use tokio::time::sleep;
@ -20,10 +21,10 @@ impl AutoJoinHandler {
} }
#[async_trait] #[async_trait]
impl EventEmitter for AutoJoinHandler { impl EventHandler for AutoJoinHandler {
async fn on_stripped_state_member( async fn on_stripped_state_member(
&self, &self,
room: RoomState, room: Room,
room_member: &StrippedStateEvent<MemberEventContent>, room_member: &StrippedStateEvent<MemberEventContent>,
_: Option<MemberEventContent>, _: Option<MemberEventContent>,
) { ) {
@ -31,9 +32,12 @@ impl EventEmitter for AutoJoinHandler {
return; return;
} }
if let RoomState::Invited(room) = room { if let Room::Invited(room) = room {
let room_id = room.room_id(); let room_id = room.room_id();
let room_name = room.display_name().await; let room_name = room
.display_name()
.await
.expect("couldn't get joined room name!");
println!( println!(
"Received invitation for room `{}`: `{}`", "Received invitation for room `{}`: `{}`",
room_id, room_name room_id, room_name
@ -44,16 +48,14 @@ impl EventEmitter for AutoJoinHandler {
"Bot isn't authorized to join room `{}`, declining invitation", "Bot isn't authorized to join room `{}`, declining invitation",
room_id room_id
); );
// leaving a room is equivalent to rejecting the invitation, as per room.reject_invitation().await.unwrap();
// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-leave
self.client.leave_room(room_id).await.unwrap();
return; return;
} }
println!("Autojoining room {}", room.room_id()); println!("Autojoining room {}", room.room_id());
let mut delay = 2; let mut delay = 2;
while let Err(err) = self.client.join_room_by_id(room.room_id()).await { while let Err(err) = room.accept_invitation().await {
// retry autojoin due to synapse sending invites, before the // retry autojoin due to synapse sending invites, before the
// invited user can join for more information see // invited user can join for more information see
// https://github.com/matrix-org/synapse/issues/4345 // https://github.com/matrix-org/synapse/issues/4345

View file

@ -4,10 +4,7 @@ use std::{
}; };
use matrix_sdk::{ use matrix_sdk::{
events::{ events::{room::message::MessageEventContent, AnyMessageEventContent},
room::message::{MessageEventContent, TextMessageEventContent},
AnyMessageEventContent,
},
Client, ClientConfig, Session, SyncSettings, Client, ClientConfig, Session, SyncSettings,
}; };
use systemd::{journal, JournalRecord}; use systemd::{journal, JournalRecord};
@ -40,7 +37,7 @@ impl BadNewsBot {
load_or_init_session(&self).await?; load_or_init_session(&self).await?;
self.client self.client
.add_event_emitter(Box::new(AutoJoinHandler::new( .set_event_handler(Box::new(AutoJoinHandler::new(
self.client.clone(), self.client.clone(),
self.config.room_id.clone(), self.config.room_id.clone(),
))) )))
@ -121,9 +118,8 @@ impl BadNewsBot {
unit.strip_suffix(".service").unwrap_or(unit), unit.strip_suffix(".service").unwrap_or(unit),
message, message,
); );
let content = AnyMessageEventContent::RoomMessage(MessageEventContent::Text( let content =
TextMessageEventContent::plain(message), AnyMessageEventContent::RoomMessage(MessageEventContent::text_plain(message));
));
let room_id = self.config.room_id.clone(); let room_id = self.config.room_id.clone();
let client_clone = self.client.clone(); let client_clone = self.client.clone();