Check PDU formats

This commit is contained in:
dasha_uwu
2025-12-18 01:34:02 +05:00
committed by Jason Volk
parent c5508bba58
commit 7b2079f714
8 changed files with 35 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
use ruma::{CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, RoomVersionId};
use tuwunel_core::{
Result, implement,
Result, err, implement,
matrix::{event::gen_event_id, room_version},
};
@@ -73,7 +73,15 @@ pub fn hash_and_sign_event(
object,
&room_version_rules.redaction,
)
.map_err(Into::into)
.map_err(|e| {
use ruma::signatures::Error::PduSize;
match e {
| PduSize => {
err!(Request(TooLarge("PDU exceeds 65535 bytes")))
},
| _ => err!(Request(Unknown(warn!("Signing event failed: {e}")))),
}
})
}
#[implement(super::Service)]