|
|
|
|
@ -2,9 +2,9 @@ use crate::Error;
@@ -2,9 +2,9 @@ use crate::Error;
|
|
|
|
|
use log::error; |
|
|
|
|
use ruma::{ |
|
|
|
|
events::{ |
|
|
|
|
pdu::EventHash, room::member::MemberEventContent, AnyEphemeralRoomEvent, AnyRoomEvent, |
|
|
|
|
AnyStateEvent, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, |
|
|
|
|
StateEvent, |
|
|
|
|
pdu::EventHash, room::member::MemberEventContent, AnyEphemeralRoomEvent, |
|
|
|
|
AnyInitialStateEvent, AnyRoomEvent, AnyStateEvent, AnyStrippedStateEvent, AnySyncRoomEvent, |
|
|
|
|
AnySyncStateEvent, EventType, StateEvent, |
|
|
|
|
}, |
|
|
|
|
serde::{CanonicalJsonObject, CanonicalJsonValue, Raw}, |
|
|
|
|
state_res, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, ServerName, |
|
|
|
|
@ -346,3 +346,17 @@ pub struct PduBuilder {
@@ -346,3 +346,17 @@ pub struct PduBuilder {
|
|
|
|
|
pub state_key: Option<String>, |
|
|
|
|
pub redacts: Option<EventId>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Direct conversion prevents loss of the empty `state_key` that ruma requires.
|
|
|
|
|
impl From<AnyInitialStateEvent> for PduBuilder { |
|
|
|
|
fn from(event: AnyInitialStateEvent) -> Self { |
|
|
|
|
Self { |
|
|
|
|
event_type: EventType::from(event.event_type()), |
|
|
|
|
content: serde_json::value::to_value(event.content()) |
|
|
|
|
.expect("AnyStateEventContent came from JSON and can thus turn back into JSON."), |
|
|
|
|
unsigned: None, |
|
|
|
|
state_key: Some(event.state_key().to_owned()), |
|
|
|
|
redacts: None, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|