use ruma_common::{
OwnedEventId, OwnedRoomId,
api::{request, response},
metadata,
};
use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue;
use crate::authentication::ServerSignatures;
metadata! {
method: PUT,
rate_limited: false,
authentication: ServerSignatures,
path: "/_matrix/federation/v2/send_join/{room_id}/{event_id}",
}
#[request]
pub struct Request {
#[ruma_api(path)]
pub room_id: OwnedRoomId,
#[ruma_api(path)]
pub event_id: OwnedEventId,
#[ruma_api(body)]
pub pdu: Box<RawJsonValue>,
#[ruma_api(query)]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub omit_members: bool,
}
#[response]
pub struct Response {
#[ruma_api(body)]
pub room_state: RoomState,
}
impl Request {
pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId, pdu: Box<RawJsonValue>) -> Self {
Self { room_id, event_id, pdu, omit_members: false }
}
}
impl Response {
pub fn new(room_state: RoomState) -> Self {
Self { room_state }
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
pub struct RoomState {
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub members_omitted: bool,
pub auth_chain: Vec<Box<RawJsonValue>>,
pub state: Vec<Box<RawJsonValue>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub event: Option<Box<RawJsonValue>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub servers_in_room: Option<Vec<String>>,
}
impl RoomState {
pub fn new() -> Self {
Self::default()
}
}