Use struct literals for consistency

This commit is contained in:
Jonas Platte 2022-01-13 11:48:18 +01:00
parent 349865d3cc
commit cf54185a1c
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
3 changed files with 29 additions and 27 deletions

View File

@ -92,18 +92,19 @@ pub async fn get_context_route(
.map(|(_, pdu)| pdu.to_room_event()) .map(|(_, pdu)| pdu.to_room_event())
.collect(); .collect();
let mut resp = get_context::Response::new(); let resp = get_context::Response {
resp.start = start_token; start: start_token,
resp.end = end_token; end: end_token,
resp.events_before = events_before; events_before,
resp.event = Some(base_event); event: Some(base_event),
resp.events_after = events_after; events_after,
resp.state = db // TODO: State at event state: db // TODO: State at event
.rooms .rooms
.room_state_full(&body.room_id)? .room_state_full(&body.room_id)?
.values() .values()
.map(|pdu| pdu.to_state_event()) .map(|pdu| pdu.to_state_event())
.collect(); .collect(),
};
Ok(resp.into()) Ok(resp.into())
} }

View File

@ -159,11 +159,12 @@ pub async fn get_message_events_route(
.map(|(_, pdu)| pdu.to_room_event()) .map(|(_, pdu)| pdu.to_room_event())
.collect(); .collect();
let mut resp = get_message_events::Response::new(); let resp = get_message_events::Response {
resp.start = body.from.to_owned(); start: body.from.to_owned(),
resp.end = end_token; end: end_token,
resp.chunk = events_after; chunk: events_after,
resp.state = Vec::new(); state: Vec::new(),
};
Ok(resp.into()) Ok(resp.into())
} }
@ -189,11 +190,12 @@ pub async fn get_message_events_route(
.map(|(_, pdu)| pdu.to_room_event()) .map(|(_, pdu)| pdu.to_room_event())
.collect(); .collect();
let mut resp = get_message_events::Response::new(); let resp = get_message_events::Response {
resp.start = body.from.to_owned(); start: body.from.to_owned(),
resp.end = start_token; end: start_token,
resp.chunk = events_before; chunk: events_before,
resp.state = Vec::new(); state: Vec::new(),
};
Ok(resp.into()) Ok(resp.into())
} }

View File

@ -17,11 +17,10 @@ use rocket::get;
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/versions"))] #[cfg_attr(feature = "conduit_bin", get("/_matrix/client/versions"))]
#[tracing::instrument] #[tracing::instrument]
pub async fn get_supported_versions_route() -> ConduitResult<get_supported_versions::Response> { pub async fn get_supported_versions_route() -> ConduitResult<get_supported_versions::Response> {
let mut resp = let resp = get_supported_versions::Response {
get_supported_versions::Response::new(vec!["r0.5.0".to_owned(), "r0.6.0".to_owned()]); versions: vec!["r0.5.0".to_owned(), "r0.6.0".to_owned()],
unstable_features: [("org.matrix.e2e_cross_signing".to_owned(), true)].into(),
resp.unstable_features };
.insert("org.matrix.e2e_cross_signing".to_owned(), true);
Ok(resp.into()) Ok(resp.into())
} }