@@ -7,7 +7,7 @@ use ruma::{
7
7
} ;
8
8
9
9
use super :: command:: Command ;
10
- use crate :: NotificationSettingsError ;
10
+ use crate :: { notification_settings :: command :: Notify , NotificationSettingsError } ;
11
11
12
12
/// A `RuleCommand` allows to generate a list of `Command` needed to modify a
13
13
/// `Ruleset`
@@ -27,7 +27,7 @@ impl RuleCommands {
27
27
& mut self ,
28
28
kind : RuleKind ,
29
29
room_id : & RoomId ,
30
- notify : bool ,
30
+ notify : Notify ,
31
31
) -> Result < ( ) , NotificationSettingsError > {
32
32
let command = match kind {
33
33
RuleKind :: Room => Command :: SetRoomPushRule { room_id : room_id. to_owned ( ) , notify } ,
@@ -210,7 +210,7 @@ mod tests {
210
210
} ;
211
211
212
212
use super :: RuleCommands ;
213
- use crate :: { error:: NotificationSettingsError , notification_settings:: command:: Command } ;
213
+ use crate :: { error:: NotificationSettingsError , notification_settings:: command:: { Command , Notify } } ;
214
214
215
215
fn get_server_default_ruleset ( ) -> Ruleset {
216
216
let user_id = UserId :: parse ( "@user:matrix.org" ) . unwrap ( ) ;
@@ -225,7 +225,7 @@ mod tests {
225
225
async fn test_insert_rule_room ( ) {
226
226
let room_id = get_test_room_id ( ) ;
227
227
let mut rule_commands = RuleCommands :: new ( get_server_default_ruleset ( ) ) ;
228
- rule_commands. insert_rule ( RuleKind :: Room , & room_id, true ) . unwrap ( ) ;
228
+ rule_commands. insert_rule ( RuleKind :: Room , & room_id, Notify :: All ) . unwrap ( ) ;
229
229
230
230
// A rule must have been inserted in the ruleset.
231
231
assert ! ( rule_commands. rules. get( RuleKind :: Room , & room_id) . is_some( ) ) ;
@@ -235,7 +235,7 @@ mod tests {
235
235
assert_matches ! ( & rule_commands. commands[ 0 ] ,
236
236
Command :: SetRoomPushRule { room_id: command_room_id, notify } => {
237
237
assert_eq!( command_room_id, & room_id) ;
238
- assert! ( notify) ;
238
+ assert_eq! ( & Notify :: All , notify) ;
239
239
}
240
240
) ;
241
241
}
@@ -244,7 +244,7 @@ mod tests {
244
244
async fn test_insert_rule_override ( ) {
245
245
let room_id = get_test_room_id ( ) ;
246
246
let mut rule_commands = RuleCommands :: new ( get_server_default_ruleset ( ) ) ;
247
- rule_commands. insert_rule ( RuleKind :: Override , & room_id, true ) . unwrap ( ) ;
247
+ rule_commands. insert_rule ( RuleKind :: Override , & room_id, Notify :: All ) . unwrap ( ) ;
248
248
249
249
// A rule must have been inserted in the ruleset.
250
250
assert ! ( rule_commands. rules. get( RuleKind :: Override , & room_id) . is_some( ) ) ;
@@ -255,7 +255,7 @@ mod tests {
255
255
Command :: SetOverridePushRule { room_id: command_room_id, rule_id, notify } => {
256
256
assert_eq!( command_room_id, & room_id) ;
257
257
assert_eq!( rule_id, room_id. as_str( ) ) ;
258
- assert! ( notify) ;
258
+ assert_eq! ( & Notify :: All , notify) ;
259
259
}
260
260
) ;
261
261
}
@@ -266,17 +266,17 @@ mod tests {
266
266
let mut rule_commands = RuleCommands :: new ( get_server_default_ruleset ( ) ) ;
267
267
268
268
assert_matches ! (
269
- rule_commands. insert_rule( RuleKind :: Underride , & room_id, true ) ,
269
+ rule_commands. insert_rule( RuleKind :: Underride , & room_id, Notify :: All ) ,
270
270
Err ( NotificationSettingsError :: InvalidParameter ( _) ) => { }
271
271
) ;
272
272
273
273
assert_matches ! (
274
- rule_commands. insert_rule( RuleKind :: Content , & room_id, true ) ,
274
+ rule_commands. insert_rule( RuleKind :: Content , & room_id, Notify :: All ) ,
275
275
Err ( NotificationSettingsError :: InvalidParameter ( _) ) => { }
276
276
) ;
277
277
278
278
assert_matches ! (
279
- rule_commands. insert_rule( RuleKind :: Sender , & room_id, true ) ,
279
+ rule_commands. insert_rule( RuleKind :: Sender , & room_id, Notify :: All ) ,
280
280
Err ( NotificationSettingsError :: InvalidParameter ( _) ) => { }
281
281
) ;
282
282
}
0 commit comments