Wire through public access toggle
This commit is contained in:
parent
f8fd77b83e
commit
f6f9b5c8cb
13 changed files with 209 additions and 38 deletions
|
@ -137,7 +137,7 @@ impl Into<i32> for ChannelRole {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Copy, Clone, Debug, EnumIter, DeriveActiveEnum, Default)]
|
||||
#[derive(Eq, PartialEq, Copy, Clone, Debug, EnumIter, DeriveActiveEnum, Default, Hash)]
|
||||
#[sea_orm(rs_type = "String", db_type = "String(None)")]
|
||||
pub enum ChannelVisibility {
|
||||
#[sea_orm(string_value = "public")]
|
||||
|
@ -151,7 +151,7 @@ impl From<proto::ChannelVisibility> for ChannelVisibility {
|
|||
fn from(value: proto::ChannelVisibility) -> Self {
|
||||
match value {
|
||||
proto::ChannelVisibility::Public => ChannelVisibility::Public,
|
||||
proto::ChannelVisibility::ChannelMembers => ChannelVisibility::Members,
|
||||
proto::ChannelVisibility::Members => ChannelVisibility::Members,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ impl Into<proto::ChannelVisibility> for ChannelVisibility {
|
|||
fn into(self) -> proto::ChannelVisibility {
|
||||
match self {
|
||||
ChannelVisibility::Public => proto::ChannelVisibility::Public,
|
||||
ChannelVisibility::Members => proto::ChannelVisibility::ChannelMembers,
|
||||
ChannelVisibility::Members => proto::ChannelVisibility::Members,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,12 +93,12 @@ impl Database {
|
|||
channel_id: ChannelId,
|
||||
visibility: ChannelVisibility,
|
||||
user_id: UserId,
|
||||
) -> Result<()> {
|
||||
) -> Result<channel::Model> {
|
||||
self.transaction(move |tx| async move {
|
||||
self.check_user_is_channel_admin(channel_id, user_id, &*tx)
|
||||
.await?;
|
||||
|
||||
channel::ActiveModel {
|
||||
let channel = channel::ActiveModel {
|
||||
id: ActiveValue::Unchanged(channel_id),
|
||||
visibility: ActiveValue::Set(visibility),
|
||||
..Default::default()
|
||||
|
@ -106,7 +106,7 @@ impl Database {
|
|||
.update(&*tx)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
Ok(channel)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
@ -219,14 +219,14 @@ impl Database {
|
|||
channel_id: ChannelId,
|
||||
user_id: UserId,
|
||||
new_name: &str,
|
||||
) -> Result<String> {
|
||||
) -> Result<Channel> {
|
||||
self.transaction(move |tx| async move {
|
||||
let new_name = Self::sanitize_channel_name(new_name)?.to_string();
|
||||
|
||||
self.check_user_is_channel_admin(channel_id, user_id, &*tx)
|
||||
.await?;
|
||||
|
||||
channel::ActiveModel {
|
||||
let channel = channel::ActiveModel {
|
||||
id: ActiveValue::Unchanged(channel_id),
|
||||
name: ActiveValue::Set(new_name.clone()),
|
||||
..Default::default()
|
||||
|
@ -234,7 +234,11 @@ impl Database {
|
|||
.update(&*tx)
|
||||
.await?;
|
||||
|
||||
Ok(new_name)
|
||||
Ok(Channel {
|
||||
id: channel.id,
|
||||
name: channel.name,
|
||||
visibility: channel.visibility,
|
||||
})
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
@ -336,6 +340,7 @@ impl Database {
|
|||
.map(|channel| Channel {
|
||||
id: channel.id,
|
||||
name: channel.name,
|
||||
visibility: channel.visibility,
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -443,6 +448,7 @@ impl Database {
|
|||
channels.push(Channel {
|
||||
id: channel.id,
|
||||
name: channel.name,
|
||||
visibility: channel.visibility,
|
||||
});
|
||||
|
||||
if role == ChannelRole::Admin {
|
||||
|
@ -963,6 +969,7 @@ impl Database {
|
|||
Ok(Some((
|
||||
Channel {
|
||||
id: channel.id,
|
||||
visibility: channel.visibility,
|
||||
name: channel.name,
|
||||
},
|
||||
is_accepted,
|
||||
|
|
|
@ -159,6 +159,7 @@ fn graph(channels: &[(ChannelId, &'static str)], edges: &[(ChannelId, ChannelId)
|
|||
graph.channels.push(Channel {
|
||||
id: *id,
|
||||
name: name.to_string(),
|
||||
visibility: ChannelVisibility::Members,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue