Merge branch 'deps-and-stuff'
commit
c1ae183795
|
@ -49,7 +49,6 @@ async-trait = "0.1.36"
|
|||
dirs = "3.0.1"
|
||||
matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" }
|
||||
tokio = { version = "0.2.21", features = ["rt-threaded", "macros"] }
|
||||
ruma-identifiers = { version = "0.16.2", features = ["rand"] }
|
||||
serde_json = "1.0.56"
|
||||
tracing-subscriber = "0.2.7"
|
||||
tempfile = "3.1.0"
|
||||
|
|
|
@ -30,8 +30,7 @@ impl EventEmitter for AutoJoinBot {
|
|||
return;
|
||||
}
|
||||
|
||||
match room {
|
||||
SyncRoom::Invited(room) => {
|
||||
if let SyncRoom::Invited(room) = room {
|
||||
let room = room.read().await;
|
||||
println!("Autojoining room {}", room.display_name());
|
||||
self.client
|
||||
|
@ -39,8 +38,6 @@ impl EventEmitter for AutoJoinBot {
|
|||
.await
|
||||
.expect("Can't join room");
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" }
|
|||
http = "0.2.1"
|
||||
tracing-subscriber = "0.2.7"
|
||||
tempfile = "3.1.0"
|
||||
mockito = "0.25.1"
|
||||
mockito = "0.26.0"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||
tokio = { version = "0.2.21", features = ["rt-threaded", "macros"] }
|
||||
|
|
|
@ -727,8 +727,8 @@ impl BaseClient {
|
|||
let mut olm = self.olm.lock().await;
|
||||
|
||||
if let Some(o) = &mut *olm {
|
||||
if let Some(decrypted) =
|
||||
o.decrypt_room_event(&encrypted_event, room_id).await.ok()
|
||||
if let Ok(decrypted) =
|
||||
o.decrypt_room_event(&encrypted_event, room_id).await
|
||||
{
|
||||
if let Ok(d) = decrypted.deserialize() {
|
||||
e = d
|
||||
|
@ -890,9 +890,9 @@ impl BaseClient {
|
|||
///
|
||||
/// * `event` - The presence event for a specified room member.
|
||||
pub async fn receive_account_data_event(&self, _: &RoomId, event: &AnyBasicEvent) -> bool {
|
||||
match &event {
|
||||
AnyBasicEvent::IgnoredUserList(event) => self.handle_ignored_users(&event).await,
|
||||
AnyBasicEvent::PushRules(event) => self.handle_push_rules(&event).await,
|
||||
match event {
|
||||
AnyBasicEvent::IgnoredUserList(event) => self.handle_ignored_users(event).await,
|
||||
AnyBasicEvent::PushRules(event) => self.handle_push_rules(event).await,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -907,7 +907,7 @@ impl BaseClient {
|
|||
///
|
||||
/// * `event` - The presence event for a specified room member.
|
||||
pub async fn receive_ephemeral_event(&self, event: &AnyEphemeralRoomEventStub) -> bool {
|
||||
match &event {
|
||||
match event {
|
||||
AnyEphemeralRoomEventStub::FullyRead(_) => {}
|
||||
AnyEphemeralRoomEventStub::Receipt(_) => {}
|
||||
AnyEphemeralRoomEventStub::Typing(_) => {}
|
||||
|
@ -1471,44 +1471,42 @@ impl BaseClient {
|
|||
}
|
||||
};
|
||||
|
||||
match &event {
|
||||
AnyRoomEventStub::State(event) => match &event {
|
||||
AnyStateEventStub::RoomMember(e) => event_emitter.on_room_member(room, &e).await,
|
||||
AnyStateEventStub::RoomName(e) => event_emitter.on_room_name(room, &e).await,
|
||||
match event {
|
||||
AnyRoomEventStub::State(event) => match event {
|
||||
AnyStateEventStub::RoomMember(e) => event_emitter.on_room_member(room, e).await,
|
||||
AnyStateEventStub::RoomName(e) => event_emitter.on_room_name(room, e).await,
|
||||
AnyStateEventStub::RoomCanonicalAlias(e) => {
|
||||
event_emitter.on_room_canonical_alias(room, &e).await
|
||||
event_emitter.on_room_canonical_alias(room, e).await
|
||||
}
|
||||
AnyStateEventStub::RoomAliases(e) => event_emitter.on_room_aliases(room, &e).await,
|
||||
AnyStateEventStub::RoomAvatar(e) => event_emitter.on_room_avatar(room, &e).await,
|
||||
AnyStateEventStub::RoomAliases(e) => event_emitter.on_room_aliases(room, e).await,
|
||||
AnyStateEventStub::RoomAvatar(e) => event_emitter.on_room_avatar(room, e).await,
|
||||
AnyStateEventStub::RoomPowerLevels(e) => {
|
||||
event_emitter.on_room_power_levels(room, &e).await
|
||||
event_emitter.on_room_power_levels(room, e).await
|
||||
}
|
||||
AnyStateEventStub::RoomTombstone(e) => {
|
||||
event_emitter.on_room_tombstone(room, &e).await
|
||||
event_emitter.on_room_tombstone(room, e).await
|
||||
}
|
||||
AnyStateEventStub::RoomJoinRules(e) => {
|
||||
event_emitter.on_room_join_rules(room, &e).await
|
||||
event_emitter.on_room_join_rules(room, e).await
|
||||
}
|
||||
AnyStateEventStub::Custom(e) => {
|
||||
event_emitter
|
||||
.on_unrecognized_event(room, &CustomOrRawEvent::State(&e))
|
||||
.on_unrecognized_event(room, &CustomOrRawEvent::State(e))
|
||||
.await
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
AnyRoomEventStub::Message(event) => match &event {
|
||||
AnyMessageEventStub::RoomMessage(e) => {
|
||||
event_emitter.on_room_message(room, &e).await
|
||||
}
|
||||
AnyRoomEventStub::Message(event) => match event {
|
||||
AnyMessageEventStub::RoomMessage(e) => event_emitter.on_room_message(room, e).await,
|
||||
AnyMessageEventStub::RoomMessageFeedback(e) => {
|
||||
event_emitter.on_room_message_feedback(room, &e).await
|
||||
event_emitter.on_room_message_feedback(room, e).await
|
||||
}
|
||||
AnyMessageEventStub::RoomRedaction(e) => {
|
||||
event_emitter.on_room_redaction(room, e).await
|
||||
}
|
||||
AnyMessageEventStub::Custom(e) => {
|
||||
event_emitter
|
||||
.on_unrecognized_event(room, &CustomOrRawEvent::Message(&e))
|
||||
.on_unrecognized_event(room, &CustomOrRawEvent::Message(e))
|
||||
.await
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -46,7 +46,7 @@ use crate::events::{
|
|||
|
||||
use crate::identifiers::{RoomAliasId, RoomId, UserId};
|
||||
|
||||
use crate::js_int::{Int, UInt};
|
||||
use crate::js_int::{uint, Int, UInt};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "messages")]
|
||||
|
@ -250,16 +250,10 @@ impl RoomName {
|
|||
} else if !self.aliases.is_empty() && !self.aliases[0].alias().is_empty() {
|
||||
self.aliases[0].alias().trim().to_string()
|
||||
} else {
|
||||
let joined = self.joined_member_count.unwrap_or(UInt::MIN);
|
||||
let invited = self.invited_member_count.unwrap_or(UInt::MIN);
|
||||
let joined = self.joined_member_count.unwrap_or(uint!(0));
|
||||
let invited = self.invited_member_count.unwrap_or(uint!(0));
|
||||
let heroes = UInt::new(self.heroes.len() as u64).unwrap();
|
||||
let one = UInt::new(1).unwrap();
|
||||
|
||||
let invited_joined = if invited + joined == UInt::MIN {
|
||||
UInt::MIN
|
||||
} else {
|
||||
invited + joined - one
|
||||
};
|
||||
let invited_joined = (invited + joined).saturating_sub(uint!(1));
|
||||
|
||||
let members = joined_members.values().chain(invited_members.values());
|
||||
|
||||
|
@ -277,7 +271,7 @@ impl RoomName {
|
|||
// stabilize ordering
|
||||
names.sort();
|
||||
names.join(", ")
|
||||
} else if heroes < invited_joined && invited + joined > one {
|
||||
} else if heroes < invited_joined && invited + joined > uint!(1) {
|
||||
let mut names = members
|
||||
.filter(|m| m.user_id != *own_user_id)
|
||||
.take(3)
|
||||
|
@ -752,27 +746,27 @@ impl Room {
|
|||
///
|
||||
/// * `event` - The event of the room.
|
||||
pub fn receive_timeline_event(&mut self, event: &AnyRoomEventStub) -> bool {
|
||||
match &event {
|
||||
AnyRoomEventStub::State(event) => match &event {
|
||||
match event {
|
||||
AnyRoomEventStub::State(event) => match event {
|
||||
// update to the current members of the room
|
||||
AnyStateEventStub::RoomMember(event) => self.handle_membership(&event),
|
||||
AnyStateEventStub::RoomMember(event) => self.handle_membership(event),
|
||||
// finds all events related to the name of the room for later use
|
||||
AnyStateEventStub::RoomName(event) => self.handle_room_name(&event),
|
||||
AnyStateEventStub::RoomCanonicalAlias(event) => self.handle_canonical(&event),
|
||||
AnyStateEventStub::RoomAliases(event) => self.handle_room_aliases(&event),
|
||||
AnyStateEventStub::RoomName(event) => self.handle_room_name(event),
|
||||
AnyStateEventStub::RoomCanonicalAlias(event) => self.handle_canonical(event),
|
||||
AnyStateEventStub::RoomAliases(event) => self.handle_room_aliases(event),
|
||||
// power levels of the room members
|
||||
AnyStateEventStub::RoomPowerLevels(event) => self.handle_power_level(&event),
|
||||
AnyStateEventStub::RoomTombstone(event) => self.handle_tombstone(&event),
|
||||
AnyStateEventStub::RoomEncryption(event) => self.handle_encryption_event(&event),
|
||||
AnyStateEventStub::RoomPowerLevels(event) => self.handle_power_level(event),
|
||||
AnyStateEventStub::RoomTombstone(event) => self.handle_tombstone(event),
|
||||
AnyStateEventStub::RoomEncryption(event) => self.handle_encryption_event(event),
|
||||
_ => false,
|
||||
},
|
||||
AnyRoomEventStub::Message(event) => match &event {
|
||||
AnyRoomEventStub::Message(event) => match event {
|
||||
#[cfg(feature = "messages")]
|
||||
// We ignore this variants event because `handle_message` takes the enum
|
||||
// to store AnyMessageEventStub events in the `MessageQueue`.
|
||||
AnyMessageEventStub::RoomMessage(_) => self.handle_message(&event),
|
||||
AnyMessageEventStub::RoomMessage(_) => self.handle_message(event),
|
||||
#[cfg(feature = "messages")]
|
||||
AnyMessageEventStub::RoomRedaction(event) => self.handle_redaction(&event),
|
||||
AnyMessageEventStub::RoomRedaction(event) => self.handle_redaction(event),
|
||||
_ => false,
|
||||
},
|
||||
}
|
||||
|
@ -810,7 +804,7 @@ impl Room {
|
|||
/// * `event` - The `AnyStrippedStateEvent` sent by the server for invited but not
|
||||
/// joined rooms.
|
||||
pub fn receive_stripped_state_event(&mut self, event: &AnyStrippedStateEventStub) -> bool {
|
||||
match &event {
|
||||
match event {
|
||||
AnyStrippedStateEventStub::RoomName(event) => self.handle_stripped_room_name(event),
|
||||
_ => false,
|
||||
}
|
||||
|
@ -1094,13 +1088,10 @@ mod test {
|
|||
assert!(room.power_levels.is_some());
|
||||
assert_eq!(
|
||||
room.power_levels.as_ref().unwrap().kick,
|
||||
crate::js_int::Int::new(50).unwrap()
|
||||
crate::js_int::int!(50)
|
||||
);
|
||||
let admin = room.joined_members.get(&user_id).unwrap();
|
||||
assert_eq!(
|
||||
admin.power_level.unwrap(),
|
||||
crate::js_int::Int::new(100).unwrap()
|
||||
);
|
||||
assert_eq!(admin.power_level.unwrap(), crate::js_int::int!(100));
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::events::room::{
|
|||
use crate::events::StateEventStub;
|
||||
use crate::identifiers::{RoomId, UserId};
|
||||
|
||||
use crate::js_int::{Int, UInt};
|
||||
use crate::js_int::{int, Int, UInt};
|
||||
use serde::{Deserialize, Serialize};
|
||||
// Notes: if Alice invites Bob into a room we will get an event with the sender as Alice and the state key as Bob.
|
||||
|
||||
|
@ -143,8 +143,8 @@ impl RoomMember {
|
|||
self.power_level = Some(event.content.users_default);
|
||||
}
|
||||
|
||||
if max_power > Int::from(0) {
|
||||
self.power_level_norm = Some((self.power_level.unwrap() * Int::from(100)) / max_power);
|
||||
if max_power > int!(0) {
|
||||
self.power_level_norm = Some((self.power_level.unwrap() * int!(100)) / max_power);
|
||||
}
|
||||
|
||||
changed
|
||||
|
@ -216,7 +216,7 @@ mod test {
|
|||
use crate::identifiers::{RoomId, UserId};
|
||||
use crate::{BaseClient, Session};
|
||||
|
||||
use crate::js_int::Int;
|
||||
use crate::js_int::int;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen_test::*;
|
||||
|
@ -258,7 +258,7 @@ mod test {
|
|||
.joined_members
|
||||
.get(&UserId::try_from("@example:localhost").unwrap())
|
||||
.unwrap();
|
||||
assert_eq!(member.power_level, Int::new(100));
|
||||
assert_eq!(member.power_level, Some(int!(100)));
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
|
@ -283,7 +283,7 @@ mod test {
|
|||
.get(&UserId::try_from("@example:localhost").unwrap())
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(member.power_level, Int::new(100));
|
||||
assert_eq!(member.power_level, Some(int!(100)));
|
||||
|
||||
assert!(member.avatar_url.is_none());
|
||||
assert_eq!(member.last_active_ago, None);
|
||||
|
|
|
@ -12,7 +12,7 @@ version = "0.1.0"
|
|||
|
||||
[dependencies]
|
||||
instant = { version = "0.1.4", features = ["wasm-bindgen", "now"] }
|
||||
js_int = "0.1.5"
|
||||
js_int = "0.1.8"
|
||||
|
||||
[dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma"
|
||||
|
|
|
@ -46,7 +46,6 @@ features = ["runtime-tokio", "sqlite"]
|
|||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "0.2.21", features = ["rt-threaded", "macros"] }
|
||||
ruma-identifiers = { version = "0.16.2", features = ["rand"] }
|
||||
serde_json = "1.0.56"
|
||||
tempfile = "3.1.0"
|
||||
http = "0.2.1"
|
||||
|
|
|
@ -1333,7 +1333,7 @@ impl OlmMachine {
|
|||
|
||||
match &event {
|
||||
AnyToDeviceEvent::RoomEncrypted(e) => {
|
||||
let decrypted_event = match self.decrypt_to_device_event(&e).await {
|
||||
let decrypted_event = match self.decrypt_to_device_event(e).await {
|
||||
Ok(e) => e,
|
||||
Err(err) => {
|
||||
warn!(
|
||||
|
@ -1350,7 +1350,7 @@ impl OlmMachine {
|
|||
// before we replace the result.
|
||||
*event_result = decrypted_event;
|
||||
}
|
||||
AnyToDeviceEvent::RoomKeyRequest(e) => self.handle_room_key_request(&e),
|
||||
AnyToDeviceEvent::RoomKeyRequest(e) => self.handle_room_key_request(e),
|
||||
AnyToDeviceEvent::KeyVerificationAccept(..)
|
||||
| AnyToDeviceEvent::KeyVerificationCancel(..)
|
||||
| AnyToDeviceEvent::KeyVerificationKey(..)
|
||||
|
@ -1485,9 +1485,10 @@ impl OlmMachine {
|
|||
mod test {
|
||||
static USER_ID: &str = "@bob:example.org";
|
||||
|
||||
use matrix_sdk_common::js_int::UInt;
|
||||
use matrix_sdk_common::js_int::uint;
|
||||
use std::collections::BTreeMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::convert::TryInto;
|
||||
use std::sync::atomic::AtomicU64;
|
||||
use std::time::SystemTime;
|
||||
|
||||
|
@ -1681,20 +1682,18 @@ mod test {
|
|||
.unwrap();
|
||||
assert!(machine.should_upload_keys().await);
|
||||
|
||||
response.one_time_key_counts.insert(
|
||||
keys::KeyAlgorithm::SignedCurve25519,
|
||||
UInt::try_from(10).unwrap(),
|
||||
);
|
||||
response
|
||||
.one_time_key_counts
|
||||
.insert(keys::KeyAlgorithm::SignedCurve25519, uint!(10));
|
||||
machine
|
||||
.receive_keys_upload_response(&response)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(machine.should_upload_keys().await);
|
||||
|
||||
response.one_time_key_counts.insert(
|
||||
keys::KeyAlgorithm::SignedCurve25519,
|
||||
UInt::try_from(50).unwrap(),
|
||||
);
|
||||
response
|
||||
.one_time_key_counts
|
||||
.insert(keys::KeyAlgorithm::SignedCurve25519, uint!(50));
|
||||
machine
|
||||
.receive_keys_upload_response(&response)
|
||||
.await
|
||||
|
@ -1718,10 +1717,9 @@ mod test {
|
|||
assert!(machine.should_upload_keys().await);
|
||||
assert!(machine.generate_one_time_keys().await.is_ok());
|
||||
|
||||
response.one_time_key_counts.insert(
|
||||
keys::KeyAlgorithm::SignedCurve25519,
|
||||
UInt::try_from(50).unwrap(),
|
||||
);
|
||||
response
|
||||
.one_time_key_counts
|
||||
.insert(keys::KeyAlgorithm::SignedCurve25519, uint!(50));
|
||||
machine
|
||||
.receive_keys_upload_response(&response)
|
||||
.await
|
||||
|
@ -1829,7 +1827,7 @@ mod test {
|
|||
let mut response = keys_upload_response();
|
||||
response.one_time_key_counts.insert(
|
||||
keys::KeyAlgorithm::SignedCurve25519,
|
||||
UInt::new_wrapping(one_time_keys.unwrap().len() as u64),
|
||||
(one_time_keys.unwrap().len() as u64).try_into().unwrap(),
|
||||
);
|
||||
|
||||
machine
|
||||
|
|
Loading…
Reference in New Issue