Refactor usage of CanonicalJsonValue

This commit is contained in:
Jonas Platte 2021-04-26 18:20:20 +02:00
parent c2b72773d5
commit 2e1d7d12ca
No known key found for this signature in database
GPG key ID: CC154DE0E30B7C67
4 changed files with 63 additions and 75 deletions

View file

@ -5,7 +5,7 @@ use ruma::{
pdu::EventHash, room::member::MemberEventContent, AnyEvent, AnyRoomEvent, AnyStateEvent,
AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, StateEvent,
},
serde::{to_canonical_value, CanonicalJsonObject, CanonicalJsonValue, Raw},
serde::{CanonicalJsonObject, CanonicalJsonValue, Raw},
EventId, RoomId, RoomVersionId, ServerName, ServerSigningKeyId, UInt, UserId,
};
use serde::{Deserialize, Serialize};
@ -238,7 +238,7 @@ impl PduEvent {
) -> Result<Self, serde_json::Error> {
json.insert(
"event_id".to_string(),
to_canonical_value(event_id).expect("event_id is a valid Value"),
CanonicalJsonValue::String(event_id.as_str().to_owned()),
);
serde_json::from_value(serde_json::to_value(json).expect("valid JSON"))