don't validate or add signature if room is not v8 or above or not using restricted joins
should resolve https://github.com/matrix-org/matrix-spec/issues/1708 on for conduwuit until spec clarifies. Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
5c4b8ad7a3
commit
52884abff6
1 changed files with 71 additions and 45 deletions
|
@ -559,7 +559,7 @@ async fn join_room_by_id_helper(
|
|||
third_party_invite: None,
|
||||
blurhash: services().users.blurhash(sender_user)?,
|
||||
reason,
|
||||
join_authorized_via_users_server,
|
||||
join_authorized_via_users_server: join_authorized_via_users_server.clone(),
|
||||
})
|
||||
.expect("event is valid, we just created it"),
|
||||
);
|
||||
|
@ -594,7 +594,7 @@ async fn join_room_by_id_helper(
|
|||
// It has enough fields to be called a proper event now
|
||||
let mut join_event = join_event_stub;
|
||||
|
||||
info!("Asking {remote_server} for send_join");
|
||||
info!("Asking {remote_server} for send_join in room {room_id}");
|
||||
let send_join_response = services()
|
||||
.sending
|
||||
.send_federation_request(
|
||||
|
@ -610,6 +610,19 @@ async fn join_room_by_id_helper(
|
|||
|
||||
info!("send_join finished");
|
||||
|
||||
if join_authorized_via_users_server.is_some() {
|
||||
match &room_version_id {
|
||||
RoomVersionId::V1
|
||||
| RoomVersionId::V2
|
||||
| RoomVersionId::V3
|
||||
| RoomVersionId::V4
|
||||
| RoomVersionId::V5
|
||||
| RoomVersionId::V6
|
||||
| RoomVersionId::V7 => {
|
||||
warn!("Found `join_authorised_via_users_server` but room {} is version {}. Ignoring.", room_id, &room_version_id);
|
||||
}
|
||||
// only room versions 8 and above using `join_authorized_via_users_server` (restricted joins) need to validate and send signatures
|
||||
RoomVersionId::V8 | RoomVersionId::V9 | RoomVersionId::V10 | RoomVersionId::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 our event");
|
||||
let (signed_event_id, signed_value) =
|
||||
|
@ -658,6 +671,19 @@ async fn join_room_by_id_helper(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
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",
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
services().rooms.short.get_or_create_shortroomid(room_id)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue