From 26d7e2f04d66ff8eff8c7555e68982c4db437940 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 31 Dec 2019 17:09:15 +0100 Subject: [PATCH] Limit `events` in `sync_events::Presence` to `PresenceEvent`s --- src/r0/sync/sync_events.rs | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/r0/sync/sync_events.rs b/src/r0/sync/sync_events.rs index b9ccf1ca..2abada9a 100644 --- a/src/r0/sync/sync_events.rs +++ b/src/r0/sync/sync_events.rs @@ -5,8 +5,13 @@ use std::collections::HashMap; use js_int::UInt; use ruma_api::{ruma_api, Outgoing}; use ruma_events::{ - collections::{all, only}, - stripped, EventResult, + collections::{ + all::{RoomEvent, StateEvent}, + only::Event as NonRoomEvent, + }, + presence::PresenceEvent, + stripped::StrippedState, + EventResult, }; use ruma_identifiers::RoomId; use serde::{Deserialize, Serialize}; @@ -182,32 +187,33 @@ pub struct Timeline { /// `/rooms/{roomId}/messages` endpoint. pub prev_batch: String, /// A list of events. - #[wrap_incoming(all::RoomEvent with EventResult)] - pub events: Vec, + #[wrap_incoming(RoomEvent with EventResult)] + pub events: Vec, } /// State events in the room. #[derive(Clone, Debug, Serialize, Outgoing)] pub struct State { /// A list of state events. - #[wrap_incoming(only::StateEvent with EventResult)] - pub events: Vec, + #[wrap_incoming(StateEvent with EventResult)] + pub events: Vec, } /// The private data that this user has attached to this room. #[derive(Clone, Debug, Serialize, Outgoing)] pub struct AccountData { /// A list of events. - #[wrap_incoming(only::Event with EventResult)] - pub events: Vec, + // TODO: Create + #[wrap_incoming(NonRoomEvent with EventResult)] + pub events: Vec, } /// Ephemeral events not recorded in the timeline or state of the room. #[derive(Clone, Debug, Serialize, Outgoing)] pub struct Ephemeral { /// A list of events. - #[wrap_incoming(only::Event with EventResult)] - pub events: Vec, + #[wrap_incoming(NonRoomEvent with EventResult)] + pub events: Vec, } /// Updates to the rooms that the user has been invited to. @@ -222,14 +228,14 @@ pub struct InvitedRoom { #[derive(Clone, Debug, Serialize, Outgoing)] pub struct InviteState { /// A list of state events. - #[wrap_incoming(stripped::StrippedState with EventResult)] - pub events: Vec, + #[wrap_incoming(StrippedState with EventResult)] + pub events: Vec, } /// Updates to the presence status of other users. #[derive(Clone, Debug, Serialize, Outgoing)] pub struct Presence { /// A list of events. - #[wrap_incoming(only::Event with EventResult)] - pub events: Vec, + #[wrap_incoming(PresenceEvent with EventResult)] + pub events: Vec, }