style: Accept event id reference in pdu_format_check_1

This commit is contained in:
timedout committed 2026-07-11 05:09:04 +01:00
1 parent 1328d45c2d
commit 4f7436a58f
3 files changed
+12 -16

No files matched your search

@@ -59,7 +59,7 @@ impl super::Service {
if let Err(e) = Self::pdu_format_check_1(
&auth_pdu_json,
room_version_rules,
&create_event.event_id().to_owned(),
create_event.event_id(),
) {
// drop this PDU
warn!(%auth_event_id, error=?e, "Dropping auth chain event as it violates the room event format");
@@ -45,17 +45,13 @@ impl super::Service {
// 1. Check that the PDU follows the format for the room version
// (in this case, just size check)
let room_version_rules = get_room_version_rules(create_event)?;
Self::pdu_format_check_1(
&value,
&room_version_rules,
&create_event.event_id().to_owned(),
)
.inspect_err(|e| {
info!(
err=?e,
"Dropping incoming PDU from {origin} because it violates the room event format"
);
})?;
Self::pdu_format_check_1(&value, &room_version_rules, create_event.event_id())
.inspect_err(|e| {
info!(
err=?e,
"Dropping incoming PDU from {origin} because it violates the room event format"
);
})?;
value.remove("unsigned");
let room_version_rules = get_room_version_rules(create_event)?;
@@ -6,8 +6,8 @@ use conduwuit::{
};
use futures::future::ready;
use ruma::{
CanonicalJsonObject, OwnedEventId, ServerName, api::error::ErrorKind, canonical_json::redact,
events::StateEventType, room_version_rules::RoomVersionRules,
CanonicalJsonObject, EventId, OwnedEventId, ServerName, api::error::ErrorKind,
canonical_json::redact, events::StateEventType, room_version_rules::RoomVersionRules,
};
use crate::rooms::{
@@ -21,7 +21,7 @@ impl super::Service {
pub(super) fn pdu_format_check_1(
pdu_json: &CanonicalJsonObject,
room_version_rules: &RoomVersionRules,
create_event_id: &OwnedEventId,
create_event_id: &EventId,
) -> Result<()> {
let event_format = &room_version_rules.event_format;
// NOTE: if we do any more validation outside of deserialisation, it has to be
@@ -42,7 +42,7 @@ impl super::Service {
return Err!(Request(BadJson("PDU has too many auth events")));
}
let create_event_in_auth_events = auth_events.contains(create_event_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")));
}