@@ -24,6 +24,10 @@ use ruma::{
2424 assign,
2525 events:: {
2626 direct:: DirectEventContent ,
27+ do_not_disturb:: {
28+ DoNotDisturbEventContent , DoNotDisturbRoom as RumaDoNotDisturbRoom ,
29+ DoNotDisturbRoomKey as RumaDoNotDisturbRoomKey ,
30+ } ,
2731 fully_read:: FullyReadEventContent ,
2832 identity_server:: IdentityServerEventContent ,
2933 ignored_user_list:: { IgnoredUser as RumaIgnoredUser , IgnoredUserListEventContent } ,
@@ -1090,6 +1094,8 @@ pub fn content_without_relation_from_message(
10901094pub enum AccountDataEventType {
10911095 /// m.direct
10921096 Direct ,
1097+ /// dm.filament.do_not_disturb
1098+ DoNotDisturbRoomList ,
10931099 /// m.identity_server
10941100 IdentityServer ,
10951101 /// m.ignored_user_list
@@ -1108,6 +1114,7 @@ impl TryFrom<RumaGlobalAccountDataEventType> for AccountDataEventType {
11081114 fn try_from ( value : RumaGlobalAccountDataEventType ) -> Result < Self , Self :: Error > {
11091115 match value {
11101116 RumaGlobalAccountDataEventType :: Direct => Ok ( Self :: Direct ) ,
1117+ RumaGlobalAccountDataEventType :: DoNotDisturb => Ok ( Self :: DoNotDisturbRoomList ) ,
11111118 RumaGlobalAccountDataEventType :: IdentityServer => Ok ( Self :: IdentityServer ) ,
11121119 RumaGlobalAccountDataEventType :: IgnoredUserList => Ok ( Self :: IgnoredUserList ) ,
11131120 RumaGlobalAccountDataEventType :: PushRules => Ok ( Self :: PushRules ) ,
@@ -1131,6 +1138,12 @@ pub enum AccountDataEvent {
11311138 /// for that user ID.
11321139 map : HashMap < String , Vec < String > > ,
11331140 } ,
1141+ /// dm.filament.do_not_disturb
1142+ DoNotDisturbRoomList {
1143+ /// The map of rooms in "Do not Disturb" mode. This is a mapping from
1144+ /// [`DoNotDisturbRoomKey`] to empty object.
1145+ rooms : HashMap < DoNotDisturbRoomKey , DoNotDisturbRoom > ,
1146+ } ,
11341147 /// m.identity_server
11351148 IdentityServer {
11361149 /// The base URL for the identity server for client-server connections.
@@ -1232,6 +1245,42 @@ impl From<InviteAvatars> for RumaInviteAvatars {
12321245 }
12331246}
12341247
1248+ /// The key for a "Do not Disturb" setting.
1249+ ///
1250+ /// This either matches a single room or all rooms.
1251+ #[ derive( Clone , Eq , Hash , PartialEq , uniffi:: Enum ) ]
1252+ pub enum DoNotDisturbRoomKey {
1253+ /// Match any room.
1254+ AllRooms ,
1255+
1256+ /// Match a single room based on its room ID.
1257+ SingleRoom ( String ) ,
1258+ }
1259+
1260+ impl From < RumaDoNotDisturbRoomKey > for DoNotDisturbRoomKey {
1261+ fn from ( value : RumaDoNotDisturbRoomKey ) -> Self {
1262+ match value {
1263+ RumaDoNotDisturbRoomKey :: AllRooms => DoNotDisturbRoomKey :: AllRooms ,
1264+ RumaDoNotDisturbRoomKey :: SingleRoom ( room_id) => {
1265+ DoNotDisturbRoomKey :: SingleRoom ( room_id. into ( ) )
1266+ }
1267+ _ => panic ! ( "Unexpected DoNotDisturbRoomKey: {value:?}" ) ,
1268+ }
1269+ }
1270+ }
1271+
1272+ /// Details about a room in "Do not Disturb" mode.
1273+ ///
1274+ /// This is currently empty.
1275+ #[ derive( Clone , uniffi:: Record ) ]
1276+ pub struct DoNotDisturbRoom { }
1277+
1278+ impl From < RumaDoNotDisturbRoom > for DoNotDisturbRoom {
1279+ fn from ( _value : RumaDoNotDisturbRoom ) -> Self {
1280+ DoNotDisturbRoom { }
1281+ }
1282+ }
1283+
12351284/// Details about an ignored user.
12361285///
12371286/// This is currently empty.
@@ -1567,6 +1616,21 @@ impl From<RumaGlobalAccountDataEvent<DirectEventContent>> for AccountDataEvent {
15671616 }
15681617}
15691618
1619+ impl From < RumaGlobalAccountDataEvent < DoNotDisturbEventContent > > for AccountDataEvent {
1620+ fn from ( value : RumaGlobalAccountDataEvent < DoNotDisturbEventContent > ) -> Self {
1621+ Self :: DoNotDisturbRoomList {
1622+ rooms : value
1623+ . content
1624+ . rooms
1625+ . into_iter ( )
1626+ . map ( |( key, do_not_disturb_room) | {
1627+ ( key. into ( ) , DoNotDisturbRoom :: from ( do_not_disturb_room) )
1628+ } )
1629+ . collect ( ) ,
1630+ }
1631+ }
1632+ }
1633+
15701634impl From < RumaGlobalAccountDataEvent < IdentityServerEventContent > > for AccountDataEvent {
15711635 fn from ( value : RumaGlobalAccountDataEvent < IdentityServerEventContent > ) -> Self {
15721636 Self :: IdentityServer { base_url : value. content . base_url . into_option ( ) }
0 commit comments