diff --git a/crates/client/src/channel_store.rs b/crates/client/src/channel_store.rs
index 317fbd1189..93b96fc629 100644
--- a/crates/client/src/channel_store.rs
+++ b/crates/client/src/channel_store.rs
@@ -301,8 +301,10 @@ impl ChannelStore {
.iter_mut()
.find(|c| c.id == channel.id)
{
- let existing_channel = Arc::make_mut(existing_channel);
+ let existing_channel = Arc::get_mut(existing_channel)
+ .expect("channel is shared, update would have been lost");
existing_channel.name = channel.name;
+ existing_channel.user_is_admin = channel.user_is_admin;
continue;
}
@@ -320,7 +322,8 @@ impl ChannelStore {
for channel in payload.channels {
if let Some(existing_channel) = self.channels.iter_mut().find(|c| c.id == channel.id) {
- let existing_channel = Arc::make_mut(existing_channel);
+ let existing_channel = Arc::get_mut(existing_channel)
+ .expect("channel is shared, update would have been lost");
existing_channel.name = channel.name;
existing_channel.user_is_admin = channel.user_is_admin;
continue;
diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs
index c3ffc12634..eb40587ea7 100644
--- a/crates/collab/src/db.rs
+++ b/crates/collab/src/db.rs
@@ -3601,7 +3601,7 @@ impl Database {
)
.one(&*tx)
.await?
- .ok_or_else(|| anyhow!("user is not a channel member"))?;
+ .ok_or_else(|| anyhow!("user is not a channel member or channel does not exist"))?;
Ok(())
}
@@ -3621,7 +3621,7 @@ impl Database {
)
.one(&*tx)
.await?
- .ok_or_else(|| anyhow!("user is not a channel admin"))?;
+ .ok_or_else(|| anyhow!("user is not a channel admin or channel does not exist"))?;
Ok(())
}
@@ -3723,31 +3723,53 @@ impl Database {
Ok(parents_by_child_id)
}
+ /// Returns the channel with the given ID and:
+ /// - true if the user is a member
+ /// - false if the user hasn't accepted the invitation yet
pub async fn get_channel(
&self,
channel_id: ChannelId,
user_id: UserId,
- ) -> Result