base: WIP inivted rooms handling.

master
Damir Jelić 2020-12-08 09:52:27 +01:00
parent 5c608ed474
commit 6d2d48a35a
2 changed files with 29 additions and 5 deletions

View File

@ -6,8 +6,8 @@ use matrix_sdk_common::{
DeviceLists, UnreadNotificationsCount as RumaUnreadNotificationsCount, DeviceLists, UnreadNotificationsCount as RumaUnreadNotificationsCount,
}, },
events::{ events::{
presence::PresenceEvent, AnyBasicEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, presence::PresenceEvent, AnyBasicEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent,
AnySyncStateEvent, AnyToDeviceEvent, AnySyncRoomEvent, AnySyncStateEvent, AnyToDeviceEvent,
}, },
identifiers::{DeviceKeyAlgorithm, RoomId}, identifiers::{DeviceKeyAlgorithm, RoomId},
}; };
@ -69,8 +69,8 @@ pub struct Rooms {
pub leave: BTreeMap<RoomId, LeftRoom>, pub leave: BTreeMap<RoomId, LeftRoom>,
/// The rooms that the user has joined. /// The rooms that the user has joined.
pub join: BTreeMap<RoomId, JoinedRoom>, pub join: BTreeMap<RoomId, JoinedRoom>,
// /// The rooms that the user has been invited to. /// The rooms that the user has been invited to.
// pub invite: BTreeMap<RoomId, InvitedRoom>, pub invite: BTreeMap<RoomId, InvitedRoom>,
} }
/// Updates to joined rooms. /// Updates to joined rooms.
@ -109,6 +109,20 @@ impl JoinedRoom {
} }
} }
/// Updates to the rooms that the user has been invited to.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct InvitedRoom {
/// The state of a room that the user has been invited to.
pub invite_state: InviteState,
}
/// The state of a room that the user has been invited to.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct InviteState {
/// A list of state events.
pub events: Vec<AnyStrippedStateEvent>,
}
/// Counts of unread notifications for a room. /// Counts of unread notifications for a room.
#[derive(Copy, Clone, Debug, Default, Deserialize, Serialize)] #[derive(Copy, Clone, Debug, Default, Deserialize, Serialize)]
pub struct UnreadNotificationsCount { pub struct UnreadNotificationsCount {

View File

@ -17,7 +17,8 @@ use matrix_sdk_common::{
encryption::EncryptionEventContent, member::MemberEventContent, encryption::EncryptionEventContent, member::MemberEventContent,
power_levels::PowerLevelsEventContent, power_levels::PowerLevelsEventContent,
}, },
AnyBasicEvent, AnySyncStateEvent, EventContent, EventType, SyncStateEvent, AnyBasicEvent, AnyStrippedStateEvent, AnySyncStateEvent, EventContent, EventType,
SyncStateEvent,
}, },
identifiers::{RoomAliasId, RoomId, UserId}, identifiers::{RoomAliasId, RoomId, UserId},
}; };
@ -55,6 +56,8 @@ pub struct StateChanges {
pub invited_user_ids: BTreeMap<RoomId, Vec<UserId>>, pub invited_user_ids: BTreeMap<RoomId, Vec<UserId>>,
pub removed_user_ids: BTreeMap<RoomId, UserId>, pub removed_user_ids: BTreeMap<RoomId, UserId>,
pub presence: BTreeMap<UserId, PresenceEvent>, pub presence: BTreeMap<UserId, PresenceEvent>,
pub invitest_state: BTreeMap<RoomId, BTreeMap<String, AnyStrippedStateEvent>>,
pub invited_room_info: BTreeMap<RoomId, InnerSummary>,
} }
impl StateChanges { impl StateChanges {
@ -111,6 +114,13 @@ impl StateChanges {
.insert(event.content().event_type().to_owned(), event); .insert(event.content().event_type().to_owned(), event);
} }
pub fn add_invited_state(&mut self, room_id: &RoomId, event: AnyStrippedStateEvent) {
self.invitest_state
.entry(room_id.to_owned())
.or_insert_with(BTreeMap::new)
.insert(event.state_key().to_string(), event);
}
pub fn add_state_event(&mut self, room_id: &RoomId, event: AnySyncStateEvent) { pub fn add_state_event(&mut self, room_id: &RoomId, event: AnySyncStateEvent) {
self.state self.state
.entry(room_id.to_owned()) .entry(room_id.to_owned())