@@ -28,8 +28,8 @@ use ruma::{
28
28
api:: client:: sync:: sync_events:: v3:: RoomSummary as RumaSummary ,
29
29
assign,
30
30
events:: {
31
- AnyStrippedStateEvent , AnySyncStateEvent , AnySyncTimelineEvent , RedactContent ,
32
- RedactedStateEventContent , StateEventType , StaticStateEventContent , SyncStateEvent ,
31
+ AnyStrippedStateEvent , AnySyncStateEvent , AnySyncTimelineEvent , StateEventType ,
32
+ SyncStateEvent ,
33
33
beacon_info:: BeaconInfoEventContent ,
34
34
call:: member:: { CallMemberEventContent , CallMemberStateKey , MembershipData } ,
35
35
direct:: OwnedDirectUserIdentifier ,
@@ -331,25 +331,42 @@ impl BaseRoomInfo {
331
331
. unwrap_or ( ROOM_VERSION_RULES_FALLBACK )
332
332
. redaction ;
333
333
334
- // FIXME: Use let chains once available to get rid of unwrap()s
335
- if self . avatar . has_event_id ( redacts) {
336
- self . avatar . as_mut ( ) . unwrap ( ) . redact ( & redaction_rules) ;
337
- } else if self . canonical_alias . has_event_id ( redacts) {
338
- self . canonical_alias . as_mut ( ) . unwrap ( ) . redact ( & redaction_rules) ;
339
- } else if self . create . has_event_id ( redacts) {
340
- self . create . as_mut ( ) . unwrap ( ) . redact ( & redaction_rules) ;
341
- } else if self . guest_access . has_event_id ( redacts) {
342
- self . guest_access . as_mut ( ) . unwrap ( ) . redact ( & redaction_rules) ;
343
- } else if self . history_visibility . has_event_id ( redacts) {
344
- self . history_visibility . as_mut ( ) . unwrap ( ) . redact ( & redaction_rules) ;
345
- } else if self . join_rules . has_event_id ( redacts) {
346
- self . join_rules . as_mut ( ) . unwrap ( ) . redact ( & redaction_rules) ;
347
- } else if self . name . has_event_id ( redacts) {
348
- self . name . as_mut ( ) . unwrap ( ) . redact ( & redaction_rules) ;
349
- } else if self . tombstone . has_event_id ( redacts) {
350
- self . tombstone . as_mut ( ) . unwrap ( ) . redact ( & redaction_rules) ;
351
- } else if self . topic . has_event_id ( redacts) {
352
- self . topic . as_mut ( ) . unwrap ( ) . redact ( & redaction_rules) ;
334
+ if let Some ( ev) = & mut self . avatar
335
+ && ev. event_id ( ) == Some ( redacts)
336
+ {
337
+ ev. redact ( & redaction_rules) ;
338
+ } else if let Some ( ev) = & mut self . canonical_alias
339
+ && ev. event_id ( ) == Some ( redacts)
340
+ {
341
+ ev. redact ( & redaction_rules) ;
342
+ } else if let Some ( ev) = & mut self . create
343
+ && ev. event_id ( ) == Some ( redacts)
344
+ {
345
+ ev. redact ( & redaction_rules) ;
346
+ } else if let Some ( ev) = & mut self . guest_access
347
+ && ev. event_id ( ) == Some ( redacts)
348
+ {
349
+ ev. redact ( & redaction_rules) ;
350
+ } else if let Some ( ev) = & mut self . history_visibility
351
+ && ev. event_id ( ) == Some ( redacts)
352
+ {
353
+ ev. redact ( & redaction_rules) ;
354
+ } else if let Some ( ev) = & mut self . join_rules
355
+ && ev. event_id ( ) == Some ( redacts)
356
+ {
357
+ ev. redact ( & redaction_rules) ;
358
+ } else if let Some ( ev) = & mut self . name
359
+ && ev. event_id ( ) == Some ( redacts)
360
+ {
361
+ ev. redact ( & redaction_rules) ;
362
+ } else if let Some ( ev) = & mut self . tombstone
363
+ && ev. event_id ( ) == Some ( redacts)
364
+ {
365
+ ev. redact ( & redaction_rules) ;
366
+ } else if let Some ( ev) = & mut self . topic
367
+ && ev. event_id ( ) == Some ( redacts)
368
+ {
369
+ ev. redact ( & redaction_rules) ;
353
370
} else {
354
371
self . rtc_member_events
355
372
. retain ( |_, member_event| member_event. event_id ( ) != Some ( redacts) ) ;
@@ -396,20 +413,6 @@ impl Default for BaseRoomInfo {
396
413
}
397
414
}
398
415
399
- trait OptionExt {
400
- fn has_event_id ( & self , ev_id : & EventId ) -> bool ;
401
- }
402
-
403
- impl < C > OptionExt for Option < MinimalStateEvent < C > >
404
- where
405
- C : StaticStateEventContent + RedactContent ,
406
- C :: Redacted : RedactedStateEventContent ,
407
- {
408
- fn has_event_id ( & self , ev_id : & EventId ) -> bool {
409
- self . as_ref ( ) . is_some_and ( |ev| ev. event_id ( ) == Some ( ev_id) )
410
- }
411
- }
412
-
413
416
/// The underlying pure data structure for joined and left rooms.
414
417
///
415
418
/// Holds all the info needed to persist a room into the state store.
0 commit comments