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

View file

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

View file

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

View file

@ -4,7 +4,8 @@ use matrix_sdk::{
self, async_trait,
events::{room::member::MemberEventContent, StrippedStateEvent},
identifiers::RoomId,
Client, EventEmitter, RoomState,
room::Room,
Client, EventHandler,
};
use tokio::time::sleep;
@ -20,10 +21,10 @@ impl AutoJoinHandler {
}
#[async_trait]
impl EventEmitter for AutoJoinHandler {
impl EventHandler for AutoJoinHandler {
async fn on_stripped_state_member(
&self,
room: RoomState,
room: Room,
room_member: &StrippedStateEvent<MemberEventContent>,
_: Option<MemberEventContent>,
) {
@ -31,9 +32,12 @@ impl EventEmitter for AutoJoinHandler {
return;
}
if let RoomState::Invited(room) = room {
if let Room::Invited(room) = room {
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!(
"Received invitation for room `{}`: `{}`",
room_id, room_name
@ -44,16 +48,14 @@ impl EventEmitter for AutoJoinHandler {
"Bot isn't authorized to join room `{}`, declining invitation",
room_id
);
// leaving a room is equivalent to rejecting the invitation, as per
// 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();
room.reject_invitation().await.unwrap();
return;
}
println!("Autojoining room {}", room.room_id());
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
// invited user can join for more information see
// https://github.com/matrix-org/synapse/issues/4345

View file

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