Update state-res, use the new Event trait
This also bumps ruma to latest and removes js_int infavor of the ruma re-export
This commit is contained in:
parent
690c066064
commit
9e83d2b2d5
11 changed files with 252 additions and 184 deletions
|
@ -124,7 +124,7 @@ pub async fn get_room_visibility_route(
|
|||
pub async fn get_public_rooms_filtered_helper(
|
||||
db: &Database,
|
||||
server: Option<&ServerName>,
|
||||
limit: Option<js_int::UInt>,
|
||||
limit: Option<ruma::UInt>,
|
||||
since: Option<&str>,
|
||||
filter: &IncomingFilter,
|
||||
_network: &IncomingRoomNetwork,
|
||||
|
|
|
@ -131,7 +131,7 @@ pub async fn get_content_thumbnail_route(
|
|||
allow_remote: false,
|
||||
height: body.height,
|
||||
width: body.width,
|
||||
method: body.method,
|
||||
method: body.method.clone(),
|
||||
server_name: &body.server_name,
|
||||
media_id: &body.media_id,
|
||||
},
|
||||
|
|
|
@ -21,7 +21,7 @@ use ruma::{
|
|||
serde::{to_canonical_value, CanonicalJsonObject, Raw},
|
||||
EventId, RoomId, RoomVersionId, ServerName, UserId,
|
||||
};
|
||||
use state_res::StateEvent;
|
||||
use state_res::Event;
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
convert::TryFrom,
|
||||
|
@ -594,19 +594,19 @@ async fn join_room_by_id_helper(
|
|||
.chain(iter::once(Ok((event_id, join_event)))) // Add join event we just created
|
||||
.map(|r| {
|
||||
let (event_id, value) = r?;
|
||||
state_res::StateEvent::from_id_canon_obj(event_id.clone(), value.clone())
|
||||
PduEvent::from_id_val(&event_id, value.clone())
|
||||
.map(|ev| (event_id, Arc::new(ev)))
|
||||
.map_err(|e| {
|
||||
warn!("{:?}: {}", value, e);
|
||||
Error::BadServerResponse("Invalid PDU in send_join response.")
|
||||
})
|
||||
})
|
||||
.collect::<Result<BTreeMap<EventId, Arc<StateEvent>>>>()?;
|
||||
.collect::<Result<BTreeMap<EventId, Arc<PduEvent>>>>()?;
|
||||
|
||||
let control_events = event_map
|
||||
.values()
|
||||
.filter(|pdu| pdu.is_power_event())
|
||||
.map(|pdu| pdu.event_id())
|
||||
.filter(|pdu| state_res::is_power_event(pdu))
|
||||
.map(|pdu| pdu.event_id.clone())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// These events are not guaranteed to be sorted but they are resolved according to spec
|
||||
|
@ -646,7 +646,8 @@ async fn join_room_by_id_helper(
|
|||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let power_level = resolved_control_events.get(&(EventType::RoomPowerLevels, "".into()));
|
||||
let power_level =
|
||||
resolved_control_events.get(&(EventType::RoomPowerLevels, Some("".to_string())));
|
||||
// Sort the remaining non control events
|
||||
let sorted_event_ids = state_res::StateResolution::mainline_sort(
|
||||
room_id,
|
||||
|
@ -685,8 +686,13 @@ async fn join_room_by_id_helper(
|
|||
pdu_id.push(0xff);
|
||||
pdu_id.extend_from_slice(&count.to_be_bytes());
|
||||
db.rooms.append_pdu(
|
||||
<<<<<<< HEAD
|
||||
&PduEvent::from(&**pdu),
|
||||
utils::to_canonical_object(&**pdu).expect("Pdu is valid canonical object"),
|
||||
=======
|
||||
&pdu,
|
||||
&utils::to_canonical_object(&**pdu).expect("Pdu is valid canonical object"),
|
||||
>>>>>>> 6232d1f (Update state-res, use the new Event trait)
|
||||
count,
|
||||
pdu_id.clone().into(),
|
||||
&db.globals,
|
||||
|
@ -695,7 +701,9 @@ async fn join_room_by_id_helper(
|
|||
)?;
|
||||
|
||||
if state_events.contains(ev_id) {
|
||||
state.insert((pdu.kind(), pdu.state_key()), pdu_id);
|
||||
if let Some(key) = &pdu.state_key {
|
||||
state.insert((pdu.kind(), key.to_string()), pdu_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@ use ruma::{
|
|||
events::EventContent,
|
||||
EventId,
|
||||
};
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
convert::{TryFrom, TryInto},
|
||||
};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
use rocket::{get, put};
|
||||
|
@ -46,7 +49,7 @@ pub async fn send_message_event_route(
|
|||
return Ok(send_message_event::Response { event_id }.into());
|
||||
}
|
||||
|
||||
let mut unsigned = serde_json::Map::new();
|
||||
let mut unsigned = BTreeMap::new();
|
||||
unsigned.insert("transaction_id".to_owned(), body.txn_id.clone().into());
|
||||
|
||||
let event_id = db.rooms.build_and_append_pdu(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue