diff --git a/Cargo.lock b/Cargo.lock index a2fc2bf2d8..ce517efd09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1558,6 +1558,7 @@ dependencies = [ "fuzzy", "gpui", "language", + "lazy_static", "log", "menu", "notifications", diff --git a/crates/collab/src/db/queries/channels.rs b/crates/collab/src/db/queries/channels.rs index d2499ab3ce..1ca38b2e3c 100644 --- a/crates/collab/src/db/queries/channels.rs +++ b/crates/collab/src/db/queries/channels.rs @@ -552,7 +552,8 @@ impl Database { user_id: UserId, ) -> Result> { self.transaction(|tx| async move { - self.check_user_is_channel_admin(channel_id, user_id, &*tx) + let user_membership = self + .check_user_is_channel_member(channel_id, user_id, &*tx) .await?; #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] @@ -613,6 +614,14 @@ impl Database { }); } + // If the user is not an admin, don't give them all of the details + if !user_membership.admin { + rows.retain_mut(|row| { + row.admin = false; + row.kind != proto::channel_member::Kind::Invitee as i32 + }); + } + Ok(rows) }) .await @@ -644,9 +653,9 @@ impl Database { channel_id: ChannelId, user_id: UserId, tx: &DatabaseTransaction, - ) -> Result<()> { + ) -> Result { let channel_ids = self.get_channel_ancestors(channel_id, tx).await?; - channel_member::Entity::find() + Ok(channel_member::Entity::find() .filter( channel_member::Column::ChannelId .is_in(channel_ids) @@ -654,8 +663,7 @@ impl Database { ) .one(&*tx) .await? - .ok_or_else(|| anyhow!("user is not a channel member or channel does not exist"))?; - Ok(()) + .ok_or_else(|| anyhow!("user is not a channel member or channel does not exist"))?) } pub async fn check_user_is_channel_admin( diff --git a/crates/collab_ui/Cargo.toml b/crates/collab_ui/Cargo.toml index 4a0f8c5e8b..697faace80 100644 --- a/crates/collab_ui/Cargo.toml +++ b/crates/collab_ui/Cargo.toml @@ -54,6 +54,7 @@ zed-actions = {path = "../zed-actions"} anyhow.workspace = true futures.workspace = true +lazy_static.workspace = true log.workspace = true schemars.workspace = true postage.workspace = true diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rs index d58a406d78..28bfe62109 100644 --- a/crates/collab_ui/src/chat_panel.rs +++ b/crates/collab_ui/src/chat_panel.rs @@ -18,8 +18,9 @@ use gpui::{ AnyViewHandle, AppContext, AsyncAppContext, Entity, ModelHandle, Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle, }; -use language::{language_settings::SoftWrap, LanguageRegistry}; +use language::LanguageRegistry; use menu::Confirm; +use message_editor::MessageEditor; use project::Fs; use rich_text::RichText; use serde::{Deserialize, Serialize}; @@ -33,6 +34,8 @@ use workspace::{ Workspace, }; +mod message_editor; + const MESSAGE_LOADING_THRESHOLD: usize = 50; const CHAT_PANEL_KEY: &'static str = "ChatPanel"; @@ -42,7 +45,7 @@ pub struct ChatPanel { languages: Arc, active_chat: Option<(ModelHandle, Subscription)>, message_list: ListState, - input_editor: ViewHandle, + input_editor: ViewHandle, channel_select: ViewHandle