mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
generalize get_room_version
There are other fields of `m.room.create` events that are useful to individually extract without caring about the values of other fields.
This commit is contained in:
parent
c9c30fba30
commit
a4e1522875
4 changed files with 69 additions and 24 deletions
|
|
@ -72,6 +72,7 @@ use crate::{
|
|||
service::{
|
||||
globals::SigningKeys,
|
||||
pdu::{gen_event_id_canonical_json, PduBuilder},
|
||||
rooms::state::ExtractVersion,
|
||||
},
|
||||
services,
|
||||
utils::{self, dbg_truncate_str, MxcData},
|
||||
|
|
@ -712,7 +713,10 @@ pub(crate) fn parse_incoming_pdu(
|
|||
"Invalid room id in pdu",
|
||||
))?;
|
||||
|
||||
let room_version_id = services().rooms.state.get_room_version(&room_id)?;
|
||||
let room_version_id = services()
|
||||
.rooms
|
||||
.state
|
||||
.get_create_content::<ExtractVersion>(&room_id)?;
|
||||
|
||||
let Ok((event_id, value)) =
|
||||
gen_event_id_canonical_json(pdu, &room_version_id)
|
||||
|
|
@ -754,7 +758,12 @@ pub(crate) async fn send_transaction_message_route(
|
|||
"Invalid room id in pdu",
|
||||
))?;
|
||||
|
||||
if services().rooms.state.get_room_version(&room_id).is_err() {
|
||||
if services()
|
||||
.rooms
|
||||
.state
|
||||
.get_create_content::<ExtractVersion>(&room_id)
|
||||
.is_err()
|
||||
{
|
||||
debug!(%room_id, "This server is not in the room");
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1514,8 +1523,10 @@ pub(crate) async fn create_join_event_template_route(
|
|||
}
|
||||
}
|
||||
|
||||
let room_version_id =
|
||||
services().rooms.state.get_room_version(&body.room_id)?;
|
||||
let room_version_id = services()
|
||||
.rooms
|
||||
.state
|
||||
.get_create_content::<ExtractVersion>(&body.room_id)?;
|
||||
if !body.ver.contains(&room_version_id) {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::IncompatibleRoomVersion {
|
||||
|
|
@ -1620,7 +1631,8 @@ async fn create_join_event(
|
|||
|
||||
// We do not add the event_id field to the pdu here because of signature and
|
||||
// hashes checks
|
||||
let room_version_id = services().rooms.state.get_room_version(room_id)?;
|
||||
let room_version_id =
|
||||
services().rooms.state.get_create_content::<ExtractVersion>(room_id)?;
|
||||
let Ok((event_id, value)) =
|
||||
gen_event_id_canonical_json(pdu, &room_version_id)
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue