1
0
Fork 0
forked from mirror/grapevine

server_server: use non-deprecated create_join_event types

Instead of working with v1 types and converting them to v2 as required,
do it the other way around. Allows us to remove a very broad
#[allow(deprecated)].
This commit is contained in:
Lambda 2024-09-01 11:32:45 +00:00
parent be14f5bddc
commit 542e097cdf

View file

@ -1,5 +1,3 @@
#![allow(deprecated)]
use std::{
collections::BTreeMap,
fmt::Debug,
@ -1543,7 +1541,7 @@ async fn create_join_event(
sender_servername: &ServerName,
room_id: &RoomId,
pdu: &RawJsonValue,
) -> Result<create_join_event::v1::RoomState> {
) -> Result<create_join_event::v2::RoomState> {
if !services().rooms.metadata.exists(room_id)? {
return Err(Error::BadRequest(
ErrorKind::NotFound,
@ -1659,7 +1657,7 @@ async fn create_join_event(
services().sending.send_pdu(servers, &pdu_id)?;
Ok(create_join_event::v1::RoomState {
Ok(create_join_event::v2::RoomState {
auth_chain: auth_chain_ids
.filter_map(|id| {
services().rooms.timeline.get_pdu_json(&id).ok().flatten()
@ -1675,20 +1673,32 @@ async fn create_join_event(
.collect(),
// TODO: handle restricted joins
event: None,
members_omitted: false,
servers_in_room: None,
})
}
/// # `PUT /_matrix/federation/v1/send_join/{roomId}/{eventId}`
///
/// Submits a signed join event.
#[allow(deprecated)]
pub(crate) async fn create_join_event_v1_route(
body: Ar<create_join_event::v1::Request>,
) -> Result<Ra<create_join_event::v1::Response>> {
let sender_servername =
body.sender_servername.as_ref().expect("server is authenticated");
let room_state =
create_join_event(sender_servername, &body.room_id, &body.pdu).await?;
let create_join_event::v2::RoomState {
auth_chain,
state,
event,
..
} = create_join_event(sender_servername, &body.room_id, &body.pdu).await?;
let room_state = create_join_event::v1::RoomState {
auth_chain,
state,
event,
};
Ok(Ra(create_join_event::v1::Response {
room_state,
@ -1704,18 +1714,8 @@ pub(crate) async fn create_join_event_v2_route(
let sender_servername =
body.sender_servername.as_ref().expect("server is authenticated");
let create_join_event::v1::RoomState {
auth_chain,
state,
event,
} = create_join_event(sender_servername, &body.room_id, &body.pdu).await?;
let room_state = create_join_event::v2::RoomState {
members_omitted: false,
auth_chain,
state,
event,
servers_in_room: None,
};
let room_state =
create_join_event(sender_servername, &body.room_id, &body.pdu).await?;
Ok(Ra(create_join_event::v2::Response {
room_state,