mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 18:41:56 +03:00
Add channel visibility columns and protos
This commit is contained in:
parent
540436a1f9
commit
78432d08ca
@ -3,7 +3,7 @@ use crate::channel_chat::ChannelChatEvent;
|
|||||||
use super::*;
|
use super::*;
|
||||||
use client::{test::FakeServer, Client, UserStore};
|
use client::{test::FakeServer, Client, UserStore};
|
||||||
use gpui::{AppContext, ModelHandle, TestAppContext};
|
use gpui::{AppContext, ModelHandle, TestAppContext};
|
||||||
use rpc::proto;
|
use rpc::proto::{self, ChannelRole};
|
||||||
use settings::SettingsStore;
|
use settings::SettingsStore;
|
||||||
use util::http::FakeHttpClient;
|
use util::http::FakeHttpClient;
|
||||||
|
|
||||||
@ -18,10 +18,12 @@ fn test_update_channels(cx: &mut AppContext) {
|
|||||||
proto::Channel {
|
proto::Channel {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "b".to_string(),
|
name: "b".to_string(),
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
},
|
},
|
||||||
proto::Channel {
|
proto::Channel {
|
||||||
id: 2,
|
id: 2,
|
||||||
name: "a".to_string(),
|
name: "a".to_string(),
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
channel_permissions: vec![proto::ChannelPermission {
|
channel_permissions: vec![proto::ChannelPermission {
|
||||||
@ -49,10 +51,12 @@ fn test_update_channels(cx: &mut AppContext) {
|
|||||||
proto::Channel {
|
proto::Channel {
|
||||||
id: 3,
|
id: 3,
|
||||||
name: "x".to_string(),
|
name: "x".to_string(),
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
},
|
},
|
||||||
proto::Channel {
|
proto::Channel {
|
||||||
id: 4,
|
id: 4,
|
||||||
name: "y".to_string(),
|
name: "y".to_string(),
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
insert_edge: vec![
|
insert_edge: vec![
|
||||||
@ -92,14 +96,17 @@ fn test_dangling_channel_paths(cx: &mut AppContext) {
|
|||||||
proto::Channel {
|
proto::Channel {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "a".to_string(),
|
name: "a".to_string(),
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
},
|
},
|
||||||
proto::Channel {
|
proto::Channel {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "b".to_string(),
|
name: "b".to_string(),
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
},
|
},
|
||||||
proto::Channel {
|
proto::Channel {
|
||||||
id: 2,
|
id: 2,
|
||||||
name: "c".to_string(),
|
name: "c".to_string(),
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
insert_edge: vec![
|
insert_edge: vec![
|
||||||
@ -158,6 +165,7 @@ async fn test_channel_messages(cx: &mut TestAppContext) {
|
|||||||
channels: vec![proto::Channel {
|
channels: vec![proto::Channel {
|
||||||
id: channel_id,
|
id: channel_id,
|
||||||
name: "the-channel".to_string(),
|
name: "the-channel".to_string(),
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
}],
|
}],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
-- Add migration script here
|
|
||||||
|
|
||||||
ALTER TABLE channel_members ADD COLUMN role TEXT;
|
ALTER TABLE channel_members ADD COLUMN role TEXT;
|
||||||
UPDATE channel_members SET role = CASE WHEN admin THEN 'admin' ELSE 'member' END;
|
UPDATE channel_members SET role = CASE WHEN admin THEN 'admin' ELSE 'member' END;
|
||||||
|
|
||||||
|
ALTER TABLE channels ADD COLUMN visibility TEXT NOT NULL DEFAULT 'channel_members';
|
||||||
|
@ -119,3 +119,38 @@ impl Into<i32> for ChannelRole {
|
|||||||
proto.into()
|
proto.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Eq, PartialEq, Copy, Clone, Debug, EnumIter, DeriveActiveEnum, Default)]
|
||||||
|
#[sea_orm(rs_type = "String", db_type = "String(None)")]
|
||||||
|
pub enum ChannelVisibility {
|
||||||
|
#[sea_orm(string_value = "public")]
|
||||||
|
Public,
|
||||||
|
#[sea_orm(string_value = "channel_members")]
|
||||||
|
#[default]
|
||||||
|
ChannelMembers,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<proto::ChannelVisibility> for ChannelVisibility {
|
||||||
|
fn from(value: proto::ChannelVisibility) -> Self {
|
||||||
|
match value {
|
||||||
|
proto::ChannelVisibility::Public => ChannelVisibility::Public,
|
||||||
|
proto::ChannelVisibility::ChannelMembers => ChannelVisibility::ChannelMembers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<proto::ChannelVisibility> for ChannelVisibility {
|
||||||
|
fn into(self) -> proto::ChannelVisibility {
|
||||||
|
match self {
|
||||||
|
ChannelVisibility::Public => proto::ChannelVisibility::Public,
|
||||||
|
ChannelVisibility::ChannelMembers => proto::ChannelVisibility::ChannelMembers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<i32> for ChannelVisibility {
|
||||||
|
fn into(self) -> i32 {
|
||||||
|
let proto: proto::ChannelVisibility = self.into();
|
||||||
|
proto.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::db::ChannelId;
|
use crate::db::{ChannelId, ChannelVisibility};
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, DeriveEntityModel)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, DeriveEntityModel)]
|
||||||
@ -7,6 +7,7 @@ pub struct Model {
|
|||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: ChannelId,
|
pub id: ChannelId,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub visbility: ChannelVisibility,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
@ -38,8 +38,8 @@ use lazy_static::lazy_static;
|
|||||||
use prometheus::{register_int_gauge, IntGauge};
|
use prometheus::{register_int_gauge, IntGauge};
|
||||||
use rpc::{
|
use rpc::{
|
||||||
proto::{
|
proto::{
|
||||||
self, Ack, AnyTypedEnvelope, ChannelEdge, EntityMessage, EnvelopedMessage,
|
self, Ack, AnyTypedEnvelope, ChannelEdge, ChannelVisibility, EntityMessage,
|
||||||
LiveKitConnectionInfo, RequestMessage, UpdateChannelBufferCollaborators,
|
EnvelopedMessage, LiveKitConnectionInfo, RequestMessage, UpdateChannelBufferCollaborators,
|
||||||
},
|
},
|
||||||
Connection, ConnectionId, Peer, Receipt, TypedEnvelope,
|
Connection, ConnectionId, Peer, Receipt, TypedEnvelope,
|
||||||
};
|
};
|
||||||
@ -2210,6 +2210,8 @@ async fn create_channel(
|
|||||||
let channel = proto::Channel {
|
let channel = proto::Channel {
|
||||||
id: id.to_proto(),
|
id: id.to_proto(),
|
||||||
name: request.name,
|
name: request.name,
|
||||||
|
// TODO: Visibility
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
};
|
};
|
||||||
|
|
||||||
response.send(proto::CreateChannelResponse {
|
response.send(proto::CreateChannelResponse {
|
||||||
@ -2299,6 +2301,8 @@ async fn invite_channel_member(
|
|||||||
update.channel_invitations.push(proto::Channel {
|
update.channel_invitations.push(proto::Channel {
|
||||||
id: channel.id.to_proto(),
|
id: channel.id.to_proto(),
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
|
// TODO: Visibility
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
});
|
});
|
||||||
for connection_id in session
|
for connection_id in session
|
||||||
.connection_pool()
|
.connection_pool()
|
||||||
@ -2394,6 +2398,8 @@ async fn rename_channel(
|
|||||||
let channel = proto::Channel {
|
let channel = proto::Channel {
|
||||||
id: request.channel_id,
|
id: request.channel_id,
|
||||||
name: new_name,
|
name: new_name,
|
||||||
|
// TODO: Visibility
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
};
|
};
|
||||||
response.send(proto::RenameChannelResponse {
|
response.send(proto::RenameChannelResponse {
|
||||||
channel: Some(channel.clone()),
|
channel: Some(channel.clone()),
|
||||||
@ -2432,6 +2438,8 @@ async fn link_channel(
|
|||||||
.map(|channel| proto::Channel {
|
.map(|channel| proto::Channel {
|
||||||
id: channel.id.to_proto(),
|
id: channel.id.to_proto(),
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
|
// TODO: Visibility
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
insert_edge: channels_to_send.edges,
|
insert_edge: channels_to_send.edges,
|
||||||
@ -2523,6 +2531,8 @@ async fn move_channel(
|
|||||||
.map(|channel| proto::Channel {
|
.map(|channel| proto::Channel {
|
||||||
id: channel.id.to_proto(),
|
id: channel.id.to_proto(),
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
|
// TODO: Visibility
|
||||||
|
visibility: proto::ChannelVisibility::ChannelMembers as i32,
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
insert_edge: channels_to_send.edges,
|
insert_edge: channels_to_send.edges,
|
||||||
@ -2579,6 +2589,8 @@ async fn respond_to_channel_invite(
|
|||||||
.map(|channel| proto::Channel {
|
.map(|channel| proto::Channel {
|
||||||
id: channel.id.to_proto(),
|
id: channel.id.to_proto(),
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
|
// TODO: Visibility
|
||||||
|
visibility: ChannelVisibility::ChannelMembers.into(),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
update.unseen_channel_messages = result.channel_messages;
|
update.unseen_channel_messages = result.channel_messages;
|
||||||
@ -3082,6 +3094,8 @@ fn build_initial_channels_update(
|
|||||||
update.channels.push(proto::Channel {
|
update.channels.push(proto::Channel {
|
||||||
id: channel.id.to_proto(),
|
id: channel.id.to_proto(),
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
|
// TODO: Visibility
|
||||||
|
visibility: ChannelVisibility::Public.into(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3114,6 +3128,8 @@ fn build_initial_channels_update(
|
|||||||
update.channel_invitations.push(proto::Channel {
|
update.channel_invitations.push(proto::Channel {
|
||||||
id: channel.id.to_proto(),
|
id: channel.id.to_proto(),
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
|
// TODO: Visibility
|
||||||
|
visibility: ChannelVisibility::Public.into(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1539,9 +1539,15 @@ message Nonce {
|
|||||||
uint64 lower_half = 2;
|
uint64 lower_half = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ChannelVisibility {
|
||||||
|
Public = 0;
|
||||||
|
ChannelMembers = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message Channel {
|
message Channel {
|
||||||
uint64 id = 1;
|
uint64 id = 1;
|
||||||
string name = 2;
|
string name = 2;
|
||||||
|
ChannelVisibility visibility = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Contact {
|
message Contact {
|
||||||
|
Loading…
Reference in New Issue
Block a user