Skip to content

Commit

Permalink
chore(room_list): only display the knock state events if the current …
Browse files Browse the repository at this point in the history
…user can act on them

That is, if their power level allows them to either invite or kick users.
  • Loading branch information
jmartinesp committed Oct 28, 2024
1 parent a4519f2 commit 7df1d4a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/matrix-sdk-base/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,18 @@ impl BaseClient {
| PossibleLatestEvent::YesCallNotify(_)
| PossibleLatestEvent::YesSticker(_)
| PossibleLatestEvent::YesKnockedStateEvent(_) => {
// The event is the right type for us to use as latest_event
return Some((Box::new(LatestEvent::new(decrypted)), i));
let own_user_profile =
room.get_member(room.own_user_id()).await.ok().flatten();

let can_accept_or_decline_knocks = own_user_profile
.map(|profile| profile.can_invite() || profile.can_kick())
.unwrap_or_default();

// The current user can act on the knock changes, so they should be
// displayed
if can_accept_or_decline_knocks {
return Some((Box::new(LatestEvent::new(decrypted)), i));
}
}
_ => (),
}
Expand Down

0 comments on commit 7df1d4a

Please sign in to comment.