matrix-sdk: Bump Ruma
parent
ffaddb22b8
commit
1f5cad136e
|
@ -3,7 +3,7 @@ use std::{env, process::exit};
|
||||||
use matrix_sdk::{
|
use matrix_sdk::{
|
||||||
self, async_trait,
|
self, async_trait,
|
||||||
events::{
|
events::{
|
||||||
room::message::{MessageEventContent, TextMessageEventContent},
|
room::message::{MessageEventContent, MessageType, TextMessageEventContent},
|
||||||
AnyMessageEventContent, SyncMessageEvent,
|
AnyMessageEventContent, SyncMessageEvent,
|
||||||
},
|
},
|
||||||
Client, ClientConfig, EventHandler, RoomState, SyncSettings,
|
Client, ClientConfig, EventHandler, RoomState, SyncSettings,
|
||||||
|
@ -31,13 +31,17 @@ impl EventHandler for CommandBot {
|
||||||
) {
|
) {
|
||||||
if let RoomState::Joined(room) = room {
|
if let RoomState::Joined(room) = room {
|
||||||
let msg_body = if let SyncMessageEvent {
|
let msg_body = if let SyncMessageEvent {
|
||||||
content: MessageEventContent::Text(TextMessageEventContent { body: msg_body, .. }),
|
content:
|
||||||
|
MessageEventContent {
|
||||||
|
msgtype: MessageType::Text(TextMessageEventContent { body: msg_body, .. }),
|
||||||
|
..
|
||||||
|
},
|
||||||
..
|
..
|
||||||
} = event
|
} = event
|
||||||
{
|
{
|
||||||
msg_body.clone()
|
msg_body
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if msg_body.contains("!party") {
|
if msg_body.contains("!party") {
|
||||||
|
|
|
@ -10,9 +10,7 @@ use url::Url;
|
||||||
|
|
||||||
use matrix_sdk::{
|
use matrix_sdk::{
|
||||||
self,
|
self,
|
||||||
events::{
|
events::{room::message::MessageType, AnySyncMessageEvent, AnySyncRoomEvent, AnyToDeviceEvent},
|
||||||
room::message::MessageEventContent, AnySyncMessageEvent, AnySyncRoomEvent, AnyToDeviceEvent,
|
|
||||||
},
|
|
||||||
identifiers::UserId,
|
identifiers::UserId,
|
||||||
Client, LoopCtrl, Sas, SyncSettings,
|
Client, LoopCtrl, Sas, SyncSettings,
|
||||||
};
|
};
|
||||||
|
@ -130,7 +128,7 @@ async fn login(
|
||||||
if let AnySyncRoomEvent::Message(event) = event {
|
if let AnySyncRoomEvent::Message(event) = event {
|
||||||
match event {
|
match event {
|
||||||
AnySyncMessageEvent::RoomMessage(m) => {
|
AnySyncMessageEvent::RoomMessage(m) => {
|
||||||
if let MessageEventContent::VerificationRequest(_) = &m.content
|
if let MessageType::VerificationRequest(_) = &m.content.msgtype
|
||||||
{
|
{
|
||||||
let request = client
|
let request = client
|
||||||
.get_verification_request(&m.event_id)
|
.get_verification_request(&m.event_id)
|
||||||
|
|
|
@ -11,7 +11,7 @@ use tokio::sync::Mutex;
|
||||||
use matrix_sdk::{
|
use matrix_sdk::{
|
||||||
self, async_trait,
|
self, async_trait,
|
||||||
events::{
|
events::{
|
||||||
room::message::{MessageEventContent, TextMessageEventContent},
|
room::message::{MessageEventContent, MessageType, TextMessageEventContent},
|
||||||
SyncMessageEvent,
|
SyncMessageEvent,
|
||||||
},
|
},
|
||||||
Client, EventHandler, RoomState, SyncSettings,
|
Client, EventHandler, RoomState, SyncSettings,
|
||||||
|
@ -39,7 +39,11 @@ impl EventHandler for ImageBot {
|
||||||
) {
|
) {
|
||||||
if let RoomState::Joined(room) = room {
|
if let RoomState::Joined(room) = room {
|
||||||
let msg_body = if let SyncMessageEvent {
|
let msg_body = if let SyncMessageEvent {
|
||||||
content: MessageEventContent::Text(TextMessageEventContent { body: msg_body, .. }),
|
content:
|
||||||
|
MessageEventContent {
|
||||||
|
msgtype: MessageType::Text(TextMessageEventContent { body: msg_body, .. }),
|
||||||
|
..
|
||||||
|
},
|
||||||
..
|
..
|
||||||
} = event
|
} = event
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ use url::Url;
|
||||||
use matrix_sdk::{
|
use matrix_sdk::{
|
||||||
self, async_trait,
|
self, async_trait,
|
||||||
events::{
|
events::{
|
||||||
room::message::{MessageEventContent, TextMessageEventContent},
|
room::message::{MessageEventContent, MessageType, TextMessageEventContent},
|
||||||
SyncMessageEvent,
|
SyncMessageEvent,
|
||||||
},
|
},
|
||||||
Client, EventHandler, RoomState, SyncSettings,
|
Client, EventHandler, RoomState, SyncSettings,
|
||||||
|
@ -21,7 +21,11 @@ impl EventHandler for EventCallback {
|
||||||
) {
|
) {
|
||||||
if let RoomState::Joined(room) = room {
|
if let RoomState::Joined(room) = room {
|
||||||
if let SyncMessageEvent {
|
if let SyncMessageEvent {
|
||||||
content: MessageEventContent::Text(TextMessageEventContent { body: msg_body, .. }),
|
content:
|
||||||
|
MessageEventContent {
|
||||||
|
msgtype: MessageType::Text(TextMessageEventContent { body: msg_body, .. }),
|
||||||
|
..
|
||||||
|
},
|
||||||
sender,
|
sender,
|
||||||
..
|
..
|
||||||
} = event
|
} = event
|
||||||
|
|
|
@ -93,7 +93,7 @@ use matrix_sdk_common::{
|
||||||
room::{
|
room::{
|
||||||
message::{
|
message::{
|
||||||
AudioMessageEventContent, FileMessageEventContent, ImageMessageEventContent,
|
AudioMessageEventContent, FileMessageEventContent, ImageMessageEventContent,
|
||||||
MessageEventContent, VideoMessageEventContent,
|
MessageEventContent, MessageType, VideoMessageEventContent,
|
||||||
},
|
},
|
||||||
EncryptedFile,
|
EncryptedFile,
|
||||||
},
|
},
|
||||||
|
@ -1378,26 +1378,26 @@ impl Client {
|
||||||
let content = match content_type.type_() {
|
let content = match content_type.type_() {
|
||||||
mime::IMAGE => {
|
mime::IMAGE => {
|
||||||
// TODO create a thumbnail using the image crate?.
|
// TODO create a thumbnail using the image crate?.
|
||||||
MessageEventContent::Image(ImageMessageEventContent {
|
MessageType::Image(ImageMessageEventContent {
|
||||||
body: body.to_owned(),
|
body: body.to_owned(),
|
||||||
info: None,
|
info: None,
|
||||||
url: Some(url),
|
url: Some(url),
|
||||||
file: encrypted_file,
|
file: encrypted_file,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
mime::AUDIO => MessageEventContent::Audio(AudioMessageEventContent {
|
mime::AUDIO => MessageType::Audio(AudioMessageEventContent {
|
||||||
body: body.to_owned(),
|
body: body.to_owned(),
|
||||||
info: None,
|
info: None,
|
||||||
url: Some(url),
|
url: Some(url),
|
||||||
file: encrypted_file,
|
file: encrypted_file,
|
||||||
}),
|
}),
|
||||||
mime::VIDEO => MessageEventContent::Video(VideoMessageEventContent {
|
mime::VIDEO => MessageType::Video(VideoMessageEventContent {
|
||||||
body: body.to_owned(),
|
body: body.to_owned(),
|
||||||
info: None,
|
info: None,
|
||||||
url: Some(url),
|
url: Some(url),
|
||||||
file: encrypted_file,
|
file: encrypted_file,
|
||||||
}),
|
}),
|
||||||
_ => MessageEventContent::File(FileMessageEventContent {
|
_ => MessageType::File(FileMessageEventContent {
|
||||||
filename: None,
|
filename: None,
|
||||||
body: body.to_owned(),
|
body: body.to_owned(),
|
||||||
info: None,
|
info: None,
|
||||||
|
@ -1408,7 +1408,7 @@ impl Client {
|
||||||
|
|
||||||
self.room_send(
|
self.room_send(
|
||||||
room_id,
|
room_id,
|
||||||
AnyMessageEventContent::RoomMessage(content),
|
AnyMessageEventContent::RoomMessage(MessageEventContent::new(content)),
|
||||||
txn_id,
|
txn_id,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -22,7 +22,7 @@ async-trait = "0.1.42"
|
||||||
[dependencies.ruma]
|
[dependencies.ruma]
|
||||||
version = "0.0.2"
|
version = "0.0.2"
|
||||||
git = "https://github.com/ruma/ruma"
|
git = "https://github.com/ruma/ruma"
|
||||||
rev = "d6aa37c848b7f682a98c25b346899e284ffc6df7"
|
rev = "c27e66741a8cb0cf5dba45ae3a977f4d6bba715d"
|
||||||
features = ["client-api", "compat", "unstable-pre-spec"]
|
features = ["client-api", "compat", "unstable-pre-spec"]
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
|
|
@ -1201,7 +1201,7 @@ pub(crate) mod test {
|
||||||
events::{
|
events::{
|
||||||
room::{
|
room::{
|
||||||
encrypted::EncryptedEventContent,
|
encrypted::EncryptedEventContent,
|
||||||
message::{MessageEventContent, TextMessageEventContent},
|
message::{MessageEventContent, MessageType},
|
||||||
},
|
},
|
||||||
AnyMessageEventContent, AnySyncMessageEvent, AnySyncRoomEvent, AnyToDeviceEvent,
|
AnyMessageEventContent, AnySyncMessageEvent, AnySyncRoomEvent, AnyToDeviceEvent,
|
||||||
EventType, SyncMessageEvent, ToDeviceEvent, Unsigned,
|
EventType, SyncMessageEvent, ToDeviceEvent, Unsigned,
|
||||||
|
@ -1746,7 +1746,7 @@ pub(crate) mod test {
|
||||||
|
|
||||||
let plaintext = "It is a secret to everybody";
|
let plaintext = "It is a secret to everybody";
|
||||||
|
|
||||||
let content = MessageEventContent::Text(TextMessageEventContent::plain(plaintext));
|
let content = MessageEventContent::text_plain(plaintext);
|
||||||
|
|
||||||
let encrypted_content = alice
|
let encrypted_content = alice
|
||||||
.encrypt(
|
.encrypt(
|
||||||
|
@ -1778,7 +1778,7 @@ pub(crate) mod test {
|
||||||
..
|
..
|
||||||
})) => {
|
})) => {
|
||||||
assert_eq!(&sender, alice.user_id());
|
assert_eq!(&sender, alice.user_id());
|
||||||
if let MessageEventContent::Text(c) = &content {
|
if let MessageType::Text(c) = &content.msgtype {
|
||||||
assert_eq!(&c.body, plaintext);
|
assert_eq!(&c.body, plaintext);
|
||||||
} else {
|
} else {
|
||||||
panic!("Decrypted event has a missmatched content");
|
panic!("Decrypted event has a missmatched content");
|
||||||
|
|
|
@ -129,10 +129,7 @@ mod test {
|
||||||
};
|
};
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
events::{
|
events::{room::message::MessageEventContent, AnyMessageEventContent},
|
||||||
room::message::{MessageEventContent, TextMessageEventContent},
|
|
||||||
AnyMessageEventContent,
|
|
||||||
},
|
|
||||||
identifiers::{room_id, user_id},
|
identifiers::{room_id, user_id},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -156,7 +153,7 @@ mod test {
|
||||||
assert!(!session.expired());
|
assert!(!session.expired());
|
||||||
let _ = session
|
let _ = session
|
||||||
.encrypt(AnyMessageEventContent::RoomMessage(
|
.encrypt(AnyMessageEventContent::RoomMessage(
|
||||||
MessageEventContent::Text(TextMessageEventContent::plain("Test message")),
|
MessageEventContent::text_plain("Test message"),
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
assert!(session.expired());
|
assert!(session.expired());
|
||||||
|
|
|
@ -20,7 +20,7 @@ use tracing::{info, trace, warn};
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
events::{
|
events::{
|
||||||
room::message::MessageEventContent, AnyMessageEvent, AnySyncMessageEvent, AnySyncRoomEvent,
|
room::message::MessageType, AnyMessageEvent, AnySyncMessageEvent, AnySyncRoomEvent,
|
||||||
AnyToDeviceEvent,
|
AnyToDeviceEvent,
|
||||||
},
|
},
|
||||||
identifiers::{DeviceId, EventId, RoomId, UserId},
|
identifiers::{DeviceId, EventId, RoomId, UserId},
|
||||||
|
@ -233,7 +233,7 @@ impl VerificationMachine {
|
||||||
|
|
||||||
match m {
|
match m {
|
||||||
AnySyncMessageEvent::RoomMessage(m) => {
|
AnySyncMessageEvent::RoomMessage(m) => {
|
||||||
if let MessageEventContent::VerificationRequest(r) = &m.content {
|
if let MessageType::VerificationRequest(r) = &m.content.msgtype {
|
||||||
if self.account.user_id() == &r.to {
|
if self.account.user_id() == &r.to {
|
||||||
info!(
|
info!(
|
||||||
"Received a new verification request from {} {}",
|
"Received a new verification request from {} {}",
|
||||||
|
|
|
@ -1345,7 +1345,7 @@ mod test {
|
||||||
|
|
||||||
*method = AcceptMethod::Custom(CustomContent {
|
*method = AcceptMethod::Custom(CustomContent {
|
||||||
method: "m.sas.custom".to_string(),
|
method: "m.sas.custom".to_string(),
|
||||||
fields: vec![].into_iter().collect(),
|
data: vec![].into_iter().collect(),
|
||||||
});
|
});
|
||||||
|
|
||||||
alice
|
alice
|
||||||
|
@ -1394,7 +1394,7 @@ mod test {
|
||||||
|
|
||||||
*method = StartMethod::Custom(CustomStartContent {
|
*method = StartMethod::Custom(CustomStartContent {
|
||||||
method: "m.sas.custom".to_string(),
|
method: "m.sas.custom".to_string(),
|
||||||
fields: vec![].into_iter().collect(),
|
data: vec![].into_iter().collect(),
|
||||||
});
|
});
|
||||||
|
|
||||||
SasState::<Started>::from_start_event(bob.clone(), alice_device, None, start_content)
|
SasState::<Started>::from_start_event(bob.clone(), alice_device, None, start_content)
|
||||||
|
|
Loading…
Reference in New Issue