Change how event data is stored in Event
Right now we can only create Event
s from SyncRoomEvent
s because we've only had to handle this type until now.
I'm working on correctly supporting rich replies, and to respect the spec and have an up to date related event. I'm trying to fetch it from the timeline but, if it's not there, I have to make a call to the homeserver to get the event, which is returned as a RoomEvent
.
In the data, the only difference from SyncRoomEvent
is that the RoomEvent
includes the room_id
, however we cannot convert the types from one to the other because the date is kept in it's raw form.
The idea would be to store the different parts of the event separately and have something like this:
pub struct Event<T: Serialize + Deserialize> {
/// The deserialized matrix event.
pub event: RefCell<Option<AnyRoomEvent>>,
/// The raw JSON of the event.
pub raw: RefCell<Option<Raw<T>>>,
/// The encryption info of the event
pub encryption_info: RefCell<Option<EncryptionInfo>>,
// ...
}
There would be two constructors: from_room_event
and from_sync_room_event
. In the latter we deserialize to an AnySyncRoomEvent
, and convert it to an AnyRoomEvent
.
The changes should be minimal downstream, appart from changing AnySyncRoomEvent
to AnyRoomEvent
.