base: WIP inivted rooms handling.
parent
5c608ed474
commit
6d2d48a35a
|
@ -6,8 +6,8 @@ use matrix_sdk_common::{
|
|||
DeviceLists, UnreadNotificationsCount as RumaUnreadNotificationsCount,
|
||||
},
|
||||
events::{
|
||||
presence::PresenceEvent, AnyBasicEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent,
|
||||
AnySyncStateEvent, AnyToDeviceEvent,
|
||||
presence::PresenceEvent, AnyBasicEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent,
|
||||
AnySyncRoomEvent, AnySyncStateEvent, AnyToDeviceEvent,
|
||||
},
|
||||
identifiers::{DeviceKeyAlgorithm, RoomId},
|
||||
};
|
||||
|
@ -69,8 +69,8 @@ pub struct Rooms {
|
|||
pub leave: BTreeMap<RoomId, LeftRoom>,
|
||||
/// The rooms that the user has joined.
|
||||
pub join: BTreeMap<RoomId, JoinedRoom>,
|
||||
// /// The rooms that the user has been invited to.
|
||||
// pub invite: BTreeMap<RoomId, InvitedRoom>,
|
||||
/// The rooms that the user has been invited to.
|
||||
pub invite: BTreeMap<RoomId, InvitedRoom>,
|
||||
}
|
||||
|
||||
/// 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.
|
||||
#[derive(Copy, Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct UnreadNotificationsCount {
|
||||
|
|
|
@ -17,7 +17,8 @@ use matrix_sdk_common::{
|
|||
encryption::EncryptionEventContent, member::MemberEventContent,
|
||||
power_levels::PowerLevelsEventContent,
|
||||
},
|
||||
AnyBasicEvent, AnySyncStateEvent, EventContent, EventType, SyncStateEvent,
|
||||
AnyBasicEvent, AnyStrippedStateEvent, AnySyncStateEvent, EventContent, EventType,
|
||||
SyncStateEvent,
|
||||
},
|
||||
identifiers::{RoomAliasId, RoomId, UserId},
|
||||
};
|
||||
|
@ -55,6 +56,8 @@ pub struct StateChanges {
|
|||
pub invited_user_ids: BTreeMap<RoomId, Vec<UserId>>,
|
||||
pub removed_user_ids: BTreeMap<RoomId, UserId>,
|
||||
pub presence: BTreeMap<UserId, PresenceEvent>,
|
||||
pub invitest_state: BTreeMap<RoomId, BTreeMap<String, AnyStrippedStateEvent>>,
|
||||
pub invited_room_info: BTreeMap<RoomId, InnerSummary>,
|
||||
}
|
||||
|
||||
impl StateChanges {
|
||||
|
@ -111,6 +114,13 @@ impl StateChanges {
|
|||
.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) {
|
||||
self.state
|
||||
.entry(room_id.to_owned())
|
||||
|
|
Loading…
Reference in New Issue