remove unnecessary "unsupported room version" error on PDU processing to allow custom room versions properly
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
c40ed0c98e
commit
826b1d1d62
5 changed files with 9 additions and 60 deletions
|
@ -819,7 +819,7 @@ async fn join_room_by_id_helper_remote(
|
|||
},
|
||||
// only room versions 8 and above using `join_authorized_via_users_server` (restricted joins) need to
|
||||
// validate and send signatures
|
||||
V8 | V9 | V10 | V11 => {
|
||||
_ => {
|
||||
if let Some(signed_raw) = &send_join_response.room_state.event {
|
||||
info!(
|
||||
"There is a signed event. This room is probably using restricted joins. Adding signature to \
|
||||
|
@ -868,16 +868,6 @@ async fn join_room_by_id_helper_remote(
|
|||
}
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
warn!(
|
||||
"Unexpected or unsupported room version {} for room {}",
|
||||
&room_version_id, room_id
|
||||
);
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Unexpected or unsupported room version found",
|
||||
));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,13 +139,8 @@ pub(crate) async fn create_room_route(
|
|||
})?,
|
||||
);
|
||||
},
|
||||
V11 => {}, // V11 removed the "creator" key
|
||||
_ => {
|
||||
warn!("Unexpected or unsupported room version {room_version}");
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Unexpected or unsupported room version found",
|
||||
));
|
||||
// V11+ removed the "creator" key
|
||||
},
|
||||
}
|
||||
content.insert(
|
||||
|
@ -161,14 +156,7 @@ pub(crate) async fn create_room_route(
|
|||
|
||||
let content = match room_version {
|
||||
V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 => RoomCreateEventContent::new_v1(sender_user.clone()),
|
||||
V11 => RoomCreateEventContent::new_v11(),
|
||||
_ => {
|
||||
warn!("Unexpected or unsupported room version {room_version}");
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Unexpected or unsupported room version found",
|
||||
));
|
||||
},
|
||||
_ => RoomCreateEventContent::new_v11(),
|
||||
};
|
||||
let mut content = serde_json::from_str::<CanonicalJsonObject>(
|
||||
to_raw_value(&content)
|
||||
|
@ -634,16 +622,9 @@ pub(crate) async fn upgrade_room_route(
|
|||
})?,
|
||||
);
|
||||
},
|
||||
V11 => {
|
||||
// "creator" key no longer exists in V11 rooms
|
||||
create_event_content.remove("creator");
|
||||
},
|
||||
_ => {
|
||||
warn!("Unexpected or unsupported room version {}", body.new_version);
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Unexpected or unsupported room version found",
|
||||
));
|
||||
// "creator" key no longer exists in V11+ rooms
|
||||
create_event_content.remove("creator");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,15 +222,8 @@ pub(crate) fn maybe_strip_event_id(pdu_json: &mut CanonicalJsonObject, room_vers
|
|||
|
||||
match room_version_id {
|
||||
V1 | V2 => {},
|
||||
V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 | V11 => {
|
||||
pdu_json.remove("event_id");
|
||||
},
|
||||
_ => {
|
||||
warn!("Unexpected or unsupported room version {room_version_id}");
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Unexpected or unsupported room version found",
|
||||
));
|
||||
pdu_json.remove("event_id");
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use conduit::{pdu::PduBuilder, warn, Error, Result};
|
||||
use conduit::{pdu::PduBuilder, Result};
|
||||
use ruma::{
|
||||
api::client::error::ErrorKind,
|
||||
events::{
|
||||
room::{
|
||||
canonical_alias::RoomCanonicalAliasEventContent,
|
||||
|
@ -45,14 +44,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
|
|||
use RoomVersionId::*;
|
||||
match room_version {
|
||||
V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 => RoomCreateEventContent::new_v1(server_user.clone()),
|
||||
V11 => RoomCreateEventContent::new_v11(),
|
||||
_ => {
|
||||
warn!("Unexpected or unsupported room version {}", room_version);
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Unexpected or unsupported room version found",
|
||||
));
|
||||
},
|
||||
_ => RoomCreateEventContent::new_v11(),
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -449,7 +449,7 @@ impl Service {
|
|||
}
|
||||
}
|
||||
},
|
||||
V11 => {
|
||||
_ => {
|
||||
let content =
|
||||
serde_json::from_str::<RoomRedactionEventContent>(pdu.content.get()).map_err(|e| {
|
||||
warn!("Invalid content in redaction pdu: {e}");
|
||||
|
@ -467,13 +467,6 @@ impl Service {
|
|||
}
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
warn!("Unexpected or unsupported room version {room_version_id}");
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Unexpected or unsupported room version found",
|
||||
));
|
||||
},
|
||||
};
|
||||
},
|
||||
TimelineEventType::SpaceChild => {
|
||||
|
|
Loading…
Add table
Reference in a new issue