@@ -24,6 +24,10 @@ use ruma::{
24
24
assign,
25
25
events:: {
26
26
direct:: DirectEventContent ,
27
+ do_not_disturb:: {
28
+ DoNotDisturbEventContent , DoNotDisturbRoom as RumaDoNotDisturbRoom ,
29
+ DoNotDisturbRoomKey as RumaDoNotDisturbRoomKey ,
30
+ } ,
27
31
fully_read:: FullyReadEventContent ,
28
32
identity_server:: IdentityServerEventContent ,
29
33
ignored_user_list:: { IgnoredUser as RumaIgnoredUser , IgnoredUserListEventContent } ,
@@ -1090,6 +1094,8 @@ pub fn content_without_relation_from_message(
1090
1094
pub enum AccountDataEventType {
1091
1095
/// m.direct
1092
1096
Direct ,
1097
+ /// dm.filament.do_not_disturb
1098
+ DoNotDisturbRoomList ,
1093
1099
/// m.identity_server
1094
1100
IdentityServer ,
1095
1101
/// m.ignored_user_list
@@ -1108,6 +1114,7 @@ impl TryFrom<RumaGlobalAccountDataEventType> for AccountDataEventType {
1108
1114
fn try_from ( value : RumaGlobalAccountDataEventType ) -> Result < Self , Self :: Error > {
1109
1115
match value {
1110
1116
RumaGlobalAccountDataEventType :: Direct => Ok ( Self :: Direct ) ,
1117
+ RumaGlobalAccountDataEventType :: DoNotDisturb => Ok ( Self :: DoNotDisturbRoomList ) ,
1111
1118
RumaGlobalAccountDataEventType :: IdentityServer => Ok ( Self :: IdentityServer ) ,
1112
1119
RumaGlobalAccountDataEventType :: IgnoredUserList => Ok ( Self :: IgnoredUserList ) ,
1113
1120
RumaGlobalAccountDataEventType :: PushRules => Ok ( Self :: PushRules ) ,
@@ -1131,6 +1138,12 @@ pub enum AccountDataEvent {
1131
1138
/// for that user ID.
1132
1139
map : HashMap < String , Vec < String > > ,
1133
1140
} ,
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
+ } ,
1134
1147
/// m.identity_server
1135
1148
IdentityServer {
1136
1149
/// The base URL for the identity server for client-server connections.
@@ -1232,6 +1245,42 @@ impl From<InviteAvatars> for RumaInviteAvatars {
1232
1245
}
1233
1246
}
1234
1247
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
+
1235
1284
/// Details about an ignored user.
1236
1285
///
1237
1286
/// This is currently empty.
@@ -1567,6 +1616,21 @@ impl From<RumaGlobalAccountDataEvent<DirectEventContent>> for AccountDataEvent {
1567
1616
}
1568
1617
}
1569
1618
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
+
1570
1634
impl From < RumaGlobalAccountDataEvent < IdentityServerEventContent > > for AccountDataEvent {
1571
1635
fn from ( value : RumaGlobalAccountDataEvent < IdentityServerEventContent > ) -> Self {
1572
1636
Self :: IdentityServer { base_url : value. content . base_url . into_option ( ) }
0 commit comments