Merge branch 'update-ruma'
commit
dedb1eb745
|
@ -1402,10 +1402,10 @@ impl Client {
|
||||||
sync_settings: SyncSettings<'_>,
|
sync_settings: SyncSettings<'_>,
|
||||||
) -> Result<sync_events::Response> {
|
) -> Result<sync_events::Response> {
|
||||||
let request = assign!(sync_events::Request::new(), {
|
let request = assign!(sync_events::Request::new(), {
|
||||||
filter: sync_settings.filter,
|
filter: sync_settings.filter.as_ref(),
|
||||||
since: sync_settings.token.as_deref(),
|
since: sync_settings.token.as_deref(),
|
||||||
full_state: sync_settings.full_state,
|
full_state: sync_settings.full_state,
|
||||||
set_presence: PresenceState::Online,
|
set_presence: &PresenceState::Online,
|
||||||
timeout: sync_settings.timeout,
|
timeout: sync_settings.timeout,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1496,13 +1496,11 @@ impl Client {
|
||||||
#[instrument(skip(callback))]
|
#[instrument(skip(callback))]
|
||||||
pub async fn sync_with_callback<C>(
|
pub async fn sync_with_callback<C>(
|
||||||
&self,
|
&self,
|
||||||
sync_settings: SyncSettings<'_>,
|
mut sync_settings: SyncSettings<'_>,
|
||||||
callback: impl Fn(sync_events::Response) -> C,
|
callback: impl Fn(sync_events::Response) -> C,
|
||||||
) where
|
) where
|
||||||
C: Future<Output = LoopCtrl>,
|
C: Future<Output = LoopCtrl>,
|
||||||
{
|
{
|
||||||
let mut sync_settings = sync_settings;
|
|
||||||
let filter = sync_settings.filter;
|
|
||||||
let mut last_sync_time: Option<Instant> = None;
|
let mut last_sync_time: Option<Instant> = None;
|
||||||
|
|
||||||
if sync_settings.token.is_none() {
|
if sync_settings.token.is_none() {
|
||||||
|
@ -1510,6 +1508,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
let filter = sync_settings.filter.clone();
|
||||||
let response = self.sync_once(sync_settings.clone()).await;
|
let response = self.sync_once(sync_settings.clone()).await;
|
||||||
|
|
||||||
let response = match response {
|
let response = match response {
|
||||||
|
@ -1577,8 +1576,8 @@ impl Client {
|
||||||
.await
|
.await
|
||||||
.expect("No sync token found after initial sync"),
|
.expect("No sync token found after initial sync"),
|
||||||
);
|
);
|
||||||
if let Some(f) = filter.as_ref() {
|
if let Some(f) = filter {
|
||||||
sync_settings = sync_settings.filter(*f);
|
sync_settings = sync_settings.filter(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2387,97 +2387,6 @@ mod test {
|
||||||
assert!(passed.load(Ordering::SeqCst))
|
assert!(passed.load(Ordering::SeqCst))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_test]
|
|
||||||
async fn test_unrecognized_custom_event() {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use crate::{EventEmitter, SyncRoom};
|
|
||||||
use matrix_sdk_common::{api::r0::sync::sync_events, locks::RwLock};
|
|
||||||
use std::sync::{
|
|
||||||
atomic::{AtomicBool, Ordering},
|
|
||||||
Arc,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EE(Arc<AtomicBool>);
|
|
||||||
#[async_trait]
|
|
||||||
impl EventEmitter for EE {
|
|
||||||
async fn on_custom_event(&self, room: SyncRoom, event: &CustomEvent<'_>) {
|
|
||||||
if let SyncRoom::Joined(_) = room {
|
|
||||||
if let CustomEvent::Message(custom) = event {
|
|
||||||
if custom.content.event_type == "m.reaction"
|
|
||||||
&& custom.content.json.get("m.relates_to").is_some()
|
|
||||||
{
|
|
||||||
self.0.swap(true, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let room_id = get_room_id();
|
|
||||||
let passed = Arc::new(AtomicBool::default());
|
|
||||||
let emitter = EE(Arc::clone(&passed));
|
|
||||||
let mut client = get_client().await;
|
|
||||||
|
|
||||||
client.event_emitter = Arc::new(RwLock::new(Some(Box::new(emitter))));
|
|
||||||
|
|
||||||
// This is needed other wise the `EventBuilder` goes through a de/ser cycle and the `prev_content` is lost.
|
|
||||||
let event: &serde_json::Value = &test_json::REACTION;
|
|
||||||
|
|
||||||
let mut joined_rooms: HashMap<RoomId, serde_json::Value> = HashMap::new();
|
|
||||||
let joined_room = serde_json::json!({
|
|
||||||
"summary": {},
|
|
||||||
"account_data": {
|
|
||||||
"events": [],
|
|
||||||
},
|
|
||||||
"ephemeral": {
|
|
||||||
"events": [],
|
|
||||||
},
|
|
||||||
"state": {
|
|
||||||
"events": [],
|
|
||||||
},
|
|
||||||
"timeline": {
|
|
||||||
"events": vec![ event ],
|
|
||||||
"limited": true,
|
|
||||||
"prev_batch": "t392-516_47314_0_7_1_1_1_11444_1"
|
|
||||||
},
|
|
||||||
"unread_notifications": {
|
|
||||||
"highlight_count": 0,
|
|
||||||
"notification_count": 11
|
|
||||||
}
|
|
||||||
});
|
|
||||||
joined_rooms.insert(room_id, joined_room);
|
|
||||||
|
|
||||||
let empty_room: HashMap<RoomId, serde_json::Value> = HashMap::new();
|
|
||||||
let body = serde_json::json!({
|
|
||||||
"device_one_time_keys_count": {},
|
|
||||||
"next_batch": "s526_47314_0_7_1_1_1_11444_1",
|
|
||||||
"device_lists": {
|
|
||||||
"changed": [],
|
|
||||||
"left": []
|
|
||||||
},
|
|
||||||
"rooms": {
|
|
||||||
"invite": empty_room,
|
|
||||||
"join": joined_rooms,
|
|
||||||
"leave": empty_room,
|
|
||||||
},
|
|
||||||
"to_device": {
|
|
||||||
"events": []
|
|
||||||
},
|
|
||||||
"presence": {
|
|
||||||
"events": []
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let response = http::Response::builder()
|
|
||||||
.body(serde_json::to_vec(&body).unwrap())
|
|
||||||
.unwrap();
|
|
||||||
let mut sync = sync_events::Response::try_from(response).unwrap();
|
|
||||||
|
|
||||||
client.receive_sync_response(&mut sync).await.unwrap();
|
|
||||||
|
|
||||||
assert!(passed.load(Ordering::SeqCst))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "messages")]
|
#[cfg(feature = "messages")]
|
||||||
#[async_test]
|
#[async_test]
|
||||||
async fn message_queue_redaction_event_store_deser() {
|
async fn message_queue_redaction_event_store_deser() {
|
||||||
|
|
|
@ -934,7 +934,7 @@ impl Room {
|
||||||
member.currently_active = *currently_active;
|
member.currently_active = *currently_active;
|
||||||
member.display_name = displayname.clone();
|
member.display_name = displayname.clone();
|
||||||
member.last_active_ago = *last_active_ago;
|
member.last_active_ago = *last_active_ago;
|
||||||
member.presence = Some(*presence);
|
member.presence = Some(presence.clone());
|
||||||
member.status_msg = status_msg.clone();
|
member.status_msg = status_msg.clone();
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
|
@ -21,7 +21,7 @@ js_int = "0.1.9"
|
||||||
[dependencies.ruma]
|
[dependencies.ruma]
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
git = "https://github.com/ruma/ruma"
|
git = "https://github.com/ruma/ruma"
|
||||||
rev = "50eb700571480d1440e15a387d10f98be8abab59"
|
rev = "d16fd4b2c1be1b06fd9be99373a3e77d74fadff3"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["client-api", "unstable-pre-spec", "unstable-synapse-quirks"]
|
features = ["client-api", "unstable-pre-spec", "unstable-synapse-quirks"]
|
||||||
|
|
||||||
|
|
|
@ -298,7 +298,7 @@ impl KeyRequestMachine {
|
||||||
&self,
|
&self,
|
||||||
event: &ToDeviceEvent<RoomKeyRequestEventContent>,
|
event: &ToDeviceEvent<RoomKeyRequestEventContent>,
|
||||||
) -> OlmResult<()> {
|
) -> OlmResult<()> {
|
||||||
let key_info = match event.content.action {
|
let key_info = match &event.content.action {
|
||||||
Action::Request => {
|
Action::Request => {
|
||||||
if let Some(info) = &event.content.body {
|
if let Some(info) = &event.content.body {
|
||||||
info
|
info
|
||||||
|
@ -313,9 +313,10 @@ impl KeyRequestMachine {
|
||||||
}
|
}
|
||||||
// We ignore cancellations here since there's nothing to serve.
|
// We ignore cancellations here since there's nothing to serve.
|
||||||
Action::CancelRequest => return Ok(()),
|
Action::CancelRequest => return Ok(()),
|
||||||
// There is no other action defined, but ruma makes all enums
|
action => {
|
||||||
// non-exhaustive.
|
warn!("Unknown room key request action: {:?}", action);
|
||||||
_ => return Ok(()),
|
return Ok(());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let session = self
|
let session = self
|
||||||
|
|
Loading…
Reference in New Issue