simplify get_pdu() interface; eliminate unconditional Arc
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
58be22e695
commit
6175e72f1c
16 changed files with 51 additions and 52 deletions
|
@ -103,7 +103,7 @@ pub(crate) async fn get_context_route(
|
|||
.collect()
|
||||
.await;
|
||||
|
||||
let lazy = once(&(base_token, (*base_event).clone()))
|
||||
let lazy = once(&(base_token, base_event.clone()))
|
||||
.chain(events_before.iter())
|
||||
.chain(events_after.iter())
|
||||
.stream()
|
||||
|
|
|
@ -137,7 +137,7 @@ pub(crate) async fn report_event_route(
|
|||
/// check if reporting user is in the reporting room
|
||||
async fn is_event_report_valid(
|
||||
services: &Services, event_id: &EventId, room_id: &RoomId, sender_user: &UserId, reason: Option<&String>,
|
||||
score: Option<ruma::Int>, pdu: &std::sync::Arc<PduEvent>,
|
||||
score: Option<ruma::Int>, pdu: &PduEvent,
|
||||
) -> Result<()> {
|
||||
debug_info!("Checking if report from user {sender_user} for event {event_id} in room {room_id} is valid");
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ pub(crate) async fn get_room_event_route(
|
|||
event: services
|
||||
.rooms
|
||||
.timeline
|
||||
.get_pdu_owned(&body.event_id)
|
||||
.get_pdu(&body.event_id)
|
||||
.map_err(|_| err!(Request(NotFound("Event {} not found.", &body.event_id))))
|
||||
.and_then(|event| async move {
|
||||
services
|
||||
|
|
|
@ -181,11 +181,7 @@ async fn procure_room_state(services: &Services, room_id: &RoomId) -> Result<Roo
|
|||
.room_state_full(room_id)
|
||||
.await?;
|
||||
|
||||
let state_events = state_map
|
||||
.values()
|
||||
.map(AsRef::as_ref)
|
||||
.map(PduEvent::to_state_event)
|
||||
.collect();
|
||||
let state_events = state_map.values().map(PduEvent::to_state_event).collect();
|
||||
|
||||
Ok(state_events)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use axum::extract::State;
|
||||
use conduit::{err, pdu::PduBuilder, utils::BoolExt, Err, Error, Result};
|
||||
use conduit::{err, pdu::PduBuilder, utils::BoolExt, Err, Error, PduEvent, Result};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -97,7 +97,7 @@ pub(crate) async fn get_state_events_route(
|
|||
.room_state_full(&body.room_id)
|
||||
.await?
|
||||
.values()
|
||||
.map(|pdu| pdu.to_state_event())
|
||||
.map(PduEvent::to_state_event)
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1021,7 +1021,7 @@ async fn load_joined_room(
|
|||
state: RoomState {
|
||||
events: state_events
|
||||
.iter()
|
||||
.map(|pdu| pdu.to_sync_state_event())
|
||||
.map(PduEvent::to_sync_state_event)
|
||||
.collect(),
|
||||
},
|
||||
ephemeral: Ephemeral {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue