|
|
@ -981,6 +981,8 @@ async fn join_room_by_id_helper(
|
|
|
|
.as_str()
|
|
|
|
.as_str()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.and_then(|s| OwnedUserId::try_from(s.unwrap_or_default()).ok());
|
|
|
|
.and_then(|s| OwnedUserId::try_from(s.unwrap_or_default()).ok());
|
|
|
|
|
|
|
|
let restricted_join = join_authorized_via_users_server.is_some();
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Is origin needed?
|
|
|
|
// TODO: Is origin needed?
|
|
|
|
join_event_stub.insert(
|
|
|
|
join_event_stub.insert(
|
|
|
|
"origin".to_owned(),
|
|
|
|
"origin".to_owned(),
|
|
|
@ -1027,7 +1029,7 @@ async fn join_room_by_id_helper(
|
|
|
|
ruma::signatures::reference_hash(&join_event_stub, &room_version_id)
|
|
|
|
ruma::signatures::reference_hash(&join_event_stub, &room_version_id)
|
|
|
|
.expect("ruma can calculate reference hashes")
|
|
|
|
.expect("ruma can calculate reference hashes")
|
|
|
|
);
|
|
|
|
);
|
|
|
|
let event_id = <&EventId>::try_from(event_id.as_str())
|
|
|
|
let event_id = OwnedEventId::try_from(event_id)
|
|
|
|
.expect("ruma's reference hashes are valid event ids");
|
|
|
|
.expect("ruma's reference hashes are valid event ids");
|
|
|
|
|
|
|
|
|
|
|
|
// Add event_id back
|
|
|
|
// Add event_id back
|
|
|
@ -1052,46 +1054,35 @@ async fn join_room_by_id_helper(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(signed_raw) = send_join_response.room_state.event {
|
|
|
|
let pdu = if let Some(signed_raw) = send_join_response.room_state.event {
|
|
|
|
let (signed_event_id, signed_value) =
|
|
|
|
let (signed_event_id, signed_pdu) =
|
|
|
|
match gen_event_id_canonical_json(&signed_raw, &room_version_id) {
|
|
|
|
gen_event_id_canonical_json(&signed_raw, &room_version_id)?;
|
|
|
|
Ok(t) => t,
|
|
|
|
|
|
|
|
Err(_) => {
|
|
|
|
|
|
|
|
// Event could not be converted to canonical json
|
|
|
|
|
|
|
|
return Err(Error::BadRequest(
|
|
|
|
|
|
|
|
ErrorKind::InvalidParam,
|
|
|
|
|
|
|
|
"Could not convert event to canonical json.",
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if signed_event_id != event_id {
|
|
|
|
if signed_event_id != event_id {
|
|
|
|
return Err(Error::BadRequest(
|
|
|
|
return Err(Error::BadServerResponse(
|
|
|
|
ErrorKind::InvalidParam,
|
|
|
|
|
|
|
|
"Server sent event with wrong event id",
|
|
|
|
"Server sent event with wrong event id",
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
signed_pdu
|
|
|
|
|
|
|
|
} else if restricted_join {
|
|
|
|
|
|
|
|
return Err(Error::BadServerResponse(
|
|
|
|
|
|
|
|
"No signed event was returned, despite just performing a restricted join",
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
join_event
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
drop(state_lock);
|
|
|
|
drop(state_lock);
|
|
|
|
let pub_key_map = RwLock::new(BTreeMap::new());
|
|
|
|
let pub_key_map = RwLock::new(BTreeMap::new());
|
|
|
|
services()
|
|
|
|
services()
|
|
|
|
.rooms
|
|
|
|
.rooms
|
|
|
|
.event_handler
|
|
|
|
.event_handler
|
|
|
|
.handle_incoming_pdu(
|
|
|
|
.handle_incoming_pdu(&remote_server, &event_id, room_id, pdu, true, &pub_key_map)
|
|
|
|
&remote_server,
|
|
|
|
|
|
|
|
&signed_event_id,
|
|
|
|
|
|
|
|
room_id,
|
|
|
|
|
|
|
|
signed_value,
|
|
|
|
|
|
|
|
true,
|
|
|
|
|
|
|
|
&pub_key_map,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.await?;
|
|
|
|
.await?;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return Err(error);
|
|
|
|
return Err(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Err(error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Ok(join_room_by_id::v3::Response::new(room_id.to_owned()))
|
|
|
|
Ok(join_room_by_id::v3::Response::new(room_id.to_owned()))
|
|
|
|