|
|
|
@ -5,12 +5,12 @@ use ruma::{ |
|
|
|
events::{ |
|
|
|
events::{ |
|
|
|
room::{member::RoomMemberEventContent, redaction::RoomRedactionEventContent}, |
|
|
|
room::{member::RoomMemberEventContent, redaction::RoomRedactionEventContent}, |
|
|
|
space::child::HierarchySpaceChildEvent, |
|
|
|
space::child::HierarchySpaceChildEvent, |
|
|
|
AnyEphemeralRoomEvent, AnyMessageLikeEvent, AnyStateEvent, AnyStrippedStateEvent, |
|
|
|
AnyInitialStateEvent, AnyMessageLikeEvent, AnyStateEvent, AnyStrippedStateEvent, |
|
|
|
AnySyncMessageLikeEvent, AnySyncStateEvent, AnySyncTimelineEvent, AnyTimelineEvent, |
|
|
|
AnySyncMessageLikeEvent, AnySyncStateEvent, AnySyncTimelineEvent, AnyTimelineEvent, |
|
|
|
StateEvent, TimelineEventType, |
|
|
|
StateEvent, TimelineEventType, |
|
|
|
}, |
|
|
|
}, |
|
|
|
room_version_rules::{RedactionRules, RoomVersionRules}, |
|
|
|
room_version_rules::{RedactionRules, RoomVersionRules}, |
|
|
|
serde::Raw, |
|
|
|
serde::{JsonCastable, Raw}, |
|
|
|
state_res, CanonicalJsonObject, CanonicalJsonValue, EventId, MilliSecondsSinceUnixEpoch, |
|
|
|
state_res, CanonicalJsonObject, CanonicalJsonValue, EventId, MilliSecondsSinceUnixEpoch, |
|
|
|
OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId, |
|
|
|
OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId, |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -197,31 +197,6 @@ impl PduEvent { |
|
|
|
serde_json::from_value(json).expect("Raw::from_value always works") |
|
|
|
serde_json::from_value(json).expect("Raw::from_value always works") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// This only works for events that are also AnyRoomEvents.
|
|
|
|
|
|
|
|
#[tracing::instrument(skip(self))] |
|
|
|
|
|
|
|
pub fn to_any_event(&self) -> Raw<AnyEphemeralRoomEvent> { |
|
|
|
|
|
|
|
let mut json = json!({ |
|
|
|
|
|
|
|
"content": self.content, |
|
|
|
|
|
|
|
"type": self.kind, |
|
|
|
|
|
|
|
"event_id": self.event_id, |
|
|
|
|
|
|
|
"sender": self.sender, |
|
|
|
|
|
|
|
"origin_server_ts": self.origin_server_ts, |
|
|
|
|
|
|
|
"room_id": self.room_id, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(unsigned) = &self.unsigned { |
|
|
|
|
|
|
|
json["unsigned"] = json!(unsigned); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if let Some(state_key) = &self.state_key { |
|
|
|
|
|
|
|
json["state_key"] = json!(state_key); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if let Some(redacts) = &self.redacts { |
|
|
|
|
|
|
|
json["redacts"] = json!(redacts); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
serde_json::from_value(json).expect("Raw::from_value always works") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip(self))] |
|
|
|
#[tracing::instrument(skip(self))] |
|
|
|
pub fn to_room_event(&self) -> Raw<AnyTimelineEvent> { |
|
|
|
pub fn to_room_event(&self) -> Raw<AnyTimelineEvent> { |
|
|
|
let (redacts, content) = self.copy_redacts(); |
|
|
|
let (redacts, content) = self.copy_redacts(); |
|
|
|
@ -499,3 +474,5 @@ pub struct PduBuilder { |
|
|
|
/// Will be set to current time if None
|
|
|
|
/// Will be set to current time if None
|
|
|
|
pub timestamp: Option<MilliSecondsSinceUnixEpoch>, |
|
|
|
pub timestamp: Option<MilliSecondsSinceUnixEpoch>, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl JsonCastable<PduBuilder> for AnyInitialStateEvent {} |
|
|
|
|