Bump ruma and fix failing unrecognized_event test

The test was broken because the JSON being fed into it was bad.
master
Devin Ragotzy 2020-08-03 19:53:44 -04:00
parent 807432b31f
commit 47690bd268
2 changed files with 17 additions and 9 deletions

View File

@ -2201,7 +2201,7 @@ mod test {
use super::*; use super::*;
use crate::{EventEmitter, SyncRoom}; use crate::{EventEmitter, SyncRoom};
use matrix_sdk_common::locks::RwLock; use matrix_sdk_common::{events::EventContent, locks::RwLock};
use std::sync::{ use std::sync::{
atomic::{AtomicBool, Ordering}, atomic::{AtomicBool, Ordering},
Arc, Arc,
@ -2212,11 +2212,8 @@ mod test {
impl EventEmitter for EE { impl EventEmitter for EE {
async fn on_unrecognized_event(&self, room: SyncRoom, event: &CustomOrRawEvent<'_>) { async fn on_unrecognized_event(&self, room: SyncRoom, event: &CustomOrRawEvent<'_>) {
if let SyncRoom::Joined(_) = room { if let SyncRoom::Joined(_) = room {
if let CustomOrRawEvent::RawJson(raw) = event { if let CustomOrRawEvent::Message(event) = event {
let val = serde_json::to_value(raw).unwrap(); if event.content.event_type() == "m.room.not_real" {
if val.get("type").unwrap() == &json! { "m.room.message" }
&& val.get("content").unwrap().get("m.relates_to").is_some()
{
self.0.swap(true, Ordering::SeqCst); self.0.swap(true, Ordering::SeqCst);
} }
} }
@ -2232,7 +2229,18 @@ mod test {
client.event_emitter = Arc::new(RwLock::new(Some(Box::new(emitter)))); 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. // 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::MESSAGE_EDIT; let event = json!({
"content": {
"whatever": "you want"
},
"event_id": "$eventid:foo",
"origin_server_ts": 159026265,
"sender": "@alice:matrix.org",
"type": "m.room.not_real",
"unsigned": {
"age": 85
}
});
let mut joined_rooms: HashMap<RoomId, serde_json::Value> = HashMap::new(); let mut joined_rooms: HashMap<RoomId, serde_json::Value> = HashMap::new();
let joined_room = serde_json::json!({ let joined_room = serde_json::json!({

View File

@ -269,12 +269,12 @@ lazy_static! {
"msgtype": "m.text" "msgtype": "m.text"
}, },
"m.relates_to": { "m.relates_to": {
"event_id": "some event id", "event_id": "$someeventid:foo",
"rel_type": "m.replace" "rel_type": "m.replace"
}, },
"msgtype": "m.text" "msgtype": "m.text"
}, },
"event_id": "edit event id", "event_id": "$eventid:foo",
"origin_server_ts": 159026265, "origin_server_ts": 159026265,
"sender": "@alice:matrix.org", "sender": "@alice:matrix.org",
"type": "m.room.message", "type": "m.room.message",