From 841cfac1f8fb65860197f98465242804bc4f85ff Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 19 Oct 2023 12:54:47 -0700 Subject: [PATCH] Fix filtering when providing non-admins info about channel members --- crates/collab/src/db/queries/channels.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/collab/src/db/queries/channels.rs b/crates/collab/src/db/queries/channels.rs index 56b1d3b7ff..60ccff2614 100644 --- a/crates/collab/src/db/queries/channels.rs +++ b/crates/collab/src/db/queries/channels.rs @@ -713,7 +713,7 @@ impl Database { user_id: UserId, ) -> Result> { self.transaction(|tx| async move { - let role = self + let user_role = self .check_user_is_channel_member(channel_id, user_id, &*tx) .await?; @@ -797,13 +797,19 @@ impl Database { Ok(user_details .into_iter() - .filter_map(|(user_id, details)| { - // If the user is not an admin, don't give them all of the details - if role != ChannelRole::Admin { - if details.kind == Kind::AncestorMember { + .filter_map(|(user_id, mut details)| { + // If the user is not an admin, don't give them as much + // information about the other members. + if user_role != ChannelRole::Admin { + if details.kind == Kind::Invitee + || details.channel_role == ChannelRole::Banned + { return None; } - return None; + + if details.channel_role == ChannelRole::Admin { + details.channel_role = ChannelRole::Member; + } } Some(proto::ChannelMember {