BlueGit

ict rusty-teams

feat(channels): meeting and recording events in channels and chats like Teams

- Parse Graph callRecording (initial/chunkFinished/success) and callTranscript events next to call started/ended; keep participant names and the recording link, title and organizer
- Rows like Teams: one "X started recording" and "Recording stopped", meeting start stays after the end, transcript notice hidden
- Saved recording card: thumbnail via Graph shares (Files.ReadWrite.All), play button, duration, Transcript chip; click opens the meeting chat Recap tab at that occurrence, otherwise the recording in the browser
- Channel feed: Meet now root shows as meeting post (ended + duration + participant avatars, or started with Join while live), saved recordings stay visible as replies, other call notices only in the thread
- Migration 0021 refetches chats and channels; masked fixtures from real Graph data; demo channel meeting and recorded standup

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-17 · 6 weeks ago

Hash
6175a027093f3c4082da4732b100454157cf33c8
Parent
690046d5
23 files changed +2440 −134
crates/app-base/src/assets.rs +5 −1
@@ -8,7 +8,7 @@ macro_rules! symbols {
8 8 };
9 9 }
10 10
11 const SYMBOLS: [(&str, &[u8]); 46] = symbols![
11 const SYMBOLS: [(&str, &[u8]); 50] = symbols![
12 12 "done",
13 13 "done_all",
14 14 "keyboard_return",
@@ -55,6 +55,10 @@ const SYMBOLS: [(&str, &[u8]); 46] = symbols![
55 55 "call",
56 56 "call_missed",
57 57 "videocam",
58 "radio_button_checked",
59 "stop_circle",
60 "play_arrow",
61 "description",
58 62 ];
59 63
60 64 pub struct AppAssets;
@@ -8,7 +8,7 @@ macro_rules! symbols {
8 };
8 };
9}
9}
10
10
11const SYMBOLS: [(&str, &[u8]); 46] = symbols![
11const SYMBOLS: [(&str, &[u8]); 50] = symbols![
12 "done",
12 "done",
13 "done_all",
13 "done_all",
14 "keyboard_return",
14 "keyboard_return",
@@ -55,6 +55,10 @@ const SYMBOLS: [(&str, &[u8]); 46] = symbols![
55 "call",
55 "call",
56 "call_missed",
56 "call_missed",
57 "videocam",
57 "videocam",
58 "radio_button_checked",
59 "stop_circle",
60 "play_arrow",
61 "description",
58];
62];
59
63
60pub struct AppAssets;
64pub struct AppAssets;
crates/app-state/src/call_rows.rs added +417 −0
@@ -0,0 +1,417 @@
1 use std::collections::{HashMap, HashSet};
2
3 use teams_core::{CallEvent, CallPhase, CallType, ImageRef, format_duration};
4
5 const MAX_AVATARS: usize = 4;
6 const RECORDING_FALLBACK_TITLE: &str = "Meeting recording";
7
8 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9 pub enum CallIcon {
10 Call,
11 Missed,
12 Video,
13 Record,
14 RecordStop,
15 }
16
17 #[derive(Debug, Clone, PartialEq, Eq)]
18 pub struct CallParticipant {
19 pub user_id: String,
20 pub name: String,
21 }
22
23 #[derive(Debug, Clone, PartialEq, Eq)]
24 pub struct RecordingCard {
25 pub message_id: String,
26 pub title: String,
27 pub duration: Option<String>,
28 pub url: Option<String>,
29 pub thumbnail: Option<ImageRef>,
30 pub transcript: bool,
31 }
32
33 #[derive(Debug, Clone, PartialEq, Eq)]
34 pub struct CallCard {
35 pub title: String,
36 pub detail: String,
37 pub icon: CallIcon,
38 pub missed: bool,
39 pub started: bool,
40 pub participants: Vec<CallParticipant>,
41 pub extra_participants: usize,
42 pub recording: Option<RecordingCard>,
43 }
44
45 pub struct CallNames<'a> {
46 pub my_user_id: Option<&'a str>,
47 pub names: &'a HashMap<String, String>,
48 }
49
50 impl CallNames<'_> {
51 fn name(&self, user_id: Option<&str>, given: Option<&str>) -> Option<String> {
52 given
53 .filter(|name| !name.is_empty())
54 .map(str::to_owned)
55 .or_else(|| self.names.get(user_id?).cloned())
56 }
57 }
58
59 /// Which call events of a timeline show as rows: Teams keeps one row per recording start and stop,
60 /// hides transcript notices and, for calls (not meetings), the start once the call ended.
61 pub struct CallTimeline {
62 hidden: Vec<bool>,
63 finished: HashSet<String>,
64 transcripts: HashSet<String>,
65 newest_open_start: Option<usize>,
66 }
67
68 impl CallTimeline {
69 pub fn new(events: &[Option<CallEvent>]) -> Self {
70 let finished: HashSet<String> = events
71 .iter()
72 .flatten()
73 .filter(|event| event.phase == CallPhase::Ended)
74 .map(|event| event.call_id.clone())
75 .collect();
76 let transcripts: HashSet<String> = events
77 .iter()
78 .flatten()
79 .filter(|event| event.phase == CallPhase::TranscriptStarted)
80 .map(|event| event.call_id.clone())
81 .collect();
82 let mut shown_once: HashSet<(String, CallPhase)> = HashSet::new();
83 let hidden = events
84 .iter()
85 .map(|event| {
86 let Some(event) = event else {
87 return false;
88 };
89 match event.phase {
90 CallPhase::TranscriptStarted => true,
91 CallPhase::RecordingStarted | CallPhase::RecordingStopped => {
92 !shown_once.insert((event.call_id.clone(), event.phase))
93 }
94 CallPhase::Started => {
95 event.call_type == CallType::Call && finished.contains(&event.call_id)
96 }
97 _ => false,
98 }
99 })
100 .collect();
101 let newest_open_start = events.iter().rposition(|event| {
102 event.as_ref().is_some_and(|event| {
103 event.phase == CallPhase::Started && !finished.contains(&event.call_id)
104 })
105 });
106 CallTimeline {
107 hidden,
108 finished,
109 transcripts,
110 newest_open_start,
111 }
112 }
113
114 pub fn hides(&self, index: usize) -> bool {
115 self.hidden.get(index).copied().unwrap_or(false)
116 }
117
118 pub fn is_live_start(&self, index: usize) -> bool {
119 self.newest_open_start == Some(index)
120 }
121
122 pub fn finished(&self, call_id: &str) -> bool {
123 self.finished.contains(call_id)
124 }
125
126 pub fn has_transcript(&self, call_id: &str) -> bool {
127 self.transcripts.contains(call_id)
128 }
129 }
130
131 fn participants(event: &CallEvent, names: &CallNames) -> Vec<CallParticipant> {
132 event
133 .participant_ids
134 .iter()
135 .enumerate()
136 .filter_map(|(index, user_id)| {
137 let given = event.participant_names.get(index).map(String::as_str);
138 Some(CallParticipant {
139 user_id: user_id.clone(),
140 name: names.name(Some(user_id), given)?,
141 })
142 })
143 .collect()
144 }
145
146 fn recording_card(event: &CallEvent, message_id: &str, transcript: bool) -> Option<RecordingCard> {
147 let recording = event.recording.as_ref()?;
148 Some(RecordingCard {
149 message_id: message_id.to_owned(),
150 title: recording
151 .title()
152 .unwrap_or_else(|| RECORDING_FALLBACK_TITLE.to_owned()),
153 duration: event
154 .duration_seconds
155 .filter(|seconds| *seconds > 0)
156 .map(format_duration),
157 url: recording.url.clone(),
158 thumbnail: recording.thumbnail_url().map(|url| ImageRef {
159 id: format!("recording-{message_id}"),
160 url,
161 width: None,
162 height: None,
163 alt: None,
164 }),
165 transcript,
166 })
167 }
168
169 fn title(event: &CallEvent, missed: bool, names: &CallNames) -> String {
170 match event.phase {
171 CallPhase::RecordingStarted => {
172 match names.name(
173 event.initiator_id.as_deref(),
174 event.initiator_name.as_deref(),
175 ) {
176 Some(name) => format!("{name} started recording"),
177 None => event.title(false).to_owned(),
178 }
179 }
180 CallPhase::RecordingSaved => {
181 let organizer_id = event
182 .recording
183 .as_ref()
184 .and_then(|recording| recording.organizer_id.as_deref());
185 if organizer_id.is_some() && organizer_id == names.my_user_id {
186 return "Recording has been saved to your OneDrive".to_owned();
187 }
188 match names.name(organizer_id, None) {
189 Some(owner) => format!("Recording has been saved to {owner}'s OneDrive"),
190 None => "Recording has been saved to OneDrive".to_owned(),
191 }
192 }
193 _ => event.title(missed).to_owned(),
194 }
195 }
196
197 pub fn call_card(
198 event: &CallEvent,
199 message_id: &str,
200 time: &str,
201 names: &CallNames,
202 transcript: bool,
203 ) -> CallCard {
204 let missed = event.missed(names.my_user_id);
205 let detail = match (event.phase, event.duration_seconds) {
206 (CallPhase::Ended, Some(seconds)) if !missed => {
207 format!("{} \u{b7} {time}", format_duration(seconds))
208 }
209 _ => time.to_owned(),
210 };
211 let mut people = if event.phase == CallPhase::Ended && event.call_type == CallType::Meeting {
212 participants(event, names)
213 } else {
214 Vec::new()
215 };
216 let extra_participants = people.len().saturating_sub(MAX_AVATARS);
217 people.truncate(MAX_AVATARS);
218 CallCard {
219 title: title(event, missed, names),
220 detail,
221 icon: match (missed, event.phase, event.call_type) {
222 (true, _, _) => CallIcon::Missed,
223 (false, CallPhase::RecordingStarted | CallPhase::RecordingSaved, _) => CallIcon::Record,
224 (false, CallPhase::RecordingStopped | CallPhase::TranscriptStarted, _) => {
225 CallIcon::RecordStop
226 }
227 (false, _, CallType::Meeting) => CallIcon::Video,
228 (false, _, CallType::Call) => CallIcon::Call,
229 },
230 missed,
231 started: event.phase == CallPhase::Started,
232 participants: people,
233 extra_participants,
234 recording: (event.phase == CallPhase::RecordingSaved)
235 .then(|| recording_card(event, message_id, transcript))
236 .flatten(),
237 }
238 }
239
240 #[cfg(test)]
241 mod tests {
242 use teams_core::Recording;
243
244 use super::*;
245
246 fn event(phase: CallPhase, call_type: CallType, call_id: &str) -> CallEvent {
247 CallEvent {
248 phase,
249 call_type,
250 call_id: call_id.to_owned(),
251 duration_seconds: None,
252 initiator_id: Some("organizer".to_owned()),
253 initiator_name: None,
254 participant_ids: Vec::new(),
255 participant_names: Vec::new(),
256 recording: None,
257 }
258 }
259
260 fn fixture_events() -> Vec<Option<CallEvent>> {
261 let path = format!(
262 "{}/../core/tests/fixtures/call_events/meeting_chat_recording.json",
263 env!("CARGO_MANIFEST_DIR")
264 );
265 let page: serde_json::Value =
266 serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap();
267 page["value"]
268 .as_array()
269 .unwrap()
270 .iter()
271 .rev()
272 .map(|message| CallEvent::from_graph(&message["eventDetail"]))
273 .collect()
274 }
275
276 fn names() -> HashMap<String, String> {
277 HashMap::from([
278 (
279 "00000000-0000-4000-8000-000000000002".to_owned(),
280 "Vera Organizer".to_owned(),
281 ),
282 (
283 "00000000-0000-4000-8000-000000000004".to_owned(),
284 "Sam Recorder".to_owned(),
285 ),
286 ])
287 }
288
289 #[test]
290 fn recorded_meeting_shows_like_teams() {
291 let events = fixture_events();
292 let timeline = CallTimeline::new(&events);
293 let names = names();
294 let lookup = CallNames {
295 my_user_id: Some("me"),
296 names: &names,
297 };
298 let titles: Vec<String> = events
299 .iter()
300 .enumerate()
301 .filter(|(index, _)| !timeline.hides(*index))
302 .map(|(_, event)| {
303 let event = event.as_ref().unwrap();
304 call_card(
305 event,
306 "m",
307 "16:15",
308 &lookup,
309 timeline.has_transcript(&event.call_id),
310 )
311 .title
312 })
313 .collect();
314 assert_eq!(
315 titles,
316 [
317 "Meeting started",
318 "Sam Recorder started recording",
319 "Recording stopped",
320 "Meeting ended",
321 "Recording has been saved to Vera Organizer's OneDrive",
322 ]
323 );
324 }
325
326 #[test]
327 fn saved_recording_becomes_a_card_with_transcript_and_thumbnail() {
328 let events = fixture_events();
329 let timeline = CallTimeline::new(&events);
330 let saved = events.last().unwrap().as_ref().unwrap();
331 let names = HashMap::new();
332 let lookup = CallNames {
333 my_user_id: None,
334 names: &names,
335 };
336 let card = call_card(
337 saved,
338 "saved-1",
339 "16:16",
340 &lookup,
341 timeline.has_transcript(&saved.call_id),
342 );
343 assert_eq!(card.title, "Recording has been saved to OneDrive");
344 assert_eq!(card.icon, CallIcon::Record);
345 let recording = card.recording.unwrap();
346 assert_eq!(recording.title, "Weekly team meeting");
347 assert_eq!(recording.duration.as_deref(), Some("13m 34s"));
348 assert!(recording.transcript);
349 assert_eq!(recording.message_id, "saved-1");
350 assert!(recording.thumbnail.unwrap().url.contains("/thumbnails/"));
351 }
352
353 #[test]
354 fn ended_meeting_lists_named_participants_up_to_four() {
355 let events = fixture_events();
356 let ended = events
357 .iter()
358 .flatten()
359 .find(|event| event.phase == CallPhase::Ended)
360 .unwrap();
361 let names = HashMap::new();
362 let lookup = CallNames {
363 my_user_id: None,
364 names: &names,
365 };
366 let card = call_card(ended, "m", "16:15", &lookup, false);
367 assert_eq!(card.detail, "16m 28s \u{b7} 16:15");
368 assert_eq!(card.icon, CallIcon::Video);
369 let shown: Vec<&str> = card
370 .participants
371 .iter()
372 .map(|person| person.name.as_str())
373 .collect();
374 assert_eq!(shown, ["Person 1", "Person 2", "Person 3", "Person 4"]);
375 assert_eq!(card.extra_participants, 20);
376 }
377
378 #[test]
379 fn meeting_start_stays_but_a_finished_call_start_hides() {
380 let events = vec![
381 Some(event(CallPhase::Started, CallType::Meeting, "meeting")),
382 Some(event(CallPhase::Ended, CallType::Meeting, "meeting")),
383 Some(event(CallPhase::Started, CallType::Call, "call")),
384 Some(event(CallPhase::Ended, CallType::Call, "call")),
385 Some(event(CallPhase::Started, CallType::Meeting, "live")),
386 None,
387 ];
388 let timeline = CallTimeline::new(&events);
389 assert!(!timeline.hides(0));
390 assert!(timeline.hides(2));
391 assert!(!timeline.hides(5));
392 assert!(timeline.is_live_start(4));
393 assert!(!timeline.is_live_start(0));
394 assert!(timeline.finished("meeting"));
395 }
396
397 #[test]
398 fn my_own_recording_is_saved_to_my_onedrive() {
399 let mut saved = event(CallPhase::RecordingSaved, CallType::Meeting, "c");
400 saved.recording = Some(Recording {
401 name: None,
402 url: Some("https://contoso.example/rec.mp4".to_owned()),
403 organizer_id: Some("me".to_owned()),
404 });
405 let names = HashMap::new();
406 let lookup = CallNames {
407 my_user_id: Some("me"),
408 names: &names,
409 };
410 let card = call_card(&saved, "m", "9:00", &lookup, false);
411 assert_eq!(card.title, "Recording has been saved to your OneDrive");
412 let recording = card.recording.unwrap();
413 assert_eq!(recording.title, "Meeting recording");
414 assert_eq!(recording.thumbnail, None);
415 assert_eq!(recording.duration, None);
416 }
417 }
@@ -0,0 +1,417 @@
1use std::collections::{HashMap, HashSet};
2
3use teams_core::{CallEvent, CallPhase, CallType, ImageRef, format_duration};
4
5const MAX_AVATARS: usize = 4;
6const RECORDING_FALLBACK_TITLE: &str = "Meeting recording";
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum CallIcon {
10 Call,
11 Missed,
12 Video,
13 Record,
14 RecordStop,
15}
16
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct CallParticipant {
19 pub user_id: String,
20 pub name: String,
21}
22
23#[derive(Debug, Clone, PartialEq, Eq)]
24pub struct RecordingCard {
25 pub message_id: String,
26 pub title: String,
27 pub duration: Option<String>,
28 pub url: Option<String>,
29 pub thumbnail: Option<ImageRef>,
30 pub transcript: bool,
31}
32
33#[derive(Debug, Clone, PartialEq, Eq)]
34pub struct CallCard {
35 pub title: String,
36 pub detail: String,
37 pub icon: CallIcon,
38 pub missed: bool,
39 pub started: bool,
40 pub participants: Vec<CallParticipant>,
41 pub extra_participants: usize,
42 pub recording: Option<RecordingCard>,
43}
44
45pub struct CallNames<'a> {
46 pub my_user_id: Option<&'a str>,
47 pub names: &'a HashMap<String, String>,
48}
49
50impl CallNames<'_> {
51 fn name(&self, user_id: Option<&str>, given: Option<&str>) -> Option<String> {
52 given
53 .filter(|name| !name.is_empty())
54 .map(str::to_owned)
55 .or_else(|| self.names.get(user_id?).cloned())
56 }
57}
58
59/// Which call events of a timeline show as rows: Teams keeps one row per recording start and stop,
60/// hides transcript notices and, for calls (not meetings), the start once the call ended.
61pub struct CallTimeline {
62 hidden: Vec<bool>,
63 finished: HashSet<String>,
64 transcripts: HashSet<String>,
65 newest_open_start: Option<usize>,
66}
67
68impl CallTimeline {
69 pub fn new(events: &[Option<CallEvent>]) -> Self {
70 let finished: HashSet<String> = events
71 .iter()
72 .flatten()
73 .filter(|event| event.phase == CallPhase::Ended)
74 .map(|event| event.call_id.clone())
75 .collect();
76 let transcripts: HashSet<String> = events
77 .iter()
78 .flatten()
79 .filter(|event| event.phase == CallPhase::TranscriptStarted)
80 .map(|event| event.call_id.clone())
81 .collect();
82 let mut shown_once: HashSet<(String, CallPhase)> = HashSet::new();
83 let hidden = events
84 .iter()
85 .map(|event| {
86 let Some(event) = event else {
87 return false;
88 };
89 match event.phase {
90 CallPhase::TranscriptStarted => true,
91 CallPhase::RecordingStarted | CallPhase::RecordingStopped => {
92 !shown_once.insert((event.call_id.clone(), event.phase))
93 }
94 CallPhase::Started => {
95 event.call_type == CallType::Call && finished.contains(&event.call_id)
96 }
97 _ => false,
98 }
99 })
100 .collect();
101 let newest_open_start = events.iter().rposition(|event| {
102 event.as_ref().is_some_and(|event| {
103 event.phase == CallPhase::Started && !finished.contains(&event.call_id)
104 })
105 });
106 CallTimeline {
107 hidden,
108 finished,
109 transcripts,
110 newest_open_start,
111 }
112 }
113
114 pub fn hides(&self, index: usize) -> bool {
115 self.hidden.get(index).copied().unwrap_or(false)
116 }
117
118 pub fn is_live_start(&self, index: usize) -> bool {
119 self.newest_open_start == Some(index)
120 }
121
122 pub fn finished(&self, call_id: &str) -> bool {
123 self.finished.contains(call_id)
124 }
125
126 pub fn has_transcript(&self, call_id: &str) -> bool {
127 self.transcripts.contains(call_id)
128 }
129}
130
131fn participants(event: &CallEvent, names: &CallNames) -> Vec<CallParticipant> {
132 event
133 .participant_ids
134 .iter()
135 .enumerate()
136 .filter_map(|(index, user_id)| {
137 let given = event.participant_names.get(index).map(String::as_str);
138 Some(CallParticipant {
139 user_id: user_id.clone(),
140 name: names.name(Some(user_id), given)?,
141 })
142 })
143 .collect()
144}
145
146fn recording_card(event: &CallEvent, message_id: &str, transcript: bool) -> Option<RecordingCard> {
147 let recording = event.recording.as_ref()?;
148 Some(RecordingCard {
149 message_id: message_id.to_owned(),
150 title: recording
151 .title()
152 .unwrap_or_else(|| RECORDING_FALLBACK_TITLE.to_owned()),
153 duration: event
154 .duration_seconds
155 .filter(|seconds| *seconds > 0)
156 .map(format_duration),
157 url: recording.url.clone(),
158 thumbnail: recording.thumbnail_url().map(|url| ImageRef {
159 id: format!("recording-{message_id}"),
160 url,
161 width: None,
162 height: None,
163 alt: None,
164 }),
165 transcript,
166 })
167}
168
169fn title(event: &CallEvent, missed: bool, names: &CallNames) -> String {
170 match event.phase {
171 CallPhase::RecordingStarted => {
172 match names.name(
173 event.initiator_id.as_deref(),
174 event.initiator_name.as_deref(),
175 ) {
176 Some(name) => format!("{name} started recording"),
177 None => event.title(false).to_owned(),
178 }
179 }
180 CallPhase::RecordingSaved => {
181 let organizer_id = event
182 .recording
183 .as_ref()
184 .and_then(|recording| recording.organizer_id.as_deref());
185 if organizer_id.is_some() && organizer_id == names.my_user_id {
186 return "Recording has been saved to your OneDrive".to_owned();
187 }
188 match names.name(organizer_id, None) {
189 Some(owner) => format!("Recording has been saved to {owner}'s OneDrive"),
190 None => "Recording has been saved to OneDrive".to_owned(),
191 }
192 }
193 _ => event.title(missed).to_owned(),
194 }
195}
196
197pub fn call_card(
198 event: &CallEvent,
199 message_id: &str,
200 time: &str,
201 names: &CallNames,
202 transcript: bool,
203) -> CallCard {
204 let missed = event.missed(names.my_user_id);
205 let detail = match (event.phase, event.duration_seconds) {
206 (CallPhase::Ended, Some(seconds)) if !missed => {
207 format!("{} \u{b7} {time}", format_duration(seconds))
208 }
209 _ => time.to_owned(),
210 };
211 let mut people = if event.phase == CallPhase::Ended && event.call_type == CallType::Meeting {
212 participants(event, names)
213 } else {
214 Vec::new()
215 };
216 let extra_participants = people.len().saturating_sub(MAX_AVATARS);
217 people.truncate(MAX_AVATARS);
218 CallCard {
219 title: title(event, missed, names),
220 detail,
221 icon: match (missed, event.phase, event.call_type) {
222 (true, _, _) => CallIcon::Missed,
223 (false, CallPhase::RecordingStarted | CallPhase::RecordingSaved, _) => CallIcon::Record,
224 (false, CallPhase::RecordingStopped | CallPhase::TranscriptStarted, _) => {
225 CallIcon::RecordStop
226 }
227 (false, _, CallType::Meeting) => CallIcon::Video,
228 (false, _, CallType::Call) => CallIcon::Call,
229 },
230 missed,
231 started: event.phase == CallPhase::Started,
232 participants: people,
233 extra_participants,
234 recording: (event.phase == CallPhase::RecordingSaved)
235 .then(|| recording_card(event, message_id, transcript))
236 .flatten(),
237 }
238}
239
240#[cfg(test)]
241mod tests {
242 use teams_core::Recording;
243
244 use super::*;
245
246 fn event(phase: CallPhase, call_type: CallType, call_id: &str) -> CallEvent {
247 CallEvent {
248 phase,
249 call_type,
250 call_id: call_id.to_owned(),
251 duration_seconds: None,
252 initiator_id: Some("organizer".to_owned()),
253 initiator_name: None,
254 participant_ids: Vec::new(),
255 participant_names: Vec::new(),
256 recording: None,
257 }
258 }
259
260 fn fixture_events() -> Vec<Option<CallEvent>> {
261 let path = format!(
262 "{}/../core/tests/fixtures/call_events/meeting_chat_recording.json",
263 env!("CARGO_MANIFEST_DIR")
264 );
265 let page: serde_json::Value =
266 serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap();
267 page["value"]
268 .as_array()
269 .unwrap()
270 .iter()
271 .rev()
272 .map(|message| CallEvent::from_graph(&message["eventDetail"]))
273 .collect()
274 }
275
276 fn names() -> HashMap<String, String> {
277 HashMap::from([
278 (
279 "00000000-0000-4000-8000-000000000002".to_owned(),
280 "Vera Organizer".to_owned(),
281 ),
282 (
283 "00000000-0000-4000-8000-000000000004".to_owned(),
284 "Sam Recorder".to_owned(),
285 ),
286 ])
287 }
288
289 #[test]
290 fn recorded_meeting_shows_like_teams() {
291 let events = fixture_events();
292 let timeline = CallTimeline::new(&events);
293 let names = names();
294 let lookup = CallNames {
295 my_user_id: Some("me"),
296 names: &names,
297 };
298 let titles: Vec<String> = events
299 .iter()
300 .enumerate()
301 .filter(|(index, _)| !timeline.hides(*index))
302 .map(|(_, event)| {
303 let event = event.as_ref().unwrap();
304 call_card(
305 event,
306 "m",
307 "16:15",
308 &lookup,
309 timeline.has_transcript(&event.call_id),
310 )
311 .title
312 })
313 .collect();
314 assert_eq!(
315 titles,
316 [
317 "Meeting started",
318 "Sam Recorder started recording",
319 "Recording stopped",
320 "Meeting ended",
321 "Recording has been saved to Vera Organizer's OneDrive",
322 ]
323 );
324 }
325
326 #[test]
327 fn saved_recording_becomes_a_card_with_transcript_and_thumbnail() {
328 let events = fixture_events();
329 let timeline = CallTimeline::new(&events);
330 let saved = events.last().unwrap().as_ref().unwrap();
331 let names = HashMap::new();
332 let lookup = CallNames {
333 my_user_id: None,
334 names: &names,
335 };
336 let card = call_card(
337 saved,
338 "saved-1",
339 "16:16",
340 &lookup,
341 timeline.has_transcript(&saved.call_id),
342 );
343 assert_eq!(card.title, "Recording has been saved to OneDrive");
344 assert_eq!(card.icon, CallIcon::Record);
345 let recording = card.recording.unwrap();
346 assert_eq!(recording.title, "Weekly team meeting");
347 assert_eq!(recording.duration.as_deref(), Some("13m 34s"));
348 assert!(recording.transcript);
349 assert_eq!(recording.message_id, "saved-1");
350 assert!(recording.thumbnail.unwrap().url.contains("/thumbnails/"));
351 }
352
353 #[test]
354 fn ended_meeting_lists_named_participants_up_to_four() {
355 let events = fixture_events();
356 let ended = events
357 .iter()
358 .flatten()
359 .find(|event| event.phase == CallPhase::Ended)
360 .unwrap();
361 let names = HashMap::new();
362 let lookup = CallNames {
363 my_user_id: None,
364 names: &names,
365 };
366 let card = call_card(ended, "m", "16:15", &lookup, false);
367 assert_eq!(card.detail, "16m 28s \u{b7} 16:15");
368 assert_eq!(card.icon, CallIcon::Video);
369 let shown: Vec<&str> = card
370 .participants
371 .iter()
372 .map(|person| person.name.as_str())
373 .collect();
374 assert_eq!(shown, ["Person 1", "Person 2", "Person 3", "Person 4"]);
375 assert_eq!(card.extra_participants, 20);
376 }
377
378 #[test]
379 fn meeting_start_stays_but_a_finished_call_start_hides() {
380 let events = vec![
381 Some(event(CallPhase::Started, CallType::Meeting, "meeting")),
382 Some(event(CallPhase::Ended, CallType::Meeting, "meeting")),
383 Some(event(CallPhase::Started, CallType::Call, "call")),
384 Some(event(CallPhase::Ended, CallType::Call, "call")),
385 Some(event(CallPhase::Started, CallType::Meeting, "live")),
386 None,
387 ];
388 let timeline = CallTimeline::new(&events);
389 assert!(!timeline.hides(0));
390 assert!(timeline.hides(2));
391 assert!(!timeline.hides(5));
392 assert!(timeline.is_live_start(4));
393 assert!(!timeline.is_live_start(0));
394 assert!(timeline.finished("meeting"));
395 }
396
397 #[test]
398 fn my_own_recording_is_saved_to_my_onedrive() {
399 let mut saved = event(CallPhase::RecordingSaved, CallType::Meeting, "c");
400 saved.recording = Some(Recording {
401 name: None,
402 url: Some("https://contoso.example/rec.mp4".to_owned()),
403 organizer_id: Some("me".to_owned()),
404 });
405 let names = HashMap::new();
406 let lookup = CallNames {
407 my_user_id: Some("me"),
408 names: &names,
409 };
410 let card = call_card(&saved, "m", "9:00", &lookup, false);
411 assert_eq!(card.title, "Recording has been saved to your OneDrive");
412 let recording = card.recording.unwrap();
413 assert_eq!(recording.title, "Meeting recording");
414 assert_eq!(recording.thumbnail, None);
415 assert_eq!(recording.duration, None);
416 }
417}
crates/app-state/src/demo.rs +3 −0
@@ -785,6 +785,7 @@ pub fn seed(store: &Store) {
785 785 let _ = store.upsert_messages(&meeting_link_messages());
786 786 let _ = store.upsert_messages(&standup_messages());
787 787 let _ = store.upsert_messages(&call_messages());
788 let _ = store.upsert_messages(&crate::demo_meetings::meeting_messages());
788 789 let _ = store.upsert_messages(&bot_messages());
789 790 seed_agent_access(store);
790 791 }
@@ -1068,6 +1069,8 @@ fn call_event(
1068 1069 initiator_id: Some(initiator.0.to_owned()),
1069 1070 initiator_name: Some(initiator.1.to_owned()),
1070 1071 participant_ids: participant_ids.iter().map(|id| (*id).to_owned()).collect(),
1072 participant_names: Vec::new(),
1073 recording: None,
1071 1074 }
1072 1075 }
1073 1076
@@ -785,6 +785,7 @@ pub fn seed(store: &Store) {
785 let _ = store.upsert_messages(&meeting_link_messages());
785 let _ = store.upsert_messages(&meeting_link_messages());
786 let _ = store.upsert_messages(&standup_messages());
786 let _ = store.upsert_messages(&standup_messages());
787 let _ = store.upsert_messages(&call_messages());
787 let _ = store.upsert_messages(&call_messages());
788 let _ = store.upsert_messages(&crate::demo_meetings::meeting_messages());
788 let _ = store.upsert_messages(&bot_messages());
789 let _ = store.upsert_messages(&bot_messages());
789 seed_agent_access(store);
790 seed_agent_access(store);
790}
791}
@@ -1068,6 +1069,8 @@ fn call_event(
1068 initiator_id: Some(initiator.0.to_owned()),
1069 initiator_id: Some(initiator.0.to_owned()),
1069 initiator_name: Some(initiator.1.to_owned()),
1070 initiator_name: Some(initiator.1.to_owned()),
1070 participant_ids: participant_ids.iter().map(|id| (*id).to_owned()).collect(),
1071 participant_ids: participant_ids.iter().map(|id| (*id).to_owned()).collect(),
1072 participant_names: Vec::new(),
1073 recording: None,
1071 }
1074 }
1072}
1075}
1073
1076
crates/app-state/src/demo_meetings.rs added +228 −0
@@ -0,0 +1,228 @@
1 use chrono::{DateTime, Duration, Utc};
2 use store::MessageRecord;
3 use teams_core::{CallEvent, CallPhase, CallType, Recording};
4
5 use crate::demo::{DEMO_USER_ID, JONAS_ID, LEA_ID, MARA_ID, PRIYA_ID, TOBIAS_ID, at};
6 use crate::demo_recap::DEMO_RECAP_CHAT;
7
8 const CHANNEL: &str = "demo-channel-1-1";
9 const CHANNEL_CALL: &str = "demo-channel-meeting";
10 const CHANNEL_ROOT: &str = "meet-1";
11 const STANDUP_CALL: &str = "demo-standup-recorded";
12 const DEMO_RECORDING_URL: &str = "https://demo.sharepoint.example/personal/demo/Recordings";
13
14 fn event(phase: CallPhase, call_id: &str, initiator: &str, seconds: Option<u64>) -> CallEvent {
15 CallEvent {
16 phase,
17 call_type: CallType::Meeting,
18 call_id: call_id.to_owned(),
19 duration_seconds: seconds,
20 initiator_id: Some(initiator.to_owned()),
21 initiator_name: None,
22 participant_ids: Vec::new(),
23 participant_names: Vec::new(),
24 recording: None,
25 }
26 }
27
28 fn recording(mut event: CallEvent, name: &str, url: Option<&str>, organizer: &str) -> CallEvent {
29 event.recording = Some(Recording {
30 name: Some(name.to_owned()),
31 url: url.map(str::to_owned),
32 organizer_id: Some(organizer.to_owned()),
33 });
34 event
35 }
36
37 fn ended(call_id: &str, initiator: &str, seconds: u64, people: &[(&str, &str)]) -> CallEvent {
38 CallEvent {
39 participant_ids: people.iter().map(|(id, _)| (*id).to_owned()).collect(),
40 participant_names: people.iter().map(|(_, name)| (*name).to_owned()).collect(),
41 ..event(CallPhase::Ended, call_id, initiator, Some(seconds))
42 }
43 }
44
45 fn record(
46 conversation: &str,
47 id: &str,
48 reply_to: Option<&str>,
49 time: DateTime<Utc>,
50 event: CallEvent,
51 ) -> MessageRecord {
52 MessageRecord {
53 conversation_id: conversation.to_owned(),
54 message_id: id.to_owned(),
55 reply_to_id: reply_to.map(str::to_owned),
56 created_at: time,
57 links_json: "[]".to_owned(),
58 attachments_json: "[]".to_owned(),
59 reactions_json: "[]".to_owned(),
60 mentions_json: "[]".to_owned(),
61 call_event_json: Some(event.to_json()),
62 ..MessageRecord::default()
63 }
64 }
65
66 fn reply(id: &str, sender: (&str, &str), time: DateTime<Utc>, html: &str) -> MessageRecord {
67 MessageRecord {
68 conversation_id: CHANNEL.to_owned(),
69 message_id: id.to_owned(),
70 reply_to_id: Some(CHANNEL_ROOT.to_owned()),
71 sender_id: Some(sender.0.to_owned()),
72 sender_name: Some(sender.1.to_owned()),
73 created_at: time,
74 body_html: html.to_owned(),
75 links_json: "[]".to_owned(),
76 attachments_json: "[]".to_owned(),
77 reactions_json: "[]".to_owned(),
78 mentions_json: "[]".to_owned(),
79 ..MessageRecord::default()
80 }
81 }
82
83 fn channel_meeting() -> Vec<MessageRecord> {
84 let start = at(0, 10, 30);
85 let minutes = |count: i64| start + Duration::minutes(count);
86 let name = "Design review-20261017_103200-Meeting Recording.mp4";
87 let url = format!("{DEMO_RECORDING_URL}/design-review.mp4");
88 let people = [
89 (MARA_ID, "Mara Lindqvist"),
90 (JONAS_ID, "Jonas Ortega"),
91 (PRIYA_ID, "Priya Nair"),
92 (DEMO_USER_ID, "Dana Demo"),
93 (TOBIAS_ID, "Tobias Klein"),
94 (LEA_ID, "Lea Schneider"),
95 ];
96 let thread = |id: &str, offset: i64, event: CallEvent| {
97 record(CHANNEL, id, Some(CHANNEL_ROOT), minutes(offset), event)
98 };
99 vec![
100 record(
101 CHANNEL,
102 CHANNEL_ROOT,
103 None,
104 start,
105 event(CallPhase::Started, CHANNEL_CALL, MARA_ID, None),
106 ),
107 thread(
108 "meet-1-rec",
109 2,
110 recording(
111 event(CallPhase::RecordingStarted, CHANNEL_CALL, MARA_ID, Some(0)),
112 name,
113 None,
114 MARA_ID,
115 ),
116 ),
117 thread(
118 "meet-1-transcript",
119 2,
120 event(CallPhase::TranscriptStarted, CHANNEL_CALL, MARA_ID, None),
121 ),
122 thread(
123 "meet-1-stop",
124 34,
125 recording(
126 event(
127 CallPhase::RecordingStopped,
128 CHANNEL_CALL,
129 MARA_ID,
130 Some(1914),
131 ),
132 name,
133 None,
134 MARA_ID,
135 ),
136 ),
137 thread(
138 "meet-1-end",
139 35,
140 ended(CHANNEL_CALL, MARA_ID, 2100, &people),
141 ),
142 thread(
143 "meet-1-saved",
144 36,
145 recording(
146 event(CallPhase::RecordingSaved, CHANNEL_CALL, MARA_ID, Some(1914)),
147 name,
148 Some(&url),
149 MARA_ID,
150 ),
151 ),
152 reply(
153 "meet-1-r1",
154 (JONAS_ID, "Jonas Ortega"),
155 minutes(41),
156 "<p>Thanks, the recording covers the open questions for Priya.</p>",
157 ),
158 ]
159 }
160
161 fn recorded_standup() -> Vec<MessageRecord> {
162 let start = at(1, 9, 0);
163 let minutes = |count: i64| start + Duration::minutes(count);
164 let name = "Daily standup-1-Meeting Recording.mp4";
165 let url = format!("{DEMO_RECORDING_URL}/standup-1.mp4");
166 let people = [
167 (JONAS_ID, "Jonas Ortega"),
168 (DEMO_USER_ID, "Dana Demo"),
169 (MARA_ID, "Mara Lindqvist"),
170 ];
171 let line = |id: &str, offset: i64, event: CallEvent| {
172 record(DEMO_RECAP_CHAT, id, None, minutes(offset), event)
173 };
174 vec![
175 line(
176 "standup-1-start",
177 0,
178 event(CallPhase::Started, STANDUP_CALL, JONAS_ID, None),
179 ),
180 line(
181 "standup-1-rec",
182 1,
183 recording(
184 event(CallPhase::RecordingStarted, STANDUP_CALL, JONAS_ID, Some(0)),
185 name,
186 None,
187 DEMO_USER_ID,
188 ),
189 ),
190 line(
191 "standup-1-stop",
192 17,
193 recording(
194 event(
195 CallPhase::RecordingStopped,
196 STANDUP_CALL,
197 JONAS_ID,
198 Some(985),
199 ),
200 name,
201 None,
202 DEMO_USER_ID,
203 ),
204 ),
205 line(
206 "standup-1-end",
207 18,
208 ended(STANDUP_CALL, JONAS_ID, 1080, &people),
209 ),
210 line(
211 "demo-recap-1",
212 19,
213 recording(
214 event(CallPhase::RecordingSaved, STANDUP_CALL, JONAS_ID, Some(985)),
215 name,
216 Some(&url),
217 DEMO_USER_ID,
218 ),
219 ),
220 ]
221 }
222
223 pub fn meeting_messages() -> Vec<MessageRecord> {
224 channel_meeting()
225 .into_iter()
226 .chain(recorded_standup())
227 .collect()
228 }
@@ -0,0 +1,228 @@
1use chrono::{DateTime, Duration, Utc};
2use store::MessageRecord;
3use teams_core::{CallEvent, CallPhase, CallType, Recording};
4
5use crate::demo::{DEMO_USER_ID, JONAS_ID, LEA_ID, MARA_ID, PRIYA_ID, TOBIAS_ID, at};
6use crate::demo_recap::DEMO_RECAP_CHAT;
7
8const CHANNEL: &str = "demo-channel-1-1";
9const CHANNEL_CALL: &str = "demo-channel-meeting";
10const CHANNEL_ROOT: &str = "meet-1";
11const STANDUP_CALL: &str = "demo-standup-recorded";
12const DEMO_RECORDING_URL: &str = "https://demo.sharepoint.example/personal/demo/Recordings";
13
14fn event(phase: CallPhase, call_id: &str, initiator: &str, seconds: Option<u64>) -> CallEvent {
15 CallEvent {
16 phase,
17 call_type: CallType::Meeting,
18 call_id: call_id.to_owned(),
19 duration_seconds: seconds,
20 initiator_id: Some(initiator.to_owned()),
21 initiator_name: None,
22 participant_ids: Vec::new(),
23 participant_names: Vec::new(),
24 recording: None,
25 }
26}
27
28fn recording(mut event: CallEvent, name: &str, url: Option<&str>, organizer: &str) -> CallEvent {
29 event.recording = Some(Recording {
30 name: Some(name.to_owned()),
31 url: url.map(str::to_owned),
32 organizer_id: Some(organizer.to_owned()),
33 });
34 event
35}
36
37fn ended(call_id: &str, initiator: &str, seconds: u64, people: &[(&str, &str)]) -> CallEvent {
38 CallEvent {
39 participant_ids: people.iter().map(|(id, _)| (*id).to_owned()).collect(),
40 participant_names: people.iter().map(|(_, name)| (*name).to_owned()).collect(),
41 ..event(CallPhase::Ended, call_id, initiator, Some(seconds))
42 }
43}
44
45fn record(
46 conversation: &str,
47 id: &str,
48 reply_to: Option<&str>,
49 time: DateTime<Utc>,
50 event: CallEvent,
51) -> MessageRecord {
52 MessageRecord {
53 conversation_id: conversation.to_owned(),
54 message_id: id.to_owned(),
55 reply_to_id: reply_to.map(str::to_owned),
56 created_at: time,
57 links_json: "[]".to_owned(),
58 attachments_json: "[]".to_owned(),
59 reactions_json: "[]".to_owned(),
60 mentions_json: "[]".to_owned(),
61 call_event_json: Some(event.to_json()),
62 ..MessageRecord::default()
63 }
64}
65
66fn reply(id: &str, sender: (&str, &str), time: DateTime<Utc>, html: &str) -> MessageRecord {
67 MessageRecord {
68 conversation_id: CHANNEL.to_owned(),
69 message_id: id.to_owned(),
70 reply_to_id: Some(CHANNEL_ROOT.to_owned()),
71 sender_id: Some(sender.0.to_owned()),
72 sender_name: Some(sender.1.to_owned()),
73 created_at: time,
74 body_html: html.to_owned(),
75 links_json: "[]".to_owned(),
76 attachments_json: "[]".to_owned(),
77 reactions_json: "[]".to_owned(),
78 mentions_json: "[]".to_owned(),
79 ..MessageRecord::default()
80 }
81}
82
83fn channel_meeting() -> Vec<MessageRecord> {
84 let start = at(0, 10, 30);
85 let minutes = |count: i64| start + Duration::minutes(count);
86 let name = "Design review-20261017_103200-Meeting Recording.mp4";
87 let url = format!("{DEMO_RECORDING_URL}/design-review.mp4");
88 let people = [
89 (MARA_ID, "Mara Lindqvist"),
90 (JONAS_ID, "Jonas Ortega"),
91 (PRIYA_ID, "Priya Nair"),
92 (DEMO_USER_ID, "Dana Demo"),
93 (TOBIAS_ID, "Tobias Klein"),
94 (LEA_ID, "Lea Schneider"),
95 ];
96 let thread = |id: &str, offset: i64, event: CallEvent| {
97 record(CHANNEL, id, Some(CHANNEL_ROOT), minutes(offset), event)
98 };
99 vec![
100 record(
101 CHANNEL,
102 CHANNEL_ROOT,
103 None,
104 start,
105 event(CallPhase::Started, CHANNEL_CALL, MARA_ID, None),
106 ),
107 thread(
108 "meet-1-rec",
109 2,
110 recording(
111 event(CallPhase::RecordingStarted, CHANNEL_CALL, MARA_ID, Some(0)),
112 name,
113 None,
114 MARA_ID,
115 ),
116 ),
117 thread(
118 "meet-1-transcript",
119 2,
120 event(CallPhase::TranscriptStarted, CHANNEL_CALL, MARA_ID, None),
121 ),
122 thread(
123 "meet-1-stop",
124 34,
125 recording(
126 event(
127 CallPhase::RecordingStopped,
128 CHANNEL_CALL,
129 MARA_ID,
130 Some(1914),
131 ),
132 name,
133 None,
134 MARA_ID,
135 ),
136 ),
137 thread(
138 "meet-1-end",
139 35,
140 ended(CHANNEL_CALL, MARA_ID, 2100, &people),
141 ),
142 thread(
143 "meet-1-saved",
144 36,
145 recording(
146 event(CallPhase::RecordingSaved, CHANNEL_CALL, MARA_ID, Some(1914)),
147 name,
148 Some(&url),
149 MARA_ID,
150 ),
151 ),
152 reply(
153 "meet-1-r1",
154 (JONAS_ID, "Jonas Ortega"),
155 minutes(41),
156 "<p>Thanks, the recording covers the open questions for Priya.</p>",
157 ),
158 ]
159}
160
161fn recorded_standup() -> Vec<MessageRecord> {
162 let start = at(1, 9, 0);
163 let minutes = |count: i64| start + Duration::minutes(count);
164 let name = "Daily standup-1-Meeting Recording.mp4";
165 let url = format!("{DEMO_RECORDING_URL}/standup-1.mp4");
166 let people = [
167 (JONAS_ID, "Jonas Ortega"),
168 (DEMO_USER_ID, "Dana Demo"),
169 (MARA_ID, "Mara Lindqvist"),
170 ];
171 let line = |id: &str, offset: i64, event: CallEvent| {
172 record(DEMO_RECAP_CHAT, id, None, minutes(offset), event)
173 };
174 vec![
175 line(
176 "standup-1-start",
177 0,
178 event(CallPhase::Started, STANDUP_CALL, JONAS_ID, None),
179 ),
180 line(
181 "standup-1-rec",
182 1,
183 recording(
184 event(CallPhase::RecordingStarted, STANDUP_CALL, JONAS_ID, Some(0)),
185 name,
186 None,
187 DEMO_USER_ID,
188 ),
189 ),
190 line(
191 "standup-1-stop",
192 17,
193 recording(
194 event(
195 CallPhase::RecordingStopped,
196 STANDUP_CALL,
197 JONAS_ID,
198 Some(985),
199 ),
200 name,
201 None,
202 DEMO_USER_ID,
203 ),
204 ),
205 line(
206 "standup-1-end",
207 18,
208 ended(STANDUP_CALL, JONAS_ID, 1080, &people),
209 ),
210 line(
211 "demo-recap-1",
212 19,
213 recording(
214 event(CallPhase::RecordingSaved, STANDUP_CALL, JONAS_ID, Some(985)),
215 name,
216 Some(&url),
217 DEMO_USER_ID,
218 ),
219 ),
220 ]
221}
222
223pub fn meeting_messages() -> Vec<MessageRecord> {
224 channel_meeting()
225 .into_iter()
226 .chain(recorded_standup())
227 .collect()
228}
crates/app-state/src/lib.rs +2 −0
@@ -4,6 +4,7 @@ pub mod agents;
4 4 pub mod app_state;
5 5 pub mod backend;
6 6 pub mod call;
7 pub mod call_rows;
7 8 pub mod card_actions;
8 9 pub mod card_inputs;
9 10 pub mod card_refresh;
@@ -11,6 +12,7 @@ pub mod card_state;
11 12 pub mod chat_actions;
12 13 pub mod data;
13 14 pub mod demo;
15 pub mod demo_meetings;
14 16 pub mod demo_profiles;
15 17 pub mod emoji;
16 18 pub mod gifs;
@@ -4,6 +4,7 @@ pub mod agents;
4pub mod app_state;
4pub mod app_state;
5pub mod backend;
5pub mod backend;
6pub mod call;
6pub mod call;
7pub mod call_rows;
7pub mod card_actions;
8pub mod card_actions;
8pub mod card_inputs;
9pub mod card_inputs;
9pub mod card_refresh;
10pub mod card_refresh;
@@ -11,6 +12,7 @@ pub mod card_state;
11pub mod chat_actions;
12pub mod chat_actions;
12pub mod data;
13pub mod data;
13pub mod demo;
14pub mod demo;
15pub mod demo_meetings;
14pub mod demo_profiles;
16pub mod demo_profiles;
15pub mod emoji;
17pub mod emoji;
16pub mod gifs;
18pub mod gifs;
crates/app-state/src/rows.rs +241 −82
@@ -1,4 +1,4 @@
1 use std::collections::{BTreeMap, HashMap, HashSet};
1 use std::collections::{BTreeMap, HashMap};
2 2 use std::ops::Range;
3 3 use std::sync::Arc;
4 4
@@ -7,13 +7,15 @@ use gpui_kit::Image;
7 7 use store::MessageRecord;
8 8 use teams_core::{
9 9 JumboEmoji, jumbo_emoji,
10 AdaptiveCard, CallEvent, CallPhase, CallType, Draft, FileCard, ForwardHeader, ForwardInfo,
10 AdaptiveCard, CallEvent, CallPhase, Draft, FileCard, ForwardHeader, ForwardInfo,
11 11 ImageRef, LinkPreview, forwards,
12 ReactionInfo, Span, adaptive_cards, call_event, card_texts, files, format_duration,
12 ReactionInfo, Span, adaptive_cards, call_event, card_texts, files,
13 13 forwarded_texts, images, is_forwarded, link_preview, linked_message_spans_with, meeting_link_in_html, message_spans, quotes,
14 14 reactions, readable_text, translated_spans,
15 15 };
16 16
17 pub use crate::call_rows::{CallCard, CallIcon, CallParticipant, RecordingCard};
18 use crate::call_rows::{CallNames, CallTimeline, call_card};
17 19 use crate::card_state::CardOverride;
18 20 use crate::format;
19 21 use crate::reaction_model::{Reactor, UNKNOWN_REACTOR};
@@ -111,22 +113,6 @@ pub struct LocalImage {
111 113 pub size: Option<(u32, u32)>,
112 114 }
113 115
114 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
115 pub enum CallIcon {
116 Call,
117 Missed,
118 Video,
119 }
120
121 #[derive(Debug, Clone, PartialEq, Eq)]
122 pub struct CallCard {
123 pub title: &'static str,
124 pub detail: String,
125 pub icon: CallIcon,
126 pub missed: bool,
127 pub started: bool,
128 }
129
130 116 #[derive(Debug, Clone, PartialEq)]
131 117 pub struct MessageRow {
132 118 pub key: String,
@@ -590,30 +576,18 @@ fn visible_reactions(record: &MessageRecord, context: &RowContext) -> Vec<Reacti
590 576 visible
591 577 }
592 578
593 pub fn call_card(event: &CallEvent, time: &str, my_user_id: Option<&str>) -> CallCard {
594 let missed = event.missed(my_user_id);
595 let detail = match (event.phase, event.duration_seconds) {
596 (CallPhase::Ended, Some(seconds)) if !missed => {
597 format!("{} \u{b7} {time}", format_duration(seconds))
598 }
599 _ => time.to_owned(),
600 };
601 CallCard {
602 title: event.title(missed),
603 detail,
604 icon: match (missed, event.call_type) {
605 (true, _) => CallIcon::Missed,
606 (false, CallType::Meeting) => CallIcon::Video,
607 (false, CallType::Call) => CallIcon::Call,
608 },
609 missed,
610 started: event.phase == CallPhase::Started,
611 }
612 }
613
614 fn call_row(record: &MessageRecord, event: &CallEvent, context: &RowContext) -> MessageRow {
579 fn call_row(
580 record: &MessageRecord,
581 event: &CallEvent,
582 context: &RowContext,
583 transcript: bool,
584 ) -> MessageRow {
615 585 let my_user_id = context.my_user_id.as_deref();
616 586 let time = clock_label(record.created_at, context.offset);
587 let names = CallNames {
588 my_user_id,
589 names: &context.names,
590 };
617 591 let author = event
618 592 .initiator_name
619 593 .clone()
@@ -658,7 +632,13 @@ fn call_row(record: &MessageRecord, event: &CallEvent, context: &RowContext) ->
658 632 own: event.initiated_by(my_user_id),
659 633 forwarded: false,
660 634 translation: None,
661 call: Some(call_card(event, &time, my_user_id)),
635 call: Some(call_card(
636 event,
637 &record.message_id,
638 &time,
639 &names,
640 transcript,
641 )),
662 642 time,
663 643 }
664 644 }
@@ -726,7 +706,7 @@ fn message_row_with(
726 706 quoted: &HashMap<String, String>,
727 707 ) -> MessageRow {
728 708 if let Some(event) = call_event(record) {
729 return call_row(record, &event, context);
709 return call_row(record, &event, context, false);
730 710 }
731 711 let local = record.created_at.with_timezone(&context.offset);
732 712 let images = images(record);
@@ -792,45 +772,30 @@ fn message_row_with(
792 772 }
793 773 }
794 774
795 fn finished_call_ids(events: &[Option<CallEvent>]) -> HashSet<&str> {
796 events
797 .iter()
798 .flatten()
799 .filter(|event| event.phase == CallPhase::Ended)
800 .map(|event| event.call_id.as_str())
801 .collect()
802 }
803
804 fn is_open_start(event: &CallEvent, finished: &HashSet<&str>) -> bool {
805 event.phase == CallPhase::Started && !finished.contains(event.call_id.as_str())
806 }
807
808 775 pub fn flat_rows(records: &[MessageRecord], context: &RowContext, has_older: bool) -> Vec<Row> {
809 776 let mut rows = Vec::with_capacity(records.len() + 1);
810 777 if has_older {
811 778 rows.push(Row::LoadOlder);
812 779 }
813 780 let events: Vec<Option<CallEvent>> = records.iter().map(call_event).collect();
814 let finished = finished_call_ids(&events);
815 let newest_open_start = events.iter().rposition(|event| {
816 event
817 .as_ref()
818 .is_some_and(|event| is_open_start(event, &finished))
819 });
781 let timeline = CallTimeline::new(&events);
820 782 let mut previous_day: Option<NaiveDate> = None;
821 783 let quoted = quoted_texts(records);
822 784 for (index, (record, event)) in records.iter().zip(&events).enumerate() {
785 if timeline.hides(index) {
786 continue;
787 }
823 788 let mut row = match event {
824 Some(event)
825 if event.phase == CallPhase::Started && !is_open_start(event, &finished) =>
826 {
827 continue;
828 }
829 Some(event) => call_row(record, event, context),
789 Some(event) => call_row(
790 record,
791 event,
792 context,
793 timeline.has_transcript(&event.call_id),
794 ),
830 795 None => message_row_with(record, context, &quoted),
831 796 };
832 797 if let Some(call) = row.call.as_mut() {
833 call.started &= newest_open_start == Some(index);
798 call.started &= timeline.is_live_start(index);
834 799 }
835 800 let day = record
836 801 .created_at
@@ -878,16 +843,60 @@ fn last_activity(thread: &Thread, by_id: &BTreeMap<&str, &MessageRecord>) -> Dat
878 843 .unwrap_or_default()
879 844 }
880 845
881 fn post_message_row(record: &MessageRecord, context: &RowContext) -> MessageRow {
882 let mut row = message_row(record, context);
846 fn post_message_row(
847 record: &MessageRecord,
848 context: &RowContext,
849 timeline: &CallTimeline,
850 ) -> MessageRow {
851 let mut row = match call_event(record) {
852 Some(event) => call_row(
853 record,
854 &event,
855 context,
856 timeline.has_transcript(&event.call_id),
857 ),
858 None => message_row(record, context),
859 };
883 860 row.day_header = None;
884 861 row.time = format::post_time_label(record.created_at, context.today, context.offset);
885 862 row
886 863 }
887 864
865 fn meeting_root_row(
866 root: &MessageRecord,
867 started: &CallEvent,
868 ended: Option<(&MessageRecord, CallEvent)>,
869 context: &RowContext,
870 timeline: &CallTimeline,
871 ) -> MessageRow {
872 let Some((ended_record, ended_event)) = ended else {
873 let mut row = post_message_row(root, context, timeline);
874 if let Some(call) = row.call.as_mut() {
875 call.started = !timeline.finished(&started.call_id);
876 }
877 return row;
878 };
879 let mut summary = CallEvent {
880 initiator_id: started.initiator_id.clone(),
881 initiator_name: started
882 .initiator_name
883 .clone()
884 .or(ended_event.initiator_name.clone()),
885 ..ended_event
886 };
887 summary.call_type = started.call_type;
888 let mut row = call_row(ended_record, &summary, context, false);
889 row.key = root.message_id.clone();
890 row.created_at = root.created_at;
891 row.reply_root = None;
892 row.day_header = None;
893 row.time = format::post_time_label(root.created_at, context.today, context.offset);
894 row
895 }
896
888 897 fn distinct_names<'a>(records: impl Iterator<Item = &'a MessageRecord>) -> Vec<String> {
889 898 let mut names: Vec<String> = Vec::new();
890 for record in records {
899 for record in records.filter(|record| record.call_event_json.is_none()) {
891 900 let name = record
892 901 .sender_name
893 902 .clone()
@@ -900,45 +909,87 @@ fn distinct_names<'a>(records: impl Iterator<Item = &'a MessageRecord>) -> Vec<S
900 909 }
901 910
902 911 fn post_row(
903 root: &MessageRecord,
912 root: MessageRow,
904 913 mut replies: Vec<&MessageRecord>,
905 914 context: &RowContext,
915 timeline: &CallTimeline,
906 916 ) -> PostRow {
907 917 replies.sort_by_key(|reply| reply.created_at);
908 918 let hidden = replies.len().saturating_sub(POST_VISIBLE_REPLIES);
909 919 PostRow {
910 root: post_message_row(root, context),
920 root,
911 921 hidden_reply_count: hidden,
912 922 hidden_repliers: distinct_names(replies[..hidden].iter().copied()),
913 923 replies: replies[hidden..]
914 924 .iter()
915 .map(|reply| post_message_row(reply, context))
925 .map(|reply| post_message_row(reply, context, timeline))
916 926 .collect(),
917 927 }
918 928 }
919 929
930 /// Channel feed: Teams shows a Meet now meeting as its own post and keeps the other call notices
931 /// inside the thread; a saved recording stays visible as a reply.
932 fn shows_in_feed(record: &MessageRecord, event: Option<&CallEvent>) -> bool {
933 match event {
934 None => true,
935 Some(event) if record.reply_to_id.is_none() => event.phase == CallPhase::Started,
936 Some(event) => event.phase == CallPhase::RecordingSaved,
937 }
938 }
939
920 940 pub fn thread_list_rows(
921 941 records: &[MessageRecord],
922 942 context: &RowContext,
923 943 has_older: bool,
924 944 ) -> Vec<Row> {
925 let by_id: BTreeMap<&str, &MessageRecord> = records
945 let events: Vec<Option<CallEvent>> = records.iter().map(call_event).collect();
946 let timeline = CallTimeline::new(&events);
947 let ended: HashMap<&str, (&MessageRecord, &CallEvent)> = records
948 .iter()
949 .zip(&events)
950 .filter_map(|(record, event)| {
951 let event = event
952 .as_ref()
953 .filter(|event| event.phase == CallPhase::Ended)?;
954 Some((event.call_id.as_str(), (record, event)))
955 })
956 .collect();
957 let by_id: BTreeMap<&str, (&MessageRecord, Option<&CallEvent>)> = records
958 .iter()
959 .zip(&events)
960 .filter(|(record, event)| shows_in_feed(record, event.as_ref()))
961 .map(|(record, event)| (record.message_id.as_str(), (record, event.as_ref())))
962 .collect();
963 let records_by_id: BTreeMap<&str, &MessageRecord> = by_id
926 964 .iter()
927 .filter(|record| record.call_event_json.is_none())
928 .map(|record| (record.message_id.as_str(), record))
965 .map(|(id, (record, _))| (*id, *record))
929 966 .collect();
930 967 let mut threads = group_threads(records);
931 threads.sort_by_key(|thread| std::cmp::Reverse(last_activity(thread, &by_id)));
968 threads.sort_by_key(|thread| std::cmp::Reverse(last_activity(thread, &records_by_id)));
932 969 let mut rows: Vec<Row> = threads
933 970 .iter()
934 971 .filter_map(|thread| {
935 let root = by_id.get(thread.root_id.as_str())?;
972 let (root, root_event) = by_id.get(thread.root_id.as_str())?;
973 let root_row = match root_event {
974 Some(started) => meeting_root_row(
975 root,
976 started,
977 ended
978 .get(started.call_id.as_str())
979 .map(|(record, event)| (*record, (*event).clone())),
980 context,
981 &timeline,
982 ),
983 None => post_message_row(root, context, &timeline),
984 };
936 985 let replies = thread
937 986 .reply_ids
938 987 .iter()
939 .filter_map(|id| by_id.get(id.as_str()).copied())
988 .filter_map(|id| records_by_id.get(id.as_str()).copied())
940 989 .collect();
941 Some(Row::Post(Box::new(post_row(root, replies, context))))
990 Some(Row::Post(Box::new(post_row(
991 root_row, replies, context, &timeline,
992 ))))
942 993 })
943 994 .collect();
944 995 if has_older {
@@ -1030,6 +1081,7 @@ pub fn changed_indices(old: &[Row], new: &[Row]) -> Vec<usize> {
1030 1081 #[cfg(test)]
1031 1082 mod tests {
1032 1083 use chrono::TimeZone;
1084 use teams_core::CallType;
1033 1085
1034 1086 use super::*;
1035 1087
@@ -1812,6 +1864,8 @@ mod tests {
1812 1864 initiator_id: Some(initiator.into()),
1813 1865 initiator_name: Some(format!("Name {initiator}")),
1814 1866 participant_ids: participants.iter().map(|id| (*id).to_owned()).collect(),
1867 participant_names: Vec::new(),
1868 recording: None,
1815 1869 }
1816 1870 }
1817 1871
@@ -1972,6 +2026,111 @@ mod tests {
1972 2026 assert!(series.iter().all(|series| *series == Series::default()));
1973 2027 }
1974 2028
2029 fn fixture_records(name: &str) -> Vec<MessageRecord> {
2030 let path = format!(
2031 "{}/../core/tests/fixtures/call_events/{name}",
2032 env!("CARGO_MANIFEST_DIR")
2033 );
2034 let thread: graph::Message =
2035 serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap();
2036 std::iter::once(&thread)
2037 .chain(&thread.replies)
2038 .filter_map(|message| teams_core::message_record("channel", message))
2039 .collect()
2040 }
2041
2042 fn feed_post(row: &Row) -> &PostRow {
2043 let Row::Post(post) = row else {
2044 panic!("not a post")
2045 };
2046 post
2047 }
2048
2049 #[test]
2050 fn meet_now_root_is_a_post_with_the_ended_meeting_card() {
2051 let records = fixture_records("channel_adhoc_meeting.json");
2052 assert_eq!(records.len(), 2);
2053 let rows = thread_list_rows(&records, &call_context(), false);
2054 assert_eq!(rows.len(), 1);
2055 let post = feed_post(&rows[0]);
2056 assert_eq!(post.root.key, records[0].message_id);
2057 assert!(post.replies.is_empty());
2058 assert_eq!(post.hidden_reply_count, 0);
2059 let card = post.root.call.as_ref().unwrap();
2060 assert_eq!(card.title, "Meeting ended");
2061 assert!(card.detail.starts_with("3h 19m 35s"));
2062 assert!(!card.started);
2063 assert_eq!(card.participants.len(), 3);
2064 assert_eq!(card.extra_participants, 0);
2065 }
2066
2067 #[test]
2068 fn meet_now_root_without_an_end_can_be_joined() {
2069 let mut records = fixture_records("channel_adhoc_meeting.json");
2070 records.truncate(1);
2071 let rows = thread_list_rows(&records, &call_context(), false);
2072 let card = feed_post(&rows[0]).root.call.clone().unwrap();
2073 assert_eq!(card.title, "Meeting started");
2074 assert!(card.started);
2075 }
2076
2077 #[test]
2078 fn scheduled_meeting_post_keeps_call_notices_in_the_thread() {
2079 let mut records = fixture_records("channel_scheduled_meeting.json");
2080 records.sort_by_key(|record| record.created_at);
2081 assert_eq!(records.len(), 3);
2082 let rows = thread_list_rows(&records, &call_context(), false);
2083 let post = feed_post(&rows[0]);
2084 assert!(post.root.call.is_none());
2085 assert!(post.replies.is_empty());
2086 let thread = thread_rows(&records, &records[0].message_id, &call_context());
2087 let titles: Vec<String> = thread
2088 .iter()
2089 .filter_map(|row| match row {
2090 Row::Message(message) => message.call.as_ref().map(|call| call.title.clone()),
2091 _ => None,
2092 })
2093 .collect();
2094 assert_eq!(titles, ["Meeting started", "Meeting ended"]);
2095 }
2096
2097 #[test]
2098 fn saved_recording_shows_in_the_channel_feed_as_a_reply() {
2099 let mut records = fixture_records("channel_adhoc_meeting.json");
2100 let root_id = records[0].message_id.clone();
2101 let page: serde_json::Value = serde_json::from_str(
2102 &std::fs::read_to_string(format!(
2103 "{}/../core/tests/fixtures/call_events/meeting_chat_recording.json",
2104 env!("CARGO_MANIFEST_DIR")
2105 ))
2106 .unwrap(),
2107 )
2108 .unwrap();
2109 for message in page["value"].as_array().unwrap() {
2110 let message: graph::Message = serde_json::from_value(message.clone()).unwrap();
2111 let mut record = teams_core::message_record("channel", &message).unwrap();
2112 record.reply_to_id = Some(root_id.clone());
2113 records.push(record);
2114 }
2115 let rows = thread_list_rows(&records, &call_context(), false);
2116 let post = feed_post(&rows[0]);
2117 assert_eq!(post.replies.len(), 1);
2118 assert_eq!(post.hidden_reply_count, 0);
2119 let recording = post.replies[0]
2120 .call
2121 .as_ref()
2122 .and_then(|call| call.recording.as_ref())
2123 .unwrap();
2124 assert_eq!(recording.title, "Weekly team meeting");
2125 assert!(recording.transcript);
2126 let thread = thread_rows(&records, &root_id, &call_context());
2127 let calls = thread
2128 .iter()
2129 .filter(|row| matches!(row, Row::Message(message) if message.call.is_some()))
2130 .count();
2131 assert_eq!(calls, 7);
2132 }
2133
1975 2134 #[test]
1976 2135 fn thread_lists_leave_call_events_out() {
1977 2136 let records = [call_record(
@@ -1,4 +1,4 @@
1use std::collections::{BTreeMap, HashMap, HashSet};
1use std::collections::{BTreeMap, HashMap};
2use std::ops::Range;
2use std::ops::Range;
3use std::sync::Arc;
3use std::sync::Arc;
4
4
@@ -7,13 +7,15 @@ use gpui_kit::Image;
7use store::MessageRecord;
7use store::MessageRecord;
8use teams_core::{
8use teams_core::{
9 JumboEmoji, jumbo_emoji,
9 JumboEmoji, jumbo_emoji,
10 AdaptiveCard, CallEvent, CallPhase, CallType, Draft, FileCard, ForwardHeader, ForwardInfo,
10 AdaptiveCard, CallEvent, CallPhase, Draft, FileCard, ForwardHeader, ForwardInfo,
11 ImageRef, LinkPreview, forwards,
11 ImageRef, LinkPreview, forwards,
12 ReactionInfo, Span, adaptive_cards, call_event, card_texts, files, format_duration,
12 ReactionInfo, Span, adaptive_cards, call_event, card_texts, files,
13 forwarded_texts, images, is_forwarded, link_preview, linked_message_spans_with, meeting_link_in_html, message_spans, quotes,
13 forwarded_texts, images, is_forwarded, link_preview, linked_message_spans_with, meeting_link_in_html, message_spans, quotes,
14 reactions, readable_text, translated_spans,
14 reactions, readable_text, translated_spans,
15};
15};
16
16
17pub use crate::call_rows::{CallCard, CallIcon, CallParticipant, RecordingCard};
18use crate::call_rows::{CallNames, CallTimeline, call_card};
17use crate::card_state::CardOverride;
19use crate::card_state::CardOverride;
18use crate::format;
20use crate::format;
19use crate::reaction_model::{Reactor, UNKNOWN_REACTOR};
21use crate::reaction_model::{Reactor, UNKNOWN_REACTOR};
@@ -111,22 +113,6 @@ pub struct LocalImage {
111 pub size: Option<(u32, u32)>,
113 pub size: Option<(u32, u32)>,
112}
114}
113
115
114#[derive(Debug, Clone, Copy, PartialEq, Eq)]
115pub enum CallIcon {
116 Call,
117 Missed,
118 Video,
119}
120
121#[derive(Debug, Clone, PartialEq, Eq)]
122pub struct CallCard {
123 pub title: &'static str,
124 pub detail: String,
125 pub icon: CallIcon,
126 pub missed: bool,
127 pub started: bool,
128}
129
130#[derive(Debug, Clone, PartialEq)]
116#[derive(Debug, Clone, PartialEq)]
131pub struct MessageRow {
117pub struct MessageRow {
132 pub key: String,
118 pub key: String,
@@ -590,30 +576,18 @@ fn visible_reactions(record: &MessageRecord, context: &RowContext) -> Vec<Reacti
590 visible
576 visible
591}
577}
592
578
593pub fn call_card(event: &CallEvent, time: &str, my_user_id: Option<&str>) -> CallCard {
579fn call_row(
594 let missed = event.missed(my_user_id);
580 record: &MessageRecord,
595 let detail = match (event.phase, event.duration_seconds) {
581 event: &CallEvent,
596 (CallPhase::Ended, Some(seconds)) if !missed => {
582 context: &RowContext,
597 format!("{} \u{b7} {time}", format_duration(seconds))
583 transcript: bool,
598 }
584) -> MessageRow {
599 _ => time.to_owned(),
600 };
601 CallCard {
602 title: event.title(missed),
603 detail,
604 icon: match (missed, event.call_type) {
605 (true, _) => CallIcon::Missed,
606 (false, CallType::Meeting) => CallIcon::Video,
607 (false, CallType::Call) => CallIcon::Call,
608 },
609 missed,
610 started: event.phase == CallPhase::Started,
611 }
612}
613
614fn call_row(record: &MessageRecord, event: &CallEvent, context: &RowContext) -> MessageRow {
615 let my_user_id = context.my_user_id.as_deref();
585 let my_user_id = context.my_user_id.as_deref();
616 let time = clock_label(record.created_at, context.offset);
586 let time = clock_label(record.created_at, context.offset);
587 let names = CallNames {
588 my_user_id,
589 names: &context.names,
590 };
617 let author = event
591 let author = event
618 .initiator_name
592 .initiator_name
619 .clone()
593 .clone()
@@ -658,7 +632,13 @@ fn call_row(record: &MessageRecord, event: &CallEvent, context: &RowContext) ->
658 own: event.initiated_by(my_user_id),
632 own: event.initiated_by(my_user_id),
659 forwarded: false,
633 forwarded: false,
660 translation: None,
634 translation: None,
661 call: Some(call_card(event, &time, my_user_id)),
635 call: Some(call_card(
636 event,
637 &record.message_id,
638 &time,
639 &names,
640 transcript,
641 )),
662 time,
642 time,
663 }
643 }
664}
644}
@@ -726,7 +706,7 @@ fn message_row_with(
726 quoted: &HashMap<String, String>,
706 quoted: &HashMap<String, String>,
727) -> MessageRow {
707) -> MessageRow {
728 if let Some(event) = call_event(record) {
708 if let Some(event) = call_event(record) {
729 return call_row(record, &event, context);
709 return call_row(record, &event, context, false);
730 }
710 }
731 let local = record.created_at.with_timezone(&context.offset);
711 let local = record.created_at.with_timezone(&context.offset);
732 let images = images(record);
712 let images = images(record);
@@ -792,45 +772,30 @@ fn message_row_with(
792 }
772 }
793}
773}
794
774
795fn finished_call_ids(events: &[Option<CallEvent>]) -> HashSet<&str> {
796 events
797 .iter()
798 .flatten()
799 .filter(|event| event.phase == CallPhase::Ended)
800 .map(|event| event.call_id.as_str())
801 .collect()
802}
803
804fn is_open_start(event: &CallEvent, finished: &HashSet<&str>) -> bool {
805 event.phase == CallPhase::Started && !finished.contains(event.call_id.as_str())
806}
807
808pub fn flat_rows(records: &[MessageRecord], context: &RowContext, has_older: bool) -> Vec<Row> {
775pub fn flat_rows(records: &[MessageRecord], context: &RowContext, has_older: bool) -> Vec<Row> {
809 let mut rows = Vec::with_capacity(records.len() + 1);
776 let mut rows = Vec::with_capacity(records.len() + 1);
810 if has_older {
777 if has_older {
811 rows.push(Row::LoadOlder);
778 rows.push(Row::LoadOlder);
812 }
779 }
813 let events: Vec<Option<CallEvent>> = records.iter().map(call_event).collect();
780 let events: Vec<Option<CallEvent>> = records.iter().map(call_event).collect();
814 let finished = finished_call_ids(&events);
781 let timeline = CallTimeline::new(&events);
815 let newest_open_start = events.iter().rposition(|event| {
816 event
817 .as_ref()
818 .is_some_and(|event| is_open_start(event, &finished))
819 });
820 let mut previous_day: Option<NaiveDate> = None;
782 let mut previous_day: Option<NaiveDate> = None;
821 let quoted = quoted_texts(records);
783 let quoted = quoted_texts(records);
822 for (index, (record, event)) in records.iter().zip(&events).enumerate() {
784 for (index, (record, event)) in records.iter().zip(&events).enumerate() {
785 if timeline.hides(index) {
786 continue;
787 }
823 let mut row = match event {
788 let mut row = match event {
824 Some(event)
789 Some(event) => call_row(
825 if event.phase == CallPhase::Started && !is_open_start(event, &finished) =>
790 record,
826 {
791 event,
827 continue;
792 context,
828 }
793 timeline.has_transcript(&event.call_id),
829 Some(event) => call_row(record, event, context),
794 ),
830 None => message_row_with(record, context, &quoted),
795 None => message_row_with(record, context, &quoted),
831 };
796 };
832 if let Some(call) = row.call.as_mut() {
797 if let Some(call) = row.call.as_mut() {
833 call.started &= newest_open_start == Some(index);
798 call.started &= timeline.is_live_start(index);
834 }
799 }
835 let day = record
800 let day = record
836 .created_at
801 .created_at
@@ -878,16 +843,60 @@ fn last_activity(thread: &Thread, by_id: &BTreeMap<&str, &MessageRecord>) -> Dat
878 .unwrap_or_default()
843 .unwrap_or_default()
879}
844}
880
845
881fn post_message_row(record: &MessageRecord, context: &RowContext) -> MessageRow {
846fn post_message_row(
882 let mut row = message_row(record, context);
847 record: &MessageRecord,
848 context: &RowContext,
849 timeline: &CallTimeline,
850) -> MessageRow {
851 let mut row = match call_event(record) {
852 Some(event) => call_row(
853 record,
854 &event,
855 context,
856 timeline.has_transcript(&event.call_id),
857 ),
858 None => message_row(record, context),
859 };
883 row.day_header = None;
860 row.day_header = None;
884 row.time = format::post_time_label(record.created_at, context.today, context.offset);
861 row.time = format::post_time_label(record.created_at, context.today, context.offset);
885 row
862 row
886}
863}
887
864
865fn meeting_root_row(
866 root: &MessageRecord,
867 started: &CallEvent,
868 ended: Option<(&MessageRecord, CallEvent)>,
869 context: &RowContext,
870 timeline: &CallTimeline,
871) -> MessageRow {
872 let Some((ended_record, ended_event)) = ended else {
873 let mut row = post_message_row(root, context, timeline);
874 if let Some(call) = row.call.as_mut() {
875 call.started = !timeline.finished(&started.call_id);
876 }
877 return row;
878 };
879 let mut summary = CallEvent {
880 initiator_id: started.initiator_id.clone(),
881 initiator_name: started
882 .initiator_name
883 .clone()
884 .or(ended_event.initiator_name.clone()),
885 ..ended_event
886 };
887 summary.call_type = started.call_type;
888 let mut row = call_row(ended_record, &summary, context, false);
889 row.key = root.message_id.clone();
890 row.created_at = root.created_at;
891 row.reply_root = None;
892 row.day_header = None;
893 row.time = format::post_time_label(root.created_at, context.today, context.offset);
894 row
895}
896
888fn distinct_names<'a>(records: impl Iterator<Item = &'a MessageRecord>) -> Vec<String> {
897fn distinct_names<'a>(records: impl Iterator<Item = &'a MessageRecord>) -> Vec<String> {
889 let mut names: Vec<String> = Vec::new();
898 let mut names: Vec<String> = Vec::new();
890 for record in records {
899 for record in records.filter(|record| record.call_event_json.is_none()) {
891 let name = record
900 let name = record
892 .sender_name
901 .sender_name
893 .clone()
902 .clone()
@@ -900,45 +909,87 @@ fn distinct_names<'a>(records: impl Iterator<Item = &'a MessageRecord>) -> Vec<S
900}
909}
901
910
902fn post_row(
911fn post_row(
903 root: &MessageRecord,
912 root: MessageRow,
904 mut replies: Vec<&MessageRecord>,
913 mut replies: Vec<&MessageRecord>,
905 context: &RowContext,
914 context: &RowContext,
915 timeline: &CallTimeline,
906) -> PostRow {
916) -> PostRow {
907 replies.sort_by_key(|reply| reply.created_at);
917 replies.sort_by_key(|reply| reply.created_at);
908 let hidden = replies.len().saturating_sub(POST_VISIBLE_REPLIES);
918 let hidden = replies.len().saturating_sub(POST_VISIBLE_REPLIES);
909 PostRow {
919 PostRow {
910 root: post_message_row(root, context),
920 root,
911 hidden_reply_count: hidden,
921 hidden_reply_count: hidden,
912 hidden_repliers: distinct_names(replies[..hidden].iter().copied()),
922 hidden_repliers: distinct_names(replies[..hidden].iter().copied()),
913 replies: replies[hidden..]
923 replies: replies[hidden..]
914 .iter()
924 .iter()
915 .map(|reply| post_message_row(reply, context))
925 .map(|reply| post_message_row(reply, context, timeline))
916 .collect(),
926 .collect(),
917 }
927 }
918}
928}
919
929
930/// Channel feed: Teams shows a Meet now meeting as its own post and keeps the other call notices
931/// inside the thread; a saved recording stays visible as a reply.
932fn shows_in_feed(record: &MessageRecord, event: Option<&CallEvent>) -> bool {
933 match event {
934 None => true,
935 Some(event) if record.reply_to_id.is_none() => event.phase == CallPhase::Started,
936 Some(event) => event.phase == CallPhase::RecordingSaved,
937 }
938}
939
920pub fn thread_list_rows(
940pub fn thread_list_rows(
921 records: &[MessageRecord],
941 records: &[MessageRecord],
922 context: &RowContext,
942 context: &RowContext,
923 has_older: bool,
943 has_older: bool,
924) -> Vec<Row> {
944) -> Vec<Row> {
925 let by_id: BTreeMap<&str, &MessageRecord> = records
945 let events: Vec<Option<CallEvent>> = records.iter().map(call_event).collect();
946 let timeline = CallTimeline::new(&events);
947 let ended: HashMap<&str, (&MessageRecord, &CallEvent)> = records
948 .iter()
949 .zip(&events)
950 .filter_map(|(record, event)| {
951 let event = event
952 .as_ref()
953 .filter(|event| event.phase == CallPhase::Ended)?;
954 Some((event.call_id.as_str(), (record, event)))
955 })
956 .collect();
957 let by_id: BTreeMap<&str, (&MessageRecord, Option<&CallEvent>)> = records
958 .iter()
959 .zip(&events)
960 .filter(|(record, event)| shows_in_feed(record, event.as_ref()))
961 .map(|(record, event)| (record.message_id.as_str(), (record, event.as_ref())))
962 .collect();
963 let records_by_id: BTreeMap<&str, &MessageRecord> = by_id
926 .iter()
964 .iter()
927 .filter(|record| record.call_event_json.is_none())
965 .map(|(id, (record, _))| (*id, *record))
928 .map(|record| (record.message_id.as_str(), record))
929 .collect();
966 .collect();
930 let mut threads = group_threads(records);
967 let mut threads = group_threads(records);
931 threads.sort_by_key(|thread| std::cmp::Reverse(last_activity(thread, &by_id)));
968 threads.sort_by_key(|thread| std::cmp::Reverse(last_activity(thread, &records_by_id)));
932 let mut rows: Vec<Row> = threads
969 let mut rows: Vec<Row> = threads
933 .iter()
970 .iter()
934 .filter_map(|thread| {
971 .filter_map(|thread| {
935 let root = by_id.get(thread.root_id.as_str())?;
972 let (root, root_event) = by_id.get(thread.root_id.as_str())?;
973 let root_row = match root_event {
974 Some(started) => meeting_root_row(
975 root,
976 started,
977 ended
978 .get(started.call_id.as_str())
979 .map(|(record, event)| (*record, (*event).clone())),
980 context,
981 &timeline,
982 ),
983 None => post_message_row(root, context, &timeline),
984 };
936 let replies = thread
985 let replies = thread
937 .reply_ids
986 .reply_ids
938 .iter()
987 .iter()
939 .filter_map(|id| by_id.get(id.as_str()).copied())
988 .filter_map(|id| records_by_id.get(id.as_str()).copied())
940 .collect();
989 .collect();
941 Some(Row::Post(Box::new(post_row(root, replies, context))))
990 Some(Row::Post(Box::new(post_row(
991 root_row, replies, context, &timeline,
992 ))))
942 })
993 })
943 .collect();
994 .collect();
944 if has_older {
995 if has_older {
@@ -1030,6 +1081,7 @@ pub fn changed_indices(old: &[Row], new: &[Row]) -> Vec<usize> {
1030#[cfg(test)]
1081#[cfg(test)]
1031mod tests {
1082mod tests {
1032 use chrono::TimeZone;
1083 use chrono::TimeZone;
1084 use teams_core::CallType;
1033
1085
1034 use super::*;
1086 use super::*;
1035
1087
@@ -1812,6 +1864,8 @@ mod tests {
1812 initiator_id: Some(initiator.into()),
1864 initiator_id: Some(initiator.into()),
1813 initiator_name: Some(format!("Name {initiator}")),
1865 initiator_name: Some(format!("Name {initiator}")),
1814 participant_ids: participants.iter().map(|id| (*id).to_owned()).collect(),
1866 participant_ids: participants.iter().map(|id| (*id).to_owned()).collect(),
1867 participant_names: Vec::new(),
1868 recording: None,
1815 }
1869 }
1816 }
1870 }
1817
1871
@@ -1972,6 +2026,111 @@ mod tests {
1972 assert!(series.iter().all(|series| *series == Series::default()));
2026 assert!(series.iter().all(|series| *series == Series::default()));
1973 }
2027 }
1974
2028
2029 fn fixture_records(name: &str) -> Vec<MessageRecord> {
2030 let path = format!(
2031 "{}/../core/tests/fixtures/call_events/{name}",
2032 env!("CARGO_MANIFEST_DIR")
2033 );
2034 let thread: graph::Message =
2035 serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap();
2036 std::iter::once(&thread)
2037 .chain(&thread.replies)
2038 .filter_map(|message| teams_core::message_record("channel", message))
2039 .collect()
2040 }
2041
2042 fn feed_post(row: &Row) -> &PostRow {
2043 let Row::Post(post) = row else {
2044 panic!("not a post")
2045 };
2046 post
2047 }
2048
2049 #[test]
2050 fn meet_now_root_is_a_post_with_the_ended_meeting_card() {
2051 let records = fixture_records("channel_adhoc_meeting.json");
2052 assert_eq!(records.len(), 2);
2053 let rows = thread_list_rows(&records, &call_context(), false);
2054 assert_eq!(rows.len(), 1);
2055 let post = feed_post(&rows[0]);
2056 assert_eq!(post.root.key, records[0].message_id);
2057 assert!(post.replies.is_empty());
2058 assert_eq!(post.hidden_reply_count, 0);
2059 let card = post.root.call.as_ref().unwrap();
2060 assert_eq!(card.title, "Meeting ended");
2061 assert!(card.detail.starts_with("3h 19m 35s"));
2062 assert!(!card.started);
2063 assert_eq!(card.participants.len(), 3);
2064 assert_eq!(card.extra_participants, 0);
2065 }
2066
2067 #[test]
2068 fn meet_now_root_without_an_end_can_be_joined() {
2069 let mut records = fixture_records("channel_adhoc_meeting.json");
2070 records.truncate(1);
2071 let rows = thread_list_rows(&records, &call_context(), false);
2072 let card = feed_post(&rows[0]).root.call.clone().unwrap();
2073 assert_eq!(card.title, "Meeting started");
2074 assert!(card.started);
2075 }
2076
2077 #[test]
2078 fn scheduled_meeting_post_keeps_call_notices_in_the_thread() {
2079 let mut records = fixture_records("channel_scheduled_meeting.json");
2080 records.sort_by_key(|record| record.created_at);
2081 assert_eq!(records.len(), 3);
2082 let rows = thread_list_rows(&records, &call_context(), false);
2083 let post = feed_post(&rows[0]);
2084 assert!(post.root.call.is_none());
2085 assert!(post.replies.is_empty());
2086 let thread = thread_rows(&records, &records[0].message_id, &call_context());
2087 let titles: Vec<String> = thread
2088 .iter()
2089 .filter_map(|row| match row {
2090 Row::Message(message) => message.call.as_ref().map(|call| call.title.clone()),
2091 _ => None,
2092 })
2093 .collect();
2094 assert_eq!(titles, ["Meeting started", "Meeting ended"]);
2095 }
2096
2097 #[test]
2098 fn saved_recording_shows_in_the_channel_feed_as_a_reply() {
2099 let mut records = fixture_records("channel_adhoc_meeting.json");
2100 let root_id = records[0].message_id.clone();
2101 let page: serde_json::Value = serde_json::from_str(
2102 &std::fs::read_to_string(format!(
2103 "{}/../core/tests/fixtures/call_events/meeting_chat_recording.json",
2104 env!("CARGO_MANIFEST_DIR")
2105 ))
2106 .unwrap(),
2107 )
2108 .unwrap();
2109 for message in page["value"].as_array().unwrap() {
2110 let message: graph::Message = serde_json::from_value(message.clone()).unwrap();
2111 let mut record = teams_core::message_record("channel", &message).unwrap();
2112 record.reply_to_id = Some(root_id.clone());
2113 records.push(record);
2114 }
2115 let rows = thread_list_rows(&records, &call_context(), false);
2116 let post = feed_post(&rows[0]);
2117 assert_eq!(post.replies.len(), 1);
2118 assert_eq!(post.hidden_reply_count, 0);
2119 let recording = post.replies[0]
2120 .call
2121 .as_ref()
2122 .and_then(|call| call.recording.as_ref())
2123 .unwrap();
2124 assert_eq!(recording.title, "Weekly team meeting");
2125 assert!(recording.transcript);
2126 let thread = thread_rows(&records, &root_id, &call_context());
2127 let calls = thread
2128 .iter()
2129 .filter(|row| matches!(row, Row::Message(message) if message.call.is_some()))
2130 .count();
2131 assert_eq!(calls, 7);
2132 }
2133
1975 #[test]
2134 #[test]
1976 fn thread_lists_leave_call_events_out() {
2135 fn thread_lists_leave_call_events_out() {
1977 let records = [call_record(
2136 let records = [call_record(
crates/app/assets/symbols/description.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-240h320v-80H320v80Zm0-160h320v-80H320v80ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-240h320v-80H320v80Zm0-160h320v-80H320v80ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"/></svg>
crates/app/assets/symbols/play_arrow.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-200v-560l440 280-440 280Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-200v-560l440 280-440 280Z"/></svg>
crates/app/assets/symbols/radio_button_checked.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M480-280q83 0 141.5-58.5T680-480q0-83-58.5-141.5T480-680q-83 0-141.5 58.5T280-480q0 83 58.5 141.5T480-280Zm0 200q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M480-280q83 0 141.5-58.5T680-480q0-83-58.5-141.5T480-680q-83 0-141.5 58.5T280-480q0 83 58.5 141.5T480-280Zm0 200q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Z"/></svg>
crates/app/assets/symbols/stop_circle.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-320h320v-320H320v320ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M320-320h320v-320H320v320ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Z"/></svg>
crates/app/src/views/call_card.rs +243 −20
@@ -7,7 +7,7 @@ use super::message_row::{AVATAR_GAP, AVATAR_SIZE, RowAction, day_separator, new_
7 7 use super::profile_card::opens_profile;
8 8 use super::widgets::symbol;
9 9 use crate::data::Directory;
10 use crate::rows::{CallCard, CallIcon, MessageRow};
10 use crate::rows::{CallCard, CallIcon, CallParticipant, MessageRow, RecordingCard};
11 11 use crate::theme;
12 12
13 13 const SERIES_START_GAP: f32 = 8.;
@@ -18,10 +18,32 @@ const ICON_SIZE: f32 = 18.;
18 18 const TITLE_SIZE: f32 = 13.;
19 19 const DETAIL_SIZE: f32 = 11.;
20 20 const JOIN_HEIGHT: f32 = 24.;
21 const PARTICIPANT_AVATAR: f32 = 20.;
22 const PARTICIPANT_GAP: f32 = 2.;
23 const TILE_WIDTH: f32 = 288.;
24 const TILE_HEIGHT: f32 = 162.;
25 const TILE_RADIUS: f32 = 8.;
26 const PLAY_CIRCLE: f32 = 40.;
27 const PLAY_GLYPH: f32 = 24.;
28 const DURATION_INSET: f32 = 6.;
29 const CHIP_HEIGHT: f32 = 26.;
21 30
22 31 pub struct CallActions {
23 32 pub call_back: RowAction,
24 33 pub join: RowAction,
34 pub open_recording: RowAction,
35 pub open_transcript: RowAction,
36 }
37
38 impl CallActions {
39 pub fn none() -> Self {
40 CallActions {
41 call_back: None,
42 join: None,
43 open_recording: None,
44 open_transcript: None,
45 }
46 }
25 47 }
26 48
27 49 fn icon_circle(call: &CallCard, own: bool) -> Div {
@@ -29,6 +51,12 @@ fn icon_circle(call: &CallCard, own: bool) -> Div {
29 51 CallIcon::Missed => (theme::red().opacity(0.2), "call_missed", theme::red_soft()),
30 52 CallIcon::Call => (circle_fill(own), "call", theme::text()),
31 53 CallIcon::Video => (circle_fill(own), "videocam", theme::text()),
54 CallIcon::Record => (
55 circle_fill(own),
56 "radio_button_checked",
57 theme::accent_text(),
58 ),
59 CallIcon::RecordStop => (circle_fill(own), "stop_circle", theme::text()),
32 60 };
33 61 h_flex()
34 62 .size(px(ICON_CIRCLE))
@@ -94,23 +122,186 @@ fn join_button(index: usize, join: RowAction) -> Stateful<Div> {
94 122 })
95 123 }
96 124
97 fn card(call: &CallCard, index: usize, own: bool, actions: CallActions) -> Div {
98 let CallActions { call_back, join } = actions;
99 let show_join = call.started && join.is_some();
125 fn participant_stack(
126 participants: &[CallParticipant],
127 extra: usize,
128 directory: &Directory,
129 own: bool,
130 ) -> Option<Div> {
131 if participants.is_empty() {
132 return None;
133 }
134 let tint = if own {
135 theme::own_meta()
136 } else {
137 theme::text_muted()
138 };
139 Some(
140 h_flex()
141 .pt(px(4.))
142 .gap(px(PARTICIPANT_GAP))
143 .items_center()
144 .children(participants.iter().map(|person| {
145 person_avatar(
146 directory,
147 Some(&person.user_id),
148 &person.name,
149 PARTICIPANT_AVATAR,
150 )
151 }))
152 .when(extra > 0, |stack| {
153 stack.child(
154 div()
155 .pl(px(4.))
156 .text_size(px(DETAIL_SIZE))
157 .text_color(tint)
158 .child(format!("+{extra}")),
159 )
160 }),
161 )
162 }
163
164 fn recording_thumbnail(recording: &RecordingCard, directory: &Directory) -> AnyElement {
165 let image = recording
166 .thumbnail
167 .as_ref()
168 .and_then(|thumbnail| directory.image(&thumbnail.url));
169 match image {
170 Some(entry) => img(entry.path.clone())
171 .size_full()
172 .object_fit(ObjectFit::Cover)
173 .into_any_element(),
174 None => div()
175 .size_full()
176 .bg(theme::code_surface())
177 .into_any_element(),
178 }
179 }
180
181 fn recording_tile(
182 recording: &RecordingCard,
183 index: usize,
184 directory: &Directory,
185 open_recording: RowAction,
186 ) -> Stateful<Div> {
187 div()
188 .id(ElementId::Name(format!("call-recording-{index}").into()))
189 .relative()
190 .w(px(TILE_WIDTH))
191 .h(px(TILE_HEIGHT))
192 .flex_none()
193 .rounded(px(TILE_RADIUS))
194 .overflow_hidden()
195 .cursor_pointer()
196 .hover(|tile| tile.opacity(0.92))
197 .child(recording_thumbnail(recording, directory))
198 .child(
199 h_flex()
200 .absolute()
201 .inset_0()
202 .items_center()
203 .justify_center()
204 .child(
205 h_flex()
206 .size(px(PLAY_CIRCLE))
207 .items_center()
208 .justify_center()
209 .rounded_full()
210 .bg(black().opacity(0.55))
211 .child(symbol("play_arrow", PLAY_GLYPH, theme::white())),
212 ),
213 )
214 .children(recording.duration.clone().map(|duration| {
215 div()
216 .absolute()
217 .bottom(px(DURATION_INSET))
218 .right(px(DURATION_INSET))
219 .px(px(6.))
220 .py(px(1.))
221 .rounded(px(4.))
222 .bg(black().opacity(0.65))
223 .text_size(px(DETAIL_SIZE))
224 .font_weight(FontWeight::SEMIBOLD)
225 .text_color(theme::white())
226 .child(duration)
227 }))
228 .when_some(open_recording, |tile, open| {
229 tile.on_click(move |_, _, cx| open(cx))
230 })
231 }
232
233 fn transcript_chip(index: usize, open_transcript: RowAction) -> Stateful<Div> {
100 234 h_flex()
101 .min_w(px(CARD_MIN_WIDTH))
102 .gap(px(8.))
235 .id(ElementId::Name(format!("call-transcript-{index}").into()))
236 .h(px(CHIP_HEIGHT))
237 .px(px(10.))
238 .gap(px(6.))
239 .flex_none()
103 240 .items_center()
104 .pt(px(8.))
105 .pr(px(12.))
106 .pb(px(8.))
107 .pl(px(8.))
108 .rounded(px(CARD_RADIUS))
109 .bg(if own {
110 theme::bubble_own()
111 } else {
112 theme::bubble_other()
241 .rounded(px(6.))
242 .border_1()
243 .border_color(theme::border())
244 .text_size(px(DETAIL_SIZE + 1.))
245 .font_weight(FontWeight::SEMIBOLD)
246 .text_color(theme::text())
247 .cursor_pointer()
248 .hover(|chip| chip.bg(theme::popup_hover()))
249 .child(symbol("description", 15., theme::accent_text()))
250 .child("Transcript")
251 .when_some(open_transcript, |chip, open| {
252 chip.on_click(move |_, _, cx| open(cx))
113 253 })
254 }
255
256 fn recording_block(
257 recording: &RecordingCard,
258 index: usize,
259 directory: &Directory,
260 open_recording: RowAction,
261 open_transcript: RowAction,
262 ) -> Div {
263 v_flex()
264 .pt(px(4.))
265 .gap(px(8.))
266 .child(recording_tile(recording, index, directory, open_recording))
267 .child(
268 h_flex()
269 .w(px(TILE_WIDTH))
270 .gap(px(8.))
271 .items_center()
272 .child(
273 div()
274 .flex_1()
275 .min_w_0()
276 .truncate()
277 .text_size(px(TITLE_SIZE))
278 .font_weight(FontWeight::SEMIBOLD)
279 .text_color(theme::text())
280 .child(recording.title.clone()),
281 )
282 .when(recording.transcript, |line| {
283 line.child(transcript_chip(index, open_transcript))
284 }),
285 )
286 }
287
288 fn card(
289 call: &CallCard,
290 index: usize,
291 own: bool,
292 actions: CallActions,
293 directory: &Directory,
294 ) -> Div {
295 let CallActions {
296 call_back,
297 join,
298 open_recording,
299 open_transcript,
300 } = actions;
301 let show_join = call.started && join.is_some();
302 let summary = h_flex()
303 .gap(px(8.))
304 .items_center()
114 305 .child(icon_circle(call, own))
115 306 .child(
116 307 v_flex()
@@ -125,11 +316,43 @@ fn card(call: &CallCard, index: usize, own: bool, actions: CallActions) -> Div {
125 316 } else {
126 317 theme::text()
127 318 })
128 .child(call.title),
319 .child(call.title.clone()),
129 320 )
130 .child(detail_line(call, index, own, call_back)),
321 .child(detail_line(call, index, own, call_back))
322 .children(participant_stack(
323 &call.participants,
324 call.extra_participants,
325 directory,
326 own,
327 )),
131 328 )
132 .when(show_join, |card| card.child(join_button(index, join)))
329 .when(show_join, |card| card.child(join_button(index, join)));
330 v_flex()
331 .min_w(px(CARD_MIN_WIDTH))
332 .gap(px(4.))
333 .pt(px(8.))
334 .pr(px(12.))
335 .pb(px(8.))
336 .pl(px(8.))
337 .rounded(px(CARD_RADIUS))
338 .bg(if own {
339 theme::bubble_own()
340 } else {
341 theme::bubble_other()
342 })
343 .child(summary)
344 .children(call.recording.as_ref().map(|recording| {
345 recording_block(recording, index, directory, open_recording, open_transcript)
346 }))
347 }
348
349 pub(super) fn post_call_card(
350 call: &CallCard,
351 index: usize,
352 actions: CallActions,
353 directory: &Directory,
354 ) -> Div {
355 h_flex().child(card(call, index, false, actions, directory))
133 356 }
134 357
135 358 pub(super) fn call_card_row(
@@ -144,7 +367,7 @@ pub(super) fn call_card_row(
144 367 h_flex()
145 368 .w_full()
146 369 .justify_end()
147 .child(card(call, index, true, actions))
370 .child(card(call, index, true, actions, directory))
148 371 } else {
149 372 h_flex()
150 373 .w_full()
@@ -164,7 +387,7 @@ pub(super) fn call_card_row(
164 387 AVATAR_SIZE,
165 388 )),
166 389 )
167 .child(card(call, index, false, actions))
390 .child(card(call, index, false, actions, directory))
168 391 };
169 392 v_flex()
170 393 .w_full()
@@ -7,7 +7,7 @@ use super::message_row::{AVATAR_GAP, AVATAR_SIZE, RowAction, day_separator, new_
7use super::profile_card::opens_profile;
7use super::profile_card::opens_profile;
8use super::widgets::symbol;
8use super::widgets::symbol;
9use crate::data::Directory;
9use crate::data::Directory;
10use crate::rows::{CallCard, CallIcon, MessageRow};
10use crate::rows::{CallCard, CallIcon, CallParticipant, MessageRow, RecordingCard};
11use crate::theme;
11use crate::theme;
12
12
13const SERIES_START_GAP: f32 = 8.;
13const SERIES_START_GAP: f32 = 8.;
@@ -18,10 +18,32 @@ const ICON_SIZE: f32 = 18.;
18const TITLE_SIZE: f32 = 13.;
18const TITLE_SIZE: f32 = 13.;
19const DETAIL_SIZE: f32 = 11.;
19const DETAIL_SIZE: f32 = 11.;
20const JOIN_HEIGHT: f32 = 24.;
20const JOIN_HEIGHT: f32 = 24.;
21const PARTICIPANT_AVATAR: f32 = 20.;
22const PARTICIPANT_GAP: f32 = 2.;
23const TILE_WIDTH: f32 = 288.;
24const TILE_HEIGHT: f32 = 162.;
25const TILE_RADIUS: f32 = 8.;
26const PLAY_CIRCLE: f32 = 40.;
27const PLAY_GLYPH: f32 = 24.;
28const DURATION_INSET: f32 = 6.;
29const CHIP_HEIGHT: f32 = 26.;
21
30
22pub struct CallActions {
31pub struct CallActions {
23 pub call_back: RowAction,
32 pub call_back: RowAction,
24 pub join: RowAction,
33 pub join: RowAction,
34 pub open_recording: RowAction,
35 pub open_transcript: RowAction,
36}
37
38impl CallActions {
39 pub fn none() -> Self {
40 CallActions {
41 call_back: None,
42 join: None,
43 open_recording: None,
44 open_transcript: None,
45 }
46 }
25}
47}
26
48
27fn icon_circle(call: &CallCard, own: bool) -> Div {
49fn icon_circle(call: &CallCard, own: bool) -> Div {
@@ -29,6 +51,12 @@ fn icon_circle(call: &CallCard, own: bool) -> Div {
29 CallIcon::Missed => (theme::red().opacity(0.2), "call_missed", theme::red_soft()),
51 CallIcon::Missed => (theme::red().opacity(0.2), "call_missed", theme::red_soft()),
30 CallIcon::Call => (circle_fill(own), "call", theme::text()),
52 CallIcon::Call => (circle_fill(own), "call", theme::text()),
31 CallIcon::Video => (circle_fill(own), "videocam", theme::text()),
53 CallIcon::Video => (circle_fill(own), "videocam", theme::text()),
54 CallIcon::Record => (
55 circle_fill(own),
56 "radio_button_checked",
57 theme::accent_text(),
58 ),
59 CallIcon::RecordStop => (circle_fill(own), "stop_circle", theme::text()),
32 };
60 };
33 h_flex()
61 h_flex()
34 .size(px(ICON_CIRCLE))
62 .size(px(ICON_CIRCLE))
@@ -94,23 +122,186 @@ fn join_button(index: usize, join: RowAction) -> Stateful<Div> {
94 })
122 })
95}
123}
96
124
97fn card(call: &CallCard, index: usize, own: bool, actions: CallActions) -> Div {
125fn participant_stack(
98 let CallActions { call_back, join } = actions;
126 participants: &[CallParticipant],
99 let show_join = call.started && join.is_some();
127 extra: usize,
128 directory: &Directory,
129 own: bool,
130) -> Option<Div> {
131 if participants.is_empty() {
132 return None;
133 }
134 let tint = if own {
135 theme::own_meta()
136 } else {
137 theme::text_muted()
138 };
139 Some(
140 h_flex()
141 .pt(px(4.))
142 .gap(px(PARTICIPANT_GAP))
143 .items_center()
144 .children(participants.iter().map(|person| {
145 person_avatar(
146 directory,
147 Some(&person.user_id),
148 &person.name,
149 PARTICIPANT_AVATAR,
150 )
151 }))
152 .when(extra > 0, |stack| {
153 stack.child(
154 div()
155 .pl(px(4.))
156 .text_size(px(DETAIL_SIZE))
157 .text_color(tint)
158 .child(format!("+{extra}")),
159 )
160 }),
161 )
162}
163
164fn recording_thumbnail(recording: &RecordingCard, directory: &Directory) -> AnyElement {
165 let image = recording
166 .thumbnail
167 .as_ref()
168 .and_then(|thumbnail| directory.image(&thumbnail.url));
169 match image {
170 Some(entry) => img(entry.path.clone())
171 .size_full()
172 .object_fit(ObjectFit::Cover)
173 .into_any_element(),
174 None => div()
175 .size_full()
176 .bg(theme::code_surface())
177 .into_any_element(),
178 }
179}
180
181fn recording_tile(
182 recording: &RecordingCard,
183 index: usize,
184 directory: &Directory,
185 open_recording: RowAction,
186) -> Stateful<Div> {
187 div()
188 .id(ElementId::Name(format!("call-recording-{index}").into()))
189 .relative()
190 .w(px(TILE_WIDTH))
191 .h(px(TILE_HEIGHT))
192 .flex_none()
193 .rounded(px(TILE_RADIUS))
194 .overflow_hidden()
195 .cursor_pointer()
196 .hover(|tile| tile.opacity(0.92))
197 .child(recording_thumbnail(recording, directory))
198 .child(
199 h_flex()
200 .absolute()
201 .inset_0()
202 .items_center()
203 .justify_center()
204 .child(
205 h_flex()
206 .size(px(PLAY_CIRCLE))
207 .items_center()
208 .justify_center()
209 .rounded_full()
210 .bg(black().opacity(0.55))
211 .child(symbol("play_arrow", PLAY_GLYPH, theme::white())),
212 ),
213 )
214 .children(recording.duration.clone().map(|duration| {
215 div()
216 .absolute()
217 .bottom(px(DURATION_INSET))
218 .right(px(DURATION_INSET))
219 .px(px(6.))
220 .py(px(1.))
221 .rounded(px(4.))
222 .bg(black().opacity(0.65))
223 .text_size(px(DETAIL_SIZE))
224 .font_weight(FontWeight::SEMIBOLD)
225 .text_color(theme::white())
226 .child(duration)
227 }))
228 .when_some(open_recording, |tile, open| {
229 tile.on_click(move |_, _, cx| open(cx))
230 })
231}
232
233fn transcript_chip(index: usize, open_transcript: RowAction) -> Stateful<Div> {
100 h_flex()
234 h_flex()
101 .min_w(px(CARD_MIN_WIDTH))
235 .id(ElementId::Name(format!("call-transcript-{index}").into()))
102 .gap(px(8.))
236 .h(px(CHIP_HEIGHT))
237 .px(px(10.))
238 .gap(px(6.))
239 .flex_none()
103 .items_center()
240 .items_center()
104 .pt(px(8.))
241 .rounded(px(6.))
105 .pr(px(12.))
242 .border_1()
106 .pb(px(8.))
243 .border_color(theme::border())
107 .pl(px(8.))
244 .text_size(px(DETAIL_SIZE + 1.))
108 .rounded(px(CARD_RADIUS))
245 .font_weight(FontWeight::SEMIBOLD)
109 .bg(if own {
246 .text_color(theme::text())
110 theme::bubble_own()
247 .cursor_pointer()
111 } else {
248 .hover(|chip| chip.bg(theme::popup_hover()))
112 theme::bubble_other()
249 .child(symbol("description", 15., theme::accent_text()))
250 .child("Transcript")
251 .when_some(open_transcript, |chip, open| {
252 chip.on_click(move |_, _, cx| open(cx))
113 })
253 })
254}
255
256fn recording_block(
257 recording: &RecordingCard,
258 index: usize,
259 directory: &Directory,
260 open_recording: RowAction,
261 open_transcript: RowAction,
262) -> Div {
263 v_flex()
264 .pt(px(4.))
265 .gap(px(8.))
266 .child(recording_tile(recording, index, directory, open_recording))
267 .child(
268 h_flex()
269 .w(px(TILE_WIDTH))
270 .gap(px(8.))
271 .items_center()
272 .child(
273 div()
274 .flex_1()
275 .min_w_0()
276 .truncate()
277 .text_size(px(TITLE_SIZE))
278 .font_weight(FontWeight::SEMIBOLD)
279 .text_color(theme::text())
280 .child(recording.title.clone()),
281 )
282 .when(recording.transcript, |line| {
283 line.child(transcript_chip(index, open_transcript))
284 }),
285 )
286}
287
288fn card(
289 call: &CallCard,
290 index: usize,
291 own: bool,
292 actions: CallActions,
293 directory: &Directory,
294) -> Div {
295 let CallActions {
296 call_back,
297 join,
298 open_recording,
299 open_transcript,
300 } = actions;
301 let show_join = call.started && join.is_some();
302 let summary = h_flex()
303 .gap(px(8.))
304 .items_center()
114 .child(icon_circle(call, own))
305 .child(icon_circle(call, own))
115 .child(
306 .child(
116 v_flex()
307 v_flex()
@@ -125,11 +316,43 @@ fn card(call: &CallCard, index: usize, own: bool, actions: CallActions) -> Div {
125 } else {
316 } else {
126 theme::text()
317 theme::text()
127 })
318 })
128 .child(call.title),
319 .child(call.title.clone()),
129 )
320 )
130 .child(detail_line(call, index, own, call_back)),
321 .child(detail_line(call, index, own, call_back))
322 .children(participant_stack(
323 &call.participants,
324 call.extra_participants,
325 directory,
326 own,
327 )),
131 )
328 )
132 .when(show_join, |card| card.child(join_button(index, join)))
329 .when(show_join, |card| card.child(join_button(index, join)));
330 v_flex()
331 .min_w(px(CARD_MIN_WIDTH))
332 .gap(px(4.))
333 .pt(px(8.))
334 .pr(px(12.))
335 .pb(px(8.))
336 .pl(px(8.))
337 .rounded(px(CARD_RADIUS))
338 .bg(if own {
339 theme::bubble_own()
340 } else {
341 theme::bubble_other()
342 })
343 .child(summary)
344 .children(call.recording.as_ref().map(|recording| {
345 recording_block(recording, index, directory, open_recording, open_transcript)
346 }))
347}
348
349pub(super) fn post_call_card(
350 call: &CallCard,
351 index: usize,
352 actions: CallActions,
353 directory: &Directory,
354) -> Div {
355 h_flex().child(card(call, index, false, actions, directory))
133}
356}
134
357
135pub(super) fn call_card_row(
358pub(super) fn call_card_row(
@@ -144,7 +367,7 @@ pub(super) fn call_card_row(
144 h_flex()
367 h_flex()
145 .w_full()
368 .w_full()
146 .justify_end()
369 .justify_end()
147 .child(card(call, index, true, actions))
370 .child(card(call, index, true, actions, directory))
148 } else {
371 } else {
149 h_flex()
372 h_flex()
150 .w_full()
373 .w_full()
@@ -164,7 +387,7 @@ pub(super) fn call_card_row(
164 AVATAR_SIZE,
387 AVATAR_SIZE,
165 )),
388 )),
166 )
389 )
167 .child(card(call, index, false, actions))
390 .child(card(call, index, false, actions, directory))
168 };
391 };
169 v_flex()
392 v_flex()
170 .w_full()
393 .w_full()
crates/app/src/views/conversation/recap.rs +24 −0
@@ -155,6 +155,30 @@ impl ConversationView {
155 155 .detach();
156 156 }
157 157
158 /// Teams opens a meeting chat recording in the Recap tab at its occurrence and plays any
159 /// other recording (channel meetings) in the browser.
160 pub(super) fn open_recording(
161 &mut self,
162 message_id: &str,
163 url: Option<&str>,
164 cx: &mut Context<Self>,
165 ) {
166 let occurrence = self
167 .occurrences()
168 .iter()
169 .position(|occurrence| occurrence.message_id == message_id);
170 match (occurrence, url) {
171 (Some(index), _) if self.is_meeting_chat(cx) => {
172 self.select_pane(ChannelPane::Recap, cx);
173 if self.recap.selected != index {
174 self.select_occurrence(index, cx);
175 }
176 }
177 (_, Some(url)) => cx.open_url(url),
178 (_, None) => {}
179 }
180 }
181
158 182 pub(super) fn open_recap_pane(&mut self, cx: &mut Context<Self>) {
159 183 self.refresh_shared_items(cx);
160 184 if matches!(self.recap.details, Load::Loading) {
@@ -155,6 +155,30 @@ impl ConversationView {
155 .detach();
155 .detach();
156 }
156 }
157
157
158 /// Teams opens a meeting chat recording in the Recap tab at its occurrence and plays any
159 /// other recording (channel meetings) in the browser.
160 pub(super) fn open_recording(
161 &mut self,
162 message_id: &str,
163 url: Option<&str>,
164 cx: &mut Context<Self>,
165 ) {
166 let occurrence = self
167 .occurrences()
168 .iter()
169 .position(|occurrence| occurrence.message_id == message_id);
170 match (occurrence, url) {
171 (Some(index), _) if self.is_meeting_chat(cx) => {
172 self.select_pane(ChannelPane::Recap, cx);
173 if self.recap.selected != index {
174 self.select_occurrence(index, cx);
175 }
176 }
177 (_, Some(url)) => cx.open_url(url),
178 (_, None) => {}
179 }
180 }
181
158 pub(super) fn open_recap_pane(&mut self, cx: &mut Context<Self>) {
182 pub(super) fn open_recap_pane(&mut self, cx: &mut Context<Self>) {
159 self.refresh_shared_items(cx);
183 self.refresh_shared_items(cx);
160 if matches!(self.recap.details, Load::Loading) {
184 if matches!(self.recap.details, Load::Loading) {
crates/app/src/views/conversation/render_env.rs +27 −6
@@ -14,7 +14,7 @@ use super::{ConversationView, HoverSlot, PENDING_KEY_PREFIX};
14 14 use crate::agent_api::agent_label;
15 15 use crate::agents::AgentRun;
16 16 use crate::app_state::AppState;
17 use crate::rows::{Delivery, MessageRow, PostRow};
17 use crate::rows::{Delivery, MessageRow, PostRow, RecordingCard};
18 18 use crate::scheduled_rows::SCHEDULED_KEY_PREFIX;
19 19 use crate::translation::TranslationLine;
20 20 use crate::views::adaptive_card::{ensure_cards_inputs, request_card_refreshes};
@@ -68,6 +68,12 @@ impl RenderEnv {
68 68 .iter()
69 69 .cloned()
70 70 .chain(message.link_preview.as_ref().and_then(LinkPreview::image))
71 .chain(
72 message
73 .call
74 .as_ref()
75 .and_then(|call| call.recording.as_ref()?.thumbnail.clone()),
76 )
71 77 .filter(|image| self.app.read(cx).directory.image(&image.url).is_none())
72 78 .collect();
73 79 if !missing_images.is_empty() {
@@ -303,10 +309,7 @@ impl RenderEnv {
303 309
304 310 fn call_actions(&self, message: &MessageRow, cx: &App) -> CallActions {
305 311 let Some(call) = &message.call else {
306 return CallActions {
307 call_back: None,
308 join: None,
309 };
312 return CallActions::none();
310 313 };
311 314 let app = self.app.clone();
312 315 let conversation_id = message.conversation_id.clone();
@@ -324,7 +327,25 @@ impl RenderEnv {
324 327 });
325 328 })
326 329 });
327 CallActions { call_back, join }
330 let open = |recording: &RecordingCard| {
331 let (view, message_id, url) = (
332 self.view.clone(),
333 recording.message_id.clone(),
334 recording.url.clone(),
335 );
336 boxed(move |cx| {
337 view.update(cx, |this, cx| {
338 this.open_recording(&message_id, url.as_deref(), cx)
339 })
340 .ok();
341 })
342 };
343 CallActions {
344 call_back,
345 join,
346 open_recording: call.recording.as_ref().map(open),
347 open_transcript: call.recording.as_ref().map(open),
348 }
328 349 }
329 350
330 351 fn translation_actions(&self, message: &MessageRow) -> Option<TranslationActions> {
@@ -14,7 +14,7 @@ use super::{ConversationView, HoverSlot, PENDING_KEY_PREFIX};
14use crate::agent_api::agent_label;
14use crate::agent_api::agent_label;
15use crate::agents::AgentRun;
15use crate::agents::AgentRun;
16use crate::app_state::AppState;
16use crate::app_state::AppState;
17use crate::rows::{Delivery, MessageRow, PostRow};
17use crate::rows::{Delivery, MessageRow, PostRow, RecordingCard};
18use crate::scheduled_rows::SCHEDULED_KEY_PREFIX;
18use crate::scheduled_rows::SCHEDULED_KEY_PREFIX;
19use crate::translation::TranslationLine;
19use crate::translation::TranslationLine;
20use crate::views::adaptive_card::{ensure_cards_inputs, request_card_refreshes};
20use crate::views::adaptive_card::{ensure_cards_inputs, request_card_refreshes};
@@ -68,6 +68,12 @@ impl RenderEnv {
68 .iter()
68 .iter()
69 .cloned()
69 .cloned()
70 .chain(message.link_preview.as_ref().and_then(LinkPreview::image))
70 .chain(message.link_preview.as_ref().and_then(LinkPreview::image))
71 .chain(
72 message
73 .call
74 .as_ref()
75 .and_then(|call| call.recording.as_ref()?.thumbnail.clone()),
76 )
71 .filter(|image| self.app.read(cx).directory.image(&image.url).is_none())
77 .filter(|image| self.app.read(cx).directory.image(&image.url).is_none())
72 .collect();
78 .collect();
73 if !missing_images.is_empty() {
79 if !missing_images.is_empty() {
@@ -303,10 +309,7 @@ impl RenderEnv {
303
309
304 fn call_actions(&self, message: &MessageRow, cx: &App) -> CallActions {
310 fn call_actions(&self, message: &MessageRow, cx: &App) -> CallActions {
305 let Some(call) = &message.call else {
311 let Some(call) = &message.call else {
306 return CallActions {
312 return CallActions::none();
307 call_back: None,
308 join: None,
309 };
310 };
313 };
311 let app = self.app.clone();
314 let app = self.app.clone();
312 let conversation_id = message.conversation_id.clone();
315 let conversation_id = message.conversation_id.clone();
@@ -324,7 +327,25 @@ impl RenderEnv {
324 });
327 });
325 })
328 })
326 });
329 });
327 CallActions { call_back, join }
330 let open = |recording: &RecordingCard| {
331 let (view, message_id, url) = (
332 self.view.clone(),
333 recording.message_id.clone(),
334 recording.url.clone(),
335 );
336 boxed(move |cx| {
337 view.update(cx, |this, cx| {
338 this.open_recording(&message_id, url.as_deref(), cx)
339 })
340 .ok();
341 })
342 };
343 CallActions {
344 call_back,
345 join,
346 open_recording: call.recording.as_ref().map(open),
347 open_transcript: call.recording.as_ref().map(open),
348 }
328 }
349 }
329
350
330 fn translation_actions(&self, message: &MessageRow) -> Option<TranslationActions> {
351 fn translation_actions(&self, message: &MessageRow) -> Option<TranslationActions> {
crates/app/src/views/post_card.rs +11 −2
@@ -6,6 +6,7 @@ use gpui_kit::*;
6 6 use super::adaptive_card::cards_view;
7 7 use super::attachments::{attachments_view, message_body};
8 8 use super::avatar::{bot_avatar, person_avatar};
9 use super::call_card::{CallActions, post_call_card};
9 10 use super::link_preview::{link_preview_card, meeting_join_chip};
10 11 use super::message_actions::message_toolbar;
11 12 use super::message_row::{BODY_SIZE, RowActions, delivery_note, forwarded_header, has_text};
@@ -181,7 +182,7 @@ fn message_block(
181 182 row: &MessageRow,
182 183 index: usize,
183 184 role: Role,
184 actions: RowActions,
185 mut actions: RowActions,
185 186 directory: &Directory,
186 187 cx: &App,
187 188 ) -> Stateful<Div> {
@@ -199,7 +200,15 @@ fn message_block(
199 200 None => person_avatar(directory, row.sender_id.as_deref(), &row.author, size),
200 201 };
201 202 let profile_user = row.sender_id.as_deref().filter(|_| actions.bot.is_none());
202 let content = message_content(row, index, directory, &actions, cx);
203 let content = match &row.call {
204 Some(call) => v_flex().child(post_call_card(
205 call,
206 index,
207 std::mem::replace(&mut actions.call, CallActions::none()),
208 directory,
209 )),
210 None => message_content(row, index, directory, &actions, cx),
211 };
203 212 let saved = actions.saved;
204 213 let RowActions {
205 214 delivery,
@@ -6,6 +6,7 @@ use gpui_kit::*;
6use super::adaptive_card::cards_view;
6use super::adaptive_card::cards_view;
7use super::attachments::{attachments_view, message_body};
7use super::attachments::{attachments_view, message_body};
8use super::avatar::{bot_avatar, person_avatar};
8use super::avatar::{bot_avatar, person_avatar};
9use super::call_card::{CallActions, post_call_card};
9use super::link_preview::{link_preview_card, meeting_join_chip};
10use super::link_preview::{link_preview_card, meeting_join_chip};
10use super::message_actions::message_toolbar;
11use super::message_actions::message_toolbar;
11use super::message_row::{BODY_SIZE, RowActions, delivery_note, forwarded_header, has_text};
12use super::message_row::{BODY_SIZE, RowActions, delivery_note, forwarded_header, has_text};
@@ -181,7 +182,7 @@ fn message_block(
181 row: &MessageRow,
182 row: &MessageRow,
182 index: usize,
183 index: usize,
183 role: Role,
184 role: Role,
184 actions: RowActions,
185 mut actions: RowActions,
185 directory: &Directory,
186 directory: &Directory,
186 cx: &App,
187 cx: &App,
187) -> Stateful<Div> {
188) -> Stateful<Div> {
@@ -199,7 +200,15 @@ fn message_block(
199 None => person_avatar(directory, row.sender_id.as_deref(), &row.author, size),
200 None => person_avatar(directory, row.sender_id.as_deref(), &row.author, size),
200 };
201 };
201 let profile_user = row.sender_id.as_deref().filter(|_| actions.bot.is_none());
202 let profile_user = row.sender_id.as_deref().filter(|_| actions.bot.is_none());
202 let content = message_content(row, index, directory, &actions, cx);
203 let content = match &row.call {
204 Some(call) => v_flex().child(post_call_card(
205 call,
206 index,
207 std::mem::replace(&mut actions.call, CallActions::none()),
208 directory,
209 )),
210 None => message_content(row, index, directory, &actions, cx),
211 };
203 let saved = actions.saved;
212 let saved = actions.saved;
204 let RowActions {
213 let RowActions {
205 delivery,
214 delivery,
crates/core/src/call_event.rs +259 −16
@@ -4,14 +4,25 @@ use store::MessageRecord;
4 4
5 5 const STARTED_TYPE: &str = "#microsoft.graph.callStartedEventMessageDetail";
6 6 const ENDED_TYPE: &str = "#microsoft.graph.callEndedEventMessageDetail";
7 const RECORDING_TYPE: &str = "#microsoft.graph.callRecordingEventMessageDetail";
8 const TRANSCRIPT_TYPE: &str = "#microsoft.graph.callTranscriptEventMessageDetail";
9 const UNRESOLVED_NAME_PREFIX: &str = "orgid:";
10 const RECORDING_SUFFIX: &str = "-Meeting Recording";
11 const GRAPH_SHARES: &str = "https://graph.microsoft.com/v1.0/shares/";
12 const THUMBNAIL_PATH: &str = "/driveItem/thumbnails/0/large/content";
13 const SHAREPOINT_HOST: &str = ".sharepoint.com/";
7 14 const SECONDS_PER_MINUTE: u64 = 60;
8 15 const SECONDS_PER_HOUR: u64 = 3600;
9 16 const SECONDS_PER_DAY: u64 = 86_400;
10 17
11 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
18 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
12 19 pub enum CallPhase {
13 20 Started,
14 21 Ended,
22 RecordingStarted,
23 RecordingStopped,
24 RecordingSaved,
25 TranscriptStarted,
15 26 }
16 27
17 28 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@@ -29,6 +40,62 @@ pub struct CallEvent {
29 40 pub initiator_id: Option<String>,
30 41 pub initiator_name: Option<String>,
31 42 pub participant_ids: Vec<String>,
43 #[serde(default)]
44 pub participant_names: Vec<String>,
45 #[serde(default)]
46 pub recording: Option<Recording>,
47 }
48
49 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
50 pub struct Recording {
51 pub name: Option<String>,
52 pub url: Option<String>,
53 pub organizer_id: Option<String>,
54 }
55
56 impl Recording {
57 pub fn title(&self) -> Option<String> {
58 let name = self.name.as_deref()?;
59 let stem = name.strip_suffix(".mp4").unwrap_or(name);
60 let stem = stem.strip_suffix(RECORDING_SUFFIX).unwrap_or(stem);
61 let title = match stem.rsplit_once('-') {
62 Some((title, stamp)) if is_recording_stamp(stamp) => title,
63 _ => stem,
64 };
65 Some(title.trim().to_owned()).filter(|title| !title.is_empty())
66 }
67
68 pub fn thumbnail_url(&self) -> Option<String> {
69 let url = self
70 .url
71 .as_deref()
72 .filter(|url| url.contains(SHAREPOINT_HOST))?;
73 Some(format!(
74 "{GRAPH_SHARES}{}{THUMBNAIL_PATH}",
75 chatsvc::transcripts::share_id(url)
76 ))
77 }
78 }
79
80 fn is_recording_stamp(stamp: &str) -> bool {
81 let digits = stamp.strip_suffix("UTC").unwrap_or(stamp);
82 digits.split_once('_').is_some_and(|(date, time)| {
83 date.len() == 8
84 && time.len() == 6
85 && date
86 .bytes()
87 .chain(time.bytes())
88 .all(|byte| byte.is_ascii_digit())
89 })
90 }
91
92 fn recording_phase(detail: &Value) -> Option<CallPhase> {
93 match detail.get("callRecordingStatus").and_then(Value::as_str)? {
94 "initial" => Some(CallPhase::RecordingStarted),
95 "chunkFinished" => Some(CallPhase::RecordingStopped),
96 "success" => Some(CallPhase::RecordingSaved),
97 _ => None,
98 }
32 99 }
33 100
34 101 impl CallEvent {
@@ -36,8 +103,26 @@ impl CallEvent {
36 103 let phase = match detail.get("@odata.type")?.as_str()? {
37 104 STARTED_TYPE => CallPhase::Started,
38 105 ENDED_TYPE => CallPhase::Ended,
106 RECORDING_TYPE => recording_phase(detail)?,
107 TRANSCRIPT_TYPE => CallPhase::TranscriptStarted,
39 108 _ => return None,
40 109 };
110 let participants: Vec<(String, Option<String>)> = detail
111 .get("callParticipants")
112 .and_then(Value::as_array)
113 .map(|participants| {
114 participants
115 .iter()
116 .filter_map(|participant| identity(participant.get("participant")?))
117 .collect()
118 })
119 .unwrap_or_default();
120 let recording =
121 (detail.get("@odata.type")?.as_str()? == RECORDING_TYPE).then(|| Recording {
122 name: text_at(detail, "/callRecordingDisplayName"),
123 url: text_at(detail, "/callRecordingUrl"),
124 organizer_id: text_at(detail, "/meetingOrganizer/user/id"),
125 });
41 126 let call_type = match detail.get("callEventType").and_then(Value::as_str) {
42 127 Some("meeting") => CallType::Meeting,
43 128 _ => CallType::Call,
@@ -48,20 +133,17 @@ impl CallEvent {
48 133 call_id: detail.get("callId")?.as_str()?.to_owned(),
49 134 duration_seconds: detail
50 135 .get("callDuration")
136 .or_else(|| detail.get("callRecordingDuration"))
51 137 .and_then(Value::as_str)
52 138 .and_then(parse_duration_seconds),
53 139 initiator_id: text_at(detail, "/initiator/user/id"),
54 initiator_name: text_at(detail, "/initiator/user/displayName"),
55 participant_ids: detail
56 .get("callParticipants")
57 .and_then(Value::as_array)
58 .map(|participants| {
59 participants
60 .iter()
61 .filter_map(|participant| identity_id(participant.get("participant")?))
62 .collect()
63 })
64 .unwrap_or_default(),
140 initiator_name: person_name(detail.pointer("/initiator/user")),
141 participant_names: participants
142 .iter()
143 .map(|(_, name)| name.clone().unwrap_or_default())
144 .collect(),
145 participant_ids: participants.into_iter().map(|(id, _)| id).collect(),
146 recording,
65 147 })
66 148 }
67 149
@@ -85,6 +167,16 @@ impl CallEvent {
85 167 && !self.initiated_by(my_user_id)
86 168 }
87 169
170 pub fn is_recording(&self) -> bool {
171 matches!(
172 self.phase,
173 CallPhase::RecordingStarted
174 | CallPhase::RecordingStopped
175 | CallPhase::RecordingSaved
176 | CallPhase::TranscriptStarted
177 )
178 }
179
88 180 pub fn title(&self, missed: bool) -> &'static str {
89 181 match (self.phase, self.call_type) {
90 182 _ if missed => "Missed call",
@@ -92,14 +184,20 @@ impl CallEvent {
92 184 (CallPhase::Ended, CallType::Call) => "Call ended",
93 185 (CallPhase::Started, CallType::Meeting) => "Meeting started",
94 186 (CallPhase::Ended, CallType::Meeting) => "Meeting ended",
187 (CallPhase::RecordingStarted, _) => "Recording has started",
188 (CallPhase::RecordingStopped, _) => "Recording stopped",
189 (CallPhase::RecordingSaved, _) => "Recording is ready",
190 (CallPhase::TranscriptStarted, _) => "Transcription has started",
95 191 }
96 192 }
97 193
98 194 pub fn plain_text(&self) -> String {
99 195 let title = self.title(false);
100 196 match self.duration_seconds {
101 Some(seconds) => format!("{title} {}", format_duration(seconds)),
102 None => title.to_owned(),
197 Some(seconds) if !self.is_recording() => {
198 format!("{title} {}", format_duration(seconds))
199 }
200 _ => title.to_owned(),
103 201 }
104 202 }
105 203 }
@@ -108,11 +206,15 @@ pub fn call_event(record: &MessageRecord) -> Option<CallEvent> {
108 206 CallEvent::from_json(record.call_event_json.as_deref()?)
109 207 }
110 208
111 fn identity_id(identity_set: &Value) -> Option<String> {
209 fn identity(identity_set: &Value) -> Option<(String, Option<String>)> {
112 210 identity_set
113 211 .as_object()?
114 212 .values()
115 .find_map(|identity| text_at(identity, "/id"))
213 .find_map(|identity| Some((text_at(identity, "/id")?, person_name(Some(identity)))))
214 }
215
216 fn person_name(identity: Option<&Value>) -> Option<String> {
217 text_at(identity?, "/displayName").filter(|name| !name.starts_with(UNRESOLVED_NAME_PREFIX))
116 218 }
117 219
118 220 fn text_at(value: &Value, pointer: &str) -> Option<String> {
@@ -172,3 +274,144 @@ pub fn format_duration(seconds: u64) -> String {
172 274 }
173 275 parts.join(" ")
174 276 }
277
278 #[cfg(test)]
279 mod tests {
280 use super::*;
281
282 fn fixture(name: &str) -> Value {
283 let path = format!(
284 "{}/tests/fixtures/call_events/{name}",
285 env!("CARGO_MANIFEST_DIR")
286 );
287 serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
288 }
289
290 fn meeting_chat_events() -> Vec<CallEvent> {
291 fixture("meeting_chat_recording.json")["value"]
292 .as_array()
293 .unwrap()
294 .iter()
295 .rev()
296 .map(|message| CallEvent::from_graph(&message["eventDetail"]).unwrap())
297 .collect()
298 }
299
300 #[test]
301 fn recorded_meeting_yields_every_phase_in_order() {
302 let phases: Vec<CallPhase> = meeting_chat_events()
303 .iter()
304 .map(|event| event.phase)
305 .collect();
306 assert_eq!(
307 phases,
308 [
309 CallPhase::Started,
310 CallPhase::RecordingStarted,
311 CallPhase::RecordingStarted,
312 CallPhase::TranscriptStarted,
313 CallPhase::RecordingStopped,
314 CallPhase::Ended,
315 CallPhase::RecordingStopped,
316 CallPhase::RecordingSaved,
317 ]
318 );
319 let call_ids: std::collections::HashSet<String> = meeting_chat_events()
320 .into_iter()
321 .map(|event| event.call_id)
322 .collect();
323 assert_eq!(call_ids.len(), 1);
324 }
325
326 #[test]
327 fn saved_recording_keeps_link_title_duration_and_owner() {
328 let saved = meeting_chat_events().pop().unwrap();
329 let recording = saved.recording.as_ref().unwrap();
330 assert_eq!(saved.duration_seconds, Some(814));
331 assert_eq!(recording.title().as_deref(), Some("Weekly team meeting"));
332 assert!(recording.url.as_deref().unwrap().contains("/:v:/"));
333 assert_eq!(
334 recording.organizer_id.as_deref(),
335 Some("00000000-0000-4000-8000-000000000002")
336 );
337 assert_eq!(saved.plain_text(), "Recording is ready");
338 let thumbnail = recording.thumbnail_url().unwrap();
339 assert!(thumbnail.starts_with("https://graph.microsoft.com/v1.0/shares/u!"));
340 assert!(thumbnail.ends_with("/driveItem/thumbnails/0/large/content"));
341 }
342
343 #[test]
344 fn started_recording_has_no_link_and_names_its_initiator_by_id() {
345 let started = &meeting_chat_events()[1];
346 assert_eq!(started.recording.as_ref().unwrap().url, None);
347 assert_eq!(started.recording.as_ref().unwrap().thumbnail_url(), None);
348 assert_eq!(started.duration_seconds, Some(0));
349 assert!(started.initiator_id.is_some());
350 assert_eq!(started.initiator_name, None);
351 }
352
353 #[test]
354 fn ended_meeting_keeps_participant_names_beside_their_ids() {
355 let ended = meeting_chat_events()
356 .into_iter()
357 .find(|event| event.phase == CallPhase::Ended)
358 .unwrap();
359 assert_eq!(ended.call_type, CallType::Meeting);
360 assert_eq!(ended.duration_seconds, Some(988));
361 assert_eq!(ended.participant_ids.len(), ended.participant_names.len());
362 assert_eq!(ended.participant_names[0], "");
363 assert_eq!(ended.participant_names[1], "Person 1");
364 assert_eq!(ended.recording, None);
365 }
366
367 #[test]
368 fn channel_meet_now_root_is_a_started_meeting() {
369 let thread = fixture("channel_adhoc_meeting.json");
370 let root = CallEvent::from_graph(&thread["eventDetail"]).unwrap();
371 let ended = CallEvent::from_graph(&thread["replies"][0]["eventDetail"]).unwrap();
372 assert_eq!(root.phase, CallPhase::Started);
373 assert_eq!(root.call_type, CallType::Meeting);
374 assert_eq!(ended.call_id, root.call_id);
375 assert_eq!(ended.duration_seconds, Some(11_975));
376 assert_eq!(ended.initiator_name, None);
377 }
378
379 #[test]
380 fn unknown_recording_status_is_not_an_event() {
381 let detail = serde_json::json!({
382 "@odata.type": RECORDING_TYPE,
383 "callId": "c",
384 "callRecordingStatus": "failure",
385 });
386 assert_eq!(CallEvent::from_graph(&detail), None);
387 }
388
389 #[test]
390 fn events_stored_before_recordings_still_load() {
391 let stored = r#"{"phase":"Ended","call_type":"Call","call_id":"c","duration_seconds":5,"initiator_id":"u","initiator_name":null,"participant_ids":["u"]}"#;
392 let event = CallEvent::from_json(stored).unwrap();
393 assert!(event.participant_names.is_empty());
394 assert_eq!(event.recording, None);
395 }
396
397 #[test]
398 fn recording_title_drops_the_stamp_only_when_it_is_one() {
399 let title = |name: &str| {
400 Recording {
401 name: Some(name.to_owned()),
402 url: None,
403 organizer_id: None,
404 }
405 .title()
406 };
407 assert_eq!(
408 title("Sync-20261012_140227UTC-Meeting Recording.mp4").as_deref(),
409 Some("Sync")
410 );
411 assert_eq!(
412 title("Q3-plan-Meeting Recording.mp4").as_deref(),
413 Some("Q3-plan")
414 );
415 assert_eq!(title("demo.mp4").as_deref(), Some("demo"));
416 }
417 }
@@ -4,14 +4,25 @@ use store::MessageRecord;
4
4
5const STARTED_TYPE: &str = "#microsoft.graph.callStartedEventMessageDetail";
5const STARTED_TYPE: &str = "#microsoft.graph.callStartedEventMessageDetail";
6const ENDED_TYPE: &str = "#microsoft.graph.callEndedEventMessageDetail";
6const ENDED_TYPE: &str = "#microsoft.graph.callEndedEventMessageDetail";
7const RECORDING_TYPE: &str = "#microsoft.graph.callRecordingEventMessageDetail";
8const TRANSCRIPT_TYPE: &str = "#microsoft.graph.callTranscriptEventMessageDetail";
9const UNRESOLVED_NAME_PREFIX: &str = "orgid:";
10const RECORDING_SUFFIX: &str = "-Meeting Recording";
11const GRAPH_SHARES: &str = "https://graph.microsoft.com/v1.0/shares/";
12const THUMBNAIL_PATH: &str = "/driveItem/thumbnails/0/large/content";
13const SHAREPOINT_HOST: &str = ".sharepoint.com/";
7const SECONDS_PER_MINUTE: u64 = 60;
14const SECONDS_PER_MINUTE: u64 = 60;
8const SECONDS_PER_HOUR: u64 = 3600;
15const SECONDS_PER_HOUR: u64 = 3600;
9const SECONDS_PER_DAY: u64 = 86_400;
16const SECONDS_PER_DAY: u64 = 86_400;
10
17
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
12pub enum CallPhase {
19pub enum CallPhase {
13 Started,
20 Started,
14 Ended,
21 Ended,
22 RecordingStarted,
23 RecordingStopped,
24 RecordingSaved,
25 TranscriptStarted,
15}
26}
16
27
17#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
28#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@@ -29,6 +40,62 @@ pub struct CallEvent {
29 pub initiator_id: Option<String>,
40 pub initiator_id: Option<String>,
30 pub initiator_name: Option<String>,
41 pub initiator_name: Option<String>,
31 pub participant_ids: Vec<String>,
42 pub participant_ids: Vec<String>,
43 #[serde(default)]
44 pub participant_names: Vec<String>,
45 #[serde(default)]
46 pub recording: Option<Recording>,
47}
48
49#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
50pub struct Recording {
51 pub name: Option<String>,
52 pub url: Option<String>,
53 pub organizer_id: Option<String>,
54}
55
56impl Recording {
57 pub fn title(&self) -> Option<String> {
58 let name = self.name.as_deref()?;
59 let stem = name.strip_suffix(".mp4").unwrap_or(name);
60 let stem = stem.strip_suffix(RECORDING_SUFFIX).unwrap_or(stem);
61 let title = match stem.rsplit_once('-') {
62 Some((title, stamp)) if is_recording_stamp(stamp) => title,
63 _ => stem,
64 };
65 Some(title.trim().to_owned()).filter(|title| !title.is_empty())
66 }
67
68 pub fn thumbnail_url(&self) -> Option<String> {
69 let url = self
70 .url
71 .as_deref()
72 .filter(|url| url.contains(SHAREPOINT_HOST))?;
73 Some(format!(
74 "{GRAPH_SHARES}{}{THUMBNAIL_PATH}",
75 chatsvc::transcripts::share_id(url)
76 ))
77 }
78}
79
80fn is_recording_stamp(stamp: &str) -> bool {
81 let digits = stamp.strip_suffix("UTC").unwrap_or(stamp);
82 digits.split_once('_').is_some_and(|(date, time)| {
83 date.len() == 8
84 && time.len() == 6
85 && date
86 .bytes()
87 .chain(time.bytes())
88 .all(|byte| byte.is_ascii_digit())
89 })
90}
91
92fn recording_phase(detail: &Value) -> Option<CallPhase> {
93 match detail.get("callRecordingStatus").and_then(Value::as_str)? {
94 "initial" => Some(CallPhase::RecordingStarted),
95 "chunkFinished" => Some(CallPhase::RecordingStopped),
96 "success" => Some(CallPhase::RecordingSaved),
97 _ => None,
98 }
32}
99}
33
100
34impl CallEvent {
101impl CallEvent {
@@ -36,8 +103,26 @@ impl CallEvent {
36 let phase = match detail.get("@odata.type")?.as_str()? {
103 let phase = match detail.get("@odata.type")?.as_str()? {
37 STARTED_TYPE => CallPhase::Started,
104 STARTED_TYPE => CallPhase::Started,
38 ENDED_TYPE => CallPhase::Ended,
105 ENDED_TYPE => CallPhase::Ended,
106 RECORDING_TYPE => recording_phase(detail)?,
107 TRANSCRIPT_TYPE => CallPhase::TranscriptStarted,
39 _ => return None,
108 _ => return None,
40 };
109 };
110 let participants: Vec<(String, Option<String>)> = detail
111 .get("callParticipants")
112 .and_then(Value::as_array)
113 .map(|participants| {
114 participants
115 .iter()
116 .filter_map(|participant| identity(participant.get("participant")?))
117 .collect()
118 })
119 .unwrap_or_default();
120 let recording =
121 (detail.get("@odata.type")?.as_str()? == RECORDING_TYPE).then(|| Recording {
122 name: text_at(detail, "/callRecordingDisplayName"),
123 url: text_at(detail, "/callRecordingUrl"),
124 organizer_id: text_at(detail, "/meetingOrganizer/user/id"),
125 });
41 let call_type = match detail.get("callEventType").and_then(Value::as_str) {
126 let call_type = match detail.get("callEventType").and_then(Value::as_str) {
42 Some("meeting") => CallType::Meeting,
127 Some("meeting") => CallType::Meeting,
43 _ => CallType::Call,
128 _ => CallType::Call,
@@ -48,20 +133,17 @@ impl CallEvent {
48 call_id: detail.get("callId")?.as_str()?.to_owned(),
133 call_id: detail.get("callId")?.as_str()?.to_owned(),
49 duration_seconds: detail
134 duration_seconds: detail
50 .get("callDuration")
135 .get("callDuration")
136 .or_else(|| detail.get("callRecordingDuration"))
51 .and_then(Value::as_str)
137 .and_then(Value::as_str)
52 .and_then(parse_duration_seconds),
138 .and_then(parse_duration_seconds),
53 initiator_id: text_at(detail, "/initiator/user/id"),
139 initiator_id: text_at(detail, "/initiator/user/id"),
54 initiator_name: text_at(detail, "/initiator/user/displayName"),
140 initiator_name: person_name(detail.pointer("/initiator/user")),
55 participant_ids: detail
141 participant_names: participants
56 .get("callParticipants")
142 .iter()
57 .and_then(Value::as_array)
143 .map(|(_, name)| name.clone().unwrap_or_default())
58 .map(|participants| {
144 .collect(),
59 participants
145 participant_ids: participants.into_iter().map(|(id, _)| id).collect(),
60 .iter()
146 recording,
61 .filter_map(|participant| identity_id(participant.get("participant")?))
62 .collect()
63 })
64 .unwrap_or_default(),
65 })
147 })
66 }
148 }
67
149
@@ -85,6 +167,16 @@ impl CallEvent {
85 && !self.initiated_by(my_user_id)
167 && !self.initiated_by(my_user_id)
86 }
168 }
87
169
170 pub fn is_recording(&self) -> bool {
171 matches!(
172 self.phase,
173 CallPhase::RecordingStarted
174 | CallPhase::RecordingStopped
175 | CallPhase::RecordingSaved
176 | CallPhase::TranscriptStarted
177 )
178 }
179
88 pub fn title(&self, missed: bool) -> &'static str {
180 pub fn title(&self, missed: bool) -> &'static str {
89 match (self.phase, self.call_type) {
181 match (self.phase, self.call_type) {
90 _ if missed => "Missed call",
182 _ if missed => "Missed call",
@@ -92,14 +184,20 @@ impl CallEvent {
92 (CallPhase::Ended, CallType::Call) => "Call ended",
184 (CallPhase::Ended, CallType::Call) => "Call ended",
93 (CallPhase::Started, CallType::Meeting) => "Meeting started",
185 (CallPhase::Started, CallType::Meeting) => "Meeting started",
94 (CallPhase::Ended, CallType::Meeting) => "Meeting ended",
186 (CallPhase::Ended, CallType::Meeting) => "Meeting ended",
187 (CallPhase::RecordingStarted, _) => "Recording has started",
188 (CallPhase::RecordingStopped, _) => "Recording stopped",
189 (CallPhase::RecordingSaved, _) => "Recording is ready",
190 (CallPhase::TranscriptStarted, _) => "Transcription has started",
95 }
191 }
96 }
192 }
97
193
98 pub fn plain_text(&self) -> String {
194 pub fn plain_text(&self) -> String {
99 let title = self.title(false);
195 let title = self.title(false);
100 match self.duration_seconds {
196 match self.duration_seconds {
101 Some(seconds) => format!("{title} {}", format_duration(seconds)),
197 Some(seconds) if !self.is_recording() => {
102 None => title.to_owned(),
198 format!("{title} {}", format_duration(seconds))
199 }
200 _ => title.to_owned(),
103 }
201 }
104 }
202 }
105}
203}
@@ -108,11 +206,15 @@ pub fn call_event(record: &MessageRecord) -> Option<CallEvent> {
108 CallEvent::from_json(record.call_event_json.as_deref()?)
206 CallEvent::from_json(record.call_event_json.as_deref()?)
109}
207}
110
208
111fn identity_id(identity_set: &Value) -> Option<String> {
209fn identity(identity_set: &Value) -> Option<(String, Option<String>)> {
112 identity_set
210 identity_set
113 .as_object()?
211 .as_object()?
114 .values()
212 .values()
115 .find_map(|identity| text_at(identity, "/id"))
213 .find_map(|identity| Some((text_at(identity, "/id")?, person_name(Some(identity)))))
214}
215
216fn person_name(identity: Option<&Value>) -> Option<String> {
217 text_at(identity?, "/displayName").filter(|name| !name.starts_with(UNRESOLVED_NAME_PREFIX))
116}
218}
117
219
118fn text_at(value: &Value, pointer: &str) -> Option<String> {
220fn text_at(value: &Value, pointer: &str) -> Option<String> {
@@ -172,3 +274,144 @@ pub fn format_duration(seconds: u64) -> String {
172 }
274 }
173 parts.join(" ")
275 parts.join(" ")
174}
276}
277
278#[cfg(test)]
279mod tests {
280 use super::*;
281
282 fn fixture(name: &str) -> Value {
283 let path = format!(
284 "{}/tests/fixtures/call_events/{name}",
285 env!("CARGO_MANIFEST_DIR")
286 );
287 serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
288 }
289
290 fn meeting_chat_events() -> Vec<CallEvent> {
291 fixture("meeting_chat_recording.json")["value"]
292 .as_array()
293 .unwrap()
294 .iter()
295 .rev()
296 .map(|message| CallEvent::from_graph(&message["eventDetail"]).unwrap())
297 .collect()
298 }
299
300 #[test]
301 fn recorded_meeting_yields_every_phase_in_order() {
302 let phases: Vec<CallPhase> = meeting_chat_events()
303 .iter()
304 .map(|event| event.phase)
305 .collect();
306 assert_eq!(
307 phases,
308 [
309 CallPhase::Started,
310 CallPhase::RecordingStarted,
311 CallPhase::RecordingStarted,
312 CallPhase::TranscriptStarted,
313 CallPhase::RecordingStopped,
314 CallPhase::Ended,
315 CallPhase::RecordingStopped,
316 CallPhase::RecordingSaved,
317 ]
318 );
319 let call_ids: std::collections::HashSet<String> = meeting_chat_events()
320 .into_iter()
321 .map(|event| event.call_id)
322 .collect();
323 assert_eq!(call_ids.len(), 1);
324 }
325
326 #[test]
327 fn saved_recording_keeps_link_title_duration_and_owner() {
328 let saved = meeting_chat_events().pop().unwrap();
329 let recording = saved.recording.as_ref().unwrap();
330 assert_eq!(saved.duration_seconds, Some(814));
331 assert_eq!(recording.title().as_deref(), Some("Weekly team meeting"));
332 assert!(recording.url.as_deref().unwrap().contains("/:v:/"));
333 assert_eq!(
334 recording.organizer_id.as_deref(),
335 Some("00000000-0000-4000-8000-000000000002")
336 );
337 assert_eq!(saved.plain_text(), "Recording is ready");
338 let thumbnail = recording.thumbnail_url().unwrap();
339 assert!(thumbnail.starts_with("https://graph.microsoft.com/v1.0/shares/u!"));
340 assert!(thumbnail.ends_with("/driveItem/thumbnails/0/large/content"));
341 }
342
343 #[test]
344 fn started_recording_has_no_link_and_names_its_initiator_by_id() {
345 let started = &meeting_chat_events()[1];
346 assert_eq!(started.recording.as_ref().unwrap().url, None);
347 assert_eq!(started.recording.as_ref().unwrap().thumbnail_url(), None);
348 assert_eq!(started.duration_seconds, Some(0));
349 assert!(started.initiator_id.is_some());
350 assert_eq!(started.initiator_name, None);
351 }
352
353 #[test]
354 fn ended_meeting_keeps_participant_names_beside_their_ids() {
355 let ended = meeting_chat_events()
356 .into_iter()
357 .find(|event| event.phase == CallPhase::Ended)
358 .unwrap();
359 assert_eq!(ended.call_type, CallType::Meeting);
360 assert_eq!(ended.duration_seconds, Some(988));
361 assert_eq!(ended.participant_ids.len(), ended.participant_names.len());
362 assert_eq!(ended.participant_names[0], "");
363 assert_eq!(ended.participant_names[1], "Person 1");
364 assert_eq!(ended.recording, None);
365 }
366
367 #[test]
368 fn channel_meet_now_root_is_a_started_meeting() {
369 let thread = fixture("channel_adhoc_meeting.json");
370 let root = CallEvent::from_graph(&thread["eventDetail"]).unwrap();
371 let ended = CallEvent::from_graph(&thread["replies"][0]["eventDetail"]).unwrap();
372 assert_eq!(root.phase, CallPhase::Started);
373 assert_eq!(root.call_type, CallType::Meeting);
374 assert_eq!(ended.call_id, root.call_id);
375 assert_eq!(ended.duration_seconds, Some(11_975));
376 assert_eq!(ended.initiator_name, None);
377 }
378
379 #[test]
380 fn unknown_recording_status_is_not_an_event() {
381 let detail = serde_json::json!({
382 "@odata.type": RECORDING_TYPE,
383 "callId": "c",
384 "callRecordingStatus": "failure",
385 });
386 assert_eq!(CallEvent::from_graph(&detail), None);
387 }
388
389 #[test]
390 fn events_stored_before_recordings_still_load() {
391 let stored = r#"{"phase":"Ended","call_type":"Call","call_id":"c","duration_seconds":5,"initiator_id":"u","initiator_name":null,"participant_ids":["u"]}"#;
392 let event = CallEvent::from_json(stored).unwrap();
393 assert!(event.participant_names.is_empty());
394 assert_eq!(event.recording, None);
395 }
396
397 #[test]
398 fn recording_title_drops_the_stamp_only_when_it_is_one() {
399 let title = |name: &str| {
400 Recording {
401 name: Some(name.to_owned()),
402 url: None,
403 organizer_id: None,
404 }
405 .title()
406 };
407 assert_eq!(
408 title("Sync-20261012_140227UTC-Meeting Recording.mp4").as_deref(),
409 Some("Sync")
410 );
411 assert_eq!(
412 title("Q3-plan-Meeting Recording.mp4").as_deref(),
413 Some("Q3-plan")
414 );
415 assert_eq!(title("demo.mp4").as_deref(), Some("demo"));
416 }
417}
crates/core/src/lib.rs +2 −1
@@ -65,7 +65,8 @@ pub use adaptive_card::{
65 65 };
66 66 pub use avatars::Avatar;
67 67 pub use call_event::{
68 CallEvent, CallPhase, CallType, call_event, format_duration, parse_duration_seconds,
68 CallEvent, CallPhase, CallType, Recording, call_event, format_duration,
69 parse_duration_seconds,
69 70 };
70 71 pub use card_actions::{CardActionOutcome, DialogIdentity, TaskDialog, TaskDialogKind};
71 72 pub use card_chart::{
@@ -65,7 +65,8 @@ pub use adaptive_card::{
65};
65};
66pub use avatars::Avatar;
66pub use avatars::Avatar;
67pub use call_event::{
67pub use call_event::{
68 CallEvent, CallPhase, CallType, call_event, format_duration, parse_duration_seconds,
68 CallEvent, CallPhase, CallType, Recording, call_event, format_duration,
69 parse_duration_seconds,
69};
70};
70pub use card_actions::{CardActionOutcome, DialogIdentity, TaskDialog, TaskDialogKind};
71pub use card_actions::{CardActionOutcome, DialogIdentity, TaskDialog, TaskDialogKind};
71pub use card_chart::{
72pub use card_chart::{
crates/core/tests/fixtures/call_events/channel_adhoc_meeting.json added +111 −0
@@ -0,0 +1,111 @@
1 {
2 "id": "1547209855775",
3 "replyToId": null,
4 "messageType": "systemEventMessage",
5 "createdDateTime": "2019-01-11T12:30:55.655Z",
6 "lastModifiedDateTime": "2019-01-11T12:30:56.931Z",
7 "lastEditedDateTime": null,
8 "deletedDateTime": null,
9 "subject": null,
10 "from": null,
11 "body": {
12 "contentType": "html",
13 "content": "<systemEventMessage/>"
14 },
15 "attachments": [],
16 "mentions": [],
17 "reactions": [],
18 "eventDetail": {
19 "@odata.type": "#microsoft.graph.callStartedEventMessageDetail",
20 "callId": "00000000-0000-4000-8000-000000000030",
21 "callEventType": "meeting",
22 "initiator": {
23 "application": null,
24 "device": null,
25 "user": {
26 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
27 "id": "00000000-0000-4000-8000-000000000031",
28 "displayName": null,
29 "userIdentityType": "aadUser",
30 "tenantId": "00000000-0000-4000-8000-000000000003"
31 }
32 }
33 },
34 "replies@odata.count": 1,
35 "replies": [
36 {
37 "id": "1547221831050",
38 "replyToId": "1547209855775",
39 "messageType": "systemEventMessage",
40 "createdDateTime": "2019-01-11T15:50:30.938Z",
41 "lastModifiedDateTime": "2019-01-11T15:50:31.05Z",
42 "lastEditedDateTime": null,
43 "deletedDateTime": null,
44 "subject": null,
45 "from": null,
46 "body": {
47 "contentType": "html",
48 "content": "<systemEventMessage/>"
49 },
50 "attachments": [],
51 "mentions": [],
52 "reactions": [],
53 "eventDetail": {
54 "@odata.type": "#microsoft.graph.callEndedEventMessageDetail",
55 "callId": "00000000-0000-4000-8000-000000000030",
56 "callDuration": "PT3H19M35S",
57 "callEventType": "meeting",
58 "callParticipants": [
59 {
60 "participant": {
61 "application": null,
62 "device": null,
63 "user": {
64 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
65 "id": "00000000-0000-4000-8000-000000000032",
66 "displayName": "Person 25",
67 "userIdentityType": "aadUser"
68 }
69 }
70 },
71 {
72 "participant": {
73 "application": null,
74 "device": null,
75 "user": {
76 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
77 "id": "00000000-0000-4000-8000-000000000033",
78 "displayName": "Person 26",
79 "userIdentityType": "aadUser"
80 }
81 }
82 },
83 {
84 "participant": {
85 "application": null,
86 "device": null,
87 "user": {
88 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
89 "id": "00000000-0000-4000-8000-000000000031",
90 "displayName": "Person 27",
91 "userIdentityType": "aadUser",
92 "tenantId": "00000000-0000-4000-8000-000000000003"
93 }
94 }
95 }
96 ],
97 "initiator": {
98 "application": null,
99 "device": null,
100 "user": {
101 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
102 "id": "00000000-0000-4000-8000-000000000031",
103 "displayName": "orgid:00000000-0000-4000-8000-000000000031",
104 "userIdentityType": "aadUser",
105 "tenantId": "00000000-0000-4000-8000-000000000003"
106 }
107 }
108 }
109 }
110 ]
111 }
@@ -0,0 +1,111 @@
1{
2 "id": "1547209855775",
3 "replyToId": null,
4 "messageType": "systemEventMessage",
5 "createdDateTime": "2019-01-11T12:30:55.655Z",
6 "lastModifiedDateTime": "2019-01-11T12:30:56.931Z",
7 "lastEditedDateTime": null,
8 "deletedDateTime": null,
9 "subject": null,
10 "from": null,
11 "body": {
12 "contentType": "html",
13 "content": "<systemEventMessage/>"
14 },
15 "attachments": [],
16 "mentions": [],
17 "reactions": [],
18 "eventDetail": {
19 "@odata.type": "#microsoft.graph.callStartedEventMessageDetail",
20 "callId": "00000000-0000-4000-8000-000000000030",
21 "callEventType": "meeting",
22 "initiator": {
23 "application": null,
24 "device": null,
25 "user": {
26 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
27 "id": "00000000-0000-4000-8000-000000000031",
28 "displayName": null,
29 "userIdentityType": "aadUser",
30 "tenantId": "00000000-0000-4000-8000-000000000003"
31 }
32 }
33 },
34 "replies@odata.count": 1,
35 "replies": [
36 {
37 "id": "1547221831050",
38 "replyToId": "1547209855775",
39 "messageType": "systemEventMessage",
40 "createdDateTime": "2019-01-11T15:50:30.938Z",
41 "lastModifiedDateTime": "2019-01-11T15:50:31.05Z",
42 "lastEditedDateTime": null,
43 "deletedDateTime": null,
44 "subject": null,
45 "from": null,
46 "body": {
47 "contentType": "html",
48 "content": "<systemEventMessage/>"
49 },
50 "attachments": [],
51 "mentions": [],
52 "reactions": [],
53 "eventDetail": {
54 "@odata.type": "#microsoft.graph.callEndedEventMessageDetail",
55 "callId": "00000000-0000-4000-8000-000000000030",
56 "callDuration": "PT3H19M35S",
57 "callEventType": "meeting",
58 "callParticipants": [
59 {
60 "participant": {
61 "application": null,
62 "device": null,
63 "user": {
64 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
65 "id": "00000000-0000-4000-8000-000000000032",
66 "displayName": "Person 25",
67 "userIdentityType": "aadUser"
68 }
69 }
70 },
71 {
72 "participant": {
73 "application": null,
74 "device": null,
75 "user": {
76 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
77 "id": "00000000-0000-4000-8000-000000000033",
78 "displayName": "Person 26",
79 "userIdentityType": "aadUser"
80 }
81 }
82 },
83 {
84 "participant": {
85 "application": null,
86 "device": null,
87 "user": {
88 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
89 "id": "00000000-0000-4000-8000-000000000031",
90 "displayName": "Person 27",
91 "userIdentityType": "aadUser",
92 "tenantId": "00000000-0000-4000-8000-000000000003"
93 }
94 }
95 }
96 ],
97 "initiator": {
98 "application": null,
99 "device": null,
100 "user": {
101 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
102 "id": "00000000-0000-4000-8000-000000000031",
103 "displayName": "orgid:00000000-0000-4000-8000-000000000031",
104 "userIdentityType": "aadUser",
105 "tenantId": "00000000-0000-4000-8000-000000000003"
106 }
107 }
108 }
109 }
110 ]
111}
crates/core/tests/fixtures/call_events/channel_scheduled_meeting.json added +125 −0
@@ -0,0 +1,125 @@
1 {
2 "id": "1600766477135",
3 "replyToId": null,
4 "messageType": "message",
5 "createdDateTime": "2020-09-22T09:21:17.135Z",
6 "lastModifiedDateTime": "2022-11-11T13:20:01.848Z",
7 "lastEditedDateTime": null,
8 "deletedDateTime": null,
9 "subject": null,
10 "eventDetail": null,
11 "from": {
12 "application": null,
13 "device": null,
14 "user": {
15 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
16 "id": "00000000-0000-4000-8000-000000000034",
17 "displayName": "Person 28",
18 "userIdentityType": "aadUser",
19 "tenantId": "00000000-0000-4000-8000-000000000003"
20 }
21 },
22 "body": {
23 "contentType": "html",
24 "content": "<p>Agenda for the meeting</p>"
25 },
26 "attachments": [
27 {
28 "id": "1668172801758",
29 "contentType": "meetingReference",
30 "contentUrl": null,
31 "content": "<p>Agenda for the meeting</p>",
32 "name": "Sprint retrospective",
33 "thumbnailUrl": null,
34 "teamsAppId": null
35 }
36 ],
37 "mentions": [],
38 "reactions": [],
39 "replies@odata.count": 127,
40 "replies": [
41 {
42 "id": "1743082988885",
43 "replyToId": "1600766477135",
44 "messageType": "systemEventMessage",
45 "createdDateTime": "2025-03-27T13:43:08.885Z",
46 "lastModifiedDateTime": "2025-03-27T13:43:08.885Z",
47 "lastEditedDateTime": null,
48 "deletedDateTime": null,
49 "subject": null,
50 "from": null,
51 "body": {
52 "contentType": "html",
53 "content": "<systemEventMessage/>"
54 },
55 "attachments": [],
56 "mentions": [],
57 "reactions": [],
58 "eventDetail": {
59 "@odata.type": "#microsoft.graph.callEndedEventMessageDetail",
60 "callId": "00000000-0000-4000-8000-000000000035",
61 "callDuration": "PT48S",
62 "callEventType": "meeting",
63 "callParticipants": [
64 {
65 "participant": {
66 "application": null,
67 "device": null,
68 "user": {
69 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
70 "id": "00000000-0000-4000-8000-000000000036",
71 "displayName": "Person 29",
72 "userIdentityType": "aadUser"
73 }
74 }
75 }
76 ],
77 "initiator": {
78 "application": null,
79 "device": null,
80 "user": {
81 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
82 "id": "00000000-0000-4000-8000-000000000034",
83 "displayName": null,
84 "userIdentityType": "aadUser",
85 "tenantId": "00000000-0000-4000-8000-000000000003"
86 }
87 }
88 }
89 },
90 {
91 "id": "1743082945914",
92 "replyToId": "1600766477135",
93 "messageType": "systemEventMessage",
94 "createdDateTime": "2025-03-27T13:42:25.914Z",
95 "lastModifiedDateTime": "2025-03-27T13:42:25.914Z",
96 "lastEditedDateTime": null,
97 "deletedDateTime": null,
98 "subject": null,
99 "from": null,
100 "body": {
101 "contentType": "html",
102 "content": "<systemEventMessage/>"
103 },
104 "attachments": [],
105 "mentions": [],
106 "reactions": [],
107 "eventDetail": {
108 "@odata.type": "#microsoft.graph.callStartedEventMessageDetail",
109 "callId": "00000000-0000-4000-8000-000000000035",
110 "callEventType": "meeting",
111 "initiator": {
112 "application": null,
113 "device": null,
114 "user": {
115 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
116 "id": "00000000-0000-4000-8000-000000000034",
117 "displayName": null,
118 "userIdentityType": "aadUser",
119 "tenantId": "00000000-0000-4000-8000-000000000003"
120 }
121 }
122 }
123 }
124 ]
125 }
@@ -0,0 +1,125 @@
1{
2 "id": "1600766477135",
3 "replyToId": null,
4 "messageType": "message",
5 "createdDateTime": "2020-09-22T09:21:17.135Z",
6 "lastModifiedDateTime": "2022-11-11T13:20:01.848Z",
7 "lastEditedDateTime": null,
8 "deletedDateTime": null,
9 "subject": null,
10 "eventDetail": null,
11 "from": {
12 "application": null,
13 "device": null,
14 "user": {
15 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
16 "id": "00000000-0000-4000-8000-000000000034",
17 "displayName": "Person 28",
18 "userIdentityType": "aadUser",
19 "tenantId": "00000000-0000-4000-8000-000000000003"
20 }
21 },
22 "body": {
23 "contentType": "html",
24 "content": "<p>Agenda for the meeting</p>"
25 },
26 "attachments": [
27 {
28 "id": "1668172801758",
29 "contentType": "meetingReference",
30 "contentUrl": null,
31 "content": "<p>Agenda for the meeting</p>",
32 "name": "Sprint retrospective",
33 "thumbnailUrl": null,
34 "teamsAppId": null
35 }
36 ],
37 "mentions": [],
38 "reactions": [],
39 "replies@odata.count": 127,
40 "replies": [
41 {
42 "id": "1743082988885",
43 "replyToId": "1600766477135",
44 "messageType": "systemEventMessage",
45 "createdDateTime": "2025-03-27T13:43:08.885Z",
46 "lastModifiedDateTime": "2025-03-27T13:43:08.885Z",
47 "lastEditedDateTime": null,
48 "deletedDateTime": null,
49 "subject": null,
50 "from": null,
51 "body": {
52 "contentType": "html",
53 "content": "<systemEventMessage/>"
54 },
55 "attachments": [],
56 "mentions": [],
57 "reactions": [],
58 "eventDetail": {
59 "@odata.type": "#microsoft.graph.callEndedEventMessageDetail",
60 "callId": "00000000-0000-4000-8000-000000000035",
61 "callDuration": "PT48S",
62 "callEventType": "meeting",
63 "callParticipants": [
64 {
65 "participant": {
66 "application": null,
67 "device": null,
68 "user": {
69 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
70 "id": "00000000-0000-4000-8000-000000000036",
71 "displayName": "Person 29",
72 "userIdentityType": "aadUser"
73 }
74 }
75 }
76 ],
77 "initiator": {
78 "application": null,
79 "device": null,
80 "user": {
81 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
82 "id": "00000000-0000-4000-8000-000000000034",
83 "displayName": null,
84 "userIdentityType": "aadUser",
85 "tenantId": "00000000-0000-4000-8000-000000000003"
86 }
87 }
88 }
89 },
90 {
91 "id": "1743082945914",
92 "replyToId": "1600766477135",
93 "messageType": "systemEventMessage",
94 "createdDateTime": "2025-03-27T13:42:25.914Z",
95 "lastModifiedDateTime": "2025-03-27T13:42:25.914Z",
96 "lastEditedDateTime": null,
97 "deletedDateTime": null,
98 "subject": null,
99 "from": null,
100 "body": {
101 "contentType": "html",
102 "content": "<systemEventMessage/>"
103 },
104 "attachments": [],
105 "mentions": [],
106 "reactions": [],
107 "eventDetail": {
108 "@odata.type": "#microsoft.graph.callStartedEventMessageDetail",
109 "callId": "00000000-0000-4000-8000-000000000035",
110 "callEventType": "meeting",
111 "initiator": {
112 "application": null,
113 "device": null,
114 "user": {
115 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
116 "id": "00000000-0000-4000-8000-000000000034",
117 "displayName": null,
118 "userIdentityType": "aadUser",
119 "tenantId": "00000000-0000-4000-8000-000000000003"
120 }
121 }
122 }
123 }
124 ]
125}
crates/core/tests/fixtures/call_events/meeting_chat_recording.json added +673 −0
@@ -0,0 +1,673 @@
1 {
2 "value": [
3 {
4 "id": "1791814618064",
5 "replyToId": null,
6 "messageType": "systemEventMessage",
7 "createdDateTime": "2026-10-12T14:16:58.064Z",
8 "lastModifiedDateTime": "2026-10-12T14:36:28.57Z",
9 "lastEditedDateTime": null,
10 "deletedDateTime": null,
11 "subject": null,
12 "from": null,
13 "body": {
14 "contentType": "html",
15 "content": "<systemEventMessage/>"
16 },
17 "attachments": [],
18 "mentions": [],
19 "reactions": [],
20 "eventDetail": {
21 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
22 "callId": "00000000-0000-4000-8000-000000000001",
23 "callRecordingDisplayName": "Weekly team meeting-20261012_160221-Meeting Recording.mp4",
24 "callRecordingUrl": "https://contoso-my.sharepoint.com/:v:/g/personal/organizer_contoso_com/RECORDING",
25 "callRecordingDuration": "PT13M34.1S",
26 "callRecordingStatus": "success",
27 "meetingOrganizer": {
28 "application": null,
29 "device": null,
30 "user": {
31 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
32 "id": "00000000-0000-4000-8000-000000000002",
33 "displayName": null,
34 "userIdentityType": "aadUser",
35 "tenantId": "00000000-0000-4000-8000-000000000003"
36 }
37 },
38 "initiator": {
39 "application": null,
40 "device": null,
41 "user": {
42 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
43 "id": "00000000-0000-4000-8000-000000000004",
44 "displayName": null,
45 "userIdentityType": "aadUser",
46 "tenantId": "00000000-0000-4000-8000-000000000003"
47 }
48 }
49 }
50 },
51 {
52 "id": "1791814559994",
53 "replyToId": null,
54 "messageType": "systemEventMessage",
55 "createdDateTime": "2026-10-12T14:15:59.994Z",
56 "lastModifiedDateTime": "2026-10-12T14:15:59.994Z",
57 "lastEditedDateTime": null,
58 "deletedDateTime": null,
59 "subject": null,
60 "from": null,
61 "body": {
62 "contentType": "html",
63 "content": "<systemEventMessage/>"
64 },
65 "attachments": [],
66 "mentions": [],
67 "reactions": [],
68 "eventDetail": {
69 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
70 "callId": "00000000-0000-4000-8000-000000000001",
71 "callRecordingDisplayName": "Weekly team meeting-20261012_140226UTC-Meeting Recording.mp4",
72 "callRecordingUrl": "",
73 "callRecordingDuration": "PT13M33.1936259S",
74 "callRecordingStatus": "chunkFinished",
75 "meetingOrganizer": {
76 "application": null,
77 "device": null,
78 "user": {
79 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
80 "id": "00000000-0000-4000-8000-000000000002",
81 "displayName": null,
82 "userIdentityType": "aadUser",
83 "tenantId": "00000000-0000-4000-8000-000000000003"
84 }
85 },
86 "initiator": {
87 "application": null,
88 "device": null,
89 "user": {
90 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
91 "id": "00000000-0000-4000-8000-000000000004",
92 "displayName": null,
93 "userIdentityType": "aadUser",
94 "tenantId": "00000000-0000-4000-8000-000000000003"
95 }
96 }
97 }
98 },
99 {
100 "id": "1791814559417",
101 "replyToId": null,
102 "messageType": "systemEventMessage",
103 "createdDateTime": "2026-10-12T14:15:59.417Z",
104 "lastModifiedDateTime": "2026-10-12T14:15:59.417Z",
105 "lastEditedDateTime": null,
106 "deletedDateTime": null,
107 "subject": null,
108 "from": null,
109 "body": {
110 "contentType": "html",
111 "content": "<systemEventMessage/>"
112 },
113 "attachments": [],
114 "mentions": [],
115 "reactions": [],
116 "eventDetail": {
117 "@odata.type": "#microsoft.graph.callEndedEventMessageDetail",
118 "callId": "00000000-0000-4000-8000-000000000001",
119 "callDuration": "PT16M28S",
120 "callEventType": "meeting",
121 "callParticipants": [
122 {
123 "participant": {
124 "device": null,
125 "user": null,
126 "application": {
127 "@odata.type": "#microsoft.graph.teamworkApplicationIdentity",
128 "id": "00000000-0000-4000-8000-000000000005",
129 "displayName": "",
130 "applicationIdentityType": "bot"
131 }
132 }
133 },
134 {
135 "participant": {
136 "application": null,
137 "device": null,
138 "user": {
139 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
140 "id": "00000000-0000-4000-8000-000000000006",
141 "displayName": "Person 1",
142 "userIdentityType": "aadUser",
143 "tenantId": "00000000-0000-4000-8000-000000000003"
144 }
145 }
146 },
147 {
148 "participant": {
149 "application": null,
150 "device": null,
151 "user": {
152 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
153 "id": "00000000-0000-4000-8000-000000000007",
154 "displayName": "Person 2",
155 "userIdentityType": "aadUser",
156 "tenantId": "00000000-0000-4000-8000-000000000003"
157 }
158 }
159 },
160 {
161 "participant": {
162 "application": null,
163 "device": null,
164 "user": {
165 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
166 "id": "00000000-0000-4000-8000-000000000008",
167 "displayName": "Person 3",
168 "userIdentityType": "aadUser",
169 "tenantId": "00000000-0000-4000-8000-000000000003"
170 }
171 }
172 },
173 {
174 "participant": {
175 "application": null,
176 "device": null,
177 "user": {
178 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
179 "id": "00000000-0000-4000-8000-000000000009",
180 "displayName": "Person 4",
181 "userIdentityType": "aadUser",
182 "tenantId": "00000000-0000-4000-8000-000000000003"
183 }
184 }
185 },
186 {
187 "participant": {
188 "application": null,
189 "device": null,
190 "user": {
191 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
192 "id": "00000000-0000-4000-8000-000000000010",
193 "displayName": "Person 5",
194 "userIdentityType": "aadUser",
195 "tenantId": "00000000-0000-4000-8000-000000000003"
196 }
197 }
198 },
199 {
200 "participant": {
201 "application": null,
202 "device": null,
203 "user": {
204 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
205 "id": "00000000-0000-4000-8000-000000000011",
206 "displayName": "Person 6",
207 "userIdentityType": "aadUser",
208 "tenantId": "00000000-0000-4000-8000-000000000003"
209 }
210 }
211 },
212 {
213 "participant": {
214 "application": null,
215 "device": null,
216 "user": {
217 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
218 "id": "00000000-0000-4000-8000-000000000012",
219 "displayName": "Person 7",
220 "userIdentityType": "aadUser",
221 "tenantId": "00000000-0000-4000-8000-000000000003"
222 }
223 }
224 },
225 {
226 "participant": {
227 "application": null,
228 "device": null,
229 "user": {
230 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
231 "id": "00000000-0000-4000-8000-000000000013",
232 "displayName": "Person 8",
233 "userIdentityType": "aadUser",
234 "tenantId": "00000000-0000-4000-8000-000000000003"
235 }
236 }
237 },
238 {
239 "participant": {
240 "application": null,
241 "device": null,
242 "user": {
243 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
244 "id": "00000000-0000-4000-8000-000000000014",
245 "displayName": "Person 9",
246 "userIdentityType": "aadUser",
247 "tenantId": "00000000-0000-4000-8000-000000000003"
248 }
249 }
250 },
251 {
252 "participant": {
253 "application": null,
254 "device": null,
255 "user": {
256 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
257 "id": "00000000-0000-4000-8000-000000000015",
258 "displayName": "Person 10",
259 "userIdentityType": "aadUser",
260 "tenantId": "00000000-0000-4000-8000-000000000003"
261 }
262 }
263 },
264 {
265 "participant": {
266 "application": null,
267 "device": null,
268 "user": {
269 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
270 "id": "00000000-0000-4000-8000-000000000016",
271 "displayName": "Person 11",
272 "userIdentityType": "aadUser",
273 "tenantId": "00000000-0000-4000-8000-000000000003"
274 }
275 }
276 },
277 {
278 "participant": {
279 "application": null,
280 "device": null,
281 "user": {
282 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
283 "id": "00000000-0000-4000-8000-000000000017",
284 "displayName": "Person 12",
285 "userIdentityType": "aadUser",
286 "tenantId": "00000000-0000-4000-8000-000000000003"
287 }
288 }
289 },
290 {
291 "participant": {
292 "application": null,
293 "device": null,
294 "user": {
295 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
296 "id": "00000000-0000-4000-8000-000000000018",
297 "displayName": "Person 13",
298 "userIdentityType": "aadUser",
299 "tenantId": "00000000-0000-4000-8000-000000000003"
300 }
301 }
302 },
303 {
304 "participant": {
305 "application": null,
306 "device": null,
307 "user": {
308 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
309 "id": "00000000-0000-4000-8000-000000000019",
310 "displayName": "Person 14",
311 "userIdentityType": "aadUser",
312 "tenantId": "00000000-0000-4000-8000-000000000003"
313 }
314 }
315 },
316 {
317 "participant": {
318 "application": null,
319 "device": null,
320 "user": {
321 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
322 "id": "00000000-0000-4000-8000-000000000020",
323 "displayName": "Person 15",
324 "userIdentityType": "aadUser",
325 "tenantId": "00000000-0000-4000-8000-000000000003"
326 }
327 }
328 },
329 {
330 "participant": {
331 "application": null,
332 "device": null,
333 "user": {
334 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
335 "id": "00000000-0000-4000-8000-000000000021",
336 "displayName": "Person 16",
337 "userIdentityType": "aadUser",
338 "tenantId": "00000000-0000-4000-8000-000000000003"
339 }
340 }
341 },
342 {
343 "participant": {
344 "application": null,
345 "device": null,
346 "user": {
347 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
348 "id": "00000000-0000-4000-8000-000000000022",
349 "displayName": "Person 17",
350 "userIdentityType": "aadUser",
351 "tenantId": "00000000-0000-4000-8000-000000000003"
352 }
353 }
354 },
355 {
356 "participant": {
357 "application": null,
358 "device": null,
359 "user": {
360 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
361 "id": "00000000-0000-4000-8000-000000000023",
362 "displayName": "Person 18",
363 "userIdentityType": "aadUser",
364 "tenantId": "00000000-0000-4000-8000-000000000003"
365 }
366 }
367 },
368 {
369 "participant": {
370 "application": null,
371 "device": null,
372 "user": {
373 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
374 "id": "00000000-0000-4000-8000-000000000024",
375 "displayName": "Person 19",
376 "userIdentityType": "aadUser",
377 "tenantId": "00000000-0000-4000-8000-000000000003"
378 }
379 }
380 },
381 {
382 "participant": {
383 "application": null,
384 "device": null,
385 "user": {
386 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
387 "id": "00000000-0000-4000-8000-000000000025",
388 "displayName": "Person 20",
389 "userIdentityType": "aadUser",
390 "tenantId": "00000000-0000-4000-8000-000000000003"
391 }
392 }
393 },
394 {
395 "participant": {
396 "application": null,
397 "device": null,
398 "user": {
399 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
400 "id": "00000000-0000-4000-8000-000000000026",
401 "displayName": "Person 21",
402 "userIdentityType": "aadUser",
403 "tenantId": "00000000-0000-4000-8000-000000000003"
404 }
405 }
406 },
407 {
408 "participant": {
409 "application": null,
410 "device": null,
411 "user": {
412 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
413 "id": "00000000-0000-4000-8000-000000000027",
414 "displayName": "Person 22",
415 "userIdentityType": "aadUser",
416 "tenantId": "00000000-0000-4000-8000-000000000003"
417 }
418 }
419 },
420 {
421 "participant": {
422 "application": null,
423 "device": null,
424 "user": {
425 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
426 "id": "00000000-0000-4000-8000-000000000028",
427 "displayName": "Person 23",
428 "userIdentityType": "aadUser",
429 "tenantId": "00000000-0000-4000-8000-000000000003"
430 }
431 }
432 },
433 {
434 "participant": {
435 "application": null,
436 "device": null,
437 "user": {
438 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
439 "id": "00000000-0000-4000-8000-000000000029",
440 "displayName": "Person 24",
441 "userIdentityType": "aadUser",
442 "tenantId": "00000000-0000-4000-8000-000000000003"
443 }
444 }
445 }
446 ],
447 "initiator": {
448 "application": null,
449 "device": null,
450 "user": {
451 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
452 "id": "00000000-0000-4000-8000-000000000002",
453 "displayName": "",
454 "userIdentityType": "aadUser",
455 "tenantId": "00000000-0000-4000-8000-000000000003"
456 }
457 }
458 }
459 },
460 {
461 "id": "1791814559242",
462 "replyToId": null,
463 "messageType": "systemEventMessage",
464 "createdDateTime": "2026-10-12T14:15:59.242Z",
465 "lastModifiedDateTime": "2026-10-12T14:15:59.242Z",
466 "lastEditedDateTime": null,
467 "deletedDateTime": null,
468 "subject": null,
469 "from": null,
470 "body": {
471 "contentType": "html",
472 "content": "<systemEventMessage/>"
473 },
474 "attachments": [],
475 "mentions": [],
476 "reactions": [],
477 "eventDetail": {
478 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
479 "callId": "00000000-0000-4000-8000-000000000001",
480 "callRecordingDisplayName": "Weekly team meeting-20261012_140227UTC-Meeting Recording.mp4",
481 "callRecordingUrl": "",
482 "callRecordingDuration": "PT13M31.7542188S",
483 "callRecordingStatus": "chunkFinished",
484 "meetingOrganizer": {
485 "application": null,
486 "device": null,
487 "user": {
488 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
489 "id": "00000000-0000-4000-8000-000000000002",
490 "displayName": null,
491 "userIdentityType": "aadUser",
492 "tenantId": "00000000-0000-4000-8000-000000000003"
493 }
494 },
495 "initiator": {
496 "application": null,
497 "device": null,
498 "user": {
499 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
500 "id": "00000000-0000-4000-8000-000000000004",
501 "displayName": null,
502 "userIdentityType": "aadUser",
503 "tenantId": "00000000-0000-4000-8000-000000000003"
504 }
505 }
506 }
507 },
508 {
509 "id": "1791813748846",
510 "replyToId": null,
511 "messageType": "systemEventMessage",
512 "createdDateTime": "2026-10-12T14:02:28.846Z",
513 "lastModifiedDateTime": "2026-10-12T14:02:28.846Z",
514 "lastEditedDateTime": null,
515 "deletedDateTime": null,
516 "subject": null,
517 "from": null,
518 "body": {
519 "contentType": "html",
520 "content": "<systemEventMessage/>"
521 },
522 "attachments": [],
523 "mentions": [],
524 "reactions": [],
525 "eventDetail": {
526 "@odata.type": "#microsoft.graph.callTranscriptEventMessageDetail",
527 "callId": "00000000-0000-4000-8000-000000000001",
528 "callTranscriptICalUid": "040000008200E00074C5B7101A82E008TRANSCRIPT",
529 "meetingOrganizer": {
530 "application": null,
531 "device": null,
532 "user": {
533 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
534 "id": "00000000-0000-4000-8000-000000000002",
535 "displayName": null,
536 "userIdentityType": "aadUser",
537 "tenantId": "00000000-0000-4000-8000-000000000003"
538 }
539 }
540 }
541 },
542 {
543 "id": "1791813747388",
544 "replyToId": null,
545 "messageType": "systemEventMessage",
546 "createdDateTime": "2026-10-12T14:02:27.388Z",
547 "lastModifiedDateTime": "2026-10-12T14:02:27.388Z",
548 "lastEditedDateTime": null,
549 "deletedDateTime": null,
550 "subject": null,
551 "from": null,
552 "body": {
553 "contentType": "html",
554 "content": "<systemEventMessage/>"
555 },
556 "attachments": [],
557 "mentions": [],
558 "reactions": [],
559 "eventDetail": {
560 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
561 "callId": "00000000-0000-4000-8000-000000000001",
562 "callRecordingDisplayName": "Weekly team meeting-20261012_140227UTC-Meeting Recording.mp4",
563 "callRecordingUrl": null,
564 "callRecordingDuration": "PT0S",
565 "callRecordingStatus": "initial",
566 "meetingOrganizer": {
567 "application": null,
568 "device": null,
569 "user": {
570 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
571 "id": "00000000-0000-4000-8000-000000000002",
572 "displayName": null,
573 "userIdentityType": "aadUser",
574 "tenantId": "00000000-0000-4000-8000-000000000003"
575 }
576 },
577 "initiator": {
578 "application": null,
579 "device": null,
580 "user": {
581 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
582 "id": "00000000-0000-4000-8000-000000000004",
583 "displayName": null,
584 "userIdentityType": "aadUser",
585 "tenantId": "00000000-0000-4000-8000-000000000003"
586 }
587 }
588 }
589 },
590 {
591 "id": "1791813746918",
592 "replyToId": null,
593 "messageType": "systemEventMessage",
594 "createdDateTime": "2026-10-12T14:02:26.918Z",
595 "lastModifiedDateTime": "2026-10-12T14:02:26.918Z",
596 "lastEditedDateTime": null,
597 "deletedDateTime": null,
598 "subject": null,
599 "from": null,
600 "body": {
601 "contentType": "html",
602 "content": "<systemEventMessage/>"
603 },
604 "attachments": [],
605 "mentions": [],
606 "reactions": [],
607 "eventDetail": {
608 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
609 "callId": "00000000-0000-4000-8000-000000000001",
610 "callRecordingDisplayName": "Weekly team meeting-20261012_140226UTC-Meeting Recording.mp4",
611 "callRecordingUrl": null,
612 "callRecordingDuration": "PT0S",
613 "callRecordingStatus": "initial",
614 "meetingOrganizer": {
615 "application": null,
616 "device": null,
617 "user": {
618 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
619 "id": "00000000-0000-4000-8000-000000000002",
620 "displayName": null,
621 "userIdentityType": "aadUser",
622 "tenantId": "00000000-0000-4000-8000-000000000003"
623 }
624 },
625 "initiator": {
626 "application": null,
627 "device": null,
628 "user": {
629 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
630 "id": "00000000-0000-4000-8000-000000000004",
631 "displayName": null,
632 "userIdentityType": "aadUser",
633 "tenantId": "00000000-0000-4000-8000-000000000003"
634 }
635 }
636 }
637 },
638 {
639 "id": "1791813580747",
640 "replyToId": null,
641 "messageType": "systemEventMessage",
642 "createdDateTime": "2026-10-12T13:59:40.747Z",
643 "lastModifiedDateTime": "2026-10-12T13:59:40.747Z",
644 "lastEditedDateTime": null,
645 "deletedDateTime": null,
646 "subject": null,
647 "from": null,
648 "body": {
649 "contentType": "html",
650 "content": "<systemEventMessage/>"
651 },
652 "attachments": [],
653 "mentions": [],
654 "reactions": [],
655 "eventDetail": {
656 "@odata.type": "#microsoft.graph.callStartedEventMessageDetail",
657 "callId": "00000000-0000-4000-8000-000000000001",
658 "callEventType": "meeting",
659 "initiator": {
660 "application": null,
661 "device": null,
662 "user": {
663 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
664 "id": "00000000-0000-4000-8000-000000000002",
665 "displayName": null,
666 "userIdentityType": "aadUser",
667 "tenantId": "00000000-0000-4000-8000-000000000003"
668 }
669 }
670 }
671 }
672 ]
673 }
@@ -0,0 +1,673 @@
1{
2 "value": [
3 {
4 "id": "1791814618064",
5 "replyToId": null,
6 "messageType": "systemEventMessage",
7 "createdDateTime": "2026-10-12T14:16:58.064Z",
8 "lastModifiedDateTime": "2026-10-12T14:36:28.57Z",
9 "lastEditedDateTime": null,
10 "deletedDateTime": null,
11 "subject": null,
12 "from": null,
13 "body": {
14 "contentType": "html",
15 "content": "<systemEventMessage/>"
16 },
17 "attachments": [],
18 "mentions": [],
19 "reactions": [],
20 "eventDetail": {
21 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
22 "callId": "00000000-0000-4000-8000-000000000001",
23 "callRecordingDisplayName": "Weekly team meeting-20261012_160221-Meeting Recording.mp4",
24 "callRecordingUrl": "https://contoso-my.sharepoint.com/:v:/g/personal/organizer_contoso_com/RECORDING",
25 "callRecordingDuration": "PT13M34.1S",
26 "callRecordingStatus": "success",
27 "meetingOrganizer": {
28 "application": null,
29 "device": null,
30 "user": {
31 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
32 "id": "00000000-0000-4000-8000-000000000002",
33 "displayName": null,
34 "userIdentityType": "aadUser",
35 "tenantId": "00000000-0000-4000-8000-000000000003"
36 }
37 },
38 "initiator": {
39 "application": null,
40 "device": null,
41 "user": {
42 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
43 "id": "00000000-0000-4000-8000-000000000004",
44 "displayName": null,
45 "userIdentityType": "aadUser",
46 "tenantId": "00000000-0000-4000-8000-000000000003"
47 }
48 }
49 }
50 },
51 {
52 "id": "1791814559994",
53 "replyToId": null,
54 "messageType": "systemEventMessage",
55 "createdDateTime": "2026-10-12T14:15:59.994Z",
56 "lastModifiedDateTime": "2026-10-12T14:15:59.994Z",
57 "lastEditedDateTime": null,
58 "deletedDateTime": null,
59 "subject": null,
60 "from": null,
61 "body": {
62 "contentType": "html",
63 "content": "<systemEventMessage/>"
64 },
65 "attachments": [],
66 "mentions": [],
67 "reactions": [],
68 "eventDetail": {
69 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
70 "callId": "00000000-0000-4000-8000-000000000001",
71 "callRecordingDisplayName": "Weekly team meeting-20261012_140226UTC-Meeting Recording.mp4",
72 "callRecordingUrl": "",
73 "callRecordingDuration": "PT13M33.1936259S",
74 "callRecordingStatus": "chunkFinished",
75 "meetingOrganizer": {
76 "application": null,
77 "device": null,
78 "user": {
79 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
80 "id": "00000000-0000-4000-8000-000000000002",
81 "displayName": null,
82 "userIdentityType": "aadUser",
83 "tenantId": "00000000-0000-4000-8000-000000000003"
84 }
85 },
86 "initiator": {
87 "application": null,
88 "device": null,
89 "user": {
90 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
91 "id": "00000000-0000-4000-8000-000000000004",
92 "displayName": null,
93 "userIdentityType": "aadUser",
94 "tenantId": "00000000-0000-4000-8000-000000000003"
95 }
96 }
97 }
98 },
99 {
100 "id": "1791814559417",
101 "replyToId": null,
102 "messageType": "systemEventMessage",
103 "createdDateTime": "2026-10-12T14:15:59.417Z",
104 "lastModifiedDateTime": "2026-10-12T14:15:59.417Z",
105 "lastEditedDateTime": null,
106 "deletedDateTime": null,
107 "subject": null,
108 "from": null,
109 "body": {
110 "contentType": "html",
111 "content": "<systemEventMessage/>"
112 },
113 "attachments": [],
114 "mentions": [],
115 "reactions": [],
116 "eventDetail": {
117 "@odata.type": "#microsoft.graph.callEndedEventMessageDetail",
118 "callId": "00000000-0000-4000-8000-000000000001",
119 "callDuration": "PT16M28S",
120 "callEventType": "meeting",
121 "callParticipants": [
122 {
123 "participant": {
124 "device": null,
125 "user": null,
126 "application": {
127 "@odata.type": "#microsoft.graph.teamworkApplicationIdentity",
128 "id": "00000000-0000-4000-8000-000000000005",
129 "displayName": "",
130 "applicationIdentityType": "bot"
131 }
132 }
133 },
134 {
135 "participant": {
136 "application": null,
137 "device": null,
138 "user": {
139 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
140 "id": "00000000-0000-4000-8000-000000000006",
141 "displayName": "Person 1",
142 "userIdentityType": "aadUser",
143 "tenantId": "00000000-0000-4000-8000-000000000003"
144 }
145 }
146 },
147 {
148 "participant": {
149 "application": null,
150 "device": null,
151 "user": {
152 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
153 "id": "00000000-0000-4000-8000-000000000007",
154 "displayName": "Person 2",
155 "userIdentityType": "aadUser",
156 "tenantId": "00000000-0000-4000-8000-000000000003"
157 }
158 }
159 },
160 {
161 "participant": {
162 "application": null,
163 "device": null,
164 "user": {
165 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
166 "id": "00000000-0000-4000-8000-000000000008",
167 "displayName": "Person 3",
168 "userIdentityType": "aadUser",
169 "tenantId": "00000000-0000-4000-8000-000000000003"
170 }
171 }
172 },
173 {
174 "participant": {
175 "application": null,
176 "device": null,
177 "user": {
178 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
179 "id": "00000000-0000-4000-8000-000000000009",
180 "displayName": "Person 4",
181 "userIdentityType": "aadUser",
182 "tenantId": "00000000-0000-4000-8000-000000000003"
183 }
184 }
185 },
186 {
187 "participant": {
188 "application": null,
189 "device": null,
190 "user": {
191 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
192 "id": "00000000-0000-4000-8000-000000000010",
193 "displayName": "Person 5",
194 "userIdentityType": "aadUser",
195 "tenantId": "00000000-0000-4000-8000-000000000003"
196 }
197 }
198 },
199 {
200 "participant": {
201 "application": null,
202 "device": null,
203 "user": {
204 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
205 "id": "00000000-0000-4000-8000-000000000011",
206 "displayName": "Person 6",
207 "userIdentityType": "aadUser",
208 "tenantId": "00000000-0000-4000-8000-000000000003"
209 }
210 }
211 },
212 {
213 "participant": {
214 "application": null,
215 "device": null,
216 "user": {
217 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
218 "id": "00000000-0000-4000-8000-000000000012",
219 "displayName": "Person 7",
220 "userIdentityType": "aadUser",
221 "tenantId": "00000000-0000-4000-8000-000000000003"
222 }
223 }
224 },
225 {
226 "participant": {
227 "application": null,
228 "device": null,
229 "user": {
230 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
231 "id": "00000000-0000-4000-8000-000000000013",
232 "displayName": "Person 8",
233 "userIdentityType": "aadUser",
234 "tenantId": "00000000-0000-4000-8000-000000000003"
235 }
236 }
237 },
238 {
239 "participant": {
240 "application": null,
241 "device": null,
242 "user": {
243 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
244 "id": "00000000-0000-4000-8000-000000000014",
245 "displayName": "Person 9",
246 "userIdentityType": "aadUser",
247 "tenantId": "00000000-0000-4000-8000-000000000003"
248 }
249 }
250 },
251 {
252 "participant": {
253 "application": null,
254 "device": null,
255 "user": {
256 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
257 "id": "00000000-0000-4000-8000-000000000015",
258 "displayName": "Person 10",
259 "userIdentityType": "aadUser",
260 "tenantId": "00000000-0000-4000-8000-000000000003"
261 }
262 }
263 },
264 {
265 "participant": {
266 "application": null,
267 "device": null,
268 "user": {
269 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
270 "id": "00000000-0000-4000-8000-000000000016",
271 "displayName": "Person 11",
272 "userIdentityType": "aadUser",
273 "tenantId": "00000000-0000-4000-8000-000000000003"
274 }
275 }
276 },
277 {
278 "participant": {
279 "application": null,
280 "device": null,
281 "user": {
282 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
283 "id": "00000000-0000-4000-8000-000000000017",
284 "displayName": "Person 12",
285 "userIdentityType": "aadUser",
286 "tenantId": "00000000-0000-4000-8000-000000000003"
287 }
288 }
289 },
290 {
291 "participant": {
292 "application": null,
293 "device": null,
294 "user": {
295 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
296 "id": "00000000-0000-4000-8000-000000000018",
297 "displayName": "Person 13",
298 "userIdentityType": "aadUser",
299 "tenantId": "00000000-0000-4000-8000-000000000003"
300 }
301 }
302 },
303 {
304 "participant": {
305 "application": null,
306 "device": null,
307 "user": {
308 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
309 "id": "00000000-0000-4000-8000-000000000019",
310 "displayName": "Person 14",
311 "userIdentityType": "aadUser",
312 "tenantId": "00000000-0000-4000-8000-000000000003"
313 }
314 }
315 },
316 {
317 "participant": {
318 "application": null,
319 "device": null,
320 "user": {
321 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
322 "id": "00000000-0000-4000-8000-000000000020",
323 "displayName": "Person 15",
324 "userIdentityType": "aadUser",
325 "tenantId": "00000000-0000-4000-8000-000000000003"
326 }
327 }
328 },
329 {
330 "participant": {
331 "application": null,
332 "device": null,
333 "user": {
334 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
335 "id": "00000000-0000-4000-8000-000000000021",
336 "displayName": "Person 16",
337 "userIdentityType": "aadUser",
338 "tenantId": "00000000-0000-4000-8000-000000000003"
339 }
340 }
341 },
342 {
343 "participant": {
344 "application": null,
345 "device": null,
346 "user": {
347 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
348 "id": "00000000-0000-4000-8000-000000000022",
349 "displayName": "Person 17",
350 "userIdentityType": "aadUser",
351 "tenantId": "00000000-0000-4000-8000-000000000003"
352 }
353 }
354 },
355 {
356 "participant": {
357 "application": null,
358 "device": null,
359 "user": {
360 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
361 "id": "00000000-0000-4000-8000-000000000023",
362 "displayName": "Person 18",
363 "userIdentityType": "aadUser",
364 "tenantId": "00000000-0000-4000-8000-000000000003"
365 }
366 }
367 },
368 {
369 "participant": {
370 "application": null,
371 "device": null,
372 "user": {
373 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
374 "id": "00000000-0000-4000-8000-000000000024",
375 "displayName": "Person 19",
376 "userIdentityType": "aadUser",
377 "tenantId": "00000000-0000-4000-8000-000000000003"
378 }
379 }
380 },
381 {
382 "participant": {
383 "application": null,
384 "device": null,
385 "user": {
386 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
387 "id": "00000000-0000-4000-8000-000000000025",
388 "displayName": "Person 20",
389 "userIdentityType": "aadUser",
390 "tenantId": "00000000-0000-4000-8000-000000000003"
391 }
392 }
393 },
394 {
395 "participant": {
396 "application": null,
397 "device": null,
398 "user": {
399 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
400 "id": "00000000-0000-4000-8000-000000000026",
401 "displayName": "Person 21",
402 "userIdentityType": "aadUser",
403 "tenantId": "00000000-0000-4000-8000-000000000003"
404 }
405 }
406 },
407 {
408 "participant": {
409 "application": null,
410 "device": null,
411 "user": {
412 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
413 "id": "00000000-0000-4000-8000-000000000027",
414 "displayName": "Person 22",
415 "userIdentityType": "aadUser",
416 "tenantId": "00000000-0000-4000-8000-000000000003"
417 }
418 }
419 },
420 {
421 "participant": {
422 "application": null,
423 "device": null,
424 "user": {
425 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
426 "id": "00000000-0000-4000-8000-000000000028",
427 "displayName": "Person 23",
428 "userIdentityType": "aadUser",
429 "tenantId": "00000000-0000-4000-8000-000000000003"
430 }
431 }
432 },
433 {
434 "participant": {
435 "application": null,
436 "device": null,
437 "user": {
438 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
439 "id": "00000000-0000-4000-8000-000000000029",
440 "displayName": "Person 24",
441 "userIdentityType": "aadUser",
442 "tenantId": "00000000-0000-4000-8000-000000000003"
443 }
444 }
445 }
446 ],
447 "initiator": {
448 "application": null,
449 "device": null,
450 "user": {
451 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
452 "id": "00000000-0000-4000-8000-000000000002",
453 "displayName": "",
454 "userIdentityType": "aadUser",
455 "tenantId": "00000000-0000-4000-8000-000000000003"
456 }
457 }
458 }
459 },
460 {
461 "id": "1791814559242",
462 "replyToId": null,
463 "messageType": "systemEventMessage",
464 "createdDateTime": "2026-10-12T14:15:59.242Z",
465 "lastModifiedDateTime": "2026-10-12T14:15:59.242Z",
466 "lastEditedDateTime": null,
467 "deletedDateTime": null,
468 "subject": null,
469 "from": null,
470 "body": {
471 "contentType": "html",
472 "content": "<systemEventMessage/>"
473 },
474 "attachments": [],
475 "mentions": [],
476 "reactions": [],
477 "eventDetail": {
478 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
479 "callId": "00000000-0000-4000-8000-000000000001",
480 "callRecordingDisplayName": "Weekly team meeting-20261012_140227UTC-Meeting Recording.mp4",
481 "callRecordingUrl": "",
482 "callRecordingDuration": "PT13M31.7542188S",
483 "callRecordingStatus": "chunkFinished",
484 "meetingOrganizer": {
485 "application": null,
486 "device": null,
487 "user": {
488 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
489 "id": "00000000-0000-4000-8000-000000000002",
490 "displayName": null,
491 "userIdentityType": "aadUser",
492 "tenantId": "00000000-0000-4000-8000-000000000003"
493 }
494 },
495 "initiator": {
496 "application": null,
497 "device": null,
498 "user": {
499 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
500 "id": "00000000-0000-4000-8000-000000000004",
501 "displayName": null,
502 "userIdentityType": "aadUser",
503 "tenantId": "00000000-0000-4000-8000-000000000003"
504 }
505 }
506 }
507 },
508 {
509 "id": "1791813748846",
510 "replyToId": null,
511 "messageType": "systemEventMessage",
512 "createdDateTime": "2026-10-12T14:02:28.846Z",
513 "lastModifiedDateTime": "2026-10-12T14:02:28.846Z",
514 "lastEditedDateTime": null,
515 "deletedDateTime": null,
516 "subject": null,
517 "from": null,
518 "body": {
519 "contentType": "html",
520 "content": "<systemEventMessage/>"
521 },
522 "attachments": [],
523 "mentions": [],
524 "reactions": [],
525 "eventDetail": {
526 "@odata.type": "#microsoft.graph.callTranscriptEventMessageDetail",
527 "callId": "00000000-0000-4000-8000-000000000001",
528 "callTranscriptICalUid": "040000008200E00074C5B7101A82E008TRANSCRIPT",
529 "meetingOrganizer": {
530 "application": null,
531 "device": null,
532 "user": {
533 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
534 "id": "00000000-0000-4000-8000-000000000002",
535 "displayName": null,
536 "userIdentityType": "aadUser",
537 "tenantId": "00000000-0000-4000-8000-000000000003"
538 }
539 }
540 }
541 },
542 {
543 "id": "1791813747388",
544 "replyToId": null,
545 "messageType": "systemEventMessage",
546 "createdDateTime": "2026-10-12T14:02:27.388Z",
547 "lastModifiedDateTime": "2026-10-12T14:02:27.388Z",
548 "lastEditedDateTime": null,
549 "deletedDateTime": null,
550 "subject": null,
551 "from": null,
552 "body": {
553 "contentType": "html",
554 "content": "<systemEventMessage/>"
555 },
556 "attachments": [],
557 "mentions": [],
558 "reactions": [],
559 "eventDetail": {
560 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
561 "callId": "00000000-0000-4000-8000-000000000001",
562 "callRecordingDisplayName": "Weekly team meeting-20261012_140227UTC-Meeting Recording.mp4",
563 "callRecordingUrl": null,
564 "callRecordingDuration": "PT0S",
565 "callRecordingStatus": "initial",
566 "meetingOrganizer": {
567 "application": null,
568 "device": null,
569 "user": {
570 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
571 "id": "00000000-0000-4000-8000-000000000002",
572 "displayName": null,
573 "userIdentityType": "aadUser",
574 "tenantId": "00000000-0000-4000-8000-000000000003"
575 }
576 },
577 "initiator": {
578 "application": null,
579 "device": null,
580 "user": {
581 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
582 "id": "00000000-0000-4000-8000-000000000004",
583 "displayName": null,
584 "userIdentityType": "aadUser",
585 "tenantId": "00000000-0000-4000-8000-000000000003"
586 }
587 }
588 }
589 },
590 {
591 "id": "1791813746918",
592 "replyToId": null,
593 "messageType": "systemEventMessage",
594 "createdDateTime": "2026-10-12T14:02:26.918Z",
595 "lastModifiedDateTime": "2026-10-12T14:02:26.918Z",
596 "lastEditedDateTime": null,
597 "deletedDateTime": null,
598 "subject": null,
599 "from": null,
600 "body": {
601 "contentType": "html",
602 "content": "<systemEventMessage/>"
603 },
604 "attachments": [],
605 "mentions": [],
606 "reactions": [],
607 "eventDetail": {
608 "@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
609 "callId": "00000000-0000-4000-8000-000000000001",
610 "callRecordingDisplayName": "Weekly team meeting-20261012_140226UTC-Meeting Recording.mp4",
611 "callRecordingUrl": null,
612 "callRecordingDuration": "PT0S",
613 "callRecordingStatus": "initial",
614 "meetingOrganizer": {
615 "application": null,
616 "device": null,
617 "user": {
618 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
619 "id": "00000000-0000-4000-8000-000000000002",
620 "displayName": null,
621 "userIdentityType": "aadUser",
622 "tenantId": "00000000-0000-4000-8000-000000000003"
623 }
624 },
625 "initiator": {
626 "application": null,
627 "device": null,
628 "user": {
629 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
630 "id": "00000000-0000-4000-8000-000000000004",
631 "displayName": null,
632 "userIdentityType": "aadUser",
633 "tenantId": "00000000-0000-4000-8000-000000000003"
634 }
635 }
636 }
637 },
638 {
639 "id": "1791813580747",
640 "replyToId": null,
641 "messageType": "systemEventMessage",
642 "createdDateTime": "2026-10-12T13:59:40.747Z",
643 "lastModifiedDateTime": "2026-10-12T13:59:40.747Z",
644 "lastEditedDateTime": null,
645 "deletedDateTime": null,
646 "subject": null,
647 "from": null,
648 "body": {
649 "contentType": "html",
650 "content": "<systemEventMessage/>"
651 },
652 "attachments": [],
653 "mentions": [],
654 "reactions": [],
655 "eventDetail": {
656 "@odata.type": "#microsoft.graph.callStartedEventMessageDetail",
657 "callId": "00000000-0000-4000-8000-000000000001",
658 "callEventType": "meeting",
659 "initiator": {
660 "application": null,
661 "device": null,
662 "user": {
663 "@odata.type": "#microsoft.graph.teamworkUserIdentity",
664 "id": "00000000-0000-4000-8000-000000000002",
665 "displayName": null,
666 "userIdentityType": "aadUser",
667 "tenantId": "00000000-0000-4000-8000-000000000003"
668 }
669 }
670 }
671 }
672 ]
673}
crates/graph/src/content.rs +10 −0
@@ -7,6 +7,8 @@ use crate::people::decode_binary;
7 7
8 8 const CHAT_PATH: &str = "/v1.0/chats/";
9 9 const CHANNEL_PATH: &str = "/v1.0/teams/";
10 const SHARES_PATH: &str = "/v1.0/shares/";
11 const SHARES_SCOPE: &str = "Files.ReadWrite.All";
10 12 const EXTERNAL_IMAGE_SCOPE: &str = "Chat.Read";
11 13
12 14 impl Graph {
@@ -40,6 +42,8 @@ pub fn hosted_content_scope(url: &str) -> Option<Scope> {
40 42 Some(Scope::graph("Chat.Read"))
41 43 } else if path.starts_with(CHANNEL_PATH) {
42 44 Some(Scope::graph("ChannelMessage.Read.All"))
45 } else if path.starts_with(SHARES_PATH) {
46 Some(Scope::graph(SHARES_SCOPE))
43 47 } else {
44 48 None
45 49 }
@@ -59,6 +63,12 @@ mod tests {
59 63 hosted_content_scope(channel).unwrap().name,
60 64 "ChannelMessage.Read.All"
61 65 );
66 let thumbnail =
67 "https://graph.microsoft.com/v1.0/shares/u!aHR0cA/driveItem/thumbnails/0/large/content";
68 assert_eq!(
69 hosted_content_scope(thumbnail).unwrap().name,
70 "Files.ReadWrite.All"
71 );
62 72 assert!(hosted_content_scope("https://graph.microsoft.com/v1.0/me").is_none());
63 73 }
64 74 }
@@ -7,6 +7,8 @@ use crate::people::decode_binary;
7
7
8const CHAT_PATH: &str = "/v1.0/chats/";
8const CHAT_PATH: &str = "/v1.0/chats/";
9const CHANNEL_PATH: &str = "/v1.0/teams/";
9const CHANNEL_PATH: &str = "/v1.0/teams/";
10const SHARES_PATH: &str = "/v1.0/shares/";
11const SHARES_SCOPE: &str = "Files.ReadWrite.All";
10const EXTERNAL_IMAGE_SCOPE: &str = "Chat.Read";
12const EXTERNAL_IMAGE_SCOPE: &str = "Chat.Read";
11
13
12impl Graph {
14impl Graph {
@@ -40,6 +42,8 @@ pub fn hosted_content_scope(url: &str) -> Option<Scope> {
40 Some(Scope::graph("Chat.Read"))
42 Some(Scope::graph("Chat.Read"))
41 } else if path.starts_with(CHANNEL_PATH) {
43 } else if path.starts_with(CHANNEL_PATH) {
42 Some(Scope::graph("ChannelMessage.Read.All"))
44 Some(Scope::graph("ChannelMessage.Read.All"))
45 } else if path.starts_with(SHARES_PATH) {
46 Some(Scope::graph(SHARES_SCOPE))
43 } else {
47 } else {
44 None
48 None
45 }
49 }
@@ -59,6 +63,12 @@ mod tests {
59 hosted_content_scope(channel).unwrap().name,
63 hosted_content_scope(channel).unwrap().name,
60 "ChannelMessage.Read.All"
64 "ChannelMessage.Read.All"
61 );
65 );
66 let thumbnail =
67 "https://graph.microsoft.com/v1.0/shares/u!aHR0cA/driveItem/thumbnails/0/large/content";
68 assert_eq!(
69 hosted_content_scope(thumbnail).unwrap().name,
70 "Files.ReadWrite.All"
71 );
62 assert!(hosted_content_scope("https://graph.microsoft.com/v1.0/me").is_none());
72 assert!(hosted_content_scope("https://graph.microsoft.com/v1.0/me").is_none());
63 }
73 }
64}
74}
crates/store/src/migrations.rs +4 −0
@@ -89,6 +89,10 @@ const MIGRATIONS: &[Migration] = &[
89 89 script: include_str!("migrations/0020_call_events.sql"),
90 90 after: None,
91 91 },
92 Migration {
93 script: include_str!("migrations/0021_recording_events.sql"),
94 after: None,
95 },
92 96 ];
93 97
94 98 pub fn latest_version() -> i64 {
@@ -89,6 +89,10 @@ const MIGRATIONS: &[Migration] = &[
89 script: include_str!("migrations/0020_call_events.sql"),
89 script: include_str!("migrations/0020_call_events.sql"),
90 after: None,
90 after: None,
91 },
91 },
92 Migration {
93 script: include_str!("migrations/0021_recording_events.sql"),
94 after: None,
95 },
92];
96];
93
97
94pub fn latest_version() -> i64 {
98pub fn latest_version() -> i64 {
crates/store/src/migrations/0021_recording_events.sql added +1 −0
@@ -0,0 +1 @@
1 DELETE FROM sync_state WHERE conversation_id IN (SELECT id FROM chats UNION SELECT id FROM channels);
@@ -0,0 +1 @@
1DELETE FROM sync_state WHERE conversation_id IN (SELECT id FROM chats UNION SELECT id FROM channels);
crates/store/tests/store.rs +50 −6
@@ -509,11 +509,11 @@ fn file_database_uses_wal_persists_and_migrates_once() {
509 509 let path = directory.path().join("nested").join("cache.sqlite3");
510 510 {
511 511 let store = Store::open(&path).unwrap();
512 assert_eq!(store.schema_version().unwrap(), 20);
512 assert_eq!(store.schema_version().unwrap(), 21);
513 513 store.upsert_messages(&[message("c", "m1", 1)]).unwrap();
514 514 }
515 515 let reopened = Store::open(&path).unwrap();
516 assert_eq!(reopened.schema_version().unwrap(), 20);
516 assert_eq!(reopened.schema_version().unwrap(), 21);
517 517 assert_eq!(reopened.message_count("c").unwrap(), 1);
518 518 drop(reopened);
519 519 let mode: String = rusqlite_open(&path)
@@ -545,7 +545,7 @@ fn old_schema_is_upgraded_in_place() {
545 545 connection.execute_batch("DROP TABLE messages; DROP TABLE sync_state; DROP TABLE chats; DROP TABLE chat_members; DROP TABLE channels; DROP TABLE teams; DROP TABLE meta; DROP TABLE avatars; DROP TABLE folder_items; DROP TABLE folders; DROP TABLE pinned_channels; DROP TABLE images; DROP TABLE search_keys; DROP TABLE message_search; DROP TABLE title_search; DROP TABLE team_layout; DROP TABLE channel_layout; DROP TABLE channel_tabs; DROP TABLE presence; DROP TABLE activity; DROP TABLE outbox; DROP TABLE drafts; DROP TABLE attachment_images; DROP TABLE agent_reaction_proposals; DROP TABLE agent_proposals; PRAGMA user_version = 0").unwrap();
546 546 drop(connection);
547 547 let store = Store::open(&path).unwrap();
548 assert_eq!(store.schema_version().unwrap(), 20);
548 assert_eq!(store.schema_version().unwrap(), 21);
549 549 store.upsert_messages(&[message("c", "m1", 1)]).unwrap();
550 550 }
551 551
@@ -611,7 +611,7 @@ fn migration_to_v2_keeps_existing_sync_state() {
611 611 let store = Store::open(&path).unwrap();
612 612 let state = store.sync_state("c").unwrap().unwrap();
613 613 assert_eq!(state.delta_link, None);
614 assert_eq!(store.schema_version().unwrap(), 20);
614 assert_eq!(store.schema_version().unwrap(), 21);
615 615 }
616 616
617 617 #[test]
@@ -639,7 +639,10 @@ fn migration_to_v13_clears_channel_delta_links_only() {
639 639 .unwrap();
640 640 }
641 641 let store = Store::open(&path).unwrap();
642 assert_eq!(store.sync_state("ch").unwrap().unwrap().delta_link, None);
642 assert_eq!(
643 store.sync_state("ch").unwrap().and_then(|state| state.delta_link),
644 None
645 );
643 646 assert_eq!(
644 647 store
645 648 .sync_state("chat")
@@ -1374,7 +1377,7 @@ fn migration_to_v20_adds_the_call_event_column() {
1374 1377 .unwrap();
1375 1378 }
1376 1379 let store = Store::open(&path).unwrap();
1377 assert_eq!(store.schema_version().unwrap(), 20);
1380 assert_eq!(store.schema_version().unwrap(), 21);
1378 1381 let old = store.messages("c", None, 10).unwrap();
1379 1382 assert_eq!(old[0].call_event_json, None);
1380 1383 assert!(store.sync_state("c").unwrap().is_none());
@@ -1382,3 +1385,44 @@ fn migration_to_v20_adds_the_call_event_column() {
1382 1385 store.upsert_messages(&[call_message("call", 2)]).unwrap();
1383 1386 assert!(store.messages("c", None, 10).unwrap()[1].call_event_json.is_some());
1384 1387 }
1388
1389 #[test]
1390 fn migration_to_v21_refetches_chats_and_channels_for_recordings() {
1391 let directory = tempfile::tempdir().unwrap();
1392 let path = directory.path().join("old.sqlite3");
1393 {
1394 let store = Store::open(&path).unwrap();
1395 store.upsert_chats(&[chat("c", "Chat", Some(at(1)))]).unwrap();
1396 store
1397 .upsert_teams(&[TeamRecord {
1398 id: "team".to_owned(),
1399 name: "Team".to_owned(),
1400 }])
1401 .unwrap();
1402 store
1403 .upsert_channels(&[ChannelRecord {
1404 id: "channel".to_owned(),
1405 team_id: "team".to_owned(),
1406 name: "General".to_owned(),
1407 membership_type: None,
1408 last_message_at: None,
1409 unread: false,
1410 }])
1411 .unwrap();
1412 for conversation_id in ["c", "channel", "other"] {
1413 store
1414 .set_sync_state(conversation_id, &SyncState::default())
1415 .unwrap();
1416 }
1417 drop(store);
1418 Connection::open(&path)
1419 .unwrap()
1420 .execute_batch("PRAGMA user_version = 20")
1421 .unwrap();
1422 }
1423 let store = Store::open(&path).unwrap();
1424 assert_eq!(store.schema_version().unwrap(), 21);
1425 assert!(store.sync_state("c").unwrap().is_none());
1426 assert!(store.sync_state("channel").unwrap().is_none());
1427 assert!(store.sync_state("other").unwrap().is_some());
1428 }
@@ -509,11 +509,11 @@ fn file_database_uses_wal_persists_and_migrates_once() {
509 let path = directory.path().join("nested").join("cache.sqlite3");
509 let path = directory.path().join("nested").join("cache.sqlite3");
510 {
510 {
511 let store = Store::open(&path).unwrap();
511 let store = Store::open(&path).unwrap();
512 assert_eq!(store.schema_version().unwrap(), 20);
512 assert_eq!(store.schema_version().unwrap(), 21);
513 store.upsert_messages(&[message("c", "m1", 1)]).unwrap();
513 store.upsert_messages(&[message("c", "m1", 1)]).unwrap();
514 }
514 }
515 let reopened = Store::open(&path).unwrap();
515 let reopened = Store::open(&path).unwrap();
516 assert_eq!(reopened.schema_version().unwrap(), 20);
516 assert_eq!(reopened.schema_version().unwrap(), 21);
517 assert_eq!(reopened.message_count("c").unwrap(), 1);
517 assert_eq!(reopened.message_count("c").unwrap(), 1);
518 drop(reopened);
518 drop(reopened);
519 let mode: String = rusqlite_open(&path)
519 let mode: String = rusqlite_open(&path)
@@ -545,7 +545,7 @@ fn old_schema_is_upgraded_in_place() {
545 connection.execute_batch("DROP TABLE messages; DROP TABLE sync_state; DROP TABLE chats; DROP TABLE chat_members; DROP TABLE channels; DROP TABLE teams; DROP TABLE meta; DROP TABLE avatars; DROP TABLE folder_items; DROP TABLE folders; DROP TABLE pinned_channels; DROP TABLE images; DROP TABLE search_keys; DROP TABLE message_search; DROP TABLE title_search; DROP TABLE team_layout; DROP TABLE channel_layout; DROP TABLE channel_tabs; DROP TABLE presence; DROP TABLE activity; DROP TABLE outbox; DROP TABLE drafts; DROP TABLE attachment_images; DROP TABLE agent_reaction_proposals; DROP TABLE agent_proposals; PRAGMA user_version = 0").unwrap();
545 connection.execute_batch("DROP TABLE messages; DROP TABLE sync_state; DROP TABLE chats; DROP TABLE chat_members; DROP TABLE channels; DROP TABLE teams; DROP TABLE meta; DROP TABLE avatars; DROP TABLE folder_items; DROP TABLE folders; DROP TABLE pinned_channels; DROP TABLE images; DROP TABLE search_keys; DROP TABLE message_search; DROP TABLE title_search; DROP TABLE team_layout; DROP TABLE channel_layout; DROP TABLE channel_tabs; DROP TABLE presence; DROP TABLE activity; DROP TABLE outbox; DROP TABLE drafts; DROP TABLE attachment_images; DROP TABLE agent_reaction_proposals; DROP TABLE agent_proposals; PRAGMA user_version = 0").unwrap();
546 drop(connection);
546 drop(connection);
547 let store = Store::open(&path).unwrap();
547 let store = Store::open(&path).unwrap();
548 assert_eq!(store.schema_version().unwrap(), 20);
548 assert_eq!(store.schema_version().unwrap(), 21);
549 store.upsert_messages(&[message("c", "m1", 1)]).unwrap();
549 store.upsert_messages(&[message("c", "m1", 1)]).unwrap();
550}
550}
551
551
@@ -611,7 +611,7 @@ fn migration_to_v2_keeps_existing_sync_state() {
611 let store = Store::open(&path).unwrap();
611 let store = Store::open(&path).unwrap();
612 let state = store.sync_state("c").unwrap().unwrap();
612 let state = store.sync_state("c").unwrap().unwrap();
613 assert_eq!(state.delta_link, None);
613 assert_eq!(state.delta_link, None);
614 assert_eq!(store.schema_version().unwrap(), 20);
614 assert_eq!(store.schema_version().unwrap(), 21);
615}
615}
616
616
617#[test]
617#[test]
@@ -639,7 +639,10 @@ fn migration_to_v13_clears_channel_delta_links_only() {
639 .unwrap();
639 .unwrap();
640 }
640 }
641 let store = Store::open(&path).unwrap();
641 let store = Store::open(&path).unwrap();
642 assert_eq!(store.sync_state("ch").unwrap().unwrap().delta_link, None);
642 assert_eq!(
643 store.sync_state("ch").unwrap().and_then(|state| state.delta_link),
644 None
645 );
643 assert_eq!(
646 assert_eq!(
644 store
647 store
645 .sync_state("chat")
648 .sync_state("chat")
@@ -1374,7 +1377,7 @@ fn migration_to_v20_adds_the_call_event_column() {
1374 .unwrap();
1377 .unwrap();
1375 }
1378 }
1376 let store = Store::open(&path).unwrap();
1379 let store = Store::open(&path).unwrap();
1377 assert_eq!(store.schema_version().unwrap(), 20);
1380 assert_eq!(store.schema_version().unwrap(), 21);
1378 let old = store.messages("c", None, 10).unwrap();
1381 let old = store.messages("c", None, 10).unwrap();
1379 assert_eq!(old[0].call_event_json, None);
1382 assert_eq!(old[0].call_event_json, None);
1380 assert!(store.sync_state("c").unwrap().is_none());
1383 assert!(store.sync_state("c").unwrap().is_none());
@@ -1382,3 +1385,44 @@ fn migration_to_v20_adds_the_call_event_column() {
1382 store.upsert_messages(&[call_message("call", 2)]).unwrap();
1385 store.upsert_messages(&[call_message("call", 2)]).unwrap();
1383 assert!(store.messages("c", None, 10).unwrap()[1].call_event_json.is_some());
1386 assert!(store.messages("c", None, 10).unwrap()[1].call_event_json.is_some());
1384}
1387}
1388
1389#[test]
1390fn migration_to_v21_refetches_chats_and_channels_for_recordings() {
1391 let directory = tempfile::tempdir().unwrap();
1392 let path = directory.path().join("old.sqlite3");
1393 {
1394 let store = Store::open(&path).unwrap();
1395 store.upsert_chats(&[chat("c", "Chat", Some(at(1)))]).unwrap();
1396 store
1397 .upsert_teams(&[TeamRecord {
1398 id: "team".to_owned(),
1399 name: "Team".to_owned(),
1400 }])
1401 .unwrap();
1402 store
1403 .upsert_channels(&[ChannelRecord {
1404 id: "channel".to_owned(),
1405 team_id: "team".to_owned(),
1406 name: "General".to_owned(),
1407 membership_type: None,
1408 last_message_at: None,
1409 unread: false,
1410 }])
1411 .unwrap();
1412 for conversation_id in ["c", "channel", "other"] {
1413 store
1414 .set_sync_state(conversation_id, &SyncState::default())
1415 .unwrap();
1416 }
1417 drop(store);
1418 Connection::open(&path)
1419 .unwrap()
1420 .execute_batch("PRAGMA user_version = 20")
1421 .unwrap();
1422 }
1423 let store = Store::open(&path).unwrap();
1424 assert_eq!(store.schema_version().unwrap(), 21);
1425 assert!(store.sync_state("c").unwrap().is_none());
1426 assert!(store.sync_state("channel").unwrap().is_none());
1427 assert!(store.sync_state("other").unwrap().is_some());
1428}