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
|
// only room versions 8 and above using `join_authorized_via_users_server` (restricted joins) need to
|
||||||
// validate and send signatures
|
// validate and send signatures
|
||||||
V8 | V9 | V10 | V11 => {
|
_ => {
|
||||||
if let Some(signed_raw) = &send_join_response.room_state.event {
|
if let Some(signed_raw) = &send_join_response.room_state.event {
|
||||||
info!(
|
info!(
|
||||||
"There is a signed event. This room is probably using restricted joins. Adding signature to \
|
"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}");
|
// V11+ removed the "creator" key
|
||||||
return Err(Error::BadRequest(
|
|
||||||
ErrorKind::BadJson,
|
|
||||||
"Unexpected or unsupported room version found",
|
|
||||||
));
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
content.insert(
|
content.insert(
|
||||||
|
@ -161,14 +156,7 @@ pub(crate) async fn create_room_route(
|
||||||
|
|
||||||
let content = match room_version {
|
let content = match room_version {
|
||||||
V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 => RoomCreateEventContent::new_v1(sender_user.clone()),
|
V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 => RoomCreateEventContent::new_v1(sender_user.clone()),
|
||||||
V11 => RoomCreateEventContent::new_v11(),
|
_ => RoomCreateEventContent::new_v11(),
|
||||||
_ => {
|
|
||||||
warn!("Unexpected or unsupported room version {room_version}");
|
|
||||||
return Err(Error::BadRequest(
|
|
||||||
ErrorKind::BadJson,
|
|
||||||
"Unexpected or unsupported room version found",
|
|
||||||
));
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
let mut content = serde_json::from_str::<CanonicalJsonObject>(
|
let mut content = serde_json::from_str::<CanonicalJsonObject>(
|
||||||
to_raw_value(&content)
|
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);
|
// "creator" key no longer exists in V11+ rooms
|
||||||
return Err(Error::BadRequest(
|
create_event_content.remove("creator");
|
||||||
ErrorKind::BadJson,
|
|
||||||
"Unexpected or unsupported room version found",
|
|
||||||
));
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,15 +222,8 @@ pub(crate) fn maybe_strip_event_id(pdu_json: &mut CanonicalJsonObject, room_vers
|
||||||
|
|
||||||
match room_version_id {
|
match room_version_id {
|
||||||
V1 | V2 => {},
|
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}");
|
pdu_json.remove("event_id");
|
||||||
return Err(Error::BadRequest(
|
|
||||||
ErrorKind::BadJson,
|
|
||||||
"Unexpected or unsupported room version found",
|
|
||||||
));
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use conduit::{pdu::PduBuilder, warn, Error, Result};
|
use conduit::{pdu::PduBuilder, Result};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::error::ErrorKind,
|
|
||||||
events::{
|
events::{
|
||||||
room::{
|
room::{
|
||||||
canonical_alias::RoomCanonicalAliasEventContent,
|
canonical_alias::RoomCanonicalAliasEventContent,
|
||||||
|
@ -45,14 +44,7 @@ pub async fn create_admin_room(services: &Services) -> Result<()> {
|
||||||
use RoomVersionId::*;
|
use RoomVersionId::*;
|
||||||
match room_version {
|
match room_version {
|
||||||
V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 => RoomCreateEventContent::new_v1(server_user.clone()),
|
V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 => RoomCreateEventContent::new_v1(server_user.clone()),
|
||||||
V11 => RoomCreateEventContent::new_v11(),
|
_ => RoomCreateEventContent::new_v11(),
|
||||||
_ => {
|
|
||||||
warn!("Unexpected or unsupported room version {}", room_version);
|
|
||||||
return Err(Error::BadRequest(
|
|
||||||
ErrorKind::BadJson,
|
|
||||||
"Unexpected or unsupported room version found",
|
|
||||||
));
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -449,7 +449,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
V11 => {
|
_ => {
|
||||||
let content =
|
let content =
|
||||||
serde_json::from_str::<RoomRedactionEventContent>(pdu.content.get()).map_err(|e| {
|
serde_json::from_str::<RoomRedactionEventContent>(pdu.content.get()).map_err(|e| {
|
||||||
warn!("Invalid content in redaction pdu: {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 => {
|
TimelineEventType::SpaceChild => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue