matrix-sdk: Bump ruma

master
Damir Jelić 2021-05-12 16:21:44 +02:00
parent 4c09c6272b
commit 77c2a4ed4f
15 changed files with 140 additions and 101 deletions

View File

@ -1573,7 +1573,7 @@ impl Client {
MIN_UPLOAD_REQUEST_TIMEOUT,
);
let request = assign!(create_content::Request::new(data), {
let request = assign!(create_content::Request::new(&data), {
content_type: Some(content_type.essence_str()),
});

View File

@ -15,7 +15,12 @@
use std::ops::Deref;
use matrix_sdk_common::{
api::r0::push::get_notifications::Notification, events::AnySyncRoomEvent, identifiers::RoomId,
api::r0::push::get_notifications::Notification,
events::{
fully_read::FullyReadEventContent, AnySyncRoomEvent, GlobalAccountDataEvent,
RoomAccountDataEvent,
},
identifiers::RoomId,
};
use serde_json::value::RawValue as RawJsonValue;
@ -27,7 +32,6 @@ use crate::{
hangup::HangupEventContent, invite::InviteEventContent,
},
custom::CustomEventContent,
fully_read::FullyReadEventContent,
ignored_user_list::IgnoredUserListEventContent,
presence::PresenceEvent,
push_rules::PushRulesEventContent,
@ -45,9 +49,9 @@ use crate::{
tombstone::TombstoneEventContent,
},
typing::TypingEventContent,
AnyBasicEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncMessageEvent,
AnySyncStateEvent, BasicEvent, StrippedStateEvent, SyncEphemeralRoomEvent,
SyncMessageEvent, SyncStateEvent,
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
AnySyncEphemeralRoomEvent, AnySyncMessageEvent, AnySyncStateEvent, StrippedStateEvent,
SyncEphemeralRoomEvent, SyncMessageEvent, SyncStateEvent,
},
room::Room,
Client,
@ -73,6 +77,15 @@ impl Handler {
}
pub(crate) async fn handle_sync(&self, response: &SyncResponse) {
for event in response
.account_data
.events
.iter()
.filter_map(|e| e.deserialize().ok())
{
self.handle_account_data_event(&event).await;
}
for (room_id, room_info) in &response.rooms.join {
if let Some(room) = self.get_room(room_id) {
for event in room_info
@ -90,7 +103,8 @@ impl Handler {
.iter()
.filter_map(|e| e.deserialize().ok())
{
self.handle_account_data_event(room.clone(), &event).await;
self.handle_room_account_data_event(room.clone(), &event)
.await;
}
for event in room_info
@ -121,7 +135,8 @@ impl Handler {
.iter()
.filter_map(|e| e.deserialize().ok())
{
self.handle_account_data_event(room.clone(), &event).await;
self.handle_room_account_data_event(room.clone(), &event)
.await;
}
for event in room_info
@ -272,13 +287,27 @@ impl Handler {
}
}
pub(crate) async fn handle_account_data_event(&self, room: Room, event: &AnyBasicEvent) {
pub(crate) async fn handle_room_account_data_event(
&self,
room: Room,
event: &AnyRoomAccountDataEvent,
) {
match event {
AnyBasicEvent::Presence(presence) => self.on_non_room_presence(room, &presence).await,
AnyBasicEvent::IgnoredUserList(ignored) => {
self.on_non_room_ignored_users(room, &ignored).await
AnyRoomAccountDataEvent::FullyRead(event) => {
self.on_non_room_fully_read(room, &event).await
}
_ => {}
}
}
pub(crate) async fn handle_account_data_event(&self, event: &AnyGlobalAccountDataEvent) {
match event {
AnyGlobalAccountDataEvent::IgnoredUserList(ignored) => {
self.on_non_room_ignored_users(&ignored).await
}
AnyGlobalAccountDataEvent::PushRules(rules) => {
self.on_non_room_push_rules(&rules).await
}
AnyBasicEvent::PushRules(rules) => self.on_non_room_push_rules(room, &rules).await,
_ => {}
}
}
@ -289,9 +318,6 @@ impl Handler {
event: &AnySyncEphemeralRoomEvent,
) {
match event {
AnySyncEphemeralRoomEvent::FullyRead(full_read) => {
self.on_non_room_fully_read(room, full_read).await
}
AnySyncEphemeralRoomEvent::Typing(typing) => {
self.on_non_room_typing(room, typing).await
}
@ -307,7 +333,7 @@ impl Handler {
#[derive(Clone, Copy, Debug)]
pub enum CustomEvent<'c> {
/// A custom basic event.
Basic(&'c BasicEvent<CustomEventContent>),
Basic(&'c GlobalAccountDataEvent<CustomEventContent>),
/// A custom basic event.
EphemeralRoom(&'c SyncEphemeralRoomEvent<CustomEventContent>),
/// A custom room event.
@ -477,17 +503,16 @@ pub trait EventHandler: Send + Sync {
/// Fires when `Client` receives a `NonRoomEvent::RoomName` event.
async fn on_non_room_ignored_users(
&self,
_: Room,
_: &BasicEvent<IgnoredUserListEventContent>,
_: &GlobalAccountDataEvent<IgnoredUserListEventContent>,
) {
}
/// Fires when `Client` receives a `NonRoomEvent::RoomCanonicalAlias` event.
async fn on_non_room_push_rules(&self, _: Room, _: &BasicEvent<PushRulesEventContent>) {}
async fn on_non_room_push_rules(&self, _: &GlobalAccountDataEvent<PushRulesEventContent>) {}
/// Fires when `Client` receives a `NonRoomEvent::RoomAliases` event.
async fn on_non_room_fully_read(
&self,
_: Room,
_: &SyncEphemeralRoomEvent<FullyReadEventContent>,
_: &RoomAccountDataEvent<FullyReadEventContent>,
) {
}
/// Fires when `Client` receives a `NonRoomEvent::Typing` event.
@ -689,18 +714,17 @@ mod test {
}
async fn on_non_room_ignored_users(
&self,
_: Room,
_: &BasicEvent<IgnoredUserListEventContent>,
_: &GlobalAccountDataEvent<IgnoredUserListEventContent>,
) {
self.0.lock().await.push("account ignore".to_string())
}
async fn on_non_room_push_rules(&self, _: Room, _: &BasicEvent<PushRulesEventContent>) {
async fn on_non_room_push_rules(&self, _: &GlobalAccountDataEvent<PushRulesEventContent>) {
self.0.lock().await.push("account push rules".to_string())
}
async fn on_non_room_fully_read(
&self,
_: Room,
_: &SyncEphemeralRoomEvent<FullyReadEventContent>,
_: &RoomAccountDataEvent<FullyReadEventContent>,
) {
self.0.lock().await.push("account read".to_string())
}
@ -774,9 +798,9 @@ mod test {
assert_eq!(
v.as_slice(),
[
"account ignore",
"receipt event",
"account read",
"account ignore",
"state rules",
"state member",
"state aliases",
@ -902,9 +926,9 @@ mod test {
assert_eq!(
v.as_slice(),
[
"account ignore",
"receipt event",
"account read",
"account ignore",
"state rules",
"state member",
"state aliases",

View File

@ -31,6 +31,7 @@ use matrix_sdk_common::{
},
identifiers::{EventId, UserId},
instant::{Duration, Instant},
receipt::ReceiptType,
uuid::Uuid,
};
@ -225,11 +226,8 @@ impl Joined {
///
/// * `event_id` - The `EventId` specifies the event to set the read receipt on.
pub async fn read_receipt(&self, event_id: &EventId) -> Result<()> {
let request = create_receipt::Request::new(
self.inner.room_id(),
create_receipt::ReceiptType::Read,
event_id,
);
let request =
create_receipt::Request::new(self.inner.room_id(), ReceiptType::Read, event_id);
self.client.send(request, None).await?;
Ok(())

View File

@ -4,7 +4,7 @@ use matrix_sdk::{
api_appservice,
api_appservice::Registration,
async_trait,
events::{room::member::MemberEventContent, AnyEvent, AnyStateEvent, SyncStateEvent},
events::{room::member::MemberEventContent, AnyRoomEvent, AnyStateEvent, SyncStateEvent},
room::Room,
EventHandler, Raw,
};
@ -82,7 +82,7 @@ async fn test_event_handler() -> Result<()> {
.await;
let event = serde_json::from_value::<AnyStateEvent>(member_json()).unwrap();
let event: Raw<AnyEvent> = AnyEvent::State(event).into();
let event: Raw<AnyRoomEvent> = AnyRoomEvent::State(event).into();
let events = vec![event];
let incoming = api_appservice::event::push_events::v1::IncomingRequest::new(
@ -100,7 +100,7 @@ async fn test_transaction() -> Result<()> {
let appservice = appservice(None).await?;
let event = serde_json::from_value::<AnyStateEvent>(member_json()).unwrap();
let event: Raw<AnyEvent> = AnyEvent::State(event).into();
let event: Raw<AnyRoomEvent> = AnyRoomEvent::State(event).into();
let events = vec![event];
let incoming = api_appservice::event::push_events::v1::IncomingRequest::new(

View File

@ -42,8 +42,8 @@ use matrix_sdk_common::{
},
events::{
room::member::{MemberEventContent, MembershipState},
AnyBasicEvent, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventContent,
EventType, StateEvent,
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
AnySyncRoomEvent, AnySyncStateEvent, EventContent, EventType, StateEvent,
},
identifiers::{RoomId, UserId},
instant::Instant,
@ -657,7 +657,7 @@ impl BaseClient {
async fn handle_room_account_data(
&self,
room_id: &RoomId,
events: &[Raw<AnyBasicEvent>],
events: &[Raw<AnyRoomAccountDataEvent>],
changes: &mut StateChanges,
) {
for raw_event in events {
@ -667,7 +667,11 @@ impl BaseClient {
}
}
async fn handle_account_data(&self, events: &[Raw<AnyBasicEvent>], changes: &mut StateChanges) {
async fn handle_account_data(
&self,
events: &[Raw<AnyGlobalAccountDataEvent>],
changes: &mut StateChanges,
) {
let mut account_data = BTreeMap::new();
for raw_event in events {
@ -677,7 +681,7 @@ impl BaseClient {
continue;
};
if let AnyBasicEvent::Direct(e) = &event {
if let AnyGlobalAccountDataEvent::Direct(e) = &event {
for (user_id, rooms) in e.content.iter() {
for room_id in rooms {
if let Some(room) = changes.room_infos.get_mut(room_id) {
@ -1348,13 +1352,13 @@ impl BaseClient {
/// Gets the push rules from `changes` if they have been updated, otherwise get them from the
/// store. As a fallback, uses `Ruleset::server_default` if the user is logged in.
pub async fn get_push_rules(&self, changes: &StateChanges) -> Result<Ruleset> {
if let Some(AnyBasicEvent::PushRules(event)) = changes
if let Some(AnyGlobalAccountDataEvent::PushRules(event)) = changes
.account_data
.get(EventType::PushRules.as_str())
.and_then(|e| e.deserialize().ok())
{
Ok(event.content.global)
} else if let Some(AnyBasicEvent::PushRules(event)) = self
} else if let Some(AnyGlobalAccountDataEvent::PushRules(event)) = self
.store
.get_account_data_event(EventType::PushRules)
.await?

View File

@ -30,7 +30,7 @@ use matrix_sdk_common::{
tombstone::TombstoneEventContent,
},
tag::Tags,
AnyBasicEvent, AnyStateEventContent, AnySyncStateEvent, EventType,
AnyRoomAccountDataEvent, AnyStateEventContent, AnySyncStateEvent, EventType,
},
identifiers::{MxcUri, RoomAliasId, RoomId, UserId},
};
@ -451,7 +451,7 @@ impl Room {
/// Get the `Tags` for this room.
pub async fn tags(&self) -> StoreResult<Option<Tags>> {
if let Some(AnyBasicEvent::Tag(event)) = self
if let Some(AnyRoomAccountDataEvent::Tag(event)) = self
.store
.get_room_account_data_event(self.room_id(), EventType::Tag)
.await?

View File

@ -23,7 +23,8 @@ use matrix_sdk_common::{
events::{
presence::PresenceEvent,
room::member::{MemberEventContent, MembershipState},
AnyBasicEvent, AnyStrippedStateEvent, AnySyncStateEvent, EventType,
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
AnySyncStateEvent, EventType,
},
identifiers::{RoomId, UserId},
instant::Instant,
@ -40,7 +41,7 @@ use super::{Result, RoomInfo, StateChanges, StateStore};
pub struct MemoryStore {
sync_token: Arc<RwLock<Option<String>>>,
filters: Arc<DashMap<String, String>>,
account_data: Arc<DashMap<String, Raw<AnyBasicEvent>>>,
account_data: Arc<DashMap<String, Raw<AnyGlobalAccountDataEvent>>>,
members: Arc<DashMap<RoomId, DashMap<UserId, MemberEvent>>>,
profiles: Arc<DashMap<RoomId, DashMap<UserId, MemberEventContent>>>,
display_names: Arc<DashMap<RoomId, DashMap<String, BTreeSet<UserId>>>>,
@ -49,7 +50,7 @@ pub struct MemoryStore {
room_info: Arc<DashMap<RoomId, RoomInfo>>,
#[allow(clippy::type_complexity)]
room_state: Arc<DashMap<RoomId, DashMap<String, DashMap<String, Raw<AnySyncStateEvent>>>>>,
room_account_data: Arc<DashMap<RoomId, DashMap<String, Raw<AnyBasicEvent>>>>,
room_account_data: Arc<DashMap<RoomId, DashMap<String, Raw<AnyRoomAccountDataEvent>>>>,
stripped_room_info: Arc<DashMap<RoomId, RoomInfo>>,
#[allow(clippy::type_complexity)]
stripped_room_state:
@ -308,7 +309,7 @@ impl MemoryStore {
async fn get_account_data_event(
&self,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>> {
) -> Result<Option<Raw<AnyGlobalAccountDataEvent>>> {
Ok(self
.account_data
.get(event_type.as_ref())
@ -319,7 +320,7 @@ impl MemoryStore {
&self,
room_id: &RoomId,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>> {
) -> Result<Option<Raw<AnyRoomAccountDataEvent>>> {
Ok(self
.room_account_data
.get(room_id)
@ -411,7 +412,7 @@ impl StateStore for MemoryStore {
async fn get_account_data_event(
&self,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>> {
) -> Result<Option<Raw<AnyGlobalAccountDataEvent>>> {
self.get_account_data_event(event_type).await
}
@ -419,7 +420,7 @@ impl StateStore for MemoryStore {
&self,
room_id: &RoomId,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>> {
) -> Result<Option<Raw<AnyRoomAccountDataEvent>>> {
self.get_room_account_data_event(room_id, event_type).await
}
}

View File

@ -26,8 +26,8 @@ use matrix_sdk_common::{
api::r0::push::get_notifications::Notification,
async_trait,
events::{
presence::PresenceEvent, room::member::MemberEventContent, AnyBasicEvent,
AnyStrippedStateEvent, AnySyncStateEvent, EventContent, EventType,
presence::PresenceEvent, room::member::MemberEventContent, AnyGlobalAccountDataEvent,
AnyRoomAccountDataEvent, AnyStrippedStateEvent, AnySyncStateEvent, EventContent, EventType,
},
identifiers::{RoomId, UserId},
locks::RwLock,
@ -195,7 +195,7 @@ pub trait StateStore: AsyncTraitDeps {
async fn get_account_data_event(
&self,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>>;
) -> Result<Option<Raw<AnyGlobalAccountDataEvent>>>;
/// Get an event out of the room account data store.
///
@ -209,7 +209,7 @@ pub trait StateStore: AsyncTraitDeps {
&self,
room_id: &RoomId,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>>;
) -> Result<Option<Raw<AnyRoomAccountDataEvent>>>;
}
/// A state store wrapper for the SDK.
@ -362,7 +362,7 @@ pub struct StateChanges {
/// A user session, containing an access token and information about the associated user account.
pub session: Option<Session>,
/// A mapping of event type string to `AnyBasicEvent`.
pub account_data: BTreeMap<String, Raw<AnyBasicEvent>>,
pub account_data: BTreeMap<String, Raw<AnyGlobalAccountDataEvent>>,
/// A mapping of `UserId` to `PresenceEvent`.
pub presence: BTreeMap<UserId, Raw<PresenceEvent>>,
@ -374,7 +374,7 @@ pub struct StateChanges {
/// A mapping of `RoomId` to a map of event type string to a state key and `AnySyncStateEvent`.
pub state: BTreeMap<RoomId, BTreeMap<String, BTreeMap<String, Raw<AnySyncStateEvent>>>>,
/// A mapping of `RoomId` to a map of event type string to `AnyBasicEvent`.
pub room_account_data: BTreeMap<RoomId, BTreeMap<String, Raw<AnyBasicEvent>>>,
pub room_account_data: BTreeMap<RoomId, BTreeMap<String, Raw<AnyRoomAccountDataEvent>>>,
/// A map of `RoomId` to `RoomInfo`.
pub room_infos: BTreeMap<RoomId, RoomInfo>,
@ -420,7 +420,11 @@ impl StateChanges {
}
/// Update the `StateChanges` struct with the given `AnyBasicEvent`.
pub fn add_account_data(&mut self, event: AnyBasicEvent, raw_event: Raw<AnyBasicEvent>) {
pub fn add_account_data(
&mut self,
event: AnyGlobalAccountDataEvent,
raw_event: Raw<AnyGlobalAccountDataEvent>,
) {
self.account_data
.insert(event.content().event_type().to_owned(), raw_event);
}
@ -429,8 +433,8 @@ impl StateChanges {
pub fn add_room_account_data(
&mut self,
room_id: &RoomId,
event: AnyBasicEvent,
raw_event: Raw<AnyBasicEvent>,
event: AnyRoomAccountDataEvent,
raw_event: Raw<AnyRoomAccountDataEvent>,
) {
self.room_account_data
.entry(room_id.to_owned())

View File

@ -31,7 +31,7 @@ use matrix_sdk_common::{
events::{
presence::PresenceEvent,
room::member::{MemberEventContent, MembershipState},
AnyBasicEvent, AnySyncStateEvent, EventType,
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncStateEvent, EventType,
},
identifiers::{RoomId, UserId},
Raw,
@ -590,7 +590,7 @@ impl SledStore {
pub async fn get_account_data_event(
&self,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>> {
) -> Result<Option<Raw<AnyGlobalAccountDataEvent>>> {
Ok(self
.account_data
.get(event_type.encode())?
@ -602,7 +602,7 @@ impl SledStore {
&self,
room_id: &RoomId,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>> {
) -> Result<Option<Raw<AnyRoomAccountDataEvent>>> {
Ok(self
.room_account_data
.get((room_id.as_str(), event_type.as_str()).encode())?
@ -690,7 +690,7 @@ impl StateStore for SledStore {
async fn get_account_data_event(
&self,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>> {
) -> Result<Option<Raw<AnyGlobalAccountDataEvent>>> {
self.get_account_data_event(event_type).await
}
@ -698,7 +698,7 @@ impl StateStore for SledStore {
&self,
room_id: &RoomId,
event_type: EventType,
) -> Result<Option<Raw<AnyBasicEvent>>> {
) -> Result<Option<Raw<AnyRoomAccountDataEvent>>> {
self.get_room_account_data_event(room_id, event_type).await
}
}

View File

@ -22,7 +22,7 @@ async-trait = "0.1.42"
[dependencies.ruma]
version = "0.0.3"
git = "https://github.com/ruma/ruma"
rev = "a0f7e1b771d3294187bae0b2816fbcf6ceb40b88"
rev = "3bdead1cf207e3ab9c8fcbfc454c054c726ba6f5"
features = ["client-api-c", "compat", "unstable-pre-spec"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]

View File

@ -1,6 +1,6 @@
use ruma::{
api::client::r0::sync::sync_events::{
AccountData, Ephemeral, InvitedRoom, Presence, State, ToDevice,
Ephemeral, InvitedRoom, Presence, RoomAccountData, State, ToDevice,
},
serde::Raw,
DeviceIdBox,
@ -12,7 +12,8 @@ use super::{
api::r0::{
push::get_notifications::Notification,
sync::sync_events::{
DeviceLists, UnreadNotificationsCount as RumaUnreadNotificationsCount,
DeviceLists, GlobalAccountData,
UnreadNotificationsCount as RumaUnreadNotificationsCount,
},
},
events::{
@ -118,7 +119,7 @@ pub struct SyncResponse {
/// Updates to the presence status of other users.
pub presence: Presence,
/// The global private data created by this user.
pub account_data: AccountData,
pub account_data: GlobalAccountData,
/// Messages sent dirrectly between devices.
pub to_device: ToDevice,
/// Information on E2E device updates.
@ -165,7 +166,7 @@ pub struct JoinedRoom {
/// given, or `full_state` is true).
pub state: State,
/// The private data that this user has attached to this room.
pub account_data: AccountData,
pub account_data: RoomAccountData,
/// The ephemeral events in the room that aren't recorded in the timeline or state of the
/// room. e.g. typing.
pub ephemeral: Ephemeral,
@ -175,7 +176,7 @@ impl JoinedRoom {
pub fn new(
timeline: Timeline,
state: State,
account_data: AccountData,
account_data: RoomAccountData,
ephemeral: Ephemeral,
unread_notifications: UnreadNotificationsCount,
) -> Self {
@ -220,11 +221,11 @@ pub struct LeftRoom {
/// given, or `full_state` is true).
pub state: State,
/// The private data that this user has attached to this room.
pub account_data: AccountData,
pub account_data: RoomAccountData,
}
impl LeftRoom {
pub fn new(timeline: Timeline, state: State, account_data: AccountData) -> Self {
pub fn new(timeline: Timeline, state: State, account_data: RoomAccountData) -> Self {
Self {
timeline,
state,

View File

@ -13,7 +13,7 @@ pub use ruma::{
},
AuthScheme, EndpointError, IncomingResponse, OutgoingRequest, SendAccessToken,
},
assign, directory, encryption, events, identifiers, int, presence, push,
assign, directory, encryption, events, identifiers, int, presence, push, receipt,
serde::{CanonicalJsonValue, Raw},
thirdparty, uint, Int, Outgoing, UInt,
};

View File

@ -33,7 +33,7 @@ use matrix_sdk_common::{
deserialized_responses::{AlgorithmInfo, EncryptionInfo, SyncRoomEvent, VerificationState},
events::{
room::encrypted::{EncryptedEventContent, EncryptedEventScheme},
room_key::RoomKeyEventContent,
room_key::RoomKeyToDeviceEventContent,
AnyMessageEventContent, AnyToDeviceEvent, SyncMessageEvent, ToDeviceEvent,
},
identifiers::{
@ -592,7 +592,7 @@ impl OlmMachine {
&self,
sender_key: &str,
signing_key: &str,
event: &mut ToDeviceEvent<RoomKeyEventContent>,
event: &mut ToDeviceEvent<RoomKeyToDeviceEventContent>,
) -> OlmResult<(Option<AnyToDeviceEvent>, Option<InboundGroupSession>)> {
match event.content.algorithm {
EventEncryptionAlgorithm::MegolmV1AesSha2 => {

View File

@ -5,8 +5,8 @@ use http::Response;
use matrix_sdk_common::{
api::r0::sync::sync_events::Response as SyncResponse,
events::{
presence::PresenceEvent, AnyBasicEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent,
AnySyncStateEvent,
presence::PresenceEvent, AnyGlobalAccountDataEvent, AnySyncEphemeralRoomEvent,
AnySyncRoomEvent, AnySyncStateEvent,
},
identifiers::{room_id, RoomId},
IncomingResponse,
@ -93,7 +93,7 @@ pub struct EventBuilder {
/// The ephemeral room events that determine the state of a `Room`.
ephemeral: Vec<AnySyncEphemeralRoomEvent>,
/// The account data events that determine the state of a `Room`.
account_data: Vec<AnyBasicEvent>,
account_data: Vec<AnyGlobalAccountDataEvent>,
/// Internal counter to enable the `prev_batch` and `next_batch` of each sync response to vary.
batch_counter: i64,
}
@ -123,7 +123,7 @@ impl EventBuilder {
_ => panic!("unknown account event {:?}", json),
};
let event = serde_json::from_value::<AnyBasicEvent>(val.clone()).unwrap();
let event = serde_json::from_value::<AnyGlobalAccountDataEvent>(val.clone()).unwrap();
self.account_data.push(event);
self
}

View File

@ -11,11 +11,6 @@ lazy_static! {
],
"left": []
},
"rooms": {
"invite": {},
"join": {
"!SVkFJHzfwvuaIEawgC:localhost": {
"summary": {},
"account_data": {
"events": [
{
@ -28,6 +23,22 @@ lazy_static! {
}
]
},
"rooms": {
"invite": {},
"join": {
"!SVkFJHzfwvuaIEawgC:localhost": {
"summary": {},
"account_data": {
"events": [
{
"content": {
"event_id": "$someplace:example.org"
},
"room_id": "!roomid:room.com",
"type": "m.fully_read"
}
]
},
"ephemeral": {
"events": [
{
@ -43,13 +54,6 @@ lazy_static! {
"room_id": "!SVkFJHzfwvuaIEawgC:localhost",
"type": "m.receipt"
},
{
"content": {
"event_id": "$someplace:example.org"
},
"room_id": "!roomid:room.com",
"type": "m.fully_read"
}
]
},
"state": {
@ -782,12 +786,6 @@ lazy_static! {
],
"left": []
},
"rooms": {
"invite": {},
"join": {},
"leave": {
"!SVkFJHzfwvuaIEawgC:localhost": {
"summary": {},
"account_data": {
"events": [
{
@ -800,6 +798,15 @@ lazy_static! {
}
]
},
"rooms": {
"invite": {},
"join": {},
"leave": {
"!SVkFJHzfwvuaIEawgC:localhost": {
"summary": {},
"account_data": {
"events": []
},
"ephemeral": {
"events": [
{