mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 12:16:54 +00:00
fix: Only check that room_id is not present on create events in PDU check 1
This commit is contained in:
1 parent
3c19206534
commit
b580379a2d
1 file changed
+5
-8
@@ -62,14 +62,6 @@ impl super::Service {
|
||||
return Err!(Request(TooLarge("PDU is too large")));
|
||||
}
|
||||
|
||||
if event_format.require_room_create_room_id {
|
||||
if pdu_json.get("room_id").is_none() {
|
||||
return Err!(Request(BadJson("Missing required PDU field: `room_id`")));
|
||||
}
|
||||
} else if pdu_json.get("room_id").is_some() {
|
||||
return Err!(Request(BadJson("Unexpected PDU field: `room_id`")));
|
||||
}
|
||||
|
||||
let auth_events = expect_event_id_array(pdu_json, "auth_events")?;
|
||||
if auth_events.len() > 10 {
|
||||
return Err!(Request(BadJson("PDU has too many auth events")));
|
||||
@@ -92,6 +84,9 @@ impl super::Service {
|
||||
let is_create_event = event_type == "m.room.create" && state_key == Some("");
|
||||
|
||||
if !is_create_event {
|
||||
if pdu_json.get("room_id").is_none() {
|
||||
return Err!(Request(BadJson("Missing required PDU field: `room_id`")));
|
||||
}
|
||||
let create_event_in_auth_events = auth_events.iter().any(|id| id == create_event_id);
|
||||
if !event_format.allow_room_create_in_auth_events && create_event_in_auth_events {
|
||||
return Err!(Request(BadJson("PDU references a create event")));
|
||||
@@ -100,6 +95,8 @@ impl super::Service {
|
||||
{
|
||||
return Err!(Request(BadJson("PDU does not reference the room create event")));
|
||||
}
|
||||
} else if !event_format.require_room_create_room_id && pdu_json.get("room_id").is_some() {
|
||||
return Err!(Request(BadJson("Unexpected PDU field: `room_id`")));
|
||||
}
|
||||
|
||||
let prev_events = expect_event_id_array(pdu_json, "prev_events")?;
|
||||
|
||||
Reference in new issue
Block a user