mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-12-27 04:53:50 +03:00
Merge branch 'fix_panic_on_long_message' into 'next'
Don't panic when signing event fails. Closes #232 See merge request famedly/conduit!343
This commit is contained in:
commit
39bc84d81c
1 changed files with 16 additions and 3 deletions
|
@ -1938,13 +1938,26 @@ impl Rooms {
|
|||
CanonicalJsonValue::String(db.globals.server_name().as_ref().to_owned()),
|
||||
);
|
||||
|
||||
ruma::signatures::hash_and_sign_event(
|
||||
match ruma::signatures::hash_and_sign_event(
|
||||
db.globals.server_name().as_str(),
|
||||
db.globals.keypair(),
|
||||
&mut pdu_json,
|
||||
&room_version_id,
|
||||
)
|
||||
.expect("event is valid, we just created it");
|
||||
) {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
return match e {
|
||||
ruma::signatures::Error::PduSize => Err(Error::BadRequest(
|
||||
ErrorKind::TooLarge,
|
||||
"Message is too long",
|
||||
)),
|
||||
_ => Err(Error::BadRequest(
|
||||
ErrorKind::Unknown,
|
||||
"Signing event failed",
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate event id
|
||||
pdu.event_id = EventId::parse_arc(format!(
|
||||
|
|
Loading…
Reference in a new issue