Merge branch 'initial_state_keys' into 'master'

Implement From<AnyInitialStateEvent> on PduBuilder

Closes #116

See merge request famedly/conduit!136
This commit is contained in:
Timo Kösters 2021-07-21 10:03:08 +00:00
commit cae2b200cc
2 changed files with 20 additions and 7 deletions

View file

@ -233,10 +233,9 @@ pub async fn create_room_route(
// 5. Events listed in initial_state
for event in &body.initial_state {
let pdu_builder = serde_json::from_str::<PduBuilder>(
&serde_json::to_string(&event).expect("AnyInitialStateEvent::to_string always works"),
)
.map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, "Invalid initial state event."))?;
let pdu_builder = PduBuilder::from(event.deserialize().map_err(|_| {
Error::BadRequest(ErrorKind::InvalidParam, "Invalid initial state event.")
})?);
// Silently skip encryption events if they are not allowed
if pdu_builder.event_type == EventType::RoomEncryption && !db.globals.allow_encryption() {