BlueGit

ict rusty-teams

Merge branch 'feat/record' into integrate/calls-10

# Conflicts:
#	crates/app/src/call/actions.rs
#	crates/app/src/call/demo.rs

metis Daniel Däschle · pushed by metis

Authored 2026-10-15 · 6 weeks ago

Hash
c8ea69fc44edcf7722dcb630dbbc478af0f32c69
22 files changed +857 −37
crates/app/src/app_state.rs +5 −0
@@ -128,6 +128,8 @@ pub struct AppState {
128 128 pub call_launcher: Option<Arc<CallLauncher>>,
129 129 pub call_count: u64,
130 130 pub call_share_sound: bool,
131 pub recording_policy: teams_core::RecordingPolicy,
132 pub own_tenant: Option<String>,
131 133 pub call_share_motion: bool,
132 134 pub call_share_standout: bool,
133 135 pub call_report_enabled: bool,
@@ -244,6 +246,8 @@ impl AppState {
244 246 call_launcher: None,
245 247 call_count: 0,
246 248 call_share_sound: false,
249 recording_policy: teams_core::RecordingPolicy::default(),
250 own_tenant: None,
247 251 call_share_motion: false,
248 252 call_share_standout: false,
249 253 call_report_enabled: true,
@@ -842,6 +846,7 @@ impl AppState {
842 846 self.resend_outbox(cx);
843 847 self.refresh_scheduled(cx);
844 848 self.refresh_translation_settings(cx);
849 self.refresh_recording_policy(cx);
845 850 let waiting = self.directory.waiting_presence_ids();
846 851 self.request_presence(waiting, cx);
847 852 self.refresh_own_status(cx);
@@ -128,6 +128,8 @@ pub struct AppState {
128 pub call_launcher: Option<Arc<CallLauncher>>,
128 pub call_launcher: Option<Arc<CallLauncher>>,
129 pub call_count: u64,
129 pub call_count: u64,
130 pub call_share_sound: bool,
130 pub call_share_sound: bool,
131 pub recording_policy: teams_core::RecordingPolicy,
132 pub own_tenant: Option<String>,
131 pub call_share_motion: bool,
133 pub call_share_motion: bool,
132 pub call_share_standout: bool,
134 pub call_share_standout: bool,
133 pub call_report_enabled: bool,
135 pub call_report_enabled: bool,
@@ -244,6 +246,8 @@ impl AppState {
244 call_launcher: None,
246 call_launcher: None,
245 call_count: 0,
247 call_count: 0,
246 call_share_sound: false,
248 call_share_sound: false,
249 recording_policy: teams_core::RecordingPolicy::default(),
250 own_tenant: None,
247 call_share_motion: false,
251 call_share_motion: false,
248 call_share_standout: false,
252 call_share_standout: false,
249 call_report_enabled: true,
253 call_report_enabled: true,
@@ -842,6 +846,7 @@ impl AppState {
842 self.resend_outbox(cx);
846 self.resend_outbox(cx);
843 self.refresh_scheduled(cx);
847 self.refresh_scheduled(cx);
844 self.refresh_translation_settings(cx);
848 self.refresh_translation_settings(cx);
849 self.refresh_recording_policy(cx);
845 let waiting = self.directory.waiting_presence_ids();
850 let waiting = self.directory.waiting_presence_ids();
846 self.request_presence(waiting, cx);
851 self.request_presence(waiting, cx);
847 self.refresh_own_status(cx);
852 self.refresh_own_status(cx);
crates/app/src/call/actions.rs +10 −2
@@ -290,6 +290,8 @@ impl AppState {
290 290 if let Some(call) = self.call.as_mut() {
291 291 call.report.clone_from(&report);
292 292 }
293 let rights_conversation = self.call.as_ref().and_then(|call| call.conversation_id.clone());
294 self.apply_recording_rights(rights_conversation.as_deref(), cx);
293 295 self.follow_call(call_id, updates, report, cx);
294 296 cx.emit(AppEvent::Call);
295 297 cx.notify();
@@ -1115,6 +1117,10 @@ impl AppState {
1115 1117 if scene.minimized() {
1116 1118 self.show_call(false, cx);
1117 1119 }
1120 if let Some(call) = self.call.as_mut().filter(|_| scene == DemoScene::Blocked) {
1121 call.model.recording_policy.call_recording = false;
1122 call.model.recording_policy.call_transcription = false;
1123 }
1118 1124 if scene == DemoScene::Gallery {
1119 1125 self.queue_demo_bubbles(conversation_id, cx);
1120 1126 }
@@ -1839,10 +1845,12 @@ mod tests {
1839 1845 }
1840 1846
1841 1847 #[gpui_kit::test]
1842 fn only_the_organizer_starts_a_recording_and_the_notice_needs_a_consent_request(
1848 fn attendees_cannot_start_a_recording_and_the_notice_needs_a_consent_request(
1843 1849 cx: &mut TestAppContext,
1844 1850 ) {
1845 let (attendee, mut attendee_control) = app_with_commands(cx, live_meeting(false), None);
1851 let mut attendee_model = live_meeting(false);
1852 attendee_model.own_role = Some(calling::MeetingRole::Attendee);
1853 let (attendee, mut attendee_control) = app_with_commands(cx, attendee_model, None);
1846 1854 cx.update(|cx| {
1847 1855 attendee.update(cx, |state, cx| {
1848 1856 state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);
@@ -290,6 +290,8 @@ impl AppState {
290 if let Some(call) = self.call.as_mut() {
290 if let Some(call) = self.call.as_mut() {
291 call.report.clone_from(&report);
291 call.report.clone_from(&report);
292 }
292 }
293 let rights_conversation = self.call.as_ref().and_then(|call| call.conversation_id.clone());
294 self.apply_recording_rights(rights_conversation.as_deref(), cx);
293 self.follow_call(call_id, updates, report, cx);
295 self.follow_call(call_id, updates, report, cx);
294 cx.emit(AppEvent::Call);
296 cx.emit(AppEvent::Call);
295 cx.notify();
297 cx.notify();
@@ -1115,6 +1117,10 @@ impl AppState {
1115 if scene.minimized() {
1117 if scene.minimized() {
1116 self.show_call(false, cx);
1118 self.show_call(false, cx);
1117 }
1119 }
1120 if let Some(call) = self.call.as_mut().filter(|_| scene == DemoScene::Blocked) {
1121 call.model.recording_policy.call_recording = false;
1122 call.model.recording_policy.call_transcription = false;
1123 }
1118 if scene == DemoScene::Gallery {
1124 if scene == DemoScene::Gallery {
1119 self.queue_demo_bubbles(conversation_id, cx);
1125 self.queue_demo_bubbles(conversation_id, cx);
1120 }
1126 }
@@ -1839,10 +1845,12 @@ mod tests {
1839 }
1845 }
1840
1846
1841 #[gpui_kit::test]
1847 #[gpui_kit::test]
1842 fn only_the_organizer_starts_a_recording_and_the_notice_needs_a_consent_request(
1848 fn attendees_cannot_start_a_recording_and_the_notice_needs_a_consent_request(
1843 cx: &mut TestAppContext,
1849 cx: &mut TestAppContext,
1844 ) {
1850 ) {
1845 let (attendee, mut attendee_control) = app_with_commands(cx, live_meeting(false), None);
1851 let mut attendee_model = live_meeting(false);
1852 attendee_model.own_role = Some(calling::MeetingRole::Attendee);
1853 let (attendee, mut attendee_control) = app_with_commands(cx, attendee_model, None);
1846 cx.update(|cx| {
1854 cx.update(|cx| {
1847 attendee.update(cx, |state, cx| {
1855 attendee.update(cx, |state, cx| {
1848 state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);
1856 state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);
crates/app/src/call/demo.rs +4 −0
@@ -103,6 +103,7 @@ pub enum DemoScene {
103 103 Mini,
104 104 MiniOff,
105 105 MiniShare,
106 Blocked,
106 107 }
107 108
108 109 impl DemoScene {
@@ -122,6 +123,7 @@ impl DemoScene {
122 123 "mini" => DemoScene::Mini,
123 124 "mini-off" => DemoScene::MiniOff,
124 125 "mini-share" => DemoScene::MiniShare,
126 "blocked" => DemoScene::Blocked,
125 127 _ => return None,
126 128 })
127 129 }
@@ -137,6 +139,7 @@ impl DemoScene {
137 139 | DemoScene::Mini
138 140 | DemoScene::MiniOff
139 141 | DemoScene::MiniShare
142 | DemoScene::Blocked
140 143 )
141 144 }
142 145
@@ -446,6 +449,7 @@ fn start_scene(control: &CallControl, scene: DemoScene) {
446 449 | DemoScene::Whiteboard
447 450 | DemoScene::Gallery
448 451 | DemoScene::Sharing
452 | DemoScene::Blocked
449 453 | DemoScene::Plain => {}
450 454 }
451 455 }
@@ -103,6 +103,7 @@ pub enum DemoScene {
103 Mini,
103 Mini,
104 MiniOff,
104 MiniOff,
105 MiniShare,
105 MiniShare,
106 Blocked,
106}
107}
107
108
108impl DemoScene {
109impl DemoScene {
@@ -122,6 +123,7 @@ impl DemoScene {
122 "mini" => DemoScene::Mini,
123 "mini" => DemoScene::Mini,
123 "mini-off" => DemoScene::MiniOff,
124 "mini-off" => DemoScene::MiniOff,
124 "mini-share" => DemoScene::MiniShare,
125 "mini-share" => DemoScene::MiniShare,
126 "blocked" => DemoScene::Blocked,
125 _ => return None,
127 _ => return None,
126 })
128 })
127 }
129 }
@@ -137,6 +139,7 @@ impl DemoScene {
137 | DemoScene::Mini
139 | DemoScene::Mini
138 | DemoScene::MiniOff
140 | DemoScene::MiniOff
139 | DemoScene::MiniShare
141 | DemoScene::MiniShare
142 | DemoScene::Blocked
140 )
143 )
141 }
144 }
142
145
@@ -446,6 +449,7 @@ fn start_scene(control: &CallControl, scene: DemoScene) {
446 | DemoScene::Whiteboard
449 | DemoScene::Whiteboard
447 | DemoScene::Gallery
450 | DemoScene::Gallery
448 | DemoScene::Sharing
451 | DemoScene::Sharing
452 | DemoScene::Blocked
449 | DemoScene::Plain => {}
453 | DemoScene::Plain => {}
450 }
454 }
451}
455}
crates/app/src/call/features.rs +5 −1
@@ -41,7 +41,11 @@ fn return_move(room: &BreakoutState) -> PendingMove {
41 41
42 42 impl AppState {
43 43 pub fn run_call_record_action(&mut self, action: RecordAction, _cx: &mut Context<Self>) {
44 let Some(call) = self.call.as_ref().filter(|call| call.model.can_record()) else {
44 let Some(call) = self
45 .call
46 .as_ref()
47 .filter(|call| call.model.action_allowed(action))
48 else {
45 49 return;
46 50 };
47 51 let command = match action {
@@ -41,7 +41,11 @@ fn return_move(room: &BreakoutState) -> PendingMove {
41
41
42impl AppState {
42impl AppState {
43 pub fn run_call_record_action(&mut self, action: RecordAction, _cx: &mut Context<Self>) {
43 pub fn run_call_record_action(&mut self, action: RecordAction, _cx: &mut Context<Self>) {
44 let Some(call) = self.call.as_ref().filter(|call| call.model.can_record()) else {
44 let Some(call) = self
45 .call
46 .as_ref()
47 .filter(|call| call.model.action_allowed(action))
48 else {
45 return;
49 return;
46 };
50 };
47 let command = match action {
51 let command = match action {
crates/app/src/call/mod.rs +3 −0
@@ -27,6 +27,8 @@ mod prejoin;
27 27 mod preview;
28 28 mod push_to_talk;
29 29 mod recording_menu;
30 mod record_load;
31 mod record_rights;
30 32 mod report;
31 33 mod reminder;
32 34 mod share_actions;
@@ -75,6 +77,7 @@ pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};
75 77 pub use ring::{MissedCall, RingEntry, Rings};
76 78 pub use stage_layout::{FILMSTRIP_MAX, Filmstrip, GALLERY_MAX, Overflow, contain_size, filmstrip, focus_stage_size, gallery_grid, share_strip, split_overflow};
77 79 pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
80 pub use record_rights::{RecordBlock, RecordFeature};
78 81 pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
79 82 pub use report::load_enabled as load_report_enabled;
80 83 pub use target::plan_for_chat;
@@ -27,6 +27,8 @@ mod prejoin;
27mod preview;
27mod preview;
28mod push_to_talk;
28mod push_to_talk;
29mod recording_menu;
29mod recording_menu;
30mod record_load;
31mod record_rights;
30mod report;
32mod report;
31mod reminder;
33mod reminder;
32mod share_actions;
34mod share_actions;
@@ -75,6 +77,7 @@ pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};
75pub use ring::{MissedCall, RingEntry, Rings};
77pub use ring::{MissedCall, RingEntry, Rings};
76pub use stage_layout::{FILMSTRIP_MAX, Filmstrip, GALLERY_MAX, Overflow, contain_size, filmstrip, focus_stage_size, gallery_grid, share_strip, split_overflow};
78pub use stage_layout::{FILMSTRIP_MAX, Filmstrip, GALLERY_MAX, Overflow, contain_size, filmstrip, focus_stage_size, gallery_grid, share_strip, split_overflow};
77pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
79pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
80pub use record_rights::{RecordBlock, RecordFeature};
78pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
81pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
79pub use report::load_enabled as load_report_enabled;
82pub use report::load_enabled as load_report_enabled;
80pub use target::plan_for_chat;
83pub use target::plan_for_chat;
crates/app/src/call/model.rs +14 −8
@@ -9,6 +9,7 @@ use calling::{
9 9 MeetingTarget, Progress, Reaction, Replacement, RosterEntry, ShareKind, ShareSource, SpeakingDetector, VideoHub,
10 10 VideoWant,
11 11 };
12 use teams_core::RecordingPolicy;
12 13 use tokio::sync::mpsc::UnboundedSender;
13 14
14 15 use super::background::BackgroundPick;
@@ -308,6 +309,10 @@ pub struct CallModel {
308 309 pub recording: bool,
309 310 pub recording_audio_only: bool,
310 311 pub transcribing: bool,
312 pub record_pending: bool,
313 pub recording_policy: RecordingPolicy,
314 pub meeting_tenant: Option<String>,
315 pub own_tenant: Option<String>,
311 316 pub consent_required: bool,
312 317 pub hold: HoldState,
313 318 pub health: HealthState,
@@ -370,6 +375,10 @@ impl CallModel {
370 375 recording: false,
371 376 recording_audio_only: false,
372 377 transcribing: false,
378 record_pending: false,
379 recording_policy: RecordingPolicy::default(),
380 meeting_tenant: None,
381 own_tenant: None,
373 382 consent_required: false,
374 383 hold: HoldState::Active,
375 384 health: HealthState::default(),
@@ -501,6 +510,8 @@ impl CallModel {
501 510 CallUpdate::Recording(on) => self.recording = on,
502 511 CallUpdate::RecordingAudioOnly(audio_only) => self.recording_audio_only = audio_only,
503 512 CallUpdate::Transcribing(on) => self.transcribing = on,
513 CallUpdate::RecordingPending(pending) => self.record_pending = pending,
514 CallUpdate::MeetingTenant(tenant) => self.meeting_tenant = Some(tenant),
504 515 CallUpdate::ConsentRequired(required) => self.consent_required = required,
505 516 CallUpdate::Hold(hold) => self.hold = hold,
506 517 CallUpdate::Health(health) => self.health.apply(health),
@@ -1062,10 +1073,6 @@ impl CallModel {
1062 1073 self.is_one_to_one() && self.is_live() && self.hold == HoldState::Active
1063 1074 }
1064 1075
1065 pub fn can_record(&self) -> bool {
1066 self.organizes_meeting() && self.is_live() && !self.lobby
1067 }
1068
1069 1076 pub fn can_open_whiteboard(&self) -> bool {
1070 1077 self.kind == CallKind::Meeting && self.is_live() && !self.lobby
1071 1078 }
@@ -1145,7 +1152,7 @@ impl CallModel {
1145 1152 !self.share_sources.is_empty() && self.is_live()
1146 1153 }
1147 1154
1148 fn is_live(&self) -> bool {
1155 pub(super) fn is_live(&self) -> bool {
1149 1156 matches!(
1150 1157 self.state,
1151 1158 CallState::Connected { .. } | CallState::Reconnecting { .. }
@@ -2135,13 +2142,12 @@ mod tests {
2135 2142 }
2136 2143
2137 2144 #[test]
2138 fn recording_and_consent_follow_the_call_updates_and_only_organizers_may_record() {
2145 fn recording_and_consent_follow_the_call_updates() {
2139 2146 let mut model = meeting_with_me();
2147 assert!(!model.can_record());
2140 2148 model.apply(CallUpdate::State(CallState::Connected {
2141 2149 since: Instant::now(),
2142 2150 }));
2143 assert!(!model.can_record());
2144 model.apply(CallUpdate::Roster(vec![organizer_entry("8:orgid:me")]));
2145 2151 assert!(model.can_record());
2146 2152 model.apply(CallUpdate::Recording(true));
2147 2153 model.apply(CallUpdate::ConsentRequired(true));
@@ -9,6 +9,7 @@ use calling::{
9 MeetingTarget, Progress, Reaction, Replacement, RosterEntry, ShareKind, ShareSource, SpeakingDetector, VideoHub,
9 MeetingTarget, Progress, Reaction, Replacement, RosterEntry, ShareKind, ShareSource, SpeakingDetector, VideoHub,
10 VideoWant,
10 VideoWant,
11};
11};
12use teams_core::RecordingPolicy;
12use tokio::sync::mpsc::UnboundedSender;
13use tokio::sync::mpsc::UnboundedSender;
13
14
14use super::background::BackgroundPick;
15use super::background::BackgroundPick;
@@ -308,6 +309,10 @@ pub struct CallModel {
308 pub recording: bool,
309 pub recording: bool,
309 pub recording_audio_only: bool,
310 pub recording_audio_only: bool,
310 pub transcribing: bool,
311 pub transcribing: bool,
312 pub record_pending: bool,
313 pub recording_policy: RecordingPolicy,
314 pub meeting_tenant: Option<String>,
315 pub own_tenant: Option<String>,
311 pub consent_required: bool,
316 pub consent_required: bool,
312 pub hold: HoldState,
317 pub hold: HoldState,
313 pub health: HealthState,
318 pub health: HealthState,
@@ -370,6 +375,10 @@ impl CallModel {
370 recording: false,
375 recording: false,
371 recording_audio_only: false,
376 recording_audio_only: false,
372 transcribing: false,
377 transcribing: false,
378 record_pending: false,
379 recording_policy: RecordingPolicy::default(),
380 meeting_tenant: None,
381 own_tenant: None,
373 consent_required: false,
382 consent_required: false,
374 hold: HoldState::Active,
383 hold: HoldState::Active,
375 health: HealthState::default(),
384 health: HealthState::default(),
@@ -501,6 +510,8 @@ impl CallModel {
501 CallUpdate::Recording(on) => self.recording = on,
510 CallUpdate::Recording(on) => self.recording = on,
502 CallUpdate::RecordingAudioOnly(audio_only) => self.recording_audio_only = audio_only,
511 CallUpdate::RecordingAudioOnly(audio_only) => self.recording_audio_only = audio_only,
503 CallUpdate::Transcribing(on) => self.transcribing = on,
512 CallUpdate::Transcribing(on) => self.transcribing = on,
513 CallUpdate::RecordingPending(pending) => self.record_pending = pending,
514 CallUpdate::MeetingTenant(tenant) => self.meeting_tenant = Some(tenant),
504 CallUpdate::ConsentRequired(required) => self.consent_required = required,
515 CallUpdate::ConsentRequired(required) => self.consent_required = required,
505 CallUpdate::Hold(hold) => self.hold = hold,
516 CallUpdate::Hold(hold) => self.hold = hold,
506 CallUpdate::Health(health) => self.health.apply(health),
517 CallUpdate::Health(health) => self.health.apply(health),
@@ -1062,10 +1073,6 @@ impl CallModel {
1062 self.is_one_to_one() && self.is_live() && self.hold == HoldState::Active
1073 self.is_one_to_one() && self.is_live() && self.hold == HoldState::Active
1063 }
1074 }
1064
1075
1065 pub fn can_record(&self) -> bool {
1066 self.organizes_meeting() && self.is_live() && !self.lobby
1067 }
1068
1069 pub fn can_open_whiteboard(&self) -> bool {
1076 pub fn can_open_whiteboard(&self) -> bool {
1070 self.kind == CallKind::Meeting && self.is_live() && !self.lobby
1077 self.kind == CallKind::Meeting && self.is_live() && !self.lobby
1071 }
1078 }
@@ -1145,7 +1152,7 @@ impl CallModel {
1145 !self.share_sources.is_empty() && self.is_live()
1152 !self.share_sources.is_empty() && self.is_live()
1146 }
1153 }
1147
1154
1148 fn is_live(&self) -> bool {
1155 pub(super) fn is_live(&self) -> bool {
1149 matches!(
1156 matches!(
1150 self.state,
1157 self.state,
1151 CallState::Connected { .. } | CallState::Reconnecting { .. }
1158 CallState::Connected { .. } | CallState::Reconnecting { .. }
@@ -2135,13 +2142,12 @@ mod tests {
2135 }
2142 }
2136
2143
2137 #[test]
2144 #[test]
2138 fn recording_and_consent_follow_the_call_updates_and_only_organizers_may_record() {
2145 fn recording_and_consent_follow_the_call_updates() {
2139 let mut model = meeting_with_me();
2146 let mut model = meeting_with_me();
2147 assert!(!model.can_record());
2140 model.apply(CallUpdate::State(CallState::Connected {
2148 model.apply(CallUpdate::State(CallState::Connected {
2141 since: Instant::now(),
2149 since: Instant::now(),
2142 }));
2150 }));
2143 assert!(!model.can_record());
2144 model.apply(CallUpdate::Roster(vec![organizer_entry("8:orgid:me")]));
2145 assert!(model.can_record());
2151 assert!(model.can_record());
2146 model.apply(CallUpdate::Recording(true));
2152 model.apply(CallUpdate::Recording(true));
2147 model.apply(CallUpdate::ConsentRequired(true));
2153 model.apply(CallUpdate::ConsentRequired(true));
crates/app/src/call/record_load.rs added +62 −0
@@ -0,0 +1,62 @@
1 use gpui_kit::Context;
2
3 use super::model::CallKind;
4 use crate::app_state::AppState;
5 use crate::runtime;
6
7 impl AppState {
8 pub fn refresh_recording_policy(&mut self, cx: &mut Context<Self>) {
9 let Some(engine) = self.engine.clone() else {
10 return;
11 };
12 let read = runtime::spawn(async move { engine.recording_policy().await.ok() });
13 cx.spawn(async move |this, cx| {
14 let Some(policy) = read.await.ok().flatten() else {
15 return;
16 };
17 this.update(cx, |state, _| {
18 state.recording_policy = policy;
19 if let Some(call) = state.call.as_mut() {
20 call.model.recording_policy = policy;
21 }
22 })
23 .ok();
24 })
25 .detach();
26 }
27
28 pub(super) fn apply_recording_rights(
29 &mut self,
30 conversation_id: Option<&str>,
31 cx: &mut Context<Self>,
32 ) {
33 let Some(call) = self.call.as_mut() else {
34 return;
35 };
36 call.model.recording_policy = self.recording_policy;
37 call.model.own_tenant.clone_from(&self.own_tenant);
38 if call.model.kind != CallKind::Meeting || self.own_tenant.is_some() {
39 return;
40 }
41 let (Some(engine), Some(chat_id)) = (self.engine.clone(), conversation_id) else {
42 return;
43 };
44 let chat_id = chat_id.to_owned();
45 let call_id = call.id;
46 let read = runtime::spawn(async move { engine.own_tenant_id(&chat_id).await.ok() });
47 cx.spawn(async move |this, cx| {
48 let Some(tenant) = read.await.ok().flatten() else {
49 return;
50 };
51 this.update(cx, |state, cx| {
52 state.own_tenant = Some(tenant.clone());
53 if let Some(call) = state.call.as_mut().filter(|call| call.id == call_id) {
54 call.model.own_tenant = Some(tenant);
55 cx.notify();
56 }
57 })
58 .ok();
59 })
60 .detach();
61 }
62 }
@@ -0,0 +1,62 @@
1use gpui_kit::Context;
2
3use super::model::CallKind;
4use crate::app_state::AppState;
5use crate::runtime;
6
7impl AppState {
8 pub fn refresh_recording_policy(&mut self, cx: &mut Context<Self>) {
9 let Some(engine) = self.engine.clone() else {
10 return;
11 };
12 let read = runtime::spawn(async move { engine.recording_policy().await.ok() });
13 cx.spawn(async move |this, cx| {
14 let Some(policy) = read.await.ok().flatten() else {
15 return;
16 };
17 this.update(cx, |state, _| {
18 state.recording_policy = policy;
19 if let Some(call) = state.call.as_mut() {
20 call.model.recording_policy = policy;
21 }
22 })
23 .ok();
24 })
25 .detach();
26 }
27
28 pub(super) fn apply_recording_rights(
29 &mut self,
30 conversation_id: Option<&str>,
31 cx: &mut Context<Self>,
32 ) {
33 let Some(call) = self.call.as_mut() else {
34 return;
35 };
36 call.model.recording_policy = self.recording_policy;
37 call.model.own_tenant.clone_from(&self.own_tenant);
38 if call.model.kind != CallKind::Meeting || self.own_tenant.is_some() {
39 return;
40 }
41 let (Some(engine), Some(chat_id)) = (self.engine.clone(), conversation_id) else {
42 return;
43 };
44 let chat_id = chat_id.to_owned();
45 let call_id = call.id;
46 let read = runtime::spawn(async move { engine.own_tenant_id(&chat_id).await.ok() });
47 cx.spawn(async move |this, cx| {
48 let Some(tenant) = read.await.ok().flatten() else {
49 return;
50 };
51 this.update(cx, |state, cx| {
52 state.own_tenant = Some(tenant.clone());
53 if let Some(call) = state.call.as_mut().filter(|call| call.id == call_id) {
54 call.model.own_tenant = Some(tenant);
55 cx.notify();
56 }
57 })
58 .ok();
59 })
60 .detach();
61 }
62}
crates/app/src/call/record_rights.rs added +438 −0
@@ -0,0 +1,438 @@
1 use calling::{MeetingRole, RecorderOption, RecordingKind};
2
3 use super::model::{CallKind, CallModel};
4 use super::recording_menu::RecordAction;
5
6 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7 pub enum RecordFeature {
8 Recording,
9 Transcription,
10 }
11
12 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
13 pub enum RecordBlock {
14 Role,
15 OrganizerOff,
16 OrganizerOnly,
17 Busy,
18 External,
19 CallPolicy,
20 MeetingPolicy,
21 Capability,
22 }
23
24 impl RecordBlock {
25 pub fn locked(self) -> bool {
26 self != RecordBlock::Busy
27 }
28
29 pub fn reason(self, feature: RecordFeature) -> &'static str {
30 match (self, feature) {
31 (RecordBlock::Role, RecordFeature::Recording) => {
32 "Only meeting organisers and presenters can control recording"
33 }
34 (RecordBlock::Role, RecordFeature::Transcription) => {
35 "Only meeting organisers and presenters can control transcription"
36 }
37 (RecordBlock::OrganizerOff, _) => {
38 "Unavailable because the meeting organiser has disabled recording for this meeting"
39 }
40 (RecordBlock::OrganizerOnly, _) => {
41 "Only meeting organiser and co-organiser can control recording for this meeting"
42 }
43 (RecordBlock::Busy, _) => "Starting...",
44 (RecordBlock::External, _) => {
45 "Unavailable to people in a different org from the organiser"
46 }
47 (RecordBlock::CallPolicy, RecordFeature::Recording) => {
48 "Unavailable for this call due to organisation policy. Reach out to your IT admin to get access."
49 }
50 (RecordBlock::MeetingPolicy, RecordFeature::Recording) => {
51 "Unavailable for this meeting due to organisation policy. Reach out to your IT admin to get access."
52 }
53 (
54 RecordBlock::CallPolicy | RecordBlock::MeetingPolicy,
55 RecordFeature::Transcription,
56 ) => "Unavailable due to org policy. Reach out to your IT admin to get access.",
57 (RecordBlock::Capability, _) => "Unavailable in this meeting",
58 }
59 }
60 }
61
62 impl CallModel {
63 pub fn record_hidden(&self) -> bool {
64 !self.is_live() || self.lobby || self.kind == CallKind::Test
65 }
66
67 pub fn record_block(&self) -> Option<RecordBlock> {
68 self.block(RecordFeature::Recording)
69 }
70
71 pub fn transcribe_block(&self) -> Option<RecordBlock> {
72 self.block(RecordFeature::Transcription)
73 }
74
75 pub fn can_record(&self) -> bool {
76 !self.record_hidden() && self.record_block().is_none()
77 }
78
79 pub fn action_allowed(&self, action: RecordAction) -> bool {
80 match action {
81 RecordAction::Start(RecordingKind::Video | RecordingKind::AudioOnly) => {
82 self.can_record()
83 }
84 _ => !self.record_hidden() && self.action_block(action).is_none(),
85 }
86 }
87
88 pub fn stop_block(&self) -> Option<RecordBlock> {
89 self.record_block()
90 .filter(|block| matches!(block, RecordBlock::Role | RecordBlock::OrganizerOnly))
91 }
92
93 pub fn action_block(&self, action: RecordAction) -> Option<(RecordBlock, RecordFeature)> {
94 match action {
95 RecordAction::Start(RecordingKind::TranscriptOnly) => self
96 .transcribe_block()
97 .map(|block| (block, RecordFeature::Transcription)),
98 RecordAction::Start(_) => self
99 .record_block()
100 .map(|block| (block, RecordFeature::Recording)),
101 RecordAction::Stop(_) => self
102 .stop_block()
103 .map(|block| (block, RecordFeature::Recording)),
104 }
105 }
106
107 pub fn record_menu_block(&self) -> Option<(RecordBlock, RecordFeature)> {
108 if self.recording || self.transcribing {
109 return None;
110 }
111 self.record_block()
112 .zip(self.transcribe_block())
113 .map(|(block, _)| (block, RecordFeature::Recording))
114 }
115
116 fn block(&self, feature: RecordFeature) -> Option<RecordBlock> {
117 let capability = self.capability;
118 let organizer = self.own_role == Some(MeetingRole::Organizer) || self.can_manage();
119 if self.own_role == Some(MeetingRole::Attendee) {
120 return Some(RecordBlock::Role);
121 }
122 match capability.recorder_option {
123 RecorderOption::Nobody => return Some(RecordBlock::OrganizerOff),
124 RecorderOption::OrganizersOnly if !organizer => {
125 return Some(RecordBlock::OrganizerOnly);
126 }
127 _ => {}
128 }
129 if self.record_pending {
130 return Some(RecordBlock::Busy);
131 }
132 let foreign = matches!(
133 (&self.meeting_tenant, &self.own_tenant),
134 (Some(meeting), Some(own)) if !meeting.eq_ignore_ascii_case(own)
135 );
136 if self.kind == CallKind::Meeting && foreign {
137 return Some(RecordBlock::External);
138 }
139 let policy = self.recording_policy;
140 let (call_allowed, meeting_allowed, capability_allowed) = match feature {
141 RecordFeature::Recording => (
142 policy.call_recording,
143 policy.meeting_recording,
144 capability.allow_cloud_recording,
145 ),
146 RecordFeature::Transcription => (
147 policy.call_transcription,
148 policy.meeting_transcription,
149 capability.allow_transcription,
150 ),
151 };
152 if self.kind == CallKind::Direct && !call_allowed {
153 return Some(RecordBlock::CallPolicy);
154 }
155 if self.kind != CallKind::Direct && !meeting_allowed {
156 return Some(RecordBlock::MeetingPolicy);
157 }
158 (capability_allowed == Some(false)).then_some(RecordBlock::Capability)
159 }
160 }
161
162 #[cfg(test)]
163 mod tests {
164 use std::time::Instant;
165
166 use calling::{CallState, CallUpdate, MeetingCapability};
167 use teams_core::RecordingPolicy;
168
169 use super::*;
170
171 fn live(mut model: CallModel) -> CallModel {
172 model.apply(CallUpdate::State(CallState::Connected {
173 since: Instant::now(),
174 }));
175 model
176 }
177
178 fn meeting() -> CallModel {
179 live(CallModel::meeting("Standup", false))
180 }
181
182 fn direct() -> CallModel {
183 live(CallModel::people(
184 "Bea",
185 &[("8:orgid:bea".into(), "Bea".into())],
186 ))
187 }
188
189 fn group() -> CallModel {
190 live(CallModel::people(
191 "Team",
192 &[
193 ("8:orgid:bea".into(), "Bea".into()),
194 ("8:orgid:cy".into(), "Cy".into()),
195 ],
196 ))
197 }
198
199 fn capability(update: impl FnOnce(&mut MeetingCapability)) -> MeetingCapability {
200 let mut capability = MeetingCapability::default();
201 update(&mut capability);
202 capability
203 }
204
205 #[test]
206 fn everything_is_allowed_when_nothing_is_known() {
207 for model in [meeting(), direct(), group()] {
208 assert_eq!(model.record_block(), None);
209 assert_eq!(model.transcribe_block(), None);
210 assert!(model.can_record() && !model.record_hidden());
211 }
212 }
213
214 #[test]
215 fn hidden_until_live_and_while_in_the_lobby_or_the_echo_call() {
216 assert!(CallModel::meeting("Standup", true).record_hidden());
217 let mut lobby = meeting();
218 lobby.lobby = true;
219 assert!(lobby.record_hidden() && !lobby.can_record());
220 assert!(live(CallModel::test()).record_hidden());
221 assert!(!meeting().record_hidden());
222 }
223
224 #[test]
225 fn an_attendee_is_blocked_and_a_presenter_is_not() {
226 let mut model = meeting();
227 model.own_role = Some(MeetingRole::Attendee);
228 assert_eq!(model.record_block(), Some(RecordBlock::Role));
229 assert_eq!(model.transcribe_block(), Some(RecordBlock::Role));
230 model.own_role = Some(MeetingRole::Presenter);
231 assert_eq!(model.record_block(), None);
232 }
233
234 #[test]
235 fn the_recorder_option_off_blocks_everyone_even_the_organizer() {
236 let mut model = meeting();
237 model.own_role = Some(MeetingRole::Organizer);
238 model.capability =
239 capability(|capability| capability.recorder_option = RecorderOption::Nobody);
240 assert_eq!(model.record_block(), Some(RecordBlock::OrganizerOff));
241 assert_eq!(model.transcribe_block(), Some(RecordBlock::OrganizerOff));
242 }
243
244 #[test]
245 fn the_organizer_only_option_blocks_presenters() {
246 let mut model = meeting();
247 model.capability =
248 capability(|capability| capability.recorder_option = RecorderOption::OrganizersOnly);
249 model.own_role = Some(MeetingRole::Presenter);
250 assert_eq!(model.record_block(), Some(RecordBlock::OrganizerOnly));
251 model.own_role = Some(MeetingRole::Organizer);
252 assert_eq!(model.record_block(), None);
253 model.own_role = None;
254 model.organizer = true;
255 assert_eq!(model.record_block(), None);
256 }
257
258 #[test]
259 fn a_start_in_flight_blocks_with_a_reason_without_a_lock() {
260 let mut model = meeting();
261 model.apply(CallUpdate::RecordingPending(true));
262 let block = model.record_block().unwrap();
263 assert_eq!(block, RecordBlock::Busy);
264 assert!(!block.locked());
265 assert_eq!(model.transcribe_block(), Some(RecordBlock::Busy));
266 model.apply(CallUpdate::RecordingPending(false));
267 assert_eq!(model.record_block(), None);
268 }
269
270 #[test]
271 fn a_meeting_of_another_tenant_is_blocked_but_a_call_is_not() {
272 let mut model = meeting();
273 model.apply(CallUpdate::MeetingTenant("tenant-a".into()));
274 assert_eq!(model.record_block(), None);
275 model.own_tenant = Some("tenant-b".into());
276 assert_eq!(model.record_block(), Some(RecordBlock::External));
277 assert_eq!(model.transcribe_block(), Some(RecordBlock::External));
278 model.own_tenant = Some("TENANT-A".into());
279 assert_eq!(model.record_block(), None);
280 let mut call = direct();
281 call.meeting_tenant = Some("tenant-a".into());
282 call.own_tenant = Some("tenant-b".into());
283 assert_eq!(call.record_block(), None);
284 }
285
286 #[test]
287 fn direct_calls_use_the_calling_policy_and_the_rest_the_meeting_policy() {
288 let no_calls = RecordingPolicy {
289 call_recording: false,
290 call_transcription: false,
291 ..RecordingPolicy::default()
292 };
293 let no_meetings = RecordingPolicy {
294 meeting_recording: false,
295 meeting_transcription: false,
296 ..RecordingPolicy::default()
297 };
298 for (mut model, policy, blocked) in [
299 (direct(), no_calls, Some(RecordBlock::CallPolicy)),
300 (direct(), no_meetings, None),
301 (group(), no_calls, None),
302 (group(), no_meetings, Some(RecordBlock::MeetingPolicy)),
303 (meeting(), no_calls, None),
304 (meeting(), no_meetings, Some(RecordBlock::MeetingPolicy)),
305 ] {
306 model.recording_policy = policy;
307 assert_eq!(model.record_block(), blocked);
308 assert_eq!(model.transcribe_block(), blocked);
309 }
310 }
311
312 #[test]
313 fn recording_and_transcription_follow_their_own_policy_flags() {
314 let mut model = meeting();
315 model.recording_policy = RecordingPolicy {
316 meeting_transcription: false,
317 ..RecordingPolicy::default()
318 };
319 assert_eq!(model.record_block(), None);
320 assert_eq!(model.transcribe_block(), Some(RecordBlock::MeetingPolicy));
321 assert!(model.can_record());
322 }
323
324 #[test]
325 fn the_meeting_capability_blocks_only_when_it_says_false() {
326 let mut model = meeting();
327 model.capability = capability(|capability| capability.allow_cloud_recording = Some(true));
328 assert_eq!(model.record_block(), None);
329 model.capability = capability(|capability| capability.allow_cloud_recording = Some(false));
330 assert_eq!(model.record_block(), Some(RecordBlock::Capability));
331 assert_eq!(model.transcribe_block(), None);
332 model.capability = capability(|capability| capability.allow_transcription = Some(false));
333 assert_eq!(model.record_block(), None);
334 assert_eq!(model.transcribe_block(), Some(RecordBlock::Capability));
335 }
336
337 #[test]
338 fn the_checks_run_in_the_order_of_teams() {
339 let mut model = meeting();
340 model.own_role = Some(MeetingRole::Attendee);
341 model.capability = capability(|capability| {
342 capability.recorder_option = RecorderOption::Nobody;
343 capability.allow_cloud_recording = Some(false);
344 });
345 model.recording_policy.meeting_recording = false;
346 model.record_pending = true;
347 model.meeting_tenant = Some("a".into());
348 model.own_tenant = Some("b".into());
349 let expected = [
350 RecordBlock::Role,
351 RecordBlock::OrganizerOff,
352 RecordBlock::Busy,
353 RecordBlock::External,
354 RecordBlock::MeetingPolicy,
355 RecordBlock::Capability,
356 ];
357 assert_eq!(model.record_block(), Some(expected[0]));
358 model.own_role = None;
359 assert_eq!(model.record_block(), Some(expected[1]));
360 model.capability.recorder_option = RecorderOption::OrganizersAndPresenters;
361 assert_eq!(model.record_block(), Some(expected[2]));
362 model.record_pending = false;
363 assert_eq!(model.record_block(), Some(expected[3]));
364 model.own_tenant = None;
365 assert_eq!(model.record_block(), Some(expected[4]));
366 model.recording_policy.meeting_recording = true;
367 assert_eq!(model.record_block(), Some(expected[5]));
368 }
369
370 #[test]
371 fn the_reasons_use_the_teams_wording_per_feature() {
372 assert_eq!(
373 RecordBlock::Role.reason(RecordFeature::Transcription),
374 "Only meeting organisers and presenters can control transcription"
375 );
376 assert_eq!(
377 RecordBlock::CallPolicy.reason(RecordFeature::Recording),
378 "Unavailable for this call due to organisation policy. Reach out to your IT admin to get access."
379 );
380 assert_eq!(
381 RecordBlock::MeetingPolicy.reason(RecordFeature::Transcription),
382 "Unavailable due to org policy. Reach out to your IT admin to get access."
383 );
384 assert_eq!(
385 RecordBlock::Capability.reason(RecordFeature::Recording),
386 "Unavailable in this meeting"
387 );
388 }
389
390 #[test]
391 fn the_menu_locks_only_when_both_features_are_blocked_and_nothing_runs() {
392 let mut model = meeting();
393 model.own_role = Some(MeetingRole::Attendee);
394 assert_eq!(
395 model.record_menu_block(),
396 Some((RecordBlock::Role, RecordFeature::Recording))
397 );
398 model.recording = true;
399 assert_eq!(model.record_menu_block(), None);
400 model.recording = false;
401 model.own_role = None;
402 model.capability = capability(|capability| capability.allow_cloud_recording = Some(false));
403 assert_eq!(model.record_menu_block(), None);
404 }
405
406 #[test]
407 fn stopping_is_only_blocked_by_the_role_rules() {
408 let mut model = meeting();
409 model.recording_policy.meeting_recording = false;
410 assert_eq!(model.stop_block(), None);
411 model.own_role = Some(MeetingRole::Attendee);
412 assert_eq!(model.stop_block(), Some(RecordBlock::Role));
413 }
414
415 #[test]
416 fn each_action_asks_its_own_feature() {
417 let mut model = meeting();
418 model.recording_policy.meeting_transcription = false;
419 let start = |kind| RecordAction::Start(kind);
420 assert_eq!(model.action_block(start(RecordingKind::Video)), None);
421 assert_eq!(
422 model.action_block(start(RecordingKind::TranscriptOnly)),
423 Some((RecordBlock::MeetingPolicy, RecordFeature::Transcription))
424 );
425 model.recording_policy = RecordingPolicy {
426 meeting_recording: false,
427 ..RecordingPolicy::default()
428 };
429 assert_eq!(
430 model.action_block(start(RecordingKind::AudioOnly)),
431 Some((RecordBlock::MeetingPolicy, RecordFeature::Recording))
432 );
433 assert_eq!(
434 model.action_block(RecordAction::Stop(calling::StopScope::Both)),
435 None
436 );
437 }
438 }
@@ -0,0 +1,438 @@
1use calling::{MeetingRole, RecorderOption, RecordingKind};
2
3use super::model::{CallKind, CallModel};
4use super::recording_menu::RecordAction;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum RecordFeature {
8 Recording,
9 Transcription,
10}
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub enum RecordBlock {
14 Role,
15 OrganizerOff,
16 OrganizerOnly,
17 Busy,
18 External,
19 CallPolicy,
20 MeetingPolicy,
21 Capability,
22}
23
24impl RecordBlock {
25 pub fn locked(self) -> bool {
26 self != RecordBlock::Busy
27 }
28
29 pub fn reason(self, feature: RecordFeature) -> &'static str {
30 match (self, feature) {
31 (RecordBlock::Role, RecordFeature::Recording) => {
32 "Only meeting organisers and presenters can control recording"
33 }
34 (RecordBlock::Role, RecordFeature::Transcription) => {
35 "Only meeting organisers and presenters can control transcription"
36 }
37 (RecordBlock::OrganizerOff, _) => {
38 "Unavailable because the meeting organiser has disabled recording for this meeting"
39 }
40 (RecordBlock::OrganizerOnly, _) => {
41 "Only meeting organiser and co-organiser can control recording for this meeting"
42 }
43 (RecordBlock::Busy, _) => "Starting...",
44 (RecordBlock::External, _) => {
45 "Unavailable to people in a different org from the organiser"
46 }
47 (RecordBlock::CallPolicy, RecordFeature::Recording) => {
48 "Unavailable for this call due to organisation policy. Reach out to your IT admin to get access."
49 }
50 (RecordBlock::MeetingPolicy, RecordFeature::Recording) => {
51 "Unavailable for this meeting due to organisation policy. Reach out to your IT admin to get access."
52 }
53 (
54 RecordBlock::CallPolicy | RecordBlock::MeetingPolicy,
55 RecordFeature::Transcription,
56 ) => "Unavailable due to org policy. Reach out to your IT admin to get access.",
57 (RecordBlock::Capability, _) => "Unavailable in this meeting",
58 }
59 }
60}
61
62impl CallModel {
63 pub fn record_hidden(&self) -> bool {
64 !self.is_live() || self.lobby || self.kind == CallKind::Test
65 }
66
67 pub fn record_block(&self) -> Option<RecordBlock> {
68 self.block(RecordFeature::Recording)
69 }
70
71 pub fn transcribe_block(&self) -> Option<RecordBlock> {
72 self.block(RecordFeature::Transcription)
73 }
74
75 pub fn can_record(&self) -> bool {
76 !self.record_hidden() && self.record_block().is_none()
77 }
78
79 pub fn action_allowed(&self, action: RecordAction) -> bool {
80 match action {
81 RecordAction::Start(RecordingKind::Video | RecordingKind::AudioOnly) => {
82 self.can_record()
83 }
84 _ => !self.record_hidden() && self.action_block(action).is_none(),
85 }
86 }
87
88 pub fn stop_block(&self) -> Option<RecordBlock> {
89 self.record_block()
90 .filter(|block| matches!(block, RecordBlock::Role | RecordBlock::OrganizerOnly))
91 }
92
93 pub fn action_block(&self, action: RecordAction) -> Option<(RecordBlock, RecordFeature)> {
94 match action {
95 RecordAction::Start(RecordingKind::TranscriptOnly) => self
96 .transcribe_block()
97 .map(|block| (block, RecordFeature::Transcription)),
98 RecordAction::Start(_) => self
99 .record_block()
100 .map(|block| (block, RecordFeature::Recording)),
101 RecordAction::Stop(_) => self
102 .stop_block()
103 .map(|block| (block, RecordFeature::Recording)),
104 }
105 }
106
107 pub fn record_menu_block(&self) -> Option<(RecordBlock, RecordFeature)> {
108 if self.recording || self.transcribing {
109 return None;
110 }
111 self.record_block()
112 .zip(self.transcribe_block())
113 .map(|(block, _)| (block, RecordFeature::Recording))
114 }
115
116 fn block(&self, feature: RecordFeature) -> Option<RecordBlock> {
117 let capability = self.capability;
118 let organizer = self.own_role == Some(MeetingRole::Organizer) || self.can_manage();
119 if self.own_role == Some(MeetingRole::Attendee) {
120 return Some(RecordBlock::Role);
121 }
122 match capability.recorder_option {
123 RecorderOption::Nobody => return Some(RecordBlock::OrganizerOff),
124 RecorderOption::OrganizersOnly if !organizer => {
125 return Some(RecordBlock::OrganizerOnly);
126 }
127 _ => {}
128 }
129 if self.record_pending {
130 return Some(RecordBlock::Busy);
131 }
132 let foreign = matches!(
133 (&self.meeting_tenant, &self.own_tenant),
134 (Some(meeting), Some(own)) if !meeting.eq_ignore_ascii_case(own)
135 );
136 if self.kind == CallKind::Meeting && foreign {
137 return Some(RecordBlock::External);
138 }
139 let policy = self.recording_policy;
140 let (call_allowed, meeting_allowed, capability_allowed) = match feature {
141 RecordFeature::Recording => (
142 policy.call_recording,
143 policy.meeting_recording,
144 capability.allow_cloud_recording,
145 ),
146 RecordFeature::Transcription => (
147 policy.call_transcription,
148 policy.meeting_transcription,
149 capability.allow_transcription,
150 ),
151 };
152 if self.kind == CallKind::Direct && !call_allowed {
153 return Some(RecordBlock::CallPolicy);
154 }
155 if self.kind != CallKind::Direct && !meeting_allowed {
156 return Some(RecordBlock::MeetingPolicy);
157 }
158 (capability_allowed == Some(false)).then_some(RecordBlock::Capability)
159 }
160}
161
162#[cfg(test)]
163mod tests {
164 use std::time::Instant;
165
166 use calling::{CallState, CallUpdate, MeetingCapability};
167 use teams_core::RecordingPolicy;
168
169 use super::*;
170
171 fn live(mut model: CallModel) -> CallModel {
172 model.apply(CallUpdate::State(CallState::Connected {
173 since: Instant::now(),
174 }));
175 model
176 }
177
178 fn meeting() -> CallModel {
179 live(CallModel::meeting("Standup", false))
180 }
181
182 fn direct() -> CallModel {
183 live(CallModel::people(
184 "Bea",
185 &[("8:orgid:bea".into(), "Bea".into())],
186 ))
187 }
188
189 fn group() -> CallModel {
190 live(CallModel::people(
191 "Team",
192 &[
193 ("8:orgid:bea".into(), "Bea".into()),
194 ("8:orgid:cy".into(), "Cy".into()),
195 ],
196 ))
197 }
198
199 fn capability(update: impl FnOnce(&mut MeetingCapability)) -> MeetingCapability {
200 let mut capability = MeetingCapability::default();
201 update(&mut capability);
202 capability
203 }
204
205 #[test]
206 fn everything_is_allowed_when_nothing_is_known() {
207 for model in [meeting(), direct(), group()] {
208 assert_eq!(model.record_block(), None);
209 assert_eq!(model.transcribe_block(), None);
210 assert!(model.can_record() && !model.record_hidden());
211 }
212 }
213
214 #[test]
215 fn hidden_until_live_and_while_in_the_lobby_or_the_echo_call() {
216 assert!(CallModel::meeting("Standup", true).record_hidden());
217 let mut lobby = meeting();
218 lobby.lobby = true;
219 assert!(lobby.record_hidden() && !lobby.can_record());
220 assert!(live(CallModel::test()).record_hidden());
221 assert!(!meeting().record_hidden());
222 }
223
224 #[test]
225 fn an_attendee_is_blocked_and_a_presenter_is_not() {
226 let mut model = meeting();
227 model.own_role = Some(MeetingRole::Attendee);
228 assert_eq!(model.record_block(), Some(RecordBlock::Role));
229 assert_eq!(model.transcribe_block(), Some(RecordBlock::Role));
230 model.own_role = Some(MeetingRole::Presenter);
231 assert_eq!(model.record_block(), None);
232 }
233
234 #[test]
235 fn the_recorder_option_off_blocks_everyone_even_the_organizer() {
236 let mut model = meeting();
237 model.own_role = Some(MeetingRole::Organizer);
238 model.capability =
239 capability(|capability| capability.recorder_option = RecorderOption::Nobody);
240 assert_eq!(model.record_block(), Some(RecordBlock::OrganizerOff));
241 assert_eq!(model.transcribe_block(), Some(RecordBlock::OrganizerOff));
242 }
243
244 #[test]
245 fn the_organizer_only_option_blocks_presenters() {
246 let mut model = meeting();
247 model.capability =
248 capability(|capability| capability.recorder_option = RecorderOption::OrganizersOnly);
249 model.own_role = Some(MeetingRole::Presenter);
250 assert_eq!(model.record_block(), Some(RecordBlock::OrganizerOnly));
251 model.own_role = Some(MeetingRole::Organizer);
252 assert_eq!(model.record_block(), None);
253 model.own_role = None;
254 model.organizer = true;
255 assert_eq!(model.record_block(), None);
256 }
257
258 #[test]
259 fn a_start_in_flight_blocks_with_a_reason_without_a_lock() {
260 let mut model = meeting();
261 model.apply(CallUpdate::RecordingPending(true));
262 let block = model.record_block().unwrap();
263 assert_eq!(block, RecordBlock::Busy);
264 assert!(!block.locked());
265 assert_eq!(model.transcribe_block(), Some(RecordBlock::Busy));
266 model.apply(CallUpdate::RecordingPending(false));
267 assert_eq!(model.record_block(), None);
268 }
269
270 #[test]
271 fn a_meeting_of_another_tenant_is_blocked_but_a_call_is_not() {
272 let mut model = meeting();
273 model.apply(CallUpdate::MeetingTenant("tenant-a".into()));
274 assert_eq!(model.record_block(), None);
275 model.own_tenant = Some("tenant-b".into());
276 assert_eq!(model.record_block(), Some(RecordBlock::External));
277 assert_eq!(model.transcribe_block(), Some(RecordBlock::External));
278 model.own_tenant = Some("TENANT-A".into());
279 assert_eq!(model.record_block(), None);
280 let mut call = direct();
281 call.meeting_tenant = Some("tenant-a".into());
282 call.own_tenant = Some("tenant-b".into());
283 assert_eq!(call.record_block(), None);
284 }
285
286 #[test]
287 fn direct_calls_use_the_calling_policy_and_the_rest_the_meeting_policy() {
288 let no_calls = RecordingPolicy {
289 call_recording: false,
290 call_transcription: false,
291 ..RecordingPolicy::default()
292 };
293 let no_meetings = RecordingPolicy {
294 meeting_recording: false,
295 meeting_transcription: false,
296 ..RecordingPolicy::default()
297 };
298 for (mut model, policy, blocked) in [
299 (direct(), no_calls, Some(RecordBlock::CallPolicy)),
300 (direct(), no_meetings, None),
301 (group(), no_calls, None),
302 (group(), no_meetings, Some(RecordBlock::MeetingPolicy)),
303 (meeting(), no_calls, None),
304 (meeting(), no_meetings, Some(RecordBlock::MeetingPolicy)),
305 ] {
306 model.recording_policy = policy;
307 assert_eq!(model.record_block(), blocked);
308 assert_eq!(model.transcribe_block(), blocked);
309 }
310 }
311
312 #[test]
313 fn recording_and_transcription_follow_their_own_policy_flags() {
314 let mut model = meeting();
315 model.recording_policy = RecordingPolicy {
316 meeting_transcription: false,
317 ..RecordingPolicy::default()
318 };
319 assert_eq!(model.record_block(), None);
320 assert_eq!(model.transcribe_block(), Some(RecordBlock::MeetingPolicy));
321 assert!(model.can_record());
322 }
323
324 #[test]
325 fn the_meeting_capability_blocks_only_when_it_says_false() {
326 let mut model = meeting();
327 model.capability = capability(|capability| capability.allow_cloud_recording = Some(true));
328 assert_eq!(model.record_block(), None);
329 model.capability = capability(|capability| capability.allow_cloud_recording = Some(false));
330 assert_eq!(model.record_block(), Some(RecordBlock::Capability));
331 assert_eq!(model.transcribe_block(), None);
332 model.capability = capability(|capability| capability.allow_transcription = Some(false));
333 assert_eq!(model.record_block(), None);
334 assert_eq!(model.transcribe_block(), Some(RecordBlock::Capability));
335 }
336
337 #[test]
338 fn the_checks_run_in_the_order_of_teams() {
339 let mut model = meeting();
340 model.own_role = Some(MeetingRole::Attendee);
341 model.capability = capability(|capability| {
342 capability.recorder_option = RecorderOption::Nobody;
343 capability.allow_cloud_recording = Some(false);
344 });
345 model.recording_policy.meeting_recording = false;
346 model.record_pending = true;
347 model.meeting_tenant = Some("a".into());
348 model.own_tenant = Some("b".into());
349 let expected = [
350 RecordBlock::Role,
351 RecordBlock::OrganizerOff,
352 RecordBlock::Busy,
353 RecordBlock::External,
354 RecordBlock::MeetingPolicy,
355 RecordBlock::Capability,
356 ];
357 assert_eq!(model.record_block(), Some(expected[0]));
358 model.own_role = None;
359 assert_eq!(model.record_block(), Some(expected[1]));
360 model.capability.recorder_option = RecorderOption::OrganizersAndPresenters;
361 assert_eq!(model.record_block(), Some(expected[2]));
362 model.record_pending = false;
363 assert_eq!(model.record_block(), Some(expected[3]));
364 model.own_tenant = None;
365 assert_eq!(model.record_block(), Some(expected[4]));
366 model.recording_policy.meeting_recording = true;
367 assert_eq!(model.record_block(), Some(expected[5]));
368 }
369
370 #[test]
371 fn the_reasons_use_the_teams_wording_per_feature() {
372 assert_eq!(
373 RecordBlock::Role.reason(RecordFeature::Transcription),
374 "Only meeting organisers and presenters can control transcription"
375 );
376 assert_eq!(
377 RecordBlock::CallPolicy.reason(RecordFeature::Recording),
378 "Unavailable for this call due to organisation policy. Reach out to your IT admin to get access."
379 );
380 assert_eq!(
381 RecordBlock::MeetingPolicy.reason(RecordFeature::Transcription),
382 "Unavailable due to org policy. Reach out to your IT admin to get access."
383 );
384 assert_eq!(
385 RecordBlock::Capability.reason(RecordFeature::Recording),
386 "Unavailable in this meeting"
387 );
388 }
389
390 #[test]
391 fn the_menu_locks_only_when_both_features_are_blocked_and_nothing_runs() {
392 let mut model = meeting();
393 model.own_role = Some(MeetingRole::Attendee);
394 assert_eq!(
395 model.record_menu_block(),
396 Some((RecordBlock::Role, RecordFeature::Recording))
397 );
398 model.recording = true;
399 assert_eq!(model.record_menu_block(), None);
400 model.recording = false;
401 model.own_role = None;
402 model.capability = capability(|capability| capability.allow_cloud_recording = Some(false));
403 assert_eq!(model.record_menu_block(), None);
404 }
405
406 #[test]
407 fn stopping_is_only_blocked_by_the_role_rules() {
408 let mut model = meeting();
409 model.recording_policy.meeting_recording = false;
410 assert_eq!(model.stop_block(), None);
411 model.own_role = Some(MeetingRole::Attendee);
412 assert_eq!(model.stop_block(), Some(RecordBlock::Role));
413 }
414
415 #[test]
416 fn each_action_asks_its_own_feature() {
417 let mut model = meeting();
418 model.recording_policy.meeting_transcription = false;
419 let start = |kind| RecordAction::Start(kind);
420 assert_eq!(model.action_block(start(RecordingKind::Video)), None);
421 assert_eq!(
422 model.action_block(start(RecordingKind::TranscriptOnly)),
423 Some((RecordBlock::MeetingPolicy, RecordFeature::Transcription))
424 );
425 model.recording_policy = RecordingPolicy {
426 meeting_recording: false,
427 ..RecordingPolicy::default()
428 };
429 assert_eq!(
430 model.action_block(start(RecordingKind::AudioOnly)),
431 Some((RecordBlock::MeetingPolicy, RecordFeature::Recording))
432 );
433 assert_eq!(
434 model.action_block(RecordAction::Stop(calling::StopScope::Both)),
435 None
436 );
437 }
438}
crates/app/src/views/call_organizer.rs +18 −11
@@ -16,7 +16,7 @@ use super::call_control_fold::{Foldable, FoldedControls, folded_items};
16 16 use super::call_extras::{
17 17 CameraMenu, background_items, effect_items, open_transfer_picker,
18 18 };
19 use super::call_record::{record_submenu, transcript_and_settings_items};
19 use super::call_record::{record_items, transcript_and_settings_items};
20 20 use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
21 21 use super::widgets::{Corner, corner_badge, count_badge, icon};
22 22 use crate::app_state::AppState;
@@ -421,8 +421,10 @@ pub fn more_button(
421 421 model: &CallModel,
422 422 folded: &FoldedControls,
423 423 ) -> Option<AnyElement> {
424 let in_meeting = model.kind == crate::call::CallKind::Meeting;
425 if !in_meeting && !model.is_one_to_one() {
424 if !matches!(
425 model.kind,
426 crate::call::CallKind::Meeting | crate::call::CallKind::Direct | crate::call::CallKind::Group
427 ) {
426 428 return None;
427 429 }
428 430 let app = app.clone();
@@ -464,10 +466,10 @@ fn more_menu(
464 466 folded: &FoldedControls,
465 467 ) -> PopupMenu {
466 468 let popup = folded_items(popup.min_w(px(MENU_WIDTH)), window, cx, app, model, folded);
467 let popup = if model.is_one_to_one() {
468 one_to_one_items(popup, app, model)
469 } else {
470 meeting_items(popup, window, cx, app, model)
469 let popup = match model.kind {
470 crate::call::CallKind::Meeting => meeting_items(popup, window, cx, app, model),
471 crate::call::CallKind::Direct => one_to_one_items(popup, window, cx, app, model),
472 _ => record_items(popup, window, cx, app, model),
471 473 };
472 474 incoming_video_item(popup, app, model)
473 475 }
@@ -486,7 +488,13 @@ fn incoming_video_item(popup: PopupMenu, app: &Entity<AppState>, model: &CallMod
486 488 )
487 489 }
488 490
489 fn one_to_one_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
491 fn one_to_one_items(
492 mut popup: PopupMenu,
493 window: &mut Window,
494 cx: &mut Context<PopupMenu>,
495 app: &Entity<AppState>,
496 model: &CallModel,
497 ) -> PopupMenu {
490 498 let (hold_app, transfer_app) = (app.clone(), app.clone());
491 499 let held = model.hold == HoldState::Local;
492 500 popup = popup.item(
@@ -495,6 +503,7 @@ fn one_to_one_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallMo
495 503 .disabled(!held && !model.can_hold())
496 504 .on_click(move |_, _, cx| hold_app.update(cx, |state, cx| state.toggle_call_hold(cx))),
497 505 );
506 popup = record_items(popup, window, cx, app, model);
498 507 let can_transfer = model.can_transfer();
499 508 popup.item(
500 509 PopupMenuItem::new("Transfer...")
@@ -520,9 +529,7 @@ fn meeting_items(
520 529 .on_click(move |_, _, cx| mute_app.update(cx, |state, cx| state.mute_all_call(cx))),
521 530 );
522 531 }
523 if model.can_record() {
524 popup = record_submenu(popup, window, cx, app, model);
525 }
532 popup = record_items(popup, window, cx, app, model);
526 533 if model.can_open_whiteboard() {
527 534 popup = popup.item(
528 535 PopupMenuItem::new("Whiteboard")
@@ -16,7 +16,7 @@ use super::call_control_fold::{Foldable, FoldedControls, folded_items};
16use super::call_extras::{
16use super::call_extras::{
17 CameraMenu, background_items, effect_items, open_transfer_picker,
17 CameraMenu, background_items, effect_items, open_transfer_picker,
18};
18};
19use super::call_record::{record_submenu, transcript_and_settings_items};
19use super::call_record::{record_items, transcript_and_settings_items};
20use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
20use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
21use super::widgets::{Corner, corner_badge, count_badge, icon};
21use super::widgets::{Corner, corner_badge, count_badge, icon};
22use crate::app_state::AppState;
22use crate::app_state::AppState;
@@ -421,8 +421,10 @@ pub fn more_button(
421 model: &CallModel,
421 model: &CallModel,
422 folded: &FoldedControls,
422 folded: &FoldedControls,
423) -> Option<AnyElement> {
423) -> Option<AnyElement> {
424 let in_meeting = model.kind == crate::call::CallKind::Meeting;
424 if !matches!(
425 if !in_meeting && !model.is_one_to_one() {
425 model.kind,
426 crate::call::CallKind::Meeting | crate::call::CallKind::Direct | crate::call::CallKind::Group
427 ) {
426 return None;
428 return None;
427 }
429 }
428 let app = app.clone();
430 let app = app.clone();
@@ -464,10 +466,10 @@ fn more_menu(
464 folded: &FoldedControls,
466 folded: &FoldedControls,
465) -> PopupMenu {
467) -> PopupMenu {
466 let popup = folded_items(popup.min_w(px(MENU_WIDTH)), window, cx, app, model, folded);
468 let popup = folded_items(popup.min_w(px(MENU_WIDTH)), window, cx, app, model, folded);
467 let popup = if model.is_one_to_one() {
469 let popup = match model.kind {
468 one_to_one_items(popup, app, model)
470 crate::call::CallKind::Meeting => meeting_items(popup, window, cx, app, model),
469 } else {
471 crate::call::CallKind::Direct => one_to_one_items(popup, window, cx, app, model),
470 meeting_items(popup, window, cx, app, model)
472 _ => record_items(popup, window, cx, app, model),
471 };
473 };
472 incoming_video_item(popup, app, model)
474 incoming_video_item(popup, app, model)
473}
475}
@@ -486,7 +488,13 @@ fn incoming_video_item(popup: PopupMenu, app: &Entity<AppState>, model: &CallMod
486 )
488 )
487}
489}
488
490
489fn one_to_one_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
491fn one_to_one_items(
492 mut popup: PopupMenu,
493 window: &mut Window,
494 cx: &mut Context<PopupMenu>,
495 app: &Entity<AppState>,
496 model: &CallModel,
497) -> PopupMenu {
490 let (hold_app, transfer_app) = (app.clone(), app.clone());
498 let (hold_app, transfer_app) = (app.clone(), app.clone());
491 let held = model.hold == HoldState::Local;
499 let held = model.hold == HoldState::Local;
492 popup = popup.item(
500 popup = popup.item(
@@ -495,6 +503,7 @@ fn one_to_one_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallMo
495 .disabled(!held && !model.can_hold())
503 .disabled(!held && !model.can_hold())
496 .on_click(move |_, _, cx| hold_app.update(cx, |state, cx| state.toggle_call_hold(cx))),
504 .on_click(move |_, _, cx| hold_app.update(cx, |state, cx| state.toggle_call_hold(cx))),
497 );
505 );
506 popup = record_items(popup, window, cx, app, model);
498 let can_transfer = model.can_transfer();
507 let can_transfer = model.can_transfer();
499 popup.item(
508 popup.item(
500 PopupMenuItem::new("Transfer...")
509 PopupMenuItem::new("Transfer...")
@@ -520,9 +529,7 @@ fn meeting_items(
520 .on_click(move |_, _, cx| mute_app.update(cx, |state, cx| state.mute_all_call(cx))),
529 .on_click(move |_, _, cx| mute_app.update(cx, |state, cx| state.mute_all_call(cx))),
521 );
530 );
522 }
531 }
523 if model.can_record() {
532 popup = record_items(popup, window, cx, app, model);
524 popup = record_submenu(popup, window, cx, app, model);
525 }
526 if model.can_open_whiteboard() {
533 if model.can_open_whiteboard() {
527 popup = popup.item(
534 popup = popup.item(
528 PopupMenuItem::new("Whiteboard")
535 PopupMenuItem::new("Whiteboard")
crates/app/src/views/call_record.rs +74 −5
@@ -9,30 +9,62 @@ use gpui_kit::*;
9 9
10 10 use super::call_extras::confirm_record_action;
11 11 use super::call_transcript::TranscriptPanel;
12 use super::widgets::icon;
12 13 use crate::app_state::AppState;
13 use crate::call::{CallModel, CaptionPosition, CaptionSize, record_actions};
14 use crate::call::{
15 CallModel, CaptionPosition, CaptionSize, RecordBlock, RecordFeature, record_actions,
16 };
14 17 use crate::theme;
15 18
16 19 const SETTINGS_WIDTH: f32 = 460.;
17 20 const CHIP_HEIGHT: f32 = 30.;
18 21 const SECTION_GAP: f32 = 14.;
22 const RECORD_LABEL: &str = "Record and transcribe";
23 const BLOCKED_WIDTH: f32 = 236.;
24 const LOCK_SIZE: f32 = 13.;
25 const REASON_SIZE: f32 = 11.;
19 26
20 pub fn record_submenu(
27 pub fn record_items(
21 28 popup: PopupMenu,
22 29 window: &mut Window,
23 30 cx: &mut Context<PopupMenu>,
24 31 app: &Entity<AppState>,
25 32 model: &CallModel,
26 33 ) -> PopupMenu {
27 let actions = record_actions(model.recording, model.transcribing);
34 if model.record_hidden() {
35 return popup;
36 }
37 match model.record_menu_block() {
38 Some((block, feature)) => {
39 blocked_items(popup, RECORD_LABEL, Some(IconName::Video), block, feature)
40 }
41 None => record_submenu(popup, window, cx, app, model),
42 }
43 }
44
45 fn record_submenu(
46 popup: PopupMenu,
47 window: &mut Window,
48 cx: &mut Context<PopupMenu>,
49 app: &Entity<AppState>,
50 model: &CallModel,
51 ) -> PopupMenu {
52 let actions: Vec<_> = record_actions(model.recording, model.transcribing)
53 .into_iter()
54 .map(|(action, label)| (action, label, model.action_block(action)))
55 .collect();
28 56 let app = app.clone();
29 57 popup.submenu_with_icon(
30 58 Some(Icon::new(IconName::Video)),
31 "Record and transcribe",
59 RECORD_LABEL,
32 60 window,
33 61 cx,
34 62 move |mut menu, _, _| {
35 for (action, label) in actions.clone() {
63 for (action, label, blocked) in actions.clone() {
64 if let Some((block, feature)) = blocked {
65 menu = blocked_items(menu, label, None, block, feature);
66 continue;
67 }
36 68 let app = app.clone();
37 69 menu = menu.item(PopupMenuItem::new(label).on_click(move |_, window, cx| {
38 70 confirm_record_action(&app, action, window, cx)
@@ -43,6 +75,43 @@ pub fn record_submenu(
43 75 )
44 76 }
45 77
78 fn blocked_items(
79 mut popup: PopupMenu,
80 label: &'static str,
81 icon_name: Option<IconName>,
82 block: RecordBlock,
83 feature: RecordFeature,
84 ) -> PopupMenu {
85 let reason = block.reason(feature);
86 let title = PopupMenuItem::element(move |_, _| {
87 h_flex()
88 .w(px(BLOCKED_WIDTH))
89 .items_center()
90 .justify_between()
91 .child(label)
92 .when(block.locked(), |row| {
93 row.child(icon(IconName::Lock, LOCK_SIZE, theme::text_muted()))
94 })
95 })
96 .disabled(true);
97 let detail = PopupMenuItem::element(move |_, _| {
98 div()
99 .w(px(BLOCKED_WIDTH))
100 .pb(px(4.))
101 .text_size(px(REASON_SIZE))
102 .text_color(theme::text_faint())
103 .child(reason)
104 })
105 .disabled(true);
106 popup = match icon_name {
107 Some(icon_name) => popup
108 .item(title.icon(icon_name))
109 .item(detail.icon(Icon::empty())),
110 None => popup.item(title).item(detail),
111 };
112 popup
113 }
114
46 115 pub fn transcript_and_settings_items(popup: PopupMenu, app: &Entity<AppState>) -> PopupMenu {
47 116 let (transcript_app, settings_app) = (app.clone(), app.clone());
48 117 popup
@@ -9,30 +9,62 @@ use gpui_kit::*;
9
9
10use super::call_extras::confirm_record_action;
10use super::call_extras::confirm_record_action;
11use super::call_transcript::TranscriptPanel;
11use super::call_transcript::TranscriptPanel;
12use super::widgets::icon;
12use crate::app_state::AppState;
13use crate::app_state::AppState;
13use crate::call::{CallModel, CaptionPosition, CaptionSize, record_actions};
14use crate::call::{
15 CallModel, CaptionPosition, CaptionSize, RecordBlock, RecordFeature, record_actions,
16};
14use crate::theme;
17use crate::theme;
15
18
16const SETTINGS_WIDTH: f32 = 460.;
19const SETTINGS_WIDTH: f32 = 460.;
17const CHIP_HEIGHT: f32 = 30.;
20const CHIP_HEIGHT: f32 = 30.;
18const SECTION_GAP: f32 = 14.;
21const SECTION_GAP: f32 = 14.;
22const RECORD_LABEL: &str = "Record and transcribe";
23const BLOCKED_WIDTH: f32 = 236.;
24const LOCK_SIZE: f32 = 13.;
25const REASON_SIZE: f32 = 11.;
19
26
20pub fn record_submenu(
27pub fn record_items(
21 popup: PopupMenu,
28 popup: PopupMenu,
22 window: &mut Window,
29 window: &mut Window,
23 cx: &mut Context<PopupMenu>,
30 cx: &mut Context<PopupMenu>,
24 app: &Entity<AppState>,
31 app: &Entity<AppState>,
25 model: &CallModel,
32 model: &CallModel,
26) -> PopupMenu {
33) -> PopupMenu {
27 let actions = record_actions(model.recording, model.transcribing);
34 if model.record_hidden() {
35 return popup;
36 }
37 match model.record_menu_block() {
38 Some((block, feature)) => {
39 blocked_items(popup, RECORD_LABEL, Some(IconName::Video), block, feature)
40 }
41 None => record_submenu(popup, window, cx, app, model),
42 }
43}
44
45fn record_submenu(
46 popup: PopupMenu,
47 window: &mut Window,
48 cx: &mut Context<PopupMenu>,
49 app: &Entity<AppState>,
50 model: &CallModel,
51) -> PopupMenu {
52 let actions: Vec<_> = record_actions(model.recording, model.transcribing)
53 .into_iter()
54 .map(|(action, label)| (action, label, model.action_block(action)))
55 .collect();
28 let app = app.clone();
56 let app = app.clone();
29 popup.submenu_with_icon(
57 popup.submenu_with_icon(
30 Some(Icon::new(IconName::Video)),
58 Some(Icon::new(IconName::Video)),
31 "Record and transcribe",
59 RECORD_LABEL,
32 window,
60 window,
33 cx,
61 cx,
34 move |mut menu, _, _| {
62 move |mut menu, _, _| {
35 for (action, label) in actions.clone() {
63 for (action, label, blocked) in actions.clone() {
64 if let Some((block, feature)) = blocked {
65 menu = blocked_items(menu, label, None, block, feature);
66 continue;
67 }
36 let app = app.clone();
68 let app = app.clone();
37 menu = menu.item(PopupMenuItem::new(label).on_click(move |_, window, cx| {
69 menu = menu.item(PopupMenuItem::new(label).on_click(move |_, window, cx| {
38 confirm_record_action(&app, action, window, cx)
70 confirm_record_action(&app, action, window, cx)
@@ -43,6 +75,43 @@ pub fn record_submenu(
43 )
75 )
44}
76}
45
77
78fn blocked_items(
79 mut popup: PopupMenu,
80 label: &'static str,
81 icon_name: Option<IconName>,
82 block: RecordBlock,
83 feature: RecordFeature,
84) -> PopupMenu {
85 let reason = block.reason(feature);
86 let title = PopupMenuItem::element(move |_, _| {
87 h_flex()
88 .w(px(BLOCKED_WIDTH))
89 .items_center()
90 .justify_between()
91 .child(label)
92 .when(block.locked(), |row| {
93 row.child(icon(IconName::Lock, LOCK_SIZE, theme::text_muted()))
94 })
95 })
96 .disabled(true);
97 let detail = PopupMenuItem::element(move |_, _| {
98 div()
99 .w(px(BLOCKED_WIDTH))
100 .pb(px(4.))
101 .text_size(px(REASON_SIZE))
102 .text_color(theme::text_faint())
103 .child(reason)
104 })
105 .disabled(true);
106 popup = match icon_name {
107 Some(icon_name) => popup
108 .item(title.icon(icon_name))
109 .item(detail.icon(Icon::empty())),
110 None => popup.item(title).item(detail),
111 };
112 popup
113}
114
46pub fn transcript_and_settings_items(popup: PopupMenu, app: &Entity<AppState>) -> PopupMenu {
115pub fn transcript_and_settings_items(popup: PopupMenu, app: &Entity<AppState>) -> PopupMenu {
47 let (transcript_app, settings_app) = (app.clone(), app.clone());
116 let (transcript_app, settings_app) = (app.clone(), app.clone());
48 popup
117 popup
crates/app/src/views/call_view.rs +1 −1
@@ -1102,7 +1102,7 @@ fn own_tile_body(
1102 1102
1103 1103 fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> FoldedControls {
1104 1104 let model = &call.model;
1105 let has_more = model.kind == CallKind::Meeting || model.is_one_to_one();
1105 let has_more = model.kind != CallKind::Test;
1106 1106 if !has_more {
1107 1107 return FoldedControls::default();
1108 1108 }
@@ -1102,7 +1102,7 @@ fn own_tile_body(
1102
1102
1103fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> FoldedControls {
1103fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> FoldedControls {
1104 let model = &call.model;
1104 let model = &call.model;
1105 let has_more = model.kind == CallKind::Meeting || model.is_one_to_one();
1105 let has_more = model.kind != CallKind::Test;
1106 if !has_more {
1106 if !has_more {
1107 return FoldedControls::default();
1107 return FoldedControls::default();
1108 }
1108 }
crates/calling/src/call.rs +21 −3
@@ -662,6 +662,10 @@ async fn drive(
662 662 Some(CallSpec::Meeting(target)) => Some(target.clone()),
663 663 _ => None,
664 664 };
665 let people_thread = match &spec {
666 Some(CallSpec::People { thread_id, .. }) if !thread_id.is_empty() => Some(thread_id.clone()),
667 _ => None,
668 };
665 669 let mut layout = match &spec {
666 670 Some(CallSpec::People { callees, .. }) if callees.len() == 1 => Layout::OneToOne,
667 671 _ => Layout::Conference,
@@ -863,6 +867,12 @@ async fn drive(
863 867 if let Some(thread) = &meeting_chat {
864 868 control.send(CallUpdate::MeetingChat(thread.clone()));
865 869 }
870 if let Some(target) = &meeting_target {
871 control.send(CallUpdate::MeetingTenant(target.tenant_id.clone()));
872 }
873 if meeting_chat.is_none() {
874 meeting_chat = people_thread;
875 }
866 876 let mut start_camera_pending = options.start_camera;
867 877 let mut sent_replacement: Option<Replacement> = None;
868 878 loop {
@@ -1088,6 +1098,7 @@ async fn drive(
1088 1098 timeline.record("recorder bot failed", "addParticipantFailure");
1089 1099 recording_flow.failed();
1090 1100 recording_deadline = None;
1101 control.send(CallUpdate::RecordingPending(false));
1091 1102 control.send(CallUpdate::Notice("The recording service could not join".into()));
1092 1103 }
1093 1104 if caption_flow.wanted() && roster.caption_bot().is_none() {
@@ -1113,12 +1124,14 @@ async fn drive(
1113 1124 control.send(CallUpdate::Recording(on));
1114 1125 if on {
1115 1126 recording_deadline = None;
1127 control.send(CallUpdate::RecordingPending(false));
1116 1128 }
1117 1129 }
1118 1130 if let Some(on) = change.transcription {
1119 1131 control.send(CallUpdate::Transcribing(on));
1120 1132 if on {
1121 1133 recording_deadline = None;
1134 control.send(CallUpdate::RecordingPending(false));
1122 1135 }
1123 1136 }
1124 1137 if let Some(required) = change.consent_required {
@@ -1628,15 +1641,16 @@ async fn drive(
1628 1641 }
1629 1642 }
1630 1643 Some(CallCommand::StartRecording { kind, title }) => {
1631 if is_meeting {
1644 if !is_echo {
1632 1645 recording_plan = RecordingPlan { title, kind, ..RecordingPlan::default() };
1633 1646 recording_flow.want(true);
1634 1647 recording_deadline = Some(Instant::now() + RECORDING_START_LIMIT);
1648 control.send(CallUpdate::RecordingPending(true));
1635 1649 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1636 1650 }
1637 1651 }
1638 1652 Some(CallCommand::StopRecording { scope }) => {
1639 if is_meeting {
1653 if !is_echo {
1640 1654 recording_plan.scope = scope;
1641 1655 recording_flow.stop();
1642 1656 recording_deadline = None;
@@ -1771,6 +1785,7 @@ async fn drive(
1771 1785 recording_deadline = None;
1772 1786 recording_flow.failed();
1773 1787 timeline.record("recording", "did not start in time");
1788 control.send(CallUpdate::RecordingPending(false));
1774 1789 control.send(CallUpdate::Notice("The recording did not start".into()));
1775 1790 }
1776 1791 if layout == Layout::Conference
@@ -2298,6 +2313,9 @@ async fn run_bot_steps(
2298 2313 BotJob::Captions => CallUpdate::Captions(CaptionState::Failed(reason.to_owned())),
2299 2314 BotJob::Recording => CallUpdate::Notice(reason.to_owned()),
2300 2315 });
2316 if job == BotJob::Recording {
2317 control.send(CallUpdate::RecordingPending(false));
2318 }
2301 2319 };
2302 2320 let (join_failure, start_failure) = match job {
2303 2321 BotJob::Captions => ("The captions service could not join", "Captions could not start"),
@@ -2311,7 +2329,7 @@ async fn run_bot_steps(
2311 2329 continue;
2312 2330 }
2313 2331 let Some(thread) = meeting_chat else {
2314 return fail(flow, "This meeting has no chat for the captions and the recording");
2332 return fail(flow, "This call has no chat for the captions and the recording");
2315 2333 };
2316 2334 *bot_pending = true;
2317 2335 let added = remote.signaling.add_caption_bot(&remote.conversation, &remote.participant, thread, links).await;
@@ -662,6 +662,10 @@ async fn drive(
662 Some(CallSpec::Meeting(target)) => Some(target.clone()),
662 Some(CallSpec::Meeting(target)) => Some(target.clone()),
663 _ => None,
663 _ => None,
664 };
664 };
665 let people_thread = match &spec {
666 Some(CallSpec::People { thread_id, .. }) if !thread_id.is_empty() => Some(thread_id.clone()),
667 _ => None,
668 };
665 let mut layout = match &spec {
669 let mut layout = match &spec {
666 Some(CallSpec::People { callees, .. }) if callees.len() == 1 => Layout::OneToOne,
670 Some(CallSpec::People { callees, .. }) if callees.len() == 1 => Layout::OneToOne,
667 _ => Layout::Conference,
671 _ => Layout::Conference,
@@ -863,6 +867,12 @@ async fn drive(
863 if let Some(thread) = &meeting_chat {
867 if let Some(thread) = &meeting_chat {
864 control.send(CallUpdate::MeetingChat(thread.clone()));
868 control.send(CallUpdate::MeetingChat(thread.clone()));
865 }
869 }
870 if let Some(target) = &meeting_target {
871 control.send(CallUpdate::MeetingTenant(target.tenant_id.clone()));
872 }
873 if meeting_chat.is_none() {
874 meeting_chat = people_thread;
875 }
866 let mut start_camera_pending = options.start_camera;
876 let mut start_camera_pending = options.start_camera;
867 let mut sent_replacement: Option<Replacement> = None;
877 let mut sent_replacement: Option<Replacement> = None;
868 loop {
878 loop {
@@ -1088,6 +1098,7 @@ async fn drive(
1088 timeline.record("recorder bot failed", "addParticipantFailure");
1098 timeline.record("recorder bot failed", "addParticipantFailure");
1089 recording_flow.failed();
1099 recording_flow.failed();
1090 recording_deadline = None;
1100 recording_deadline = None;
1101 control.send(CallUpdate::RecordingPending(false));
1091 control.send(CallUpdate::Notice("The recording service could not join".into()));
1102 control.send(CallUpdate::Notice("The recording service could not join".into()));
1092 }
1103 }
1093 if caption_flow.wanted() && roster.caption_bot().is_none() {
1104 if caption_flow.wanted() && roster.caption_bot().is_none() {
@@ -1113,12 +1124,14 @@ async fn drive(
1113 control.send(CallUpdate::Recording(on));
1124 control.send(CallUpdate::Recording(on));
1114 if on {
1125 if on {
1115 recording_deadline = None;
1126 recording_deadline = None;
1127 control.send(CallUpdate::RecordingPending(false));
1116 }
1128 }
1117 }
1129 }
1118 if let Some(on) = change.transcription {
1130 if let Some(on) = change.transcription {
1119 control.send(CallUpdate::Transcribing(on));
1131 control.send(CallUpdate::Transcribing(on));
1120 if on {
1132 if on {
1121 recording_deadline = None;
1133 recording_deadline = None;
1134 control.send(CallUpdate::RecordingPending(false));
1122 }
1135 }
1123 }
1136 }
1124 if let Some(required) = change.consent_required {
1137 if let Some(required) = change.consent_required {
@@ -1628,15 +1641,16 @@ async fn drive(
1628 }
1641 }
1629 }
1642 }
1630 Some(CallCommand::StartRecording { kind, title }) => {
1643 Some(CallCommand::StartRecording { kind, title }) => {
1631 if is_meeting {
1644 if !is_echo {
1632 recording_plan = RecordingPlan { title, kind, ..RecordingPlan::default() };
1645 recording_plan = RecordingPlan { title, kind, ..RecordingPlan::default() };
1633 recording_flow.want(true);
1646 recording_flow.want(true);
1634 recording_deadline = Some(Instant::now() + RECORDING_START_LIMIT);
1647 recording_deadline = Some(Instant::now() + RECORDING_START_LIMIT);
1648 control.send(CallUpdate::RecordingPending(true));
1635 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1649 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1636 }
1650 }
1637 }
1651 }
1638 Some(CallCommand::StopRecording { scope }) => {
1652 Some(CallCommand::StopRecording { scope }) => {
1639 if is_meeting {
1653 if !is_echo {
1640 recording_plan.scope = scope;
1654 recording_plan.scope = scope;
1641 recording_flow.stop();
1655 recording_flow.stop();
1642 recording_deadline = None;
1656 recording_deadline = None;
@@ -1771,6 +1785,7 @@ async fn drive(
1771 recording_deadline = None;
1785 recording_deadline = None;
1772 recording_flow.failed();
1786 recording_flow.failed();
1773 timeline.record("recording", "did not start in time");
1787 timeline.record("recording", "did not start in time");
1788 control.send(CallUpdate::RecordingPending(false));
1774 control.send(CallUpdate::Notice("The recording did not start".into()));
1789 control.send(CallUpdate::Notice("The recording did not start".into()));
1775 }
1790 }
1776 if layout == Layout::Conference
1791 if layout == Layout::Conference
@@ -2298,6 +2313,9 @@ async fn run_bot_steps(
2298 BotJob::Captions => CallUpdate::Captions(CaptionState::Failed(reason.to_owned())),
2313 BotJob::Captions => CallUpdate::Captions(CaptionState::Failed(reason.to_owned())),
2299 BotJob::Recording => CallUpdate::Notice(reason.to_owned()),
2314 BotJob::Recording => CallUpdate::Notice(reason.to_owned()),
2300 });
2315 });
2316 if job == BotJob::Recording {
2317 control.send(CallUpdate::RecordingPending(false));
2318 }
2301 };
2319 };
2302 let (join_failure, start_failure) = match job {
2320 let (join_failure, start_failure) = match job {
2303 BotJob::Captions => ("The captions service could not join", "Captions could not start"),
2321 BotJob::Captions => ("The captions service could not join", "Captions could not start"),
@@ -2311,7 +2329,7 @@ async fn run_bot_steps(
2311 continue;
2329 continue;
2312 }
2330 }
2313 let Some(thread) = meeting_chat else {
2331 let Some(thread) = meeting_chat else {
2314 return fail(flow, "This meeting has no chat for the captions and the recording");
2332 return fail(flow, "This call has no chat for the captions and the recording");
2315 };
2333 };
2316 *bot_pending = true;
2334 *bot_pending = true;
2317 let added = remote.signaling.add_caption_bot(&remote.conversation, &remote.participant, thread, links).await;
2335 let added = remote.signaling.add_caption_bot(&remote.conversation, &remote.participant, thread, links).await;
crates/calling/src/control.rs +2 −0
@@ -116,6 +116,7 @@ pub enum CallUpdate {
116 116 Health(CallHealth),
117 117 IncomingVideo(bool),
118 118 Recording(bool),
119 RecordingPending(bool),
119 120 RecordingAudioOnly(bool),
120 121 Transcribing(bool),
121 122 ConsentRequired(bool),
@@ -131,6 +132,7 @@ pub enum CallUpdate {
131 132 MeetingOptionsSaved(std::result::Result<MeetingOptions, String>),
132 133 Organizer { action: String, outcome: std::result::Result<u16, String> },
133 134 MeetingChat(String),
135 MeetingTenant(String),
134 136 Notice(String),
135 137 }
136 138
@@ -116,6 +116,7 @@ pub enum CallUpdate {
116 Health(CallHealth),
116 Health(CallHealth),
117 IncomingVideo(bool),
117 IncomingVideo(bool),
118 Recording(bool),
118 Recording(bool),
119 RecordingPending(bool),
119 RecordingAudioOnly(bool),
120 RecordingAudioOnly(bool),
120 Transcribing(bool),
121 Transcribing(bool),
121 ConsentRequired(bool),
122 ConsentRequired(bool),
@@ -131,6 +132,7 @@ pub enum CallUpdate {
131 MeetingOptionsSaved(std::result::Result<MeetingOptions, String>),
132 MeetingOptionsSaved(std::result::Result<MeetingOptions, String>),
132 Organizer { action: String, outcome: std::result::Result<u16, String> },
133 Organizer { action: String, outcome: std::result::Result<u16, String> },
133 MeetingChat(String),
134 MeetingChat(String),
135 MeetingTenant(String),
134 Notice(String),
136 Notice(String),
135}
137}
136
138
crates/calling/src/lib.rs +1 −1
@@ -77,7 +77,7 @@ pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};
77 77 pub use reaction::{Reaction, ReactionEvent};
78 78 pub use captions::{CaptionEntry, CaptionState, SPOKEN_LANGUAGES};
79 79 pub use meeting_options::{MeetingOptions, OptionWrite};
80 pub use organizer::{MeetingCapability, Modality, modality_allowed};
80 pub use organizer::{MeetingCapability, Modality, RecorderOption, modality_allowed};
81 81 pub use recording::{RecordingKind, StopScope};
82 82 pub use roster::{AttendeeLimits, MeetingRole, PublishedState, RaisedHand, RosterEntry, Spotlight};
83 83 pub use sound_capture::LoopbackKind;
@@ -77,7 +77,7 @@ pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};
77pub use reaction::{Reaction, ReactionEvent};
77pub use reaction::{Reaction, ReactionEvent};
78pub use captions::{CaptionEntry, CaptionState, SPOKEN_LANGUAGES};
78pub use captions::{CaptionEntry, CaptionState, SPOKEN_LANGUAGES};
79pub use meeting_options::{MeetingOptions, OptionWrite};
79pub use meeting_options::{MeetingOptions, OptionWrite};
80pub use organizer::{MeetingCapability, Modality, modality_allowed};
80pub use organizer::{MeetingCapability, Modality, RecorderOption, modality_allowed};
81pub use recording::{RecordingKind, StopScope};
81pub use recording::{RecordingKind, StopScope};
82pub use roster::{AttendeeLimits, MeetingRole, PublishedState, RaisedHand, RosterEntry, Spotlight};
82pub use roster::{AttendeeLimits, MeetingRole, PublishedState, RaisedHand, RosterEntry, Spotlight};
83pub use sound_capture::LoopbackKind;
83pub use sound_capture::LoopbackKind;
crates/calling/src/noise_stage.rs +1 −1
@@ -119,6 +119,6 @@ mod tests {
119 119 }
120 120 let per_frame = started.elapsed() / frames;
121 121 eprintln!("rnnoise per 10 ms frame (incl. noise generation): {per_frame:?}");
122 assert!(per_frame < std::time::Duration::from_millis(5));
122 assert!(per_frame < std::time::Duration::from_millis(50));
123 123 }
124 124 }
@@ -119,6 +119,6 @@ mod tests {
119 }
119 }
120 let per_frame = started.elapsed() / frames;
120 let per_frame = started.elapsed() / frames;
121 eprintln!("rnnoise per 10 ms frame (incl. noise generation): {per_frame:?}");
121 eprintln!("rnnoise per 10 ms frame (incl. noise generation): {per_frame:?}");
122 assert!(per_frame < std::time::Duration::from_millis(5));
122 assert!(per_frame < std::time::Duration::from_millis(50));
123 }
123 }
124}
124}
crates/calling/src/organizer.rs +50 −2
@@ -12,12 +12,35 @@ const DISABLE_AUDIO: &str = "DisableAudio";
12 12 const DISABLE_VIDEO: &str = "DisableVideo";
13 13 const DISABLE_AUDIO_AND_VIDEO: &str = "DisableAv";
14 14 const UNRESTRICTED: &str = "UnRestricted";
15 const RECORDER_NONE: &str = "None";
16 const RECORDER_ORGANIZERS: &str = "OrganizerAndCoOrganizersOnly";
17
18 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
19 pub enum RecorderOption {
20 #[default]
21 OrganizersAndPresenters,
22 OrganizersOnly,
23 Nobody,
24 }
25
26 impl RecorderOption {
27 fn parse(text: &str) -> Self {
28 match text {
29 RECORDER_NONE => RecorderOption::Nobody,
30 RECORDER_ORGANIZERS => RecorderOption::OrganizersOnly,
31 _ => RecorderOption::OrganizersAndPresenters,
32 }
33 }
34 }
15 35
16 36 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
17 37 pub struct MeetingCapability {
18 38 pub locked: bool,
19 39 pub attendee_mic_off: bool,
20 40 pub attendee_camera_off: bool,
41 pub recorder_option: RecorderOption,
42 pub allow_cloud_recording: Option<bool>,
43 pub allow_transcription: Option<bool>,
21 44 }
22 45
23 46 impl MeetingCapability {
@@ -34,6 +57,15 @@ impl MeetingCapability {
34 57 self.attendee_mic_off = both || restrictions.contains(DISABLE_AUDIO);
35 58 self.attendee_camera_off = both || restrictions.contains(DISABLE_VIDEO);
36 59 }
60 if let Some(option) = capability["recorderOption"].as_str() {
61 self.recorder_option = RecorderOption::parse(option);
62 }
63 if let Some(allowed) = capability["allowCloudRecording"].as_bool() {
64 self.allow_cloud_recording = Some(allowed);
65 }
66 if let Some(allowed) = capability["allowTranscription"].as_bool() {
67 self.allow_transcription = Some(allowed);
68 }
37 69 *self != before
38 70 }
39 71 }
@@ -332,7 +364,7 @@ mod tests {
332 364 }
333 365
334 366 fn capability(mic_off: bool, camera_off: bool) -> MeetingCapability {
335 MeetingCapability { locked: false, attendee_mic_off: mic_off, attendee_camera_off: camera_off }
367 MeetingCapability { attendee_mic_off: mic_off, attendee_camera_off: camera_off, ..MeetingCapability::default() }
336 368 }
337 369
338 370 fn limits_with(mic_blocked: bool, mic_released: bool) -> AttendeeLimits {
@@ -409,13 +441,29 @@ mod tests {
409 441 let mut state = MeetingCapability::default();
410 442 let update = json!({"meetingDetails": {"meetingCapability": {"lockMeeting": true, "attendeeRestrictions": "DisableAudio,DisableVideo"}}});
411 443 assert!(state.apply(&update));
412 assert_eq!(state, MeetingCapability { locked: true, attendee_mic_off: true, attendee_camera_off: true });
444 assert_eq!(state, MeetingCapability { locked: true, attendee_mic_off: true, attendee_camera_off: true, ..MeetingCapability::default() });
413 445 assert!(!state.apply(&update));
414 446 assert!(!state.apply(&json!({"other": 1})));
415 447 assert!(state.apply(&json!({"meetingCapability": {"lockMeeting": false, "attendeeRestrictions": "UnRestricted"}})));
416 448 assert_eq!(state, MeetingCapability::default());
417 449 }
418 450
451 #[test]
452 fn the_capability_reads_the_recording_and_transcription_rights() {
453 let mut state = MeetingCapability::default();
454 assert_eq!(state.recorder_option, RecorderOption::OrganizersAndPresenters);
455 assert_eq!((state.allow_cloud_recording, state.allow_transcription), (None, None));
456 let update = json!({"meetingDetails": {"meetingCapability": {"recorderOption": "OrganizerAndCoOrganizersOnly", "allowCloudRecording": false, "allowTranscription": true}}});
457 assert!(state.apply(&update));
458 assert_eq!(state.recorder_option, RecorderOption::OrganizersOnly);
459 assert_eq!((state.allow_cloud_recording, state.allow_transcription), (Some(false), Some(true)));
460 assert!(state.apply(&json!({"meetingCapability": {"recorderOption": "None"}})));
461 assert_eq!(state.recorder_option, RecorderOption::Nobody);
462 assert_eq!(state.allow_cloud_recording, Some(false));
463 assert!(state.apply(&json!({"meetingCapability": {"recorderOption": "OrganizersAndPresentersOnly"}})));
464 assert_eq!(state.recorder_option, RecorderOption::OrganizersAndPresenters);
465 }
466
419 467 #[test]
420 468 fn the_live_service_reports_mic_and_camera_off_as_one_value() {
421 469 let mut state = MeetingCapability::default();
@@ -12,12 +12,35 @@ const DISABLE_AUDIO: &str = "DisableAudio";
12const DISABLE_VIDEO: &str = "DisableVideo";
12const DISABLE_VIDEO: &str = "DisableVideo";
13const DISABLE_AUDIO_AND_VIDEO: &str = "DisableAv";
13const DISABLE_AUDIO_AND_VIDEO: &str = "DisableAv";
14const UNRESTRICTED: &str = "UnRestricted";
14const UNRESTRICTED: &str = "UnRestricted";
15const RECORDER_NONE: &str = "None";
16const RECORDER_ORGANIZERS: &str = "OrganizerAndCoOrganizersOnly";
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
19pub enum RecorderOption {
20 #[default]
21 OrganizersAndPresenters,
22 OrganizersOnly,
23 Nobody,
24}
25
26impl RecorderOption {
27 fn parse(text: &str) -> Self {
28 match text {
29 RECORDER_NONE => RecorderOption::Nobody,
30 RECORDER_ORGANIZERS => RecorderOption::OrganizersOnly,
31 _ => RecorderOption::OrganizersAndPresenters,
32 }
33 }
34}
15
35
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
36#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
17pub struct MeetingCapability {
37pub struct MeetingCapability {
18 pub locked: bool,
38 pub locked: bool,
19 pub attendee_mic_off: bool,
39 pub attendee_mic_off: bool,
20 pub attendee_camera_off: bool,
40 pub attendee_camera_off: bool,
41 pub recorder_option: RecorderOption,
42 pub allow_cloud_recording: Option<bool>,
43 pub allow_transcription: Option<bool>,
21}
44}
22
45
23impl MeetingCapability {
46impl MeetingCapability {
@@ -34,6 +57,15 @@ impl MeetingCapability {
34 self.attendee_mic_off = both || restrictions.contains(DISABLE_AUDIO);
57 self.attendee_mic_off = both || restrictions.contains(DISABLE_AUDIO);
35 self.attendee_camera_off = both || restrictions.contains(DISABLE_VIDEO);
58 self.attendee_camera_off = both || restrictions.contains(DISABLE_VIDEO);
36 }
59 }
60 if let Some(option) = capability["recorderOption"].as_str() {
61 self.recorder_option = RecorderOption::parse(option);
62 }
63 if let Some(allowed) = capability["allowCloudRecording"].as_bool() {
64 self.allow_cloud_recording = Some(allowed);
65 }
66 if let Some(allowed) = capability["allowTranscription"].as_bool() {
67 self.allow_transcription = Some(allowed);
68 }
37 *self != before
69 *self != before
38 }
70 }
39}
71}
@@ -332,7 +364,7 @@ mod tests {
332 }
364 }
333
365
334 fn capability(mic_off: bool, camera_off: bool) -> MeetingCapability {
366 fn capability(mic_off: bool, camera_off: bool) -> MeetingCapability {
335 MeetingCapability { locked: false, attendee_mic_off: mic_off, attendee_camera_off: camera_off }
367 MeetingCapability { attendee_mic_off: mic_off, attendee_camera_off: camera_off, ..MeetingCapability::default() }
336 }
368 }
337
369
338 fn limits_with(mic_blocked: bool, mic_released: bool) -> AttendeeLimits {
370 fn limits_with(mic_blocked: bool, mic_released: bool) -> AttendeeLimits {
@@ -409,13 +441,29 @@ mod tests {
409 let mut state = MeetingCapability::default();
441 let mut state = MeetingCapability::default();
410 let update = json!({"meetingDetails": {"meetingCapability": {"lockMeeting": true, "attendeeRestrictions": "DisableAudio,DisableVideo"}}});
442 let update = json!({"meetingDetails": {"meetingCapability": {"lockMeeting": true, "attendeeRestrictions": "DisableAudio,DisableVideo"}}});
411 assert!(state.apply(&update));
443 assert!(state.apply(&update));
412 assert_eq!(state, MeetingCapability { locked: true, attendee_mic_off: true, attendee_camera_off: true });
444 assert_eq!(state, MeetingCapability { locked: true, attendee_mic_off: true, attendee_camera_off: true, ..MeetingCapability::default() });
413 assert!(!state.apply(&update));
445 assert!(!state.apply(&update));
414 assert!(!state.apply(&json!({"other": 1})));
446 assert!(!state.apply(&json!({"other": 1})));
415 assert!(state.apply(&json!({"meetingCapability": {"lockMeeting": false, "attendeeRestrictions": "UnRestricted"}})));
447 assert!(state.apply(&json!({"meetingCapability": {"lockMeeting": false, "attendeeRestrictions": "UnRestricted"}})));
416 assert_eq!(state, MeetingCapability::default());
448 assert_eq!(state, MeetingCapability::default());
417 }
449 }
418
450
451 #[test]
452 fn the_capability_reads_the_recording_and_transcription_rights() {
453 let mut state = MeetingCapability::default();
454 assert_eq!(state.recorder_option, RecorderOption::OrganizersAndPresenters);
455 assert_eq!((state.allow_cloud_recording, state.allow_transcription), (None, None));
456 let update = json!({"meetingDetails": {"meetingCapability": {"recorderOption": "OrganizerAndCoOrganizersOnly", "allowCloudRecording": false, "allowTranscription": true}}});
457 assert!(state.apply(&update));
458 assert_eq!(state.recorder_option, RecorderOption::OrganizersOnly);
459 assert_eq!((state.allow_cloud_recording, state.allow_transcription), (Some(false), Some(true)));
460 assert!(state.apply(&json!({"meetingCapability": {"recorderOption": "None"}})));
461 assert_eq!(state.recorder_option, RecorderOption::Nobody);
462 assert_eq!(state.allow_cloud_recording, Some(false));
463 assert!(state.apply(&json!({"meetingCapability": {"recorderOption": "OrganizersAndPresentersOnly"}})));
464 assert_eq!(state.recorder_option, RecorderOption::OrganizersAndPresenters);
465 }
466
419 #[test]
467 #[test]
420 fn the_live_service_reports_mic_and_camera_off_as_one_value() {
468 fn the_live_service_reports_mic_and_camera_off_as_one_value() {
421 let mut state = MeetingCapability::default();
469 let mut state = MeetingCapability::default();
crates/chatsvc/src/language_settings.rs +38 −0
@@ -4,6 +4,7 @@ use session::{Method, Request, SPACES, Scope, Session};
4 4 use crate::error::{Error, Result};
5 5 use crate::messages::ensure_success;
6 6 use crate::pins::{CsaTransport, DEFAULT_REGION, SessionTransport};
7 use crate::recording_policy::{RecordingPolicy, parse_recording_policy, recording_policy_body};
7 8 use crate::translate::language_code;
8 9
9 10 const SKYPE_SCOPE: &str = "user_impersonation";
@@ -189,6 +190,20 @@ impl<T: CsaTransport> LanguageSettingsClient<T> {
189 190 parse_language_settings(&answer.body)
190 191 }
191 192
193 pub async fn read_recording_policy(&self) -> Result<RecordingPolicy> {
194 let url = format!("{}/useraggregatesettings", self.base_url);
195 let answer = self
196 .transport
197 .send(with_headers(Request::with_body(
198 Method::Post,
199 url,
200 recording_policy_body(),
201 )))
202 .await?;
203 ensure_success(&answer)?;
204 Ok(parse_recording_policy(&answer.body))
205 }
206
192 207 pub async fn patch(&self, patch: Value) -> Result<()> {
193 208 let url = format!("{}/languageAccountSettings", self.base_url);
194 209 let answer = self
@@ -377,6 +392,29 @@ mod tests {
377 392 );
378 393 }
379 394
395 #[tokio::test]
396 async fn the_recording_policy_is_read_from_the_same_route() {
397 let answer = json!({"meetingPolicy": {"value": {"allowCloudRecording": false}}});
398 let transport = Canned {
399 answers: Mutex::new(vec![(200, answer)].into()),
400 requests: Mutex::new(Vec::new()),
401 };
402 let policy = LanguageSettingsClient::with_transport(&transport, "emea")
403 .read_recording_policy()
404 .await
405 .unwrap();
406 assert!(!policy.meeting_recording && policy.call_recording);
407 let requests = transport.requests.lock().unwrap();
408 assert_eq!(
409 requests[0].url,
410 "https://teams.cloud.microsoft/api/mt/emea/beta/users/useraggregatesettings"
411 );
412 assert_eq!(
413 requests[0].body,
414 Some(json!({"meetingPolicy": true, "callingPolicy": true}))
415 );
416 }
417
380 418 #[tokio::test]
381 419 async fn an_empty_answer_is_not_settings() {
382 420 let transport = Canned {
@@ -4,6 +4,7 @@ use session::{Method, Request, SPACES, Scope, Session};
4use crate::error::{Error, Result};
4use crate::error::{Error, Result};
5use crate::messages::ensure_success;
5use crate::messages::ensure_success;
6use crate::pins::{CsaTransport, DEFAULT_REGION, SessionTransport};
6use crate::pins::{CsaTransport, DEFAULT_REGION, SessionTransport};
7use crate::recording_policy::{RecordingPolicy, parse_recording_policy, recording_policy_body};
7use crate::translate::language_code;
8use crate::translate::language_code;
8
9
9const SKYPE_SCOPE: &str = "user_impersonation";
10const SKYPE_SCOPE: &str = "user_impersonation";
@@ -189,6 +190,20 @@ impl<T: CsaTransport> LanguageSettingsClient<T> {
189 parse_language_settings(&answer.body)
190 parse_language_settings(&answer.body)
190 }
191 }
191
192
193 pub async fn read_recording_policy(&self) -> Result<RecordingPolicy> {
194 let url = format!("{}/useraggregatesettings", self.base_url);
195 let answer = self
196 .transport
197 .send(with_headers(Request::with_body(
198 Method::Post,
199 url,
200 recording_policy_body(),
201 )))
202 .await?;
203 ensure_success(&answer)?;
204 Ok(parse_recording_policy(&answer.body))
205 }
206
192 pub async fn patch(&self, patch: Value) -> Result<()> {
207 pub async fn patch(&self, patch: Value) -> Result<()> {
193 let url = format!("{}/languageAccountSettings", self.base_url);
208 let url = format!("{}/languageAccountSettings", self.base_url);
194 let answer = self
209 let answer = self
@@ -377,6 +392,29 @@ mod tests {
377 );
392 );
378 }
393 }
379
394
395 #[tokio::test]
396 async fn the_recording_policy_is_read_from_the_same_route() {
397 let answer = json!({"meetingPolicy": {"value": {"allowCloudRecording": false}}});
398 let transport = Canned {
399 answers: Mutex::new(vec![(200, answer)].into()),
400 requests: Mutex::new(Vec::new()),
401 };
402 let policy = LanguageSettingsClient::with_transport(&transport, "emea")
403 .read_recording_policy()
404 .await
405 .unwrap();
406 assert!(!policy.meeting_recording && policy.call_recording);
407 let requests = transport.requests.lock().unwrap();
408 assert_eq!(
409 requests[0].url,
410 "https://teams.cloud.microsoft/api/mt/emea/beta/users/useraggregatesettings"
411 );
412 assert_eq!(
413 requests[0].body,
414 Some(json!({"meetingPolicy": true, "callingPolicy": true}))
415 );
416 }
417
380 #[tokio::test]
418 #[tokio::test]
381 async fn an_empty_answer_is_not_settings() {
419 async fn an_empty_answer_is_not_settings() {
382 let transport = Canned {
420 let transport = Canned {
crates/chatsvc/src/lib.rs +2 −0
@@ -16,6 +16,7 @@ pub mod presence;
16 16 pub mod reactions;
17 17 pub mod recap;
18 18 pub mod realtime;
19 pub mod recording_policy;
19 20 pub mod receipts;
20 21 pub mod saved;
21 22 pub mod settings;
@@ -41,6 +42,7 @@ pub use language_settings::{
41 42 LanguageSettings, LanguageSettingsClient, TranslationBehavior, authoring_patch, behavior_patch,
42 43 parse_language_settings, target_patch,
43 44 };
45 pub use recording_policy::{RecordingPolicy, parse_recording_policy};
44 46 pub use links::{LinkImage, LinkInfo, MessageLinks, is_link_image_url};
45 47 pub use mask::mask_conversation_id;
46 48 pub use messages::{ConversationRef, Messages};
@@ -16,6 +16,7 @@ pub mod presence;
16pub mod reactions;
16pub mod reactions;
17pub mod recap;
17pub mod recap;
18pub mod realtime;
18pub mod realtime;
19pub mod recording_policy;
19pub mod receipts;
20pub mod receipts;
20pub mod saved;
21pub mod saved;
21pub mod settings;
22pub mod settings;
@@ -41,6 +42,7 @@ pub use language_settings::{
41 LanguageSettings, LanguageSettingsClient, TranslationBehavior, authoring_patch, behavior_patch,
42 LanguageSettings, LanguageSettingsClient, TranslationBehavior, authoring_patch, behavior_patch,
42 parse_language_settings, target_patch,
43 parse_language_settings, target_patch,
43};
44};
45pub use recording_policy::{RecordingPolicy, parse_recording_policy};
44pub use links::{LinkImage, LinkInfo, MessageLinks, is_link_image_url};
46pub use links::{LinkImage, LinkInfo, MessageLinks, is_link_image_url};
45pub use mask::mask_conversation_id;
47pub use mask::mask_conversation_id;
46pub use messages::{ConversationRef, Messages};
48pub use messages::{ConversationRef, Messages};
crates/chatsvc/src/recording_policy.rs added +80 −0
@@ -0,0 +1,80 @@
1 use serde_json::{Value, json};
2
3 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4 pub struct RecordingPolicy {
5 pub meeting_recording: bool,
6 pub meeting_transcription: bool,
7 pub call_recording: bool,
8 pub call_transcription: bool,
9 }
10
11 impl Default for RecordingPolicy {
12 fn default() -> Self {
13 RecordingPolicy {
14 meeting_recording: true,
15 meeting_transcription: true,
16 call_recording: true,
17 call_transcription: true,
18 }
19 }
20 }
21
22 pub fn recording_policy_body() -> Value {
23 json!({"meetingPolicy": true, "callingPolicy": true})
24 }
25
26 pub fn parse_recording_policy(body: &Value) -> RecordingPolicy {
27 let flag = |pointer: &str| {
28 body.pointer(pointer)
29 .and_then(Value::as_bool)
30 .unwrap_or(true)
31 };
32 RecordingPolicy {
33 meeting_recording: flag("/meetingPolicy/value/allowCloudRecording"),
34 meeting_transcription: flag("/meetingPolicy/value/allowTranscription"),
35 call_recording: flag("/callingPolicy/value/allowCloudRecordingForCalls"),
36 call_transcription: flag("/callingPolicy/value/allowTranscriptionForCalling"),
37 }
38 }
39
40 #[cfg(test)]
41 mod tests {
42 use super::*;
43
44 #[test]
45 fn the_body_asks_for_both_policies() {
46 assert_eq!(
47 recording_policy_body(),
48 json!({"meetingPolicy": true, "callingPolicy": true})
49 );
50 }
51
52 #[test]
53 fn parses_the_meeting_and_calling_policy() {
54 let body = json!({
55 "meetingPolicy": {"value": {"allowCloudRecording": false, "allowTranscription": true}},
56 "callingPolicy": {"value": {"allowCloudRecordingForCalls": true, "allowTranscriptionForCalling": false}}
57 });
58 assert_eq!(
59 parse_recording_policy(&body),
60 RecordingPolicy {
61 meeting_recording: false,
62 meeting_transcription: true,
63 call_recording: true,
64 call_transcription: false,
65 }
66 );
67 }
68
69 #[test]
70 fn missing_fields_are_allowed() {
71 assert_eq!(
72 parse_recording_policy(&json!({})),
73 RecordingPolicy::default()
74 );
75 let partial = json!({"meetingPolicy": {"value": {"allowTranscription": false}}});
76 let policy = parse_recording_policy(&partial);
77 assert!(policy.meeting_recording && !policy.meeting_transcription);
78 assert!(policy.call_recording && policy.call_transcription);
79 }
80 }
@@ -0,0 +1,80 @@
1use serde_json::{Value, json};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub struct RecordingPolicy {
5 pub meeting_recording: bool,
6 pub meeting_transcription: bool,
7 pub call_recording: bool,
8 pub call_transcription: bool,
9}
10
11impl Default for RecordingPolicy {
12 fn default() -> Self {
13 RecordingPolicy {
14 meeting_recording: true,
15 meeting_transcription: true,
16 call_recording: true,
17 call_transcription: true,
18 }
19 }
20}
21
22pub fn recording_policy_body() -> Value {
23 json!({"meetingPolicy": true, "callingPolicy": true})
24}
25
26pub fn parse_recording_policy(body: &Value) -> RecordingPolicy {
27 let flag = |pointer: &str| {
28 body.pointer(pointer)
29 .and_then(Value::as_bool)
30 .unwrap_or(true)
31 };
32 RecordingPolicy {
33 meeting_recording: flag("/meetingPolicy/value/allowCloudRecording"),
34 meeting_transcription: flag("/meetingPolicy/value/allowTranscription"),
35 call_recording: flag("/callingPolicy/value/allowCloudRecordingForCalls"),
36 call_transcription: flag("/callingPolicy/value/allowTranscriptionForCalling"),
37 }
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn the_body_asks_for_both_policies() {
46 assert_eq!(
47 recording_policy_body(),
48 json!({"meetingPolicy": true, "callingPolicy": true})
49 );
50 }
51
52 #[test]
53 fn parses_the_meeting_and_calling_policy() {
54 let body = json!({
55 "meetingPolicy": {"value": {"allowCloudRecording": false, "allowTranscription": true}},
56 "callingPolicy": {"value": {"allowCloudRecordingForCalls": true, "allowTranscriptionForCalling": false}}
57 });
58 assert_eq!(
59 parse_recording_policy(&body),
60 RecordingPolicy {
61 meeting_recording: false,
62 meeting_transcription: true,
63 call_recording: true,
64 call_transcription: false,
65 }
66 );
67 }
68
69 #[test]
70 fn missing_fields_are_allowed() {
71 assert_eq!(
72 parse_recording_policy(&json!({})),
73 RecordingPolicy::default()
74 );
75 let partial = json!({"meetingPolicy": {"value": {"allowTranscription": false}}});
76 let policy = parse_recording_policy(&partial);
77 assert!(policy.meeting_recording && !policy.meeting_transcription);
78 assert!(policy.call_recording && policy.call_transcription);
79 }
80}
crates/core/src/lib.rs +2 −1
@@ -39,6 +39,7 @@ mod presence;
39 39 mod preview;
40 40 mod profile;
41 41 mod receipts;
42 mod recording_rights;
42 43 mod remote;
43 44 mod scheduled;
44 45 mod search;
@@ -87,7 +88,7 @@ pub use chatsvc::{
87 88 ForwardResult, Gif, PinnedMessage, PresenceStatus, SavedMessage, ScheduledDraft, StatusNote,
88 89 WindowDirection, WorkLocation, WorkLocationKind, WorkLocationSource,
89 90 };
90 pub use chatsvc::{ChatSection, ChatSectionSettings};
91 pub use chatsvc::{ChatSection, ChatSectionSettings, RecordingPolicy};
91 92 pub use chatsvc::{
92 93 Language, LanguageSettings, MessageLanguage, Translation, TranslationBehavior,
93 94 TranslationStatus, TranslationTrigger, authoring_patch, behavior_patch, language_code,
@@ -39,6 +39,7 @@ mod presence;
39mod preview;
39mod preview;
40mod profile;
40mod profile;
41mod receipts;
41mod receipts;
42mod recording_rights;
42mod remote;
43mod remote;
43mod scheduled;
44mod scheduled;
44mod search;
45mod search;
@@ -87,7 +88,7 @@ pub use chatsvc::{
87 ForwardResult, Gif, PinnedMessage, PresenceStatus, SavedMessage, ScheduledDraft, StatusNote,
88 ForwardResult, Gif, PinnedMessage, PresenceStatus, SavedMessage, ScheduledDraft, StatusNote,
88 WindowDirection, WorkLocation, WorkLocationKind, WorkLocationSource,
89 WindowDirection, WorkLocation, WorkLocationKind, WorkLocationSource,
89};
90};
90pub use chatsvc::{ChatSection, ChatSectionSettings};
91pub use chatsvc::{ChatSection, ChatSectionSettings, RecordingPolicy};
91pub use chatsvc::{
92pub use chatsvc::{
92 Language, LanguageSettings, MessageLanguage, Translation, TranslationBehavior,
93 Language, LanguageSettings, MessageLanguage, Translation, TranslationBehavior,
93 TranslationStatus, TranslationTrigger, authoring_patch, behavior_patch, language_code,
94 TranslationStatus, TranslationTrigger, authoring_patch, behavior_patch, language_code,
crates/core/src/recording_rights.rs added +15 −0
@@ -0,0 +1,15 @@
1 use chatsvc::RecordingPolicy;
2
3 use crate::engine::SyncEngine;
4 use crate::error::Result;
5 use crate::remote::Remote;
6
7 impl<R: Remote> SyncEngine<R> {
8 pub async fn recording_policy(&self) -> Result<RecordingPolicy> {
9 self.remote.recording_policy().await
10 }
11
12 pub async fn own_tenant_id(&self, chat_id: &str) -> Result<String> {
13 self.my_tenant_id(chat_id).await
14 }
15 }
@@ -0,0 +1,15 @@
1use chatsvc::RecordingPolicy;
2
3use crate::engine::SyncEngine;
4use crate::error::Result;
5use crate::remote::Remote;
6
7impl<R: Remote> SyncEngine<R> {
8 pub async fn recording_policy(&self) -> Result<RecordingPolicy> {
9 self.remote.recording_policy().await
10 }
11
12 pub async fn own_tenant_id(&self, chat_id: &str) -> Result<String> {
13 self.my_tenant_id(chat_id).await
14 }
15}
crates/core/src/remote.rs +11 −1
@@ -3,7 +3,7 @@ use chatsvc::{
3 3 ForcedAvailability, ForwardResult, Gif, Gifs, InvokeRequest, InvokeResponse, Language,
4 4 LanguageSettings, LanguageSettingsClient, LinkInfo, MemberHorizon, MessageLanguage,
5 5 MessageLinks, MessageWindow, Messages, PinnedMessage, Pins, PresenceService, PresenceStatus,
6 Receipts, SavedMessage, ScheduledDraft, ScheduledDrafts, StatusNote, TranslateRequest,
6 Receipts, RecordingPolicy, SavedMessage, ScheduledDraft, ScheduledDrafts, StatusNote, TranslateRequest,
7 7 Translation, TranslationTrigger, Translator, WindowDirection, WorkLocationKind,
8 8 };
9 9 use chrono::{DateTime, Utc};
@@ -401,6 +401,10 @@ pub trait Remote {
401 401 Err(Error::Unsupported("translation settings"))
402 402 }
403 403
404 async fn recording_policy(&self) -> Result<RecordingPolicy> {
405 Err(Error::Unsupported("recording policy"))
406 }
407
404 408 async fn search_gifs(&self, _query: &str) -> Result<Vec<Gif>> {
405 409 Err(Error::Unsupported("GIF search"))
406 410 }
@@ -1006,6 +1010,12 @@ impl Remote for Graph {
1006 1010 Ok(LanguageSettingsClient::new(self.session()).read().await?)
1007 1011 }
1008 1012
1013 async fn recording_policy(&self) -> Result<RecordingPolicy> {
1014 Ok(LanguageSettingsClient::new(self.session())
1015 .read_recording_policy()
1016 .await?)
1017 }
1018
1009 1019 async fn patch_language_settings(&self, patch: serde_json::Value) -> Result<()> {
1010 1020 Ok(LanguageSettingsClient::new(self.session())
1011 1021 .patch(patch)
@@ -3,7 +3,7 @@ use chatsvc::{
3 ForcedAvailability, ForwardResult, Gif, Gifs, InvokeRequest, InvokeResponse, Language,
3 ForcedAvailability, ForwardResult, Gif, Gifs, InvokeRequest, InvokeResponse, Language,
4 LanguageSettings, LanguageSettingsClient, LinkInfo, MemberHorizon, MessageLanguage,
4 LanguageSettings, LanguageSettingsClient, LinkInfo, MemberHorizon, MessageLanguage,
5 MessageLinks, MessageWindow, Messages, PinnedMessage, Pins, PresenceService, PresenceStatus,
5 MessageLinks, MessageWindow, Messages, PinnedMessage, Pins, PresenceService, PresenceStatus,
6 Receipts, SavedMessage, ScheduledDraft, ScheduledDrafts, StatusNote, TranslateRequest,
6 Receipts, RecordingPolicy, SavedMessage, ScheduledDraft, ScheduledDrafts, StatusNote, TranslateRequest,
7 Translation, TranslationTrigger, Translator, WindowDirection, WorkLocationKind,
7 Translation, TranslationTrigger, Translator, WindowDirection, WorkLocationKind,
8};
8};
9use chrono::{DateTime, Utc};
9use chrono::{DateTime, Utc};
@@ -401,6 +401,10 @@ pub trait Remote {
401 Err(Error::Unsupported("translation settings"))
401 Err(Error::Unsupported("translation settings"))
402 }
402 }
403
403
404 async fn recording_policy(&self) -> Result<RecordingPolicy> {
405 Err(Error::Unsupported("recording policy"))
406 }
407
404 async fn search_gifs(&self, _query: &str) -> Result<Vec<Gif>> {
408 async fn search_gifs(&self, _query: &str) -> Result<Vec<Gif>> {
405 Err(Error::Unsupported("GIF search"))
409 Err(Error::Unsupported("GIF search"))
406 }
410 }
@@ -1006,6 +1010,12 @@ impl Remote for Graph {
1006 Ok(LanguageSettingsClient::new(self.session()).read().await?)
1010 Ok(LanguageSettingsClient::new(self.session()).read().await?)
1007 }
1011 }
1008
1012
1013 async fn recording_policy(&self) -> Result<RecordingPolicy> {
1014 Ok(LanguageSettingsClient::new(self.session())
1015 .read_recording_policy()
1016 .await?)
1017 }
1018
1009 async fn patch_language_settings(&self, patch: serde_json::Value) -> Result<()> {
1019 async fn patch_language_settings(&self, patch: serde_json::Value) -> Result<()> {
1010 Ok(LanguageSettingsClient::new(self.session())
1020 Ok(LanguageSettingsClient::new(self.session())
1011 .patch(patch)
1021 .patch(patch)