refactor various Arc<EventId> to OwnedEventId

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-12-28 00:57:02 +00:00 committed by strawberry
parent 5a335933b8
commit 6458f4b195
29 changed files with 142 additions and 152 deletions

View file

@ -24,7 +24,7 @@ pub(crate) async fn redact_event_route(
.timeline
.build_and_append_pdu(
PduBuilder {
redacts: Some(body.event_id.clone().into()),
redacts: Some(body.event_id.clone()),
..PduBuilder::timeline(&RoomRedactionEventContent {
redacts: Some(body.event_id.clone()),
reason: body.reason.clone(),
@ -38,5 +38,5 @@ pub(crate) async fn redact_event_route(
drop(state_lock);
Ok(redact_event::v3::Response { event_id: event_id.into() })
Ok(redact_event::v3::Response { event_id })
}

View file

@ -92,5 +92,5 @@ pub(crate) async fn send_message_event_route(
drop(state_lock);
Ok(send_message_event::v3::Response { event_id: event_id.into() })
Ok(send_message_event::v3::Response { event_id })
}

View file

@ -1,5 +1,3 @@
use std::sync::Arc;
use axum::extract::State;
use conduwuit::{err, pdu::PduBuilder, utils::BoolExt, Err, Error, PduEvent, Result};
use ruma::{
@ -16,7 +14,7 @@ use ruma::{
AnyStateEventContent, StateEventType,
},
serde::Raw,
EventId, RoomId, UserId,
OwnedEventId, RoomId, UserId,
};
use service::Services;
@ -50,8 +48,7 @@ pub(crate) async fn send_state_event_for_key_route(
None
},
)
.await?
.into(),
.await?,
})
}
@ -177,7 +174,7 @@ async fn send_state_event_for_key_helper(
json: &Raw<AnyStateEventContent>,
state_key: String,
timestamp: Option<ruma::MilliSecondsSinceUnixEpoch>,
) -> Result<Arc<EventId>> {
) -> Result<OwnedEventId> {
allowed_to_send_state_event(services, room_id, event_type, json).await?;
let state_lock = services.rooms.state.mutex.lock(room_id).await;
let event_id = services

View file

@ -441,7 +441,7 @@ async fn handle_left_room(
// This is just a rejected invite, not a room we know
// Insert a leave event anyways
let event = PduEvent {
event_id: EventId::new(services.globals.server_name()).into(),
event_id: EventId::new(services.globals.server_name()),
sender: sender_user.to_owned(),
origin: None,
origin_server_ts: utils::millis_since_unix_epoch()

View file

@ -6,7 +6,7 @@ use conduwuit::{
debug, debug_warn, err, error, result::LogErr, trace, utils::ReadyExt, warn, Err, Error,
Result,
};
use futures::StreamExt;
use futures::{FutureExt, StreamExt};
use ruma::{
api::{
client::error::ErrorKind,
@ -74,8 +74,13 @@ pub(crate) async fn send_transaction_message_route(
);
let resolved_map =
handle_pdus(&services, &client, &body.pdus, body.origin(), &txn_start_time).await?;
handle_edus(&services, &client, &body.edus, body.origin()).await;
handle_pdus(&services, &client, &body.pdus, body.origin(), &txn_start_time)
.boxed()
.await?;
handle_edus(&services, &client, &body.edus, body.origin())
.boxed()
.await;
debug!(
pdus = ?body.pdus.len(),

View file

@ -2,6 +2,7 @@
use axum::extract::State;
use conduwuit::{err, Err, Result};
use futures::FutureExt;
use ruma::{
api::federation::membership::create_leave_event,
events::{
@ -154,10 +155,15 @@ async fn create_leave_event(
.rooms
.event_handler
.handle_incoming_pdu(origin, room_id, &event_id, value, true)
.boxed()
.await?
.ok_or_else(|| err!(Request(InvalidParam("Could not accept as timeline event."))))?;
drop(mutex_lock);
services.sending.send_pdu_room(room_id, &pdu_id).await
services
.sending
.send_pdu_room(room_id, &pdu_id)
.boxed()
.await
}