Prevent guests from screen-sharing, unmuting or screen sharing
This commit is contained in:
parent
6877bd4969
commit
9fe17a1d1d
5 changed files with 60 additions and 25 deletions
|
@ -1251,6 +1251,11 @@ impl Room {
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn can_publish(&self) -> bool {
|
||||||
|
self.local_participant().role == proto::ChannelRole::Member
|
||||||
|
|| self.local_participant().role == proto::ChannelRole::Admin
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_speaking(&self) -> bool {
|
pub fn is_speaking(&self) -> bool {
|
||||||
self.live_kit
|
self.live_kit
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
@ -132,6 +132,14 @@ impl ChannelRole {
|
||||||
Admin | Member | Banned => false,
|
Admin | Member | Banned => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn can_share_projects(&self) -> bool {
|
||||||
|
use ChannelRole::*;
|
||||||
|
match self {
|
||||||
|
Admin | Member => true,
|
||||||
|
Guest | Banned => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<proto::ChannelRole> for ChannelRole {
|
impl From<proto::ChannelRole> for ChannelRole {
|
||||||
|
|
|
@ -46,6 +46,13 @@ impl Database {
|
||||||
if participant.room_id != room_id {
|
if participant.room_id != room_id {
|
||||||
return Err(anyhow!("shared project on unexpected room"))?;
|
return Err(anyhow!("shared project on unexpected room"))?;
|
||||||
}
|
}
|
||||||
|
if !participant
|
||||||
|
.role
|
||||||
|
.unwrap_or(ChannelRole::Member)
|
||||||
|
.can_share_projects()
|
||||||
|
{
|
||||||
|
return Err(anyhow!("guests cannot share projects"))?;
|
||||||
|
}
|
||||||
|
|
||||||
let project = project::ActiveModel {
|
let project = project::ActiveModel {
|
||||||
room_id: ActiveValue::set(participant.room_id),
|
room_id: ActiveValue::set(participant.room_id),
|
||||||
|
|
|
@ -173,8 +173,9 @@ impl Render for CollabTitlebarItem {
|
||||||
let is_muted = room.is_muted(cx);
|
let is_muted = room.is_muted(cx);
|
||||||
let is_deafened = room.is_deafened().unwrap_or(false);
|
let is_deafened = room.is_deafened().unwrap_or(false);
|
||||||
let is_screen_sharing = room.is_screen_sharing();
|
let is_screen_sharing = room.is_screen_sharing();
|
||||||
|
let can_publish = room.can_publish();
|
||||||
|
|
||||||
this.when(is_local, |this| {
|
this.when(is_local && can_publish, |this| {
|
||||||
this.child(
|
this.child(
|
||||||
Button::new(
|
Button::new(
|
||||||
"toggle_sharing",
|
"toggle_sharing",
|
||||||
|
@ -203,20 +204,22 @@ impl Render for CollabTitlebarItem {
|
||||||
.detach_and_log_err(cx);
|
.detach_and_log_err(cx);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.child(
|
.when(can_publish, |this| {
|
||||||
IconButton::new(
|
this.child(
|
||||||
"mute-microphone",
|
IconButton::new(
|
||||||
if is_muted {
|
"mute-microphone",
|
||||||
ui::Icon::MicMute
|
if is_muted {
|
||||||
} else {
|
ui::Icon::MicMute
|
||||||
ui::Icon::Mic
|
} else {
|
||||||
},
|
ui::Icon::Mic
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.style(ButtonStyle::Subtle)
|
||||||
|
.icon_size(IconSize::Small)
|
||||||
|
.selected(is_muted)
|
||||||
|
.on_click(move |_, cx| crate::toggle_mute(&Default::default(), cx)),
|
||||||
)
|
)
|
||||||
.style(ButtonStyle::Subtle)
|
})
|
||||||
.icon_size(IconSize::Small)
|
|
||||||
.selected(is_muted)
|
|
||||||
.on_click(move |_, cx| crate::toggle_mute(&Default::default(), cx)),
|
|
||||||
)
|
|
||||||
.child(
|
.child(
|
||||||
IconButton::new(
|
IconButton::new(
|
||||||
"mute-sound",
|
"mute-sound",
|
||||||
|
@ -230,19 +233,30 @@ impl Render for CollabTitlebarItem {
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.selected(is_deafened)
|
.selected(is_deafened)
|
||||||
.tooltip(move |cx| {
|
.tooltip(move |cx| {
|
||||||
Tooltip::with_meta("Deafen Audio", None, "Mic will be muted", cx)
|
if can_publish {
|
||||||
|
Tooltip::with_meta(
|
||||||
|
"Deafen Audio",
|
||||||
|
None,
|
||||||
|
"Mic will be muted",
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Tooltip::text("Deafen Audio", cx)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.on_click(move |_, cx| crate::toggle_mute(&Default::default(), cx)),
|
.on_click(move |_, cx| crate::toggle_deafen(&Default::default(), cx)),
|
||||||
)
|
|
||||||
.child(
|
|
||||||
IconButton::new("screen-share", ui::Icon::Screen)
|
|
||||||
.style(ButtonStyle::Subtle)
|
|
||||||
.icon_size(IconSize::Small)
|
|
||||||
.selected(is_screen_sharing)
|
|
||||||
.on_click(move |_, cx| {
|
|
||||||
crate::toggle_screen_sharing(&Default::default(), cx)
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
|
.when(can_publish, |this| {
|
||||||
|
this.child(
|
||||||
|
IconButton::new("screen-share", ui::Icon::Screen)
|
||||||
|
.style(ButtonStyle::Subtle)
|
||||||
|
.icon_size(IconSize::Small)
|
||||||
|
.selected(is_screen_sharing)
|
||||||
|
.on_click(move |_, cx| {
|
||||||
|
crate::toggle_screen_sharing(&Default::default(), cx)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.map(|el| {
|
.map(|el| {
|
||||||
let status = self.client.status();
|
let status = self.client.status();
|
||||||
|
|
|
@ -62,6 +62,7 @@ impl<'a> VideoGrant<'a> {
|
||||||
Self {
|
Self {
|
||||||
room: Some(Cow::Borrowed(room)),
|
room: Some(Cow::Borrowed(room)),
|
||||||
room_join: Some(true),
|
room_join: Some(true),
|
||||||
|
can_publish: Some(false),
|
||||||
can_subscribe: Some(true),
|
can_subscribe: Some(true),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue