Merge remote-tracking branch 'origin/main' into feat/teams-sounds
@@ -194,7 +194,7 @@ Feature parity with the Microsoft Teams desktop client.
194
194
| In a call shown in presence | Done | "In a call", "In a meeting", "Presenting" from Teams activity on profile cards and chat headers; no notification sounds during a native call |
195
195
| Schedule a meeting | Partial | Calls tab "New meeting": title, people chips, date, start, end (next half hour, 30 min), Repeat (does not repeat, daily, weekdays, weekly), details, Teams meeting always on. Graph `POST /me/events` with `isOnlineMeeting` and `teamsForBusiness`, local wall time in the own mailbox time zone (series keep their time across DST, weekday from the local date). Body building unit tested; never run against a real calendar |
196
196
| Answer meeting invitations | Partial | Upcoming rows of invited meetings show Accepted / Tentative / Declined / Respond as a menu with "Send a response" (default on); own meetings say Organizer. Graph `accept`, `tentativelyAccept`, `decline`, falls back to the iCalUId lookup when the Teams id is not a Graph id. Not run against a real invitation |
197
| Meeting start reminder | Partial | Toast 5 min before the start of an Upcoming meeting: title, time, Join, Snooze (back at the start or first join). Corner X dismisses for good. Live state (green dot) from polled live-meeting state. One chime at the start or first join; quiet with sound off and during Do not disturb or a call. Ctrl+Shift+J joins from the latest. Driven by the polled calendar; push event 128 not wired (the realtime layer does not receive it) |
197
| Meeting start reminder | Partial | Toast 5 min before the start of an Upcoming meeting: title, time, Join, Snooze (back at the start or first join). Corner X dismisses for good. Snooze and X are saved to the Outlook reminder (Graph snoozeReminder / dismissReminder, occurrence id); reminders snoozed or dismissed in Outlook or on another device are read from reminderView every 60 s near a meeting and are not shown again. Live state (green dot) from polled live-meeting state. One chime at the start or first join; quiet with sound off and during Do not disturb or a call. Ctrl+Shift+J joins from the latest. Driven by the polled calendar; push event 128 not wired (the realtime layer does not receive it) |
198
198
| Pre-join screen | Partial | Join from Upcoming, chat, Join with ID, link or reminder opens a screen in the chat pane: camera preview, camera and mic switches, background menu, camera, microphone and speaker selects, "Computer audio" or "Don't use audio" (audio off in both directions), Join now, Cancel. Camera, mic and devices remembered. 1:1 calls and Meet now skip it. Checked in the demo only |
199
199
| Narrow windows in a call | Done | Controls that do not fit move into "..." (View, Reactions, Raise hand, People, Chat; mic, camera, share, "..." and Leave always stay). Below 960 px, or when a side panel would leave the call under 720 px, the chat list hides; still too narrow, the panel overlays the call. Layout guard checks 640x480, 1280x800, 1920x1080 |
200
200
| Give and take control | Missing | Protocol known (main-channel data channel, action codes 0-11); needs a second person and a security review |
@@ -194,7 +194,7 @@ Feature parity with the Microsoft Teams desktop client.194
| In a call shown in presence | Done | "In a call", "In a meeting", "Presenting" from Teams activity on profile cards and chat headers; no notification sounds during a native call |194
| In a call shown in presence | Done | "In a call", "In a meeting", "Presenting" from Teams activity on profile cards and chat headers; no notification sounds during a native call |195
| Schedule a meeting | Partial | Calls tab "New meeting": title, people chips, date, start, end (next half hour, 30 min), Repeat (does not repeat, daily, weekdays, weekly), details, Teams meeting always on. Graph `POST /me/events` with `isOnlineMeeting` and `teamsForBusiness`, local wall time in the own mailbox time zone (series keep their time across DST, weekday from the local date). Body building unit tested; never run against a real calendar |195
| Schedule a meeting | Partial | Calls tab "New meeting": title, people chips, date, start, end (next half hour, 30 min), Repeat (does not repeat, daily, weekdays, weekly), details, Teams meeting always on. Graph `POST /me/events` with `isOnlineMeeting` and `teamsForBusiness`, local wall time in the own mailbox time zone (series keep their time across DST, weekday from the local date). Body building unit tested; never run against a real calendar |196
| Answer meeting invitations | Partial | Upcoming rows of invited meetings show Accepted / Tentative / Declined / Respond as a menu with "Send a response" (default on); own meetings say Organizer. Graph `accept`, `tentativelyAccept`, `decline`, falls back to the iCalUId lookup when the Teams id is not a Graph id. Not run against a real invitation |196
| Answer meeting invitations | Partial | Upcoming rows of invited meetings show Accepted / Tentative / Declined / Respond as a menu with "Send a response" (default on); own meetings say Organizer. Graph `accept`, `tentativelyAccept`, `decline`, falls back to the iCalUId lookup when the Teams id is not a Graph id. Not run against a real invitation |197
| Meeting start reminder | Partial | Toast 5 min before the start of an Upcoming meeting: title, time, Join, Snooze (back at the start or first join). Corner X dismisses for good. Live state (green dot) from polled live-meeting state. One chime at the start or first join; quiet with sound off and during Do not disturb or a call. Ctrl+Shift+J joins from the latest. Driven by the polled calendar; push event 128 not wired (the realtime layer does not receive it) |197
| Meeting start reminder | Partial | Toast 5 min before the start of an Upcoming meeting: title, time, Join, Snooze (back at the start or first join). Corner X dismisses for good. Snooze and X are saved to the Outlook reminder (Graph snoozeReminder / dismissReminder, occurrence id); reminders snoozed or dismissed in Outlook or on another device are read from reminderView every 60 s near a meeting and are not shown again. Live state (green dot) from polled live-meeting state. One chime at the start or first join; quiet with sound off and during Do not disturb or a call. Ctrl+Shift+J joins from the latest. Driven by the polled calendar; push event 128 not wired (the realtime layer does not receive it) |198
| Pre-join screen | Partial | Join from Upcoming, chat, Join with ID, link or reminder opens a screen in the chat pane: camera preview, camera and mic switches, background menu, camera, microphone and speaker selects, "Computer audio" or "Don't use audio" (audio off in both directions), Join now, Cancel. Camera, mic and devices remembered. 1:1 calls and Meet now skip it. Checked in the demo only |198
| Pre-join screen | Partial | Join from Upcoming, chat, Join with ID, link or reminder opens a screen in the chat pane: camera preview, camera and mic switches, background menu, camera, microphone and speaker selects, "Computer audio" or "Don't use audio" (audio off in both directions), Join now, Cancel. Camera, mic and devices remembered. 1:1 calls and Meet now skip it. Checked in the demo only |199
| Narrow windows in a call | Done | Controls that do not fit move into "..." (View, Reactions, Raise hand, People, Chat; mic, camera, share, "..." and Leave always stay). Below 960 px, or when a side panel would leave the call under 720 px, the chat list hides; still too narrow, the panel overlays the call. Layout guard checks 640x480, 1280x800, 1920x1080 |199
| Narrow windows in a call | Done | Controls that do not fit move into "..." (View, Reactions, Raise hand, People, Chat; mic, camera, share, "..." and Leave always stay). Below 960 px, or when a side panel would leave the call under 720 px, the chat list hides; still too narrow, the panel overlays the call. Layout guard checks 640x480, 1280x800, 1920x1080 |200
| Give and take control | Missing | Protocol known (main-channel data channel, action codes 0-11); needs a second person and a security review |200
| Give and take control | Missing | Protocol known (main-channel data channel, action codes 0-11); needs a second person and a security review |@@ -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
11
const SYMBOLS: [(&str, &[u8]); 46] = symbols![11
const 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
60
pub struct AppAssets;64
pub struct AppAssets;@@ -225,6 +225,46 @@ impl CallLauncher {
225
225
.map_err(|error| error.to_string())
226
226
}
227
227
228
pub async fn reminder_view(
229
&self,
230
start: chrono::DateTime<chrono::Utc>,
231
end: chrono::DateTime<chrono::Utc>,
232
) -> Result<Vec<chatsvc::Reminder>, String> {
233
let session = self.engine().ok_or_else(|| NOT_READY.to_owned())?.session();
234
chatsvc::Calendar::new(&session)
235
.reminder_view(start, end)
236
.await
237
.map_err(|error| error.to_string())
238
}
239
240
pub async fn snooze_reminder(
241
&self,
242
event_id: &str,
243
until: chrono::DateTime<chrono::Utc>,
244
) -> Result<(), String> {
245
let session = self
246
.ready_engine()
247
.await
248
.ok_or_else(|| NOT_READY.to_owned())?
249
.session();
250
chatsvc::Calendar::new(&session)
251
.snooze_reminder(event_id, until)
252
.await
253
.map_err(|error| error.to_string())
254
}
255
256
pub async fn dismiss_reminder(&self, event_id: &str) -> Result<(), String> {
257
let session = self
258
.ready_engine()
259
.await
260
.ok_or_else(|| NOT_READY.to_owned())?
261
.session();
262
chatsvc::Calendar::new(&session)
263
.dismiss_reminder(event_id)
264
.await
265
.map_err(|error| error.to_string())
266
}
267
228
268
pub async fn live_meeting(&self, thread_id: &str) -> Option<LiveMeeting> {
229
269
let session = self.engine()?.session();
230
270
fetch_live_meeting(&session, thread_id).await.ok().flatten()
@@ -225,6 +225,46 @@ impl CallLauncher {225
.map_err(|error| error.to_string())225
.map_err(|error| error.to_string())226
}226
}227
227
228
pub async fn reminder_view(229
&self,230
start: chrono::DateTime<chrono::Utc>,231
end: chrono::DateTime<chrono::Utc>,232
) -> Result<Vec<chatsvc::Reminder>, String> {233
let session = self.engine().ok_or_else(|| NOT_READY.to_owned())?.session();234
chatsvc::Calendar::new(&session)235
.reminder_view(start, end)236
.await237
.map_err(|error| error.to_string())238
}239
240
pub async fn snooze_reminder(241
&self,242
event_id: &str,243
until: chrono::DateTime<chrono::Utc>,244
) -> Result<(), String> {245
let session = self246
.ready_engine()247
.await248
.ok_or_else(|| NOT_READY.to_owned())?249
.session();250
chatsvc::Calendar::new(&session)251
.snooze_reminder(event_id, until)252
.await253
.map_err(|error| error.to_string())254
}255
256
pub async fn dismiss_reminder(&self, event_id: &str) -> Result<(), String> {257
let session = self258
.ready_engine()259
.await260
.ok_or_else(|| NOT_READY.to_owned())?261
.session();262
chatsvc::Calendar::new(&session)263
.dismiss_reminder(event_id)264
.await265
.map_err(|error| error.to_string())266
}267
228
pub async fn live_meeting(&self, thread_id: &str) -> Option<LiveMeeting> {268
pub async fn live_meeting(&self, thread_id: &str) -> Option<LiveMeeting> {229
let session = self.engine()?.session();269
let session = self.engine()?.session();230
fetch_live_meeting(&session, thread_id).await.ok().flatten()270
fetch_live_meeting(&session, thread_id).await.ok().flatten()@@ -7,6 +7,7 @@ pub mod history;
7
7
pub mod join;
8
8
pub mod launcher;
9
9
pub mod list;
10
pub mod outlook_reminders;
10
11
pub mod overlay_layout;
11
12
pub mod people_actions;
12
13
pub mod prejoin;
@@ -7,6 +7,7 @@ pub mod history;7
pub mod join;7
pub mod join;8
pub mod launcher;8
pub mod launcher;9
pub mod list;9
pub mod list;10
pub mod outlook_reminders;10
pub mod overlay_layout;11
pub mod overlay_layout;11
pub mod people_actions;12
pub mod people_actions;12
pub mod prejoin;13
pub mod prejoin;@@ -0,0 +1,270 @@
1
use std::collections::HashMap;
2
3
use chatsvc::{CalendarEvent, Reminder};
4
use chrono::{DateTime, Duration, Utc};
5
use gpui_kit::Context;
6
7
use super::reminder::{GRACE_MINUTES, LEAD_MINUTES, is_eligible};
8
use crate::app_state::AppState;
9
use crate::runtime;
10
11
const POLL_SECONDS: i64 = 60;
12
const WATCH_BEFORE_LEAD_MINUTES: i64 = 1;
13
const RANGE_HOURS: i64 = 1;
14
15
#[derive(Debug, Clone, PartialEq, Eq)]
16
struct KnownReminders {
17
start: DateTime<Utc>,
18
end: DateTime<Utc>,
19
fire_times: HashMap<String, DateTime<Utc>>,
20
}
21
22
#[derive(Debug, Default)]
23
pub struct OutlookReminders {
24
known: Option<KnownReminders>,
25
last_poll: Option<DateTime<Utc>>,
26
polling: bool,
27
}
28
29
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30
pub enum ReminderWrite {
31
Snooze(DateTime<Utc>),
32
Dismiss,
33
}
34
35
fn watched(event: &CalendarEvent, now: DateTime<Utc>) -> bool {
36
let watch_from = event.start - Duration::minutes(LEAD_MINUTES + WATCH_BEFORE_LEAD_MINUTES);
37
let watch_until = event
38
.end
39
.min(event.start + Duration::minutes(GRACE_MINUTES));
40
is_eligible(event) && now >= watch_from && now < watch_until
41
}
42
43
impl OutlookReminders {
44
pub fn poll_range(
45
&mut self,
46
events: &[CalendarEvent],
47
now: DateTime<Utc>,
48
) -> Option<(DateTime<Utc>, DateTime<Utc>)> {
49
let due = !self.polling
50
&& self
51
.last_poll
52
.is_none_or(|last| now - last >= Duration::seconds(POLL_SECONDS));
53
if !due || !events.iter().any(|event| watched(event, now)) {
54
return None;
55
}
56
self.polling = true;
57
self.last_poll = Some(now);
58
Some((
59
now - Duration::hours(RANGE_HOURS),
60
now + Duration::hours(RANGE_HOURS),
61
))
62
}
63
64
pub fn apply(
65
&mut self,
66
start: DateTime<Utc>,
67
end: DateTime<Utc>,
68
fetched: Result<Vec<Reminder>, String>,
69
) {
70
self.polling = false;
71
self.known = fetched.ok().map(|reminders| KnownReminders {
72
start,
73
end,
74
fire_times: reminders
75
.into_iter()
76
.map(|reminder| (reminder.event_id, reminder.fire_time))
77
.collect(),
78
});
79
}
80
81
pub fn allows(&self, event: &CalendarEvent, now: DateTime<Utc>) -> bool {
82
let Some(known) = &self.known else {
83
return true;
84
};
85
if event.start < known.start || event.start >= known.end {
86
return true;
87
}
88
known
89
.fire_times
90
.get(&event.object_id)
91
.is_some_and(|fire_time| now >= *fire_time)
92
}
93
94
pub fn note(&mut self, event_id: &str, write: ReminderWrite) {
95
let Some(known) = self.known.as_mut() else {
96
return;
97
};
98
match write {
99
ReminderWrite::Snooze(until) => {
100
known.fire_times.insert(event_id.to_owned(), until);
101
}
102
ReminderWrite::Dismiss => {
103
known.fire_times.remove(event_id);
104
}
105
}
106
}
107
}
108
109
impl AppState {
110
pub(super) fn poll_outlook_reminders(&mut self, now: DateTime<Utc>, cx: &mut Context<Self>) {
111
if self.mode.demo {
112
return;
113
}
114
let Some(launcher) = self.call_launcher.clone() else {
115
return;
116
};
117
let Some((start, end)) = self
118
.meeting_toasts
119
.outlook_mut()
120
.poll_range(&self.calendar_events, now)
121
else {
122
return;
123
};
124
let fetched = runtime::spawn(async move { launcher.reminder_view(start, end).await });
125
cx.spawn(async move |this, cx| {
126
let fetched = fetched
127
.await
128
.unwrap_or_else(|_| Err("reminder fetch was dropped".to_owned()));
129
if let Err(error) = &fetched {
130
crate::diagnostics::record(format!(
131
"calendar: Outlook reminders not read: {error}"
132
));
133
}
134
this.update(cx, |state, _| {
135
state
136
.meeting_toasts
137
.outlook_mut()
138
.apply(start, end, fetched);
139
})
140
.ok();
141
})
142
.detach();
143
}
144
145
pub(super) fn write_outlook_reminder(&mut self, event_id: String, write: ReminderWrite) {
146
if self.mode.demo || self.mode.read_only {
147
return;
148
}
149
let Some(launcher) = self.call_launcher.clone() else {
150
return;
151
};
152
self.meeting_toasts.outlook_mut().note(&event_id, write);
153
runtime::handle().spawn(async move {
154
let written = match write {
155
ReminderWrite::Snooze(until) => launcher.snooze_reminder(&event_id, until).await,
156
ReminderWrite::Dismiss => launcher.dismiss_reminder(&event_id).await,
157
};
158
if let Err(error) = written {
159
crate::diagnostics::record(format!(
160
"calendar: Outlook reminder {write:?} not saved: {error}"
161
));
162
}
163
});
164
}
165
}
166
167
#[cfg(test)]
168
mod tests {
169
use chatsvc::ResponseType;
170
use chrono::TimeZone;
171
172
use super::*;
173
174
fn at(hour: u32, minute: u32) -> DateTime<Utc> {
175
Utc.with_ymd_and_hms(2026, 10, 19, hour, minute, 0).unwrap()
176
}
177
178
fn event(id: &str) -> CalendarEvent {
179
CalendarEvent {
180
object_id: id.into(),
181
subject: "Daily Standup".into(),
182
start: at(9, 45),
183
end: at(10, 0),
184
all_day: false,
185
cancelled: false,
186
online: true,
187
join_url: Some("https://teams.microsoft.com/l/meetup-join/x".into()),
188
thread_id: None,
189
organizer_name: None,
190
organizer_address: None,
191
ical_uid: None,
192
response: ResponseType::Accepted,
193
}
194
}
195
196
fn reminder(event_id: &str, fire_time: DateTime<Utc>) -> Reminder {
197
Reminder {
198
event_id: event_id.into(),
199
fire_time,
200
}
201
}
202
203
fn known(reminders: Vec<Reminder>, now: DateTime<Utc>) -> OutlookReminders {
204
let mut outlook = OutlookReminders::default();
205
let (start, end) = outlook.poll_range(&[event("a")], now).unwrap();
206
outlook.apply(start, end, Ok(reminders));
207
outlook
208
}
209
210
#[test]
211
fn polls_only_near_a_meeting_and_once_a_minute() {
212
let events = [event("a")];
213
let mut outlook = OutlookReminders::default();
214
assert_eq!(outlook.poll_range(&events, at(9, 38)), None);
215
let range = outlook.poll_range(&events, at(9, 39)).unwrap();
216
assert_eq!(range, (at(8, 39), at(10, 39)));
217
assert_eq!(outlook.poll_range(&events, at(9, 41)), None);
218
outlook.apply(range.0, range.1, Ok(Vec::new()));
219
assert_eq!(
220
outlook.poll_range(&events, at(9, 39) + Duration::seconds(59)),
221
None
222
);
223
assert!(outlook.poll_range(&events, at(9, 40)).is_some());
224
let mut later = OutlookReminders::default();
225
assert_eq!(later.poll_range(&events, at(9, 50)), None);
226
}
227
228
#[test]
229
fn unknown_state_keeps_the_local_behaviour() {
230
let mut outlook = OutlookReminders::default();
231
assert!(outlook.allows(&event("a"), at(9, 40)));
232
let (start, end) = outlook.poll_range(&[event("a")], at(9, 39)).unwrap();
233
outlook.apply(start, end, Err("offline".into()));
234
assert!(outlook.allows(&event("a"), at(9, 40)));
235
}
236
237
#[test]
238
fn a_reminder_missing_in_outlook_was_dismissed_there() {
239
let outlook = known(vec![reminder("b", at(9, 30))], at(9, 39));
240
assert!(!outlook.allows(&event("a"), at(9, 40)));
241
assert!(outlook.allows(&event("b"), at(9, 40)));
242
}
243
244
#[test]
245
fn a_reminder_snoozed_in_outlook_waits_for_its_fire_time() {
246
let outlook = known(vec![reminder("a", at(9, 43))], at(9, 39));
247
assert!(!outlook.allows(&event("a"), at(9, 42)));
248
assert!(outlook.allows(&event("a"), at(9, 43)));
249
}
250
251
#[test]
252
fn events_outside_the_read_range_are_not_judged() {
253
let outlook = known(Vec::new(), at(9, 39));
254
let tomorrow = CalendarEvent {
255
start: at(9, 45) + Duration::days(1),
256
..event("a")
257
};
258
assert!(outlook.allows(&tomorrow, at(9, 40)));
259
}
260
261
#[test]
262
fn own_writes_update_the_known_state_at_once() {
263
let mut outlook = known(vec![reminder("a", at(9, 30))], at(9, 39));
264
outlook.note("a", ReminderWrite::Snooze(at(9, 45)));
265
assert!(!outlook.allows(&event("a"), at(9, 44)));
266
assert!(outlook.allows(&event("a"), at(9, 45)));
267
outlook.note("a", ReminderWrite::Dismiss);
268
assert!(!outlook.allows(&event("a"), at(9, 46)));
269
}
270
}
@@ -0,0 +1,270 @@1
use std::collections::HashMap;2
3
use chatsvc::{CalendarEvent, Reminder};4
use chrono::{DateTime, Duration, Utc};5
use gpui_kit::Context;6
7
use super::reminder::{GRACE_MINUTES, LEAD_MINUTES, is_eligible};8
use crate::app_state::AppState;9
use crate::runtime;10
11
const POLL_SECONDS: i64 = 60;12
const WATCH_BEFORE_LEAD_MINUTES: i64 = 1;13
const RANGE_HOURS: i64 = 1;14
15
#[derive(Debug, Clone, PartialEq, Eq)]16
struct KnownReminders {17
start: DateTime<Utc>,18
end: DateTime<Utc>,19
fire_times: HashMap<String, DateTime<Utc>>,20
}21
22
#[derive(Debug, Default)]23
pub struct OutlookReminders {24
known: Option<KnownReminders>,25
last_poll: Option<DateTime<Utc>>,26
polling: bool,27
}28
29
#[derive(Debug, Clone, Copy, PartialEq, Eq)]30
pub enum ReminderWrite {31
Snooze(DateTime<Utc>),32
Dismiss,33
}34
35
fn watched(event: &CalendarEvent, now: DateTime<Utc>) -> bool {36
let watch_from = event.start - Duration::minutes(LEAD_MINUTES + WATCH_BEFORE_LEAD_MINUTES);37
let watch_until = event38
.end39
.min(event.start + Duration::minutes(GRACE_MINUTES));40
is_eligible(event) && now >= watch_from && now < watch_until41
}42
43
impl OutlookReminders {44
pub fn poll_range(45
&mut self,46
events: &[CalendarEvent],47
now: DateTime<Utc>,48
) -> Option<(DateTime<Utc>, DateTime<Utc>)> {49
let due = !self.polling50
&& self51
.last_poll52
.is_none_or(|last| now - last >= Duration::seconds(POLL_SECONDS));53
if !due || !events.iter().any(|event| watched(event, now)) {54
return None;55
}56
self.polling = true;57
self.last_poll = Some(now);58
Some((59
now - Duration::hours(RANGE_HOURS),60
now + Duration::hours(RANGE_HOURS),61
))62
}63
64
pub fn apply(65
&mut self,66
start: DateTime<Utc>,67
end: DateTime<Utc>,68
fetched: Result<Vec<Reminder>, String>,69
) {70
self.polling = false;71
self.known = fetched.ok().map(|reminders| KnownReminders {72
start,73
end,74
fire_times: reminders75
.into_iter()76
.map(|reminder| (reminder.event_id, reminder.fire_time))77
.collect(),78
});79
}80
81
pub fn allows(&self, event: &CalendarEvent, now: DateTime<Utc>) -> bool {82
let Some(known) = &self.known else {83
return true;84
};85
if event.start < known.start || event.start >= known.end {86
return true;87
}88
known89
.fire_times90
.get(&event.object_id)91
.is_some_and(|fire_time| now >= *fire_time)92
}93
94
pub fn note(&mut self, event_id: &str, write: ReminderWrite) {95
let Some(known) = self.known.as_mut() else {96
return;97
};98
match write {99
ReminderWrite::Snooze(until) => {100
known.fire_times.insert(event_id.to_owned(), until);101
}102
ReminderWrite::Dismiss => {103
known.fire_times.remove(event_id);104
}105
}106
}107
}108
109
impl AppState {110
pub(super) fn poll_outlook_reminders(&mut self, now: DateTime<Utc>, cx: &mut Context<Self>) {111
if self.mode.demo {112
return;113
}114
let Some(launcher) = self.call_launcher.clone() else {115
return;116
};117
let Some((start, end)) = self118
.meeting_toasts119
.outlook_mut()120
.poll_range(&self.calendar_events, now)121
else {122
return;123
};124
let fetched = runtime::spawn(async move { launcher.reminder_view(start, end).await });125
cx.spawn(async move |this, cx| {126
let fetched = fetched127
.await128
.unwrap_or_else(|_| Err("reminder fetch was dropped".to_owned()));129
if let Err(error) = &fetched {130
crate::diagnostics::record(format!(131
"calendar: Outlook reminders not read: {error}"132
));133
}134
this.update(cx, |state, _| {135
state136
.meeting_toasts137
.outlook_mut()138
.apply(start, end, fetched);139
})140
.ok();141
})142
.detach();143
}144
145
pub(super) fn write_outlook_reminder(&mut self, event_id: String, write: ReminderWrite) {146
if self.mode.demo || self.mode.read_only {147
return;148
}149
let Some(launcher) = self.call_launcher.clone() else {150
return;151
};152
self.meeting_toasts.outlook_mut().note(&event_id, write);153
runtime::handle().spawn(async move {154
let written = match write {155
ReminderWrite::Snooze(until) => launcher.snooze_reminder(&event_id, until).await,156
ReminderWrite::Dismiss => launcher.dismiss_reminder(&event_id).await,157
};158
if let Err(error) = written {159
crate::diagnostics::record(format!(160
"calendar: Outlook reminder {write:?} not saved: {error}"161
));162
}163
});164
}165
}166
167
#[cfg(test)]168
mod tests {169
use chatsvc::ResponseType;170
use chrono::TimeZone;171
172
use super::*;173
174
fn at(hour: u32, minute: u32) -> DateTime<Utc> {175
Utc.with_ymd_and_hms(2026, 10, 19, hour, minute, 0).unwrap()176
}177
178
fn event(id: &str) -> CalendarEvent {179
CalendarEvent {180
object_id: id.into(),181
subject: "Daily Standup".into(),182
start: at(9, 45),183
end: at(10, 0),184
all_day: false,185
cancelled: false,186
online: true,187
join_url: Some("https://teams.microsoft.com/l/meetup-join/x".into()),188
thread_id: None,189
organizer_name: None,190
organizer_address: None,191
ical_uid: None,192
response: ResponseType::Accepted,193
}194
}195
196
fn reminder(event_id: &str, fire_time: DateTime<Utc>) -> Reminder {197
Reminder {198
event_id: event_id.into(),199
fire_time,200
}201
}202
203
fn known(reminders: Vec<Reminder>, now: DateTime<Utc>) -> OutlookReminders {204
let mut outlook = OutlookReminders::default();205
let (start, end) = outlook.poll_range(&[event("a")], now).unwrap();206
outlook.apply(start, end, Ok(reminders));207
outlook208
}209
210
#[test]211
fn polls_only_near_a_meeting_and_once_a_minute() {212
let events = [event("a")];213
let mut outlook = OutlookReminders::default();214
assert_eq!(outlook.poll_range(&events, at(9, 38)), None);215
let range = outlook.poll_range(&events, at(9, 39)).unwrap();216
assert_eq!(range, (at(8, 39), at(10, 39)));217
assert_eq!(outlook.poll_range(&events, at(9, 41)), None);218
outlook.apply(range.0, range.1, Ok(Vec::new()));219
assert_eq!(220
outlook.poll_range(&events, at(9, 39) + Duration::seconds(59)),221
None222
);223
assert!(outlook.poll_range(&events, at(9, 40)).is_some());224
let mut later = OutlookReminders::default();225
assert_eq!(later.poll_range(&events, at(9, 50)), None);226
}227
228
#[test]229
fn unknown_state_keeps_the_local_behaviour() {230
let mut outlook = OutlookReminders::default();231
assert!(outlook.allows(&event("a"), at(9, 40)));232
let (start, end) = outlook.poll_range(&[event("a")], at(9, 39)).unwrap();233
outlook.apply(start, end, Err("offline".into()));234
assert!(outlook.allows(&event("a"), at(9, 40)));235
}236
237
#[test]238
fn a_reminder_missing_in_outlook_was_dismissed_there() {239
let outlook = known(vec![reminder("b", at(9, 30))], at(9, 39));240
assert!(!outlook.allows(&event("a"), at(9, 40)));241
assert!(outlook.allows(&event("b"), at(9, 40)));242
}243
244
#[test]245
fn a_reminder_snoozed_in_outlook_waits_for_its_fire_time() {246
let outlook = known(vec![reminder("a", at(9, 43))], at(9, 39));247
assert!(!outlook.allows(&event("a"), at(9, 42)));248
assert!(outlook.allows(&event("a"), at(9, 43)));249
}250
251
#[test]252
fn events_outside_the_read_range_are_not_judged() {253
let outlook = known(Vec::new(), at(9, 39));254
let tomorrow = CalendarEvent {255
start: at(9, 45) + Duration::days(1),256
..event("a")257
};258
assert!(outlook.allows(&tomorrow, at(9, 40)));259
}260
261
#[test]262
fn own_writes_update_the_known_state_at_once() {263
let mut outlook = known(vec![reminder("a", at(9, 30))], at(9, 39));264
outlook.note("a", ReminderWrite::Snooze(at(9, 45)));265
assert!(!outlook.allows(&event("a"), at(9, 44)));266
assert!(outlook.allows(&event("a"), at(9, 45)));267
outlook.note("a", ReminderWrite::Dismiss);268
assert!(!outlook.allows(&event("a"), at(9, 46)));269
}270
}@@ -4,6 +4,7 @@ use chatsvc::{CalendarEvent, ResponseType};
4
4
use chrono::{DateTime, Duration, FixedOffset, Utc};
5
5
use gpui_kit::Context;
6
6
7
use super::outlook_reminders::{OutlookReminders, ReminderWrite};
7
8
use crate::app_state::{AppEvent, AppState};
8
9
9
10
pub const LEAD_MINUTES: i64 = 5;
@@ -22,6 +23,7 @@ pub enum ReminderPhase {
22
23
pub struct MeetingToast {
23
24
pub id: u64,
24
25
pub event_key: String,
26
pub event_id: String,
25
27
pub phase: ReminderPhase,
26
28
pub subject: String,
27
29
pub start: DateTime<Utc>,
@@ -32,13 +34,16 @@ fn event_key(event: &CalendarEvent) -> String {
32
34
format!("{}@{}", event.object_id, event.start.timestamp())
33
35
}
34
36
35
pub fn phase_at(event: &CalendarEvent, now: DateTime<Utc>, live: bool) -> Option<ReminderPhase> {
36
let eligible = event.online
37
pub(super) fn is_eligible(event: &CalendarEvent) -> bool {
38
event.online
37
39
&& !event.cancelled
38
40
&& !event.all_day
39
41
&& event.join_url.is_some()
40
&& event.response != ResponseType::Declined;
41
if !eligible {
42
&& event.response != ResponseType::Declined
43
}
44
45
pub fn phase_at(event: &CalendarEvent, now: DateTime<Utc>, live: bool) -> Option<ReminderPhase> {
46
if !is_eligible(event) {
42
47
return None;
43
48
}
44
49
let opens = event.start - Duration::minutes(LEAD_MINUTES);
@@ -93,6 +98,7 @@ pub struct MeetingToasts {
93
98
next_id: u64,
94
99
last_check: Option<DateTime<Utc>>,
95
100
last_live_poll: Option<DateTime<Utc>>,
101
outlook: OutlookReminders,
96
102
}
97
103
98
104
impl MeetingToasts {
@@ -112,6 +118,10 @@ impl MeetingToasts {
112
118
self.entries.is_empty()
113
119
}
114
120
121
pub fn outlook_mut(&mut self) -> &mut OutlookReminders {
122
&mut self.outlook
123
}
124
115
125
pub fn dismiss(&mut self, id: u64) -> Option<MeetingToast> {
116
126
let index = self.entries.iter().position(|toast| toast.id == id)?;
117
127
let toast = self.entries.remove(index);
@@ -166,9 +176,11 @@ impl MeetingToasts {
166
176
) -> ReminderUpdate {
167
177
self.last_check = Some(now);
168
178
let before = self.entries.clone();
179
let outlook = &self.outlook;
169
180
self.entries.retain(|toast| {
170
181
events.iter().any(|event| {
171
182
event_key(event) == toast.event_key
183
&& outlook.allows(event, now)
172
184
&& phase_at(event, now, is_live(event, live_threads)).is_some()
173
185
})
174
186
});
@@ -186,6 +198,10 @@ impl MeetingToasts {
186
198
if self.dismissed.contains(&key) {
187
199
continue;
188
200
}
201
if !self.outlook.allows(event, now) {
202
self.fired.retain(|(fired_key, _)| *fired_key != key);
203
continue;
204
}
189
205
let chime_due = phase != ReminderPhase::Soon && !self.chimed.contains(&key);
190
206
if let Some(existing) = self.entries.iter_mut().find(|toast| toast.event_key == key) {
191
207
existing.phase = phase;
@@ -224,6 +240,7 @@ impl MeetingToasts {
224
240
self.entries.push(MeetingToast {
225
241
id: self.next_id,
226
242
event_key: key,
243
event_id: event.object_id.clone(),
227
244
phase,
228
245
subject,
229
246
start: event.start,
@@ -240,6 +257,7 @@ impl MeetingToasts {
240
257
impl AppState {
241
258
pub fn tick_meeting_reminders(&mut self, show: bool, cx: &mut Context<Self>) {
242
259
let now = Utc::now();
260
self.poll_outlook_reminders(now, cx);
243
261
let in_call = self.call.is_some();
244
262
let show = show && !in_call && !self.mode.read_only;
245
263
for thread_id in self
@@ -284,14 +302,16 @@ impl AppState {
284
302
}
285
303
286
304
pub fn snooze_meeting_toast(&mut self, id: u64, cx: &mut Context<Self>) {
287
if self.meeting_toasts.snooze(id).is_some() {
305
if let Some(toast) = self.meeting_toasts.snooze(id) {
306
self.write_outlook_reminder(toast.event_id, ReminderWrite::Snooze(toast.start));
288
307
cx.emit(AppEvent::MeetingReminder);
289
308
cx.notify();
290
309
}
291
310
}
292
311
293
312
pub fn dismiss_meeting_toast(&mut self, id: u64, cx: &mut Context<Self>) {
294
if self.meeting_toasts.dismiss(id).is_some() {
313
if let Some(toast) = self.meeting_toasts.dismiss(id) {
314
self.write_outlook_reminder(toast.event_id, ReminderWrite::Dismiss);
295
315
cx.emit(AppEvent::MeetingReminder);
296
316
cx.notify();
297
317
}
@@ -613,6 +633,7 @@ mod tests {
613
633
let toast = |phase| MeetingToast {
614
634
id: 1,
615
635
event_key: "a".into(),
636
event_id: "a".into(),
616
637
phase,
617
638
subject: "Planning".into(),
618
639
start: at(9, 0, 0),
@@ -653,6 +674,66 @@ mod tests {
653
674
assert!(!toasts.clear());
654
675
}
655
676
677
fn outlook_state(
678
toasts: &mut MeetingToasts,
679
now: DateTime<Utc>,
680
fire_times: &[(&str, DateTime<Utc>)],
681
) {
682
let outlook = toasts.outlook_mut();
683
let (start, end) = outlook.poll_range(&[event("a")], now).unwrap();
684
let reminders = fire_times
685
.iter()
686
.map(|(event_id, fire_time)| chatsvc::Reminder {
687
event_id: (*event_id).into(),
688
fire_time: *fire_time,
689
})
690
.collect();
691
outlook.apply(start, end, Ok(reminders));
692
}
693
694
#[test]
695
fn a_reminder_dismissed_in_outlook_is_not_shown_and_closes_an_open_toast() {
696
let events = [event("a"), event("b")];
697
let mut toasts = MeetingToasts::default();
698
outlook_state(&mut toasts, at(8, 54, 0), &[("b", at(8, 45, 0))]);
699
tick(&mut toasts, &events, at(8, 56, 0), true);
700
assert_eq!(toasts.entries().len(), 1);
701
assert_eq!(toasts.entries()[0].event_id, "b");
702
outlook_state(&mut toasts, at(8, 57, 0), &[]);
703
assert!(tick(&mut toasts, &events, at(8, 57, 1), true).changed);
704
assert!(toasts.is_empty());
705
}
706
707
#[test]
708
fn a_reminder_snoozed_in_outlook_comes_back_at_its_fire_time() {
709
let events = [event("a")];
710
let mut toasts = MeetingToasts::default();
711
outlook_state(&mut toasts, at(8, 54, 0), &[("a", at(8, 45, 0))]);
712
tick(&mut toasts, &events, at(8, 56, 0), true);
713
assert_eq!(toasts.entries().len(), 1);
714
outlook_state(&mut toasts, at(8, 57, 0), &[("a", at(8, 59, 0))]);
715
tick(&mut toasts, &events, at(8, 57, 1), true);
716
assert!(toasts.is_empty());
717
tick(&mut toasts, &events, at(8, 58, 59), true);
718
assert!(toasts.is_empty());
719
tick(&mut toasts, &events, at(8, 59, 0), true);
720
assert_eq!(toasts.entries().len(), 1);
721
}
722
723
#[test]
724
fn snooze_and_dismiss_hand_back_the_event_for_the_outlook_write() {
725
let events = [event("a"), event("b")];
726
let mut toasts = MeetingToasts::default();
727
tick(&mut toasts, &events, at(8, 56, 0), true);
728
let snoozed = toasts.snooze(toasts.entries()[0].id).unwrap();
729
assert_eq!(
730
(snoozed.event_id.as_str(), snoozed.start),
731
("a", at(9, 0, 0))
732
);
733
let dismissed = toasts.dismiss(toasts.entries()[0].id).unwrap();
734
assert_eq!(dismissed.event_id, "b");
735
}
736
656
737
#[test]
657
738
fn checks_run_at_most_once_a_second() {
658
739
let mut toasts = MeetingToasts::default();
@@ -4,6 +4,7 @@ use chatsvc::{CalendarEvent, ResponseType};4
use chrono::{DateTime, Duration, FixedOffset, Utc};4
use chrono::{DateTime, Duration, FixedOffset, Utc};5
use gpui_kit::Context;5
use gpui_kit::Context;6
6
7
use super::outlook_reminders::{OutlookReminders, ReminderWrite};7
use crate::app_state::{AppEvent, AppState};8
use crate::app_state::{AppEvent, AppState};8
9
9
pub const LEAD_MINUTES: i64 = 5;10
pub const LEAD_MINUTES: i64 = 5;@@ -22,6 +23,7 @@ pub enum ReminderPhase {22
pub struct MeetingToast {23
pub struct MeetingToast {23
pub id: u64,24
pub id: u64,24
pub event_key: String,25
pub event_key: String,26
pub event_id: String,25
pub phase: ReminderPhase,27
pub phase: ReminderPhase,26
pub subject: String,28
pub subject: String,27
pub start: DateTime<Utc>,29
pub start: DateTime<Utc>,@@ -32,13 +34,16 @@ fn event_key(event: &CalendarEvent) -> String {32
format!("{}@{}", event.object_id, event.start.timestamp())34
format!("{}@{}", event.object_id, event.start.timestamp())33
}35
}34
36
35
pub fn phase_at(event: &CalendarEvent, now: DateTime<Utc>, live: bool) -> Option<ReminderPhase> {37
pub(super) fn is_eligible(event: &CalendarEvent) -> bool {36
let eligible = event.online38
event.online37
&& !event.cancelled39
&& !event.cancelled38
&& !event.all_day40
&& !event.all_day39
&& event.join_url.is_some()41
&& event.join_url.is_some()40
&& event.response != ResponseType::Declined;42
&& event.response != ResponseType::Declined41
if !eligible {43
}44
45
pub fn phase_at(event: &CalendarEvent, now: DateTime<Utc>, live: bool) -> Option<ReminderPhase> {46
if !is_eligible(event) {42
return None;47
return None;43
}48
}44
let opens = event.start - Duration::minutes(LEAD_MINUTES);49
let opens = event.start - Duration::minutes(LEAD_MINUTES);@@ -93,6 +98,7 @@ pub struct MeetingToasts {93
next_id: u64,98
next_id: u64,94
last_check: Option<DateTime<Utc>>,99
last_check: Option<DateTime<Utc>>,95
last_live_poll: Option<DateTime<Utc>>,100
last_live_poll: Option<DateTime<Utc>>,101
outlook: OutlookReminders,96
}102
}97
103
98
impl MeetingToasts {104
impl MeetingToasts {@@ -112,6 +118,10 @@ impl MeetingToasts {112
self.entries.is_empty()118
self.entries.is_empty()113
}119
}114
120
121
pub fn outlook_mut(&mut self) -> &mut OutlookReminders {122
&mut self.outlook123
}124
115
pub fn dismiss(&mut self, id: u64) -> Option<MeetingToast> {125
pub fn dismiss(&mut self, id: u64) -> Option<MeetingToast> {116
let index = self.entries.iter().position(|toast| toast.id == id)?;126
let index = self.entries.iter().position(|toast| toast.id == id)?;117
let toast = self.entries.remove(index);127
let toast = self.entries.remove(index);@@ -166,9 +176,11 @@ impl MeetingToasts {166
) -> ReminderUpdate {176
) -> ReminderUpdate {167
self.last_check = Some(now);177
self.last_check = Some(now);168
let before = self.entries.clone();178
let before = self.entries.clone();179
let outlook = &self.outlook;169
self.entries.retain(|toast| {180
self.entries.retain(|toast| {170
events.iter().any(|event| {181
events.iter().any(|event| {171
event_key(event) == toast.event_key182
event_key(event) == toast.event_key183
&& outlook.allows(event, now)172
&& phase_at(event, now, is_live(event, live_threads)).is_some()184
&& phase_at(event, now, is_live(event, live_threads)).is_some()173
})185
})174
});186
});@@ -186,6 +198,10 @@ impl MeetingToasts {186
if self.dismissed.contains(&key) {198
if self.dismissed.contains(&key) {187
continue;199
continue;188
}200
}201
if !self.outlook.allows(event, now) {202
self.fired.retain(|(fired_key, _)| *fired_key != key);203
continue;204
}189
let chime_due = phase != ReminderPhase::Soon && !self.chimed.contains(&key);205
let chime_due = phase != ReminderPhase::Soon && !self.chimed.contains(&key);190
if let Some(existing) = self.entries.iter_mut().find(|toast| toast.event_key == key) {206
if let Some(existing) = self.entries.iter_mut().find(|toast| toast.event_key == key) {191
existing.phase = phase;207
existing.phase = phase;@@ -224,6 +240,7 @@ impl MeetingToasts {224
self.entries.push(MeetingToast {240
self.entries.push(MeetingToast {225
id: self.next_id,241
id: self.next_id,226
event_key: key,242
event_key: key,243
event_id: event.object_id.clone(),227
phase,244
phase,228
subject,245
subject,229
start: event.start,246
start: event.start,@@ -240,6 +257,7 @@ impl MeetingToasts {240
impl AppState {257
impl AppState {241
pub fn tick_meeting_reminders(&mut self, show: bool, cx: &mut Context<Self>) {258
pub fn tick_meeting_reminders(&mut self, show: bool, cx: &mut Context<Self>) {242
let now = Utc::now();259
let now = Utc::now();260
self.poll_outlook_reminders(now, cx);243
let in_call = self.call.is_some();261
let in_call = self.call.is_some();244
let show = show && !in_call && !self.mode.read_only;262
let show = show && !in_call && !self.mode.read_only;245
for thread_id in self263
for thread_id in self@@ -284,14 +302,16 @@ impl AppState {284
}302
}285
303
286
pub fn snooze_meeting_toast(&mut self, id: u64, cx: &mut Context<Self>) {304
pub fn snooze_meeting_toast(&mut self, id: u64, cx: &mut Context<Self>) {287
if self.meeting_toasts.snooze(id).is_some() {305
if let Some(toast) = self.meeting_toasts.snooze(id) {306
self.write_outlook_reminder(toast.event_id, ReminderWrite::Snooze(toast.start));288
cx.emit(AppEvent::MeetingReminder);307
cx.emit(AppEvent::MeetingReminder);289
cx.notify();308
cx.notify();290
}309
}291
}310
}292
311
293
pub fn dismiss_meeting_toast(&mut self, id: u64, cx: &mut Context<Self>) {312
pub fn dismiss_meeting_toast(&mut self, id: u64, cx: &mut Context<Self>) {294
if self.meeting_toasts.dismiss(id).is_some() {313
if let Some(toast) = self.meeting_toasts.dismiss(id) {314
self.write_outlook_reminder(toast.event_id, ReminderWrite::Dismiss);295
cx.emit(AppEvent::MeetingReminder);315
cx.emit(AppEvent::MeetingReminder);296
cx.notify();316
cx.notify();297
}317
}@@ -613,6 +633,7 @@ mod tests {613
let toast = |phase| MeetingToast {633
let toast = |phase| MeetingToast {614
id: 1,634
id: 1,615
event_key: "a".into(),635
event_key: "a".into(),636
event_id: "a".into(),616
phase,637
phase,617
subject: "Planning".into(),638
subject: "Planning".into(),618
start: at(9, 0, 0),639
start: at(9, 0, 0),@@ -653,6 +674,66 @@ mod tests {653
assert!(!toasts.clear());674
assert!(!toasts.clear());654
}675
}655
676
677
fn outlook_state(678
toasts: &mut MeetingToasts,679
now: DateTime<Utc>,680
fire_times: &[(&str, DateTime<Utc>)],681
) {682
let outlook = toasts.outlook_mut();683
let (start, end) = outlook.poll_range(&[event("a")], now).unwrap();684
let reminders = fire_times685
.iter()686
.map(|(event_id, fire_time)| chatsvc::Reminder {687
event_id: (*event_id).into(),688
fire_time: *fire_time,689
})690
.collect();691
outlook.apply(start, end, Ok(reminders));692
}693
694
#[test]695
fn a_reminder_dismissed_in_outlook_is_not_shown_and_closes_an_open_toast() {696
let events = [event("a"), event("b")];697
let mut toasts = MeetingToasts::default();698
outlook_state(&mut toasts, at(8, 54, 0), &[("b", at(8, 45, 0))]);699
tick(&mut toasts, &events, at(8, 56, 0), true);700
assert_eq!(toasts.entries().len(), 1);701
assert_eq!(toasts.entries()[0].event_id, "b");702
outlook_state(&mut toasts, at(8, 57, 0), &[]);703
assert!(tick(&mut toasts, &events, at(8, 57, 1), true).changed);704
assert!(toasts.is_empty());705
}706
707
#[test]708
fn a_reminder_snoozed_in_outlook_comes_back_at_its_fire_time() {709
let events = [event("a")];710
let mut toasts = MeetingToasts::default();711
outlook_state(&mut toasts, at(8, 54, 0), &[("a", at(8, 45, 0))]);712
tick(&mut toasts, &events, at(8, 56, 0), true);713
assert_eq!(toasts.entries().len(), 1);714
outlook_state(&mut toasts, at(8, 57, 0), &[("a", at(8, 59, 0))]);715
tick(&mut toasts, &events, at(8, 57, 1), true);716
assert!(toasts.is_empty());717
tick(&mut toasts, &events, at(8, 58, 59), true);718
assert!(toasts.is_empty());719
tick(&mut toasts, &events, at(8, 59, 0), true);720
assert_eq!(toasts.entries().len(), 1);721
}722
723
#[test]724
fn snooze_and_dismiss_hand_back_the_event_for_the_outlook_write() {725
let events = [event("a"), event("b")];726
let mut toasts = MeetingToasts::default();727
tick(&mut toasts, &events, at(8, 56, 0), true);728
let snoozed = toasts.snooze(toasts.entries()[0].id).unwrap();729
assert_eq!(730
(snoozed.event_id.as_str(), snoozed.start),731
("a", at(9, 0, 0))732
);733
let dismissed = toasts.dismiss(toasts.entries()[0].id).unwrap();734
assert_eq!(dismissed.event_id, "b");735
}736
656
#[test]737
#[test]657
fn checks_run_at_most_once_a_second() {738
fn checks_run_at_most_once_a_second() {658
let mut toasts = MeetingToasts::default();739
let mut toasts = MeetingToasts::default();@@ -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 @@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
given53
.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> = events71
.iter()72
.flatten()73
.filter(|event| event.phase == CallPhase::Ended)74
.map(|event| event.call_id.clone())75
.collect();76
let transcripts: HashSet<String> = events77
.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 = events84
.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
event133
.participant_ids134
.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: recording151
.title()152
.unwrap_or_else(|| RECORDING_FALLBACK_TITLE.to_owned()),153
duration: event154
.duration_seconds155
.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 = event182
.recording183
.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::RecordStop226
}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> = events299
.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
.title312
})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 = events357
.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> = card370
.participants371
.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
}@@ -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
@@ -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 @@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
event35
}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
}@@ -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;
@@ -12,6 +13,7 @@ pub mod chat_actions;
12
13
pub mod chat_members;
13
14
pub mod data;
14
15
pub mod demo;
16
pub mod demo_meetings;
15
17
pub mod demo_profiles;
16
18
pub mod emoji;
17
19
pub mod gifs;
@@ -4,6 +4,7 @@ pub mod agents;4
pub mod app_state;4
pub mod app_state;5
pub mod backend;5
pub mod backend;6
pub mod call;6
pub mod call;7
pub mod call_rows;7
pub mod card_actions;8
pub mod card_actions;8
pub mod card_inputs;9
pub mod card_inputs;9
pub mod card_refresh;10
pub mod card_refresh;@@ -12,6 +13,7 @@ pub mod chat_actions;12
pub mod chat_members;13
pub mod chat_members;13
pub mod data;14
pub mod data;14
pub mod demo;15
pub mod demo;16
pub mod demo_meetings;15
pub mod demo_profiles;17
pub mod demo_profiles;16
pub mod emoji;18
pub mod emoji;17
pub mod gifs;19
pub mod gifs;@@ -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, "ed),
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 @@1
use std::collections::{BTreeMap, HashMap, HashSet};1
use std::collections::{BTreeMap, HashMap};2
use std::ops::Range;2
use std::ops::Range;3
use std::sync::Arc;3
use std::sync::Arc;4
4
@@ -7,13 +7,15 @@ use gpui_kit::Image;7
use store::MessageRecord;7
use store::MessageRecord;8
use teams_core::{8
use 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
17
pub use crate::call_rows::{CallCard, CallIcon, CallParticipant, RecordingCard};18
use crate::call_rows::{CallNames, CallTimeline, call_card};17
use crate::card_state::CardOverride;19
use crate::card_state::CardOverride;18
use crate::format;20
use crate::format;19
use crate::reaction_model::{Reactor, UNKNOWN_REACTOR};21
use 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)]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
#[derive(Debug, Clone, PartialEq)]116
#[derive(Debug, Clone, PartialEq)]131
pub struct MessageRow {117
pub struct MessageRow {132
pub key: String,118
pub key: String,@@ -590,30 +576,18 @@ fn visible_reactions(record: &MessageRecord, context: &RowContext) -> Vec<Reacti590
visible576
visible591
}577
}592
578
593
pub fn call_card(event: &CallEvent, time: &str, my_user_id: Option<&str>) -> CallCard {579
fn 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
614
fn 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 = event591
let author = event618
.initiator_name592
.initiator_name619
.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
795
fn finished_call_ids(events: &[Option<CallEvent>]) -> HashSet<&str> {796
events797
.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
pub fn flat_rows(records: &[MessageRecord], context: &RowContext, has_older: bool) -> Vec<Row> {775
pub 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
event817
.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, "ed),795
None => message_row_with(record, context, "ed),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 = record800
let day = record836
.created_at801
.created_at@@ -878,16 +843,60 @@ fn last_activity(thread: &Thread, by_id: &BTreeMap<&str, &MessageRecord>) -> Dat878
.unwrap_or_default()843
.unwrap_or_default()879
}844
}880
845
881
fn post_message_row(record: &MessageRecord, context: &RowContext) -> MessageRow {846
fn 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
row862
row886
}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: started882
.initiator_name883
.clone()884
.or(ended_event.initiator_name.clone()),885
..ended_event886
};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
row895
}896
888
fn distinct_names<'a>(records: impl Iterator<Item = &'a MessageRecord>) -> Vec<String> {897
fn 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 = record900
let name = record892
.sender_name901
.sender_name893
.clone()902
.clone()@@ -900,45 +909,87 @@ fn distinct_names<'a>(records: impl Iterator<Item = &'a MessageRecord>) -> Vec<S900
}909
}901
910
902
fn post_row(911
fn 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 notices931
/// 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
pub fn thread_list_rows(940
pub 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> = records945
let events: Vec<Option<CallEvent>> = records.iter().map(call_event).collect();946
let timeline = CallTimeline::new(&events);947
let ended: HashMap<&str, (&MessageRecord, &CallEvent)> = records948
.iter()949
.zip(&events)950
.filter_map(|(record, event)| {951
let event = event952
.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>)> = records958
.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_id926
.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> = threads969
let mut rows: Vec<Row> = threads933
.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
ended978
.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 = thread985
let replies = thread937
.reply_ids986
.reply_ids938
.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)]1031
mod tests {1082
mod 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
post2047
}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> = thread2088
.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
.call2121
.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 = thread2128
.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(@@ -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>@@ -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>@@ -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>@@ -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>@@ -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_7
use super::profile_card::opens_profile;7
use super::profile_card::opens_profile;8
use super::widgets::symbol;8
use super::widgets::symbol;9
use crate::data::Directory;9
use crate::data::Directory;10
use crate::rows::{CallCard, CallIcon, MessageRow};10
use crate::rows::{CallCard, CallIcon, CallParticipant, MessageRow, RecordingCard};11
use crate::theme;11
use crate::theme;12
12
13
const SERIES_START_GAP: f32 = 8.;13
const SERIES_START_GAP: f32 = 8.;@@ -18,10 +18,32 @@ const ICON_SIZE: f32 = 18.;18
const TITLE_SIZE: f32 = 13.;18
const TITLE_SIZE: f32 = 13.;19
const DETAIL_SIZE: f32 = 11.;19
const DETAIL_SIZE: f32 = 11.;20
const JOIN_HEIGHT: f32 = 24.;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
pub struct CallActions {31
pub 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
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
fn icon_circle(call: &CallCard, own: bool) -> Div {49
fn 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
97
fn card(call: &CallCard, index: usize, own: bool, actions: CallActions) -> Div {125
fn 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
164
fn recording_thumbnail(recording: &RecordingCard, directory: &Directory) -> AnyElement {165
let image = recording166
.thumbnail167
.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
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
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
.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
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
pub(super) fn call_card_row(358
pub(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()@@ -40,6 +40,7 @@ use super::message_actions::{Action, DelegateEntry, MessageMenu, QUICK_REACTION_
40
40
use super::message_row::{AVATAR_GAP, AVATAR_SIZE, render_message_row, render_skeleton_row};
41
41
use super::new_chat::{NewChatDraft, NewChatEvent, composer_placeholder};
42
42
use super::post_card::render_post;
43
use super::pin_banner::{pin_banner_inset, pin_banner_overlay};
43
44
use super::profile_card::opens_profile;
44
45
use super::reaction_picker::{PickHandler, ReactionPicker};
45
46
use super::reaction_pills::{ReactionControls, ReactionPopover};
@@ -3401,6 +3402,9 @@ impl Render for ConversationView {
3401
3402
agent_runs: self.agent_runs.clone(),
3402
3403
reaction_proposals: self.reaction_proposals.clone(),
3403
3404
};
3405
let pin_banner = self
3406
.render_pin_banner(cx)
3407
.filter(|_| !drafting && !self.shared_active() && !self.recap_active());
3404
3408
let scroller = MessageScroller::new(
3405
3409
"messages",
3406
3410
self.scroller.clone(),
@@ -3496,7 +3500,8 @@ impl Render for ConversationView {
3496
3500
view.update(cx, |this, cx| this.leave_detached(cx)).ok();
3497
3501
})
3498
3502
})
3499
.with_bottom_fade(background);
3503
.with_bottom_fade(background)
3504
.with_top_inset(pin_banner_inset(pin_banner.is_some()));
3500
3505
3501
3506
root = match self.current.as_ref().filter(|_| !drafting) {
3502
3507
Some(current) => root.child(self.render_header(current, cx)),
@@ -3506,7 +3511,6 @@ impl Render for ConversationView {
3506
3511
.render_tab_bar(window, cx)
3507
3512
.or_else(|| self.render_meeting_tab_bar(cx));
3508
3513
root = root.children(tab_bar.filter(|_| !drafting));
3509
root = root.children(self.render_pin_banner(cx).filter(|_| !drafting));
3510
3514
let sync_failed = self
3511
3515
.current
3512
3516
.as_ref()
@@ -3572,7 +3576,8 @@ impl Render for ConversationView {
3572
3576
.on_scroll_wheel(
3573
3577
cx.listener(|this, _, _, cx| this.close_reaction_details(cx)),
3574
3578
)
3575
.child(body),
3579
.child(body)
3580
.children(pin_banner.map(pin_banner_overlay)),
3576
3581
)
3577
3582
.children(self.render_draft_error(cx))
3578
3583
.when(!in_feed && !recap_active, |column| {
@@ -40,6 +40,7 @@ use super::message_actions::{Action, DelegateEntry, MessageMenu, QUICK_REACTION_40
use super::message_row::{AVATAR_GAP, AVATAR_SIZE, render_message_row, render_skeleton_row};40
use super::message_row::{AVATAR_GAP, AVATAR_SIZE, render_message_row, render_skeleton_row};41
use super::new_chat::{NewChatDraft, NewChatEvent, composer_placeholder};41
use super::new_chat::{NewChatDraft, NewChatEvent, composer_placeholder};42
use super::post_card::render_post;42
use super::post_card::render_post;43
use super::pin_banner::{pin_banner_inset, pin_banner_overlay};43
use super::profile_card::opens_profile;44
use super::profile_card::opens_profile;44
use super::reaction_picker::{PickHandler, ReactionPicker};45
use super::reaction_picker::{PickHandler, ReactionPicker};45
use super::reaction_pills::{ReactionControls, ReactionPopover};46
use super::reaction_pills::{ReactionControls, ReactionPopover};@@ -3401,6 +3402,9 @@ impl Render for ConversationView {3401
agent_runs: self.agent_runs.clone(),3402
agent_runs: self.agent_runs.clone(),3402
reaction_proposals: self.reaction_proposals.clone(),3403
reaction_proposals: self.reaction_proposals.clone(),3403
};3404
};3405
let pin_banner = self3406
.render_pin_banner(cx)3407
.filter(|_| !drafting && !self.shared_active() && !self.recap_active());3404
let scroller = MessageScroller::new(3408
let scroller = MessageScroller::new(3405
"messages",3409
"messages",3406
self.scroller.clone(),3410
self.scroller.clone(),@@ -3496,7 +3500,8 @@ impl Render for ConversationView {3496
view.update(cx, |this, cx| this.leave_detached(cx)).ok();3500
view.update(cx, |this, cx| this.leave_detached(cx)).ok();3497
})3501
})3498
})3502
})3499
.with_bottom_fade(background);3503
.with_bottom_fade(background)3504
.with_top_inset(pin_banner_inset(pin_banner.is_some()));3500
3505
3501
root = match self.current.as_ref().filter(|_| !drafting) {3506
root = match self.current.as_ref().filter(|_| !drafting) {3502
Some(current) => root.child(self.render_header(current, cx)),3507
Some(current) => root.child(self.render_header(current, cx)),@@ -3506,7 +3511,6 @@ impl Render for ConversationView {3506
.render_tab_bar(window, cx)3511
.render_tab_bar(window, cx)3507
.or_else(|| self.render_meeting_tab_bar(cx));3512
.or_else(|| self.render_meeting_tab_bar(cx));3508
root = root.children(tab_bar.filter(|_| !drafting));3513
root = root.children(tab_bar.filter(|_| !drafting));3509
root = root.children(self.render_pin_banner(cx).filter(|_| !drafting));3510
let sync_failed = self3514
let sync_failed = self3511
.current3515
.current3512
.as_ref()3516
.as_ref()@@ -3572,7 +3576,8 @@ impl Render for ConversationView {3572
.on_scroll_wheel(3576
.on_scroll_wheel(3573
cx.listener(|this, _, _, cx| this.close_reaction_details(cx)),3577
cx.listener(|this, _, _, cx| this.close_reaction_details(cx)),3574
)3578
)3575
.child(body),3579
.child(body)3580
.children(pin_banner.map(pin_banner_overlay)),3576
)3581
)3577
.children(self.render_draft_error(cx))3582
.children(self.render_draft_error(cx))3578
.when(!in_feed && !recap_active, |column| {3583
.when(!in_feed && !recap_active, |column| {@@ -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 any159
/// 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 = self167
.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) {@@ -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};14
use crate::agent_api::agent_label;14
use crate::agent_api::agent_label;15
use crate::agents::AgentRun;15
use crate::agents::AgentRun;16
use crate::app_state::AppState;16
use crate::app_state::AppState;17
use crate::rows::{Delivery, MessageRow, PostRow};17
use crate::rows::{Delivery, MessageRow, PostRow, RecordingCard};18
use crate::scheduled_rows::SCHEDULED_KEY_PREFIX;18
use crate::scheduled_rows::SCHEDULED_KEY_PREFIX;19
use crate::translation::TranslationLine;19
use crate::translation::TranslationLine;20
use crate::views::adaptive_card::{ensure_cards_inputs, request_card_refreshes};20
use 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
message73
.call74
.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> {@@ -8,6 +8,8 @@ use super::widgets::icon;
8
8
use crate::theme;
9
9
10
10
const BANNER_HEIGHT: f32 = 40.;
11
const BANNER_MARGIN: f32 = 20.;
12
const BANNER_GAP: f32 = 8.;
11
13
const BANNER_PADDING: f32 = 12.;
12
14
const BUTTON_SIZE: f32 = 28.;
13
15
const FALLBACK_PREVIEW: &str = "Pinned message";
@@ -26,6 +28,20 @@ pub struct PinBannerActions {
26
28
pub unpin: Action,
27
29
}
28
30
31
pub fn pin_banner_inset(shown: bool) -> Pixels {
32
px(if shown { BANNER_HEIGHT + BANNER_GAP } else { 0. })
33
}
34
35
pub fn pin_banner_overlay(banner: AnyElement) -> AnyElement {
36
div()
37
.absolute()
38
.top_0()
39
.left(px(BANNER_MARGIN))
40
.right(px(BANNER_MARGIN))
41
.child(banner)
42
.into_any_element()
43
}
44
29
45
pub fn cycle_pin(index: usize, length: usize, delta: isize) -> usize {
30
46
if length == 0 {
31
47
return 0;
@@ -71,16 +87,18 @@ pub fn render_pin_banner(data: PinBannerData, actions: PinBannerActions) -> AnyE
71
87
h_flex()
72
88
.id("pin-banner")
73
89
.group("pin-banner")
90
.occlude()
91
.w_full()
74
92
.h(px(BANNER_HEIGHT))
75
.flex_none()
76
.mx(px(20.))
77
.mb(px(8.))
78
93
.pl(px(BANNER_PADDING))
79
94
.pr(px(6.))
80
95
.gap(px(8.))
81
96
.items_center()
82
97
.rounded(px(8.))
98
.border_1()
99
.border_color(theme::border())
83
100
.bg(theme::row_hover())
101
.shadow(theme::toast_shadow())
84
102
.cursor_pointer()
85
103
.hover(|banner| banner.bg(theme::surface_raised()))
86
104
.on_click(move |_, window, cx| open(window, cx))
@@ -134,7 +152,8 @@ pub fn render_pin_banner(data: PinBannerData, actions: PinBannerActions) -> AnyE
134
152
135
153
#[cfg(test)]
136
154
mod tests {
137
use super::{cycle_pin, position_label};
155
use super::{BANNER_HEIGHT, cycle_pin, pin_banner_inset, position_label};
156
use gpui_kit::px;
138
157
139
158
#[test]
140
159
fn cycling_wraps_around_both_ends() {
@@ -151,6 +170,12 @@ mod tests {
151
170
assert_eq!(cycle_pin(0, 1, -1), 0);
152
171
}
153
172
173
#[test]
174
fn inset_clears_the_banner_only_while_it_shows() {
175
assert!(pin_banner_inset(true) > px(BANNER_HEIGHT));
176
assert_eq!(pin_banner_inset(false), px(0.));
177
}
178
154
179
#[test]
155
180
fn position_is_one_based() {
156
181
assert_eq!(position_label(0, 3), "1 of 3");
@@ -8,6 +8,8 @@ use super::widgets::icon;8
use crate::theme;8
use crate::theme;9
9
10
const BANNER_HEIGHT: f32 = 40.;10
const BANNER_HEIGHT: f32 = 40.;11
const BANNER_MARGIN: f32 = 20.;12
const BANNER_GAP: f32 = 8.;11
const BANNER_PADDING: f32 = 12.;13
const BANNER_PADDING: f32 = 12.;12
const BUTTON_SIZE: f32 = 28.;14
const BUTTON_SIZE: f32 = 28.;13
const FALLBACK_PREVIEW: &str = "Pinned message";15
const FALLBACK_PREVIEW: &str = "Pinned message";@@ -26,6 +28,20 @@ pub struct PinBannerActions {26
pub unpin: Action,28
pub unpin: Action,27
}29
}28
30
31
pub fn pin_banner_inset(shown: bool) -> Pixels {32
px(if shown { BANNER_HEIGHT + BANNER_GAP } else { 0. })33
}34
35
pub fn pin_banner_overlay(banner: AnyElement) -> AnyElement {36
div()37
.absolute()38
.top_0()39
.left(px(BANNER_MARGIN))40
.right(px(BANNER_MARGIN))41
.child(banner)42
.into_any_element()43
}44
29
pub fn cycle_pin(index: usize, length: usize, delta: isize) -> usize {45
pub fn cycle_pin(index: usize, length: usize, delta: isize) -> usize {30
if length == 0 {46
if length == 0 {31
return 0;47
return 0;@@ -71,16 +87,18 @@ pub fn render_pin_banner(data: PinBannerData, actions: PinBannerActions) -> AnyE71
h_flex()87
h_flex()72
.id("pin-banner")88
.id("pin-banner")73
.group("pin-banner")89
.group("pin-banner")90
.occlude()91
.w_full()74
.h(px(BANNER_HEIGHT))92
.h(px(BANNER_HEIGHT))75
.flex_none()76
.mx(px(20.))77
.mb(px(8.))78
.pl(px(BANNER_PADDING))93
.pl(px(BANNER_PADDING))79
.pr(px(6.))94
.pr(px(6.))80
.gap(px(8.))95
.gap(px(8.))81
.items_center()96
.items_center()82
.rounded(px(8.))97
.rounded(px(8.))98
.border_1()99
.border_color(theme::border())83
.bg(theme::row_hover())100
.bg(theme::row_hover())101
.shadow(theme::toast_shadow())84
.cursor_pointer()102
.cursor_pointer()85
.hover(|banner| banner.bg(theme::surface_raised()))103
.hover(|banner| banner.bg(theme::surface_raised()))86
.on_click(move |_, window, cx| open(window, cx))104
.on_click(move |_, window, cx| open(window, cx))@@ -134,7 +152,8 @@ pub fn render_pin_banner(data: PinBannerData, actions: PinBannerActions) -> AnyE134
152
135
#[cfg(test)]153
#[cfg(test)]136
mod tests {154
mod tests {137
use super::{cycle_pin, position_label};155
use super::{BANNER_HEIGHT, cycle_pin, pin_banner_inset, position_label};156
use gpui_kit::px;138
157
139
#[test]158
#[test]140
fn cycling_wraps_around_both_ends() {159
fn cycling_wraps_around_both_ends() {@@ -151,6 +170,12 @@ mod tests {151
assert_eq!(cycle_pin(0, 1, -1), 0);170
assert_eq!(cycle_pin(0, 1, -1), 0);152
}171
}153
172
173
#[test]174
fn inset_clears_the_banner_only_while_it_shows() {175
assert!(pin_banner_inset(true) > px(BANNER_HEIGHT));176
assert_eq!(pin_banner_inset(false), px(0.));177
}178
154
#[test]179
#[test]155
fn position_is_one_based() {180
fn position_is_one_based() {156
assert_eq!(position_label(0, 3), "1 of 3");181
assert_eq!(position_label(0, 3), "1 of 3");@@ -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::*;6
use super::adaptive_card::cards_view;6
use super::adaptive_card::cards_view;7
use super::attachments::{attachments_view, message_body};7
use super::attachments::{attachments_view, message_body};8
use super::avatar::{bot_avatar, person_avatar};8
use super::avatar::{bot_avatar, person_avatar};9
use super::call_card::{CallActions, post_call_card};9
use super::link_preview::{link_preview_card, meeting_join_chip};10
use super::link_preview::{link_preview_card, meeting_join_chip};10
use super::message_actions::message_toolbar;11
use super::message_actions::message_toolbar;11
use super::message_row::{BODY_SIZE, RowActions, delivery_note, forwarded_header, has_text};12
use 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,@@ -5,8 +5,10 @@ use session::{ApiResponse, Method, Request, Session};
5
5
use crate::cards::{CardTransport, DEFAULT_MT_REGION, SessionCardTransport, spaces_scope};
6
6
use crate::error::{Error, Result};
7
7
8
mod reminders;
8
9
mod schedule;
9
10
11
pub use reminders::{Reminder, parse_reminders};
10
12
pub use schedule::{
11
13
Attendee, CreatedEvent, NewEvent, Repeat, Reply, new_event_body, parse_created_event,
12
14
};
@@ -5,8 +5,10 @@ use session::{ApiResponse, Method, Request, Session};5
use crate::cards::{CardTransport, DEFAULT_MT_REGION, SessionCardTransport, spaces_scope};5
use crate::cards::{CardTransport, DEFAULT_MT_REGION, SessionCardTransport, spaces_scope};6
use crate::error::{Error, Result};6
use crate::error::{Error, Result};7
7
8
mod reminders;8
mod schedule;9
mod schedule;9
10
11
pub use reminders::{Reminder, parse_reminders};10
pub use schedule::{12
pub use schedule::{11
Attendee, CreatedEvent, NewEvent, Repeat, Reply, new_event_body, parse_created_event,13
Attendee, CreatedEvent, NewEvent, Repeat, Reply, new_event_body, parse_created_event,12
};14
};@@ -0,0 +1,273 @@
1
use chrono::{DateTime, NaiveDateTime, Utc};
2
use serde_json::{Value, json};
3
use session::{GRAPH, Method, Request, Scope};
4
5
use super::Calendar;
6
use super::schedule::CALENDARS_SCOPE;
7
use crate::cards::CardTransport;
8
use crate::error::{Error, Result};
9
use crate::messages::encode;
10
11
const QUERY_TIME_FORMAT: &str = "%Y-%m-%dT%H:%M:%SZ";
12
const GRAPH_TIME_FORMAT: &str = "%Y-%m-%dT%H:%M:%S";
13
const GRAPH_READ_FORMAT: &str = "%Y-%m-%dT%H:%M:%S%.f";
14
const UTC_PREFERENCE: &str = "outlook.timezone=\"UTC\"";
15
const MAX_PAGES: usize = 5;
16
17
#[derive(Debug, Clone, PartialEq, Eq)]
18
pub struct Reminder {
19
pub event_id: String,
20
pub fire_time: DateTime<Utc>,
21
}
22
23
fn reminder_view_url(start: DateTime<Utc>, end: DateTime<Utc>) -> String {
24
format!(
25
"{GRAPH}/v1.0/me/reminderView(startDateTime='{}',endDateTime='{}')",
26
start.format(QUERY_TIME_FORMAT),
27
end.format(QUERY_TIME_FORMAT)
28
)
29
}
30
31
fn reminder_action_url(event_id: &str, action: &str) -> String {
32
format!("{GRAPH}/v1.0/me/events/{}/{action}", encode(event_id))
33
}
34
35
fn utc_time(value: &Value) -> Option<DateTime<Utc>> {
36
let text = value.get("dateTime")?.as_str()?;
37
let zone = value
38
.get("timeZone")
39
.and_then(Value::as_str)
40
.unwrap_or("UTC");
41
if !zone.eq_ignore_ascii_case("UTC") {
42
return None;
43
}
44
NaiveDateTime::parse_from_str(text, GRAPH_READ_FORMAT)
45
.ok()
46
.map(|time| time.and_utc())
47
}
48
49
pub fn parse_reminders(body: &Value) -> Vec<Reminder> {
50
body.get("value")
51
.and_then(Value::as_array)
52
.into_iter()
53
.flatten()
54
.filter_map(|entry| {
55
Some(Reminder {
56
event_id: entry.get("eventId")?.as_str()?.to_owned(),
57
fire_time: utc_time(entry.get("reminderFireTime")?)?,
58
})
59
})
60
.collect()
61
}
62
63
impl<T: CardTransport> Calendar<T> {
64
pub async fn reminder_view(
65
&self,
66
start: DateTime<Utc>,
67
end: DateTime<Utc>,
68
) -> Result<Vec<Reminder>> {
69
let mut url = reminder_view_url(start, end);
70
let mut reminders = Vec::new();
71
for _ in 0..MAX_PAGES {
72
let mut request = Request::get(&url);
73
request
74
.headers
75
.push(("Prefer".to_owned(), UTC_PREFERENCE.to_owned()));
76
let answer = self
77
.transport
78
.send(request, Scope::graph(CALENDARS_SCOPE))
79
.await?;
80
if !answer.is_success() {
81
return Err(Error::Session(session::Error::api(
82
answer.status,
83
&url,
84
answer.body,
85
)));
86
}
87
reminders.extend(parse_reminders(&answer.body));
88
match answer.body.get("@odata.nextLink").and_then(Value::as_str) {
89
Some(next) => url = next.to_owned(),
90
None => break,
91
}
92
}
93
Ok(reminders)
94
}
95
96
pub async fn snooze_reminder(&self, event_id: &str, until: DateTime<Utc>) -> Result<()> {
97
let body = json!({"newReminderTime": {
98
"dateTime": until.format(GRAPH_TIME_FORMAT).to_string(),
99
"timeZone": "UTC",
100
}});
101
self.reminder_action(event_id, "snoozeReminder", Some(body))
102
.await
103
}
104
105
pub async fn dismiss_reminder(&self, event_id: &str) -> Result<()> {
106
self.reminder_action(event_id, "dismissReminder", None)
107
.await
108
}
109
110
async fn reminder_action(
111
&self,
112
event_id: &str,
113
action: &str,
114
body: Option<Value>,
115
) -> Result<()> {
116
let url = reminder_action_url(event_id, action);
117
let request = Request::with_body(Method::Post, &url, body.unwrap_or_else(|| json!({})));
118
let answer = self
119
.transport
120
.send(request, Scope::graph(CALENDARS_SCOPE))
121
.await?;
122
if answer.is_success() {
123
return Ok(());
124
}
125
Err(Error::Session(session::Error::api(
126
answer.status,
127
&url,
128
answer.body,
129
)))
130
}
131
}
132
133
#[cfg(test)]
134
mod tests {
135
use std::sync::Mutex;
136
137
use chrono::TimeZone;
138
use session::ApiResponse;
139
140
use super::*;
141
142
struct Scripted {
143
answers: Mutex<Vec<(u16, Value)>>,
144
sent: Mutex<Vec<Request>>,
145
}
146
147
impl Scripted {
148
fn new(answers: Vec<(u16, Value)>) -> Self {
149
Scripted {
150
answers: Mutex::new(answers),
151
sent: Mutex::new(Vec::new()),
152
}
153
}
154
}
155
156
impl CardTransport for Scripted {
157
async fn send(&self, request: Request, scope: Scope) -> Result<ApiResponse> {
158
assert_eq!(scope, Scope::graph(CALENDARS_SCOPE));
159
self.sent.lock().unwrap().push(request);
160
let (status, body) = self.answers.lock().unwrap().remove(0);
161
Ok(ApiResponse {
162
status,
163
body,
164
retry_after: None,
165
})
166
}
167
}
168
169
fn at(hour: u32, minute: u32) -> DateTime<Utc> {
170
Utc.with_ymd_and_hms(2026, 10, 19, hour, minute, 0).unwrap()
171
}
172
173
fn reminder_entry(event_id: &str, fire_time: &str) -> Value {
174
json!({
175
"eventId": event_id,
176
"eventSubject": "Daily Standup",
177
"eventStartTime": {"dateTime": "2026-10-19T09:45:00.0000000", "timeZone": "UTC"},
178
"reminderFireTime": {"dateTime": fire_time, "timeZone": "UTC"},
179
})
180
}
181
182
#[test]
183
fn reminders_carry_the_event_id_and_the_fire_time() {
184
let body = json!({"value": [
185
reminder_entry("AAMk-a", "2026-10-19T09:30:00.0000000"),
186
{"eventId": "AAMk-b", "reminderFireTime": {"dateTime": "2026-10-19T09:30:00", "timeZone": "W. Europe Standard Time"}},
187
{"reminderFireTime": {"dateTime": "2026-10-19T09:30:00", "timeZone": "UTC"}},
188
]});
189
assert_eq!(
190
parse_reminders(&body),
191
vec![Reminder {
192
event_id: "AAMk-a".into(),
193
fire_time: at(9, 30),
194
}]
195
);
196
}
197
198
#[tokio::test]
199
async fn the_reminder_view_asks_for_utc_and_follows_the_next_link() {
200
let calendar = Calendar::with_transport(
201
Scripted::new(vec![
202
(
203
200,
204
json!({
205
"value": [reminder_entry("AAMk-a", "2026-10-19T09:30:00.0000000")],
206
"@odata.nextLink": "https://graph.microsoft.com/v1.0/next-page",
207
}),
208
),
209
(
210
200,
211
json!({"value": [reminder_entry("AAMk-b", "2026-10-19T09:40:00.0000000")]}),
212
),
213
]),
214
"emea",
215
);
216
let reminders = calendar.reminder_view(at(9, 0), at(11, 0)).await.unwrap();
217
assert_eq!(reminders.len(), 2);
218
let sent = calendar.transport.sent.lock().unwrap();
219
assert_eq!(
220
sent[0].url,
221
"https://graph.microsoft.com/v1.0/me/reminderView(startDateTime='2026-10-19T09:00:00Z',endDateTime='2026-10-19T11:00:00Z')"
222
);
223
assert!(
224
sent[0]
225
.headers
226
.contains(&("Prefer".to_owned(), UTC_PREFERENCE.to_owned()))
227
);
228
assert_eq!(sent[1].url, "https://graph.microsoft.com/v1.0/next-page");
229
}
230
231
#[tokio::test]
232
async fn snooze_posts_the_new_reminder_time_for_the_occurrence() {
233
let calendar = Calendar::with_transport(Scripted::new(vec![(200, Value::Null)]), "emea");
234
calendar
235
.snooze_reminder("AAMk+a/b=", at(9, 45))
236
.await
237
.unwrap();
238
let sent = calendar.transport.sent.lock().unwrap();
239
assert_eq!(sent[0].method, Method::Post);
240
assert_eq!(
241
sent[0].url,
242
"https://graph.microsoft.com/v1.0/me/events/AAMk%2Ba%2Fb%3D/snoozeReminder"
243
);
244
assert_eq!(
245
sent[0].body,
246
Some(
247
json!({"newReminderTime": {"dateTime": "2026-10-19T09:45:00", "timeZone": "UTC"}})
248
)
249
);
250
}
251
252
#[tokio::test]
253
async fn dismiss_posts_and_reports_a_failure() {
254
let calendar = Calendar::with_transport(
255
Scripted::new(vec![
256
(200, Value::Null),
257
(
258
404,
259
json!({"error": {"message": "The specified object was not found"}}),
260
),
261
]),
262
"emea",
263
);
264
calendar.dismiss_reminder("AAMk-a").await.unwrap();
265
let error = calendar.dismiss_reminder("AAMk-gone").await.unwrap_err();
266
assert!(error.to_string().contains("not found"));
267
let sent = calendar.transport.sent.lock().unwrap();
268
assert_eq!(
269
sent[0].url,
270
"https://graph.microsoft.com/v1.0/me/events/AAMk-a/dismissReminder"
271
);
272
}
273
}
@@ -0,0 +1,273 @@1
use chrono::{DateTime, NaiveDateTime, Utc};2
use serde_json::{Value, json};3
use session::{GRAPH, Method, Request, Scope};4
5
use super::Calendar;6
use super::schedule::CALENDARS_SCOPE;7
use crate::cards::CardTransport;8
use crate::error::{Error, Result};9
use crate::messages::encode;10
11
const QUERY_TIME_FORMAT: &str = "%Y-%m-%dT%H:%M:%SZ";12
const GRAPH_TIME_FORMAT: &str = "%Y-%m-%dT%H:%M:%S";13
const GRAPH_READ_FORMAT: &str = "%Y-%m-%dT%H:%M:%S%.f";14
const UTC_PREFERENCE: &str = "outlook.timezone=\"UTC\"";15
const MAX_PAGES: usize = 5;16
17
#[derive(Debug, Clone, PartialEq, Eq)]18
pub struct Reminder {19
pub event_id: String,20
pub fire_time: DateTime<Utc>,21
}22
23
fn reminder_view_url(start: DateTime<Utc>, end: DateTime<Utc>) -> String {24
format!(25
"{GRAPH}/v1.0/me/reminderView(startDateTime='{}',endDateTime='{}')",26
start.format(QUERY_TIME_FORMAT),27
end.format(QUERY_TIME_FORMAT)28
)29
}30
31
fn reminder_action_url(event_id: &str, action: &str) -> String {32
format!("{GRAPH}/v1.0/me/events/{}/{action}", encode(event_id))33
}34
35
fn utc_time(value: &Value) -> Option<DateTime<Utc>> {36
let text = value.get("dateTime")?.as_str()?;37
let zone = value38
.get("timeZone")39
.and_then(Value::as_str)40
.unwrap_or("UTC");41
if !zone.eq_ignore_ascii_case("UTC") {42
return None;43
}44
NaiveDateTime::parse_from_str(text, GRAPH_READ_FORMAT)45
.ok()46
.map(|time| time.and_utc())47
}48
49
pub fn parse_reminders(body: &Value) -> Vec<Reminder> {50
body.get("value")51
.and_then(Value::as_array)52
.into_iter()53
.flatten()54
.filter_map(|entry| {55
Some(Reminder {56
event_id: entry.get("eventId")?.as_str()?.to_owned(),57
fire_time: utc_time(entry.get("reminderFireTime")?)?,58
})59
})60
.collect()61
}62
63
impl<T: CardTransport> Calendar<T> {64
pub async fn reminder_view(65
&self,66
start: DateTime<Utc>,67
end: DateTime<Utc>,68
) -> Result<Vec<Reminder>> {69
let mut url = reminder_view_url(start, end);70
let mut reminders = Vec::new();71
for _ in 0..MAX_PAGES {72
let mut request = Request::get(&url);73
request74
.headers75
.push(("Prefer".to_owned(), UTC_PREFERENCE.to_owned()));76
let answer = self77
.transport78
.send(request, Scope::graph(CALENDARS_SCOPE))79
.await?;80
if !answer.is_success() {81
return Err(Error::Session(session::Error::api(82
answer.status,83
&url,84
answer.body,85
)));86
}87
reminders.extend(parse_reminders(&answer.body));88
match answer.body.get("@odata.nextLink").and_then(Value::as_str) {89
Some(next) => url = next.to_owned(),90
None => break,91
}92
}93
Ok(reminders)94
}95
96
pub async fn snooze_reminder(&self, event_id: &str, until: DateTime<Utc>) -> Result<()> {97
let body = json!({"newReminderTime": {98
"dateTime": until.format(GRAPH_TIME_FORMAT).to_string(),99
"timeZone": "UTC",100
}});101
self.reminder_action(event_id, "snoozeReminder", Some(body))102
.await103
}104
105
pub async fn dismiss_reminder(&self, event_id: &str) -> Result<()> {106
self.reminder_action(event_id, "dismissReminder", None)107
.await108
}109
110
async fn reminder_action(111
&self,112
event_id: &str,113
action: &str,114
body: Option<Value>,115
) -> Result<()> {116
let url = reminder_action_url(event_id, action);117
let request = Request::with_body(Method::Post, &url, body.unwrap_or_else(|| json!({})));118
let answer = self119
.transport120
.send(request, Scope::graph(CALENDARS_SCOPE))121
.await?;122
if answer.is_success() {123
return Ok(());124
}125
Err(Error::Session(session::Error::api(126
answer.status,127
&url,128
answer.body,129
)))130
}131
}132
133
#[cfg(test)]134
mod tests {135
use std::sync::Mutex;136
137
use chrono::TimeZone;138
use session::ApiResponse;139
140
use super::*;141
142
struct Scripted {143
answers: Mutex<Vec<(u16, Value)>>,144
sent: Mutex<Vec<Request>>,145
}146
147
impl Scripted {148
fn new(answers: Vec<(u16, Value)>) -> Self {149
Scripted {150
answers: Mutex::new(answers),151
sent: Mutex::new(Vec::new()),152
}153
}154
}155
156
impl CardTransport for Scripted {157
async fn send(&self, request: Request, scope: Scope) -> Result<ApiResponse> {158
assert_eq!(scope, Scope::graph(CALENDARS_SCOPE));159
self.sent.lock().unwrap().push(request);160
let (status, body) = self.answers.lock().unwrap().remove(0);161
Ok(ApiResponse {162
status,163
body,164
retry_after: None,165
})166
}167
}168
169
fn at(hour: u32, minute: u32) -> DateTime<Utc> {170
Utc.with_ymd_and_hms(2026, 10, 19, hour, minute, 0).unwrap()171
}172
173
fn reminder_entry(event_id: &str, fire_time: &str) -> Value {174
json!({175
"eventId": event_id,176
"eventSubject": "Daily Standup",177
"eventStartTime": {"dateTime": "2026-10-19T09:45:00.0000000", "timeZone": "UTC"},178
"reminderFireTime": {"dateTime": fire_time, "timeZone": "UTC"},179
})180
}181
182
#[test]183
fn reminders_carry_the_event_id_and_the_fire_time() {184
let body = json!({"value": [185
reminder_entry("AAMk-a", "2026-10-19T09:30:00.0000000"),186
{"eventId": "AAMk-b", "reminderFireTime": {"dateTime": "2026-10-19T09:30:00", "timeZone": "W. Europe Standard Time"}},187
{"reminderFireTime": {"dateTime": "2026-10-19T09:30:00", "timeZone": "UTC"}},188
]});189
assert_eq!(190
parse_reminders(&body),191
vec![Reminder {192
event_id: "AAMk-a".into(),193
fire_time: at(9, 30),194
}]195
);196
}197
198
#[tokio::test]199
async fn the_reminder_view_asks_for_utc_and_follows_the_next_link() {200
let calendar = Calendar::with_transport(201
Scripted::new(vec![202
(203
200,204
json!({205
"value": [reminder_entry("AAMk-a", "2026-10-19T09:30:00.0000000")],206
"@odata.nextLink": "https://graph.microsoft.com/v1.0/next-page",207
}),208
),209
(210
200,211
json!({"value": [reminder_entry("AAMk-b", "2026-10-19T09:40:00.0000000")]}),212
),213
]),214
"emea",215
);216
let reminders = calendar.reminder_view(at(9, 0), at(11, 0)).await.unwrap();217
assert_eq!(reminders.len(), 2);218
let sent = calendar.transport.sent.lock().unwrap();219
assert_eq!(220
sent[0].url,221
"https://graph.microsoft.com/v1.0/me/reminderView(startDateTime='2026-10-19T09:00:00Z',endDateTime='2026-10-19T11:00:00Z')"222
);223
assert!(224
sent[0]225
.headers226
.contains(&("Prefer".to_owned(), UTC_PREFERENCE.to_owned()))227
);228
assert_eq!(sent[1].url, "https://graph.microsoft.com/v1.0/next-page");229
}230
231
#[tokio::test]232
async fn snooze_posts_the_new_reminder_time_for_the_occurrence() {233
let calendar = Calendar::with_transport(Scripted::new(vec![(200, Value::Null)]), "emea");234
calendar235
.snooze_reminder("AAMk+a/b=", at(9, 45))236
.await237
.unwrap();238
let sent = calendar.transport.sent.lock().unwrap();239
assert_eq!(sent[0].method, Method::Post);240
assert_eq!(241
sent[0].url,242
"https://graph.microsoft.com/v1.0/me/events/AAMk%2Ba%2Fb%3D/snoozeReminder"243
);244
assert_eq!(245
sent[0].body,246
Some(247
json!({"newReminderTime": {"dateTime": "2026-10-19T09:45:00", "timeZone": "UTC"}})248
)249
);250
}251
252
#[tokio::test]253
async fn dismiss_posts_and_reports_a_failure() {254
let calendar = Calendar::with_transport(255
Scripted::new(vec![256
(200, Value::Null),257
(258
404,259
json!({"error": {"message": "The specified object was not found"}}),260
),261
]),262
"emea",263
);264
calendar.dismiss_reminder("AAMk-a").await.unwrap();265
let error = calendar.dismiss_reminder("AAMk-gone").await.unwrap_err();266
assert!(error.to_string().contains("not found"));267
let sent = calendar.transport.sent.lock().unwrap();268
assert_eq!(269
sent[0].url,270
"https://graph.microsoft.com/v1.0/me/events/AAMk-a/dismissReminder"271
);272
}273
}@@ -7,7 +7,7 @@ use crate::cards::CardTransport;
7
7
use crate::error::{Error, Result};
8
8
use crate::messages::encode;
9
9
10
const CALENDARS_SCOPE: &str = "Calendars.ReadWrite";
10
pub(super) const CALENDARS_SCOPE: &str = "Calendars.ReadWrite";
11
11
const GRAPH_TIME_FORMAT: &str = "%Y-%m-%dT%H:%M:%S";
12
12
const GRAPH_DATE_FORMAT: &str = "%Y-%m-%d";
13
13
const TIME_ZONE: &str = "UTC";
@@ -7,7 +7,7 @@ use crate::cards::CardTransport;7
use crate::error::{Error, Result};7
use crate::error::{Error, Result};8
use crate::messages::encode;8
use crate::messages::encode;9
9
10
const CALENDARS_SCOPE: &str = "Calendars.ReadWrite";10
pub(super) const CALENDARS_SCOPE: &str = "Calendars.ReadWrite";11
const GRAPH_TIME_FORMAT: &str = "%Y-%m-%dT%H:%M:%S";11
const GRAPH_TIME_FORMAT: &str = "%Y-%m-%dT%H:%M:%S";12
const GRAPH_DATE_FORMAT: &str = "%Y-%m-%d";12
const GRAPH_DATE_FORMAT: &str = "%Y-%m-%d";13
const TIME_ZONE: &str = "UTC";13
const TIME_ZONE: &str = "UTC";@@ -29,7 +29,7 @@ pub mod translate;
29
29
pub mod window;
30
30
31
31
pub use calendar::{
32
Attendee, Calendar, CalendarEvent, CreatedEvent, NewEvent, Repeat, Reply, ResponseType,
32
Attendee, Calendar, CalendarEvent, CreatedEvent, NewEvent, Reminder, Repeat, Reply, ResponseType,
33
33
meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,
34
34
};
35
35
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};
@@ -29,7 +29,7 @@ pub mod translate;29
pub mod window;29
pub mod window;30
30
31
pub use calendar::{31
pub use calendar::{32
Attendee, Calendar, CalendarEvent, CreatedEvent, NewEvent, Repeat, Reply, ResponseType,32
Attendee, Calendar, CalendarEvent, CreatedEvent, NewEvent, Reminder, Repeat, Reply, ResponseType,33
meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,33
meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,34
};34
};35
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};35
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};@@ -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
5
const STARTED_TYPE: &str = "#microsoft.graph.callStartedEventMessageDetail";5
const STARTED_TYPE: &str = "#microsoft.graph.callStartedEventMessageDetail";6
const ENDED_TYPE: &str = "#microsoft.graph.callEndedEventMessageDetail";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
const SECONDS_PER_MINUTE: u64 = 60;14
const SECONDS_PER_MINUTE: u64 = 60;8
const SECONDS_PER_HOUR: u64 = 3600;15
const SECONDS_PER_HOUR: u64 = 3600;9
const SECONDS_PER_DAY: u64 = 86_400;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
pub enum CallPhase {19
pub 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)]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 = self70
.url71
.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() == 884
&& time.len() == 685
&& date86
.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
impl CallEvent {101
impl 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>)> = detail111
.get("callParticipants")112
.and_then(Value::as_array)113
.map(|participants| {114
participants115
.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: detail134
duration_seconds: detail50
.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: detail141
participant_names: participants56
.get("callParticipants")142
.iter()57
.and_then(Value::as_array)143
.map(|(_, name)| name.clone().unwrap_or_default())58
.map(|participants| {144
.collect(),59
participants145
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::RecordingStarted174
| CallPhase::RecordingStopped175
| CallPhase::RecordingSaved176
| CallPhase::TranscriptStarted177
)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
111
fn identity_id(identity_set: &Value) -> Option<String> {209
fn identity(identity_set: &Value) -> Option<(String, Option<String>)> {112
identity_set210
identity_set113
.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
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
fn text_at(value: &Value, pointer: &str) -> Option<String> {220
fn 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)]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
}@@ -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
};66
pub use avatars::Avatar;66
pub use avatars::Avatar;67
pub use call_event::{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
pub use card_actions::{CardActionOutcome, DialogIdentity, TaskDialog, TaskDialogKind};71
pub use card_actions::{CardActionOutcome, DialogIdentity, TaskDialog, TaskDialogKind};71
pub use card_chart::{72
pub use card_chart::{@@ -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
}@@ -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": null35
}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,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
}@@ -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
8
const CHAT_PATH: &str = "/v1.0/chats/";8
const CHAT_PATH: &str = "/v1.0/chats/";9
const CHANNEL_PATH: &str = "/v1.0/teams/";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
const EXTERNAL_IMAGE_SCOPE: &str = "Chat.Read";12
const EXTERNAL_IMAGE_SCOPE: &str = "Chat.Read";11
13
12
impl Graph {14
impl 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
None48
None45
}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
}@@ -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
94
pub fn latest_version() -> i64 {98
pub fn latest_version() -> i64 {@@ -0,0 +1 @@
1
DELETE FROM sync_state WHERE conversation_id IN (SELECT id FROM chats UNION SELECT id FROM channels);
@@ -0,0 +1 @@1
DELETE FROM sync_state WHERE conversation_id IN (SELECT id FROM chats UNION SELECT id FROM channels);@@ -545,11 +545,11 @@ fn file_database_uses_wal_persists_and_migrates_once() {
545
545
let path = directory.path().join("nested").join("cache.sqlite3");
546
546
{
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
let reopened = Store::open(&path).unwrap();
552
assert_eq!(reopened.schema_version().unwrap(), 20);
552
assert_eq!(reopened.schema_version().unwrap(), 21);
553
553
assert_eq!(reopened.message_count("c").unwrap(), 1);
554
554
drop(reopened);
555
555
let mode: String = rusqlite_open(&path)
@@ -581,7 +581,7 @@ fn old_schema_is_upgraded_in_place() {
581
581
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();
582
582
drop(connection);
583
583
let store = Store::open(&path).unwrap();
584
assert_eq!(store.schema_version().unwrap(), 20);
584
assert_eq!(store.schema_version().unwrap(), 21);
585
585
store.upsert_messages(&[message("c", "m1", 1)]).unwrap();
586
586
}
587
587
@@ -647,7 +647,7 @@ fn migration_to_v2_keeps_existing_sync_state() {
647
647
let store = Store::open(&path).unwrap();
648
648
let state = store.sync_state("c").unwrap().unwrap();
649
649
assert_eq!(state.delta_link, None);
650
assert_eq!(store.schema_version().unwrap(), 20);
650
assert_eq!(store.schema_version().unwrap(), 21);
651
651
}
652
652
653
653
#[test]
@@ -675,7 +675,10 @@ fn migration_to_v13_clears_channel_delta_links_only() {
675
675
.unwrap();
676
676
}
677
677
let store = Store::open(&path).unwrap();
678
assert_eq!(store.sync_state("ch").unwrap().unwrap().delta_link, None);
678
assert_eq!(
679
store.sync_state("ch").unwrap().and_then(|state| state.delta_link),
680
None
681
);
679
682
assert_eq!(
680
683
store
681
684
.sync_state("chat")
@@ -1410,7 +1413,7 @@ fn migration_to_v20_adds_the_call_event_column() {
1410
1413
.unwrap();
1411
1414
}
1412
1415
let store = Store::open(&path).unwrap();
1413
assert_eq!(store.schema_version().unwrap(), 20);
1416
assert_eq!(store.schema_version().unwrap(), 21);
1414
1417
let old = store.messages("c", None, 10).unwrap();
1415
1418
assert_eq!(old[0].call_event_json, None);
1416
1419
assert!(store.sync_state("c").unwrap().is_none());
@@ -1418,3 +1421,44 @@ fn migration_to_v20_adds_the_call_event_column() {
1418
1421
store.upsert_messages(&[call_message("call", 2)]).unwrap();
1419
1422
assert!(store.messages("c", None, 10).unwrap()[1].call_event_json.is_some());
1420
1423
}
1424
1425
#[test]
1426
fn migration_to_v21_refetches_chats_and_channels_for_recordings() {
1427
let directory = tempfile::tempdir().unwrap();
1428
let path = directory.path().join("old.sqlite3");
1429
{
1430
let store = Store::open(&path).unwrap();
1431
store.upsert_chats(&[chat("c", "Chat", Some(at(1)))]).unwrap();
1432
store
1433
.upsert_teams(&[TeamRecord {
1434
id: "team".to_owned(),
1435
name: "Team".to_owned(),
1436
}])
1437
.unwrap();
1438
store
1439
.upsert_channels(&[ChannelRecord {
1440
id: "channel".to_owned(),
1441
team_id: "team".to_owned(),
1442
name: "General".to_owned(),
1443
membership_type: None,
1444
last_message_at: None,
1445
unread: false,
1446
}])
1447
.unwrap();
1448
for conversation_id in ["c", "channel", "other"] {
1449
store
1450
.set_sync_state(conversation_id, &SyncState::default())
1451
.unwrap();
1452
}
1453
drop(store);
1454
Connection::open(&path)
1455
.unwrap()
1456
.execute_batch("PRAGMA user_version = 20")
1457
.unwrap();
1458
}
1459
let store = Store::open(&path).unwrap();
1460
assert_eq!(store.schema_version().unwrap(), 21);
1461
assert!(store.sync_state("c").unwrap().is_none());
1462
assert!(store.sync_state("channel").unwrap().is_none());
1463
assert!(store.sync_state("other").unwrap().is_some());
1464
}
@@ -545,11 +545,11 @@ fn file_database_uses_wal_persists_and_migrates_once() {545
let path = directory.path().join("nested").join("cache.sqlite3");545
let path = directory.path().join("nested").join("cache.sqlite3");546
{546
{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
let reopened = Store::open(&path).unwrap();551
let reopened = Store::open(&path).unwrap();552
assert_eq!(reopened.schema_version().unwrap(), 20);552
assert_eq!(reopened.schema_version().unwrap(), 21);553
assert_eq!(reopened.message_count("c").unwrap(), 1);553
assert_eq!(reopened.message_count("c").unwrap(), 1);554
drop(reopened);554
drop(reopened);555
let mode: String = rusqlite_open(&path)555
let mode: String = rusqlite_open(&path)@@ -581,7 +581,7 @@ fn old_schema_is_upgraded_in_place() {581
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();581
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();582
drop(connection);582
drop(connection);583
let store = Store::open(&path).unwrap();583
let store = Store::open(&path).unwrap();584
assert_eq!(store.schema_version().unwrap(), 20);584
assert_eq!(store.schema_version().unwrap(), 21);585
store.upsert_messages(&[message("c", "m1", 1)]).unwrap();585
store.upsert_messages(&[message("c", "m1", 1)]).unwrap();586
}586
}587
587
@@ -647,7 +647,7 @@ fn migration_to_v2_keeps_existing_sync_state() {647
let store = Store::open(&path).unwrap();647
let store = Store::open(&path).unwrap();648
let state = store.sync_state("c").unwrap().unwrap();648
let state = store.sync_state("c").unwrap().unwrap();649
assert_eq!(state.delta_link, None);649
assert_eq!(state.delta_link, None);650
assert_eq!(store.schema_version().unwrap(), 20);650
assert_eq!(store.schema_version().unwrap(), 21);651
}651
}652
652
653
#[test]653
#[test]@@ -675,7 +675,10 @@ fn migration_to_v13_clears_channel_delta_links_only() {675
.unwrap();675
.unwrap();676
}676
}677
let store = Store::open(&path).unwrap();677
let store = Store::open(&path).unwrap();678
assert_eq!(store.sync_state("ch").unwrap().unwrap().delta_link, None);678
assert_eq!(679
store.sync_state("ch").unwrap().and_then(|state| state.delta_link),680
None681
);679
assert_eq!(682
assert_eq!(680
store683
store681
.sync_state("chat")684
.sync_state("chat")@@ -1410,7 +1413,7 @@ fn migration_to_v20_adds_the_call_event_column() {1410
.unwrap();1413
.unwrap();1411
}1414
}1412
let store = Store::open(&path).unwrap();1415
let store = Store::open(&path).unwrap();1413
assert_eq!(store.schema_version().unwrap(), 20);1416
assert_eq!(store.schema_version().unwrap(), 21);1414
let old = store.messages("c", None, 10).unwrap();1417
let old = store.messages("c", None, 10).unwrap();1415
assert_eq!(old[0].call_event_json, None);1418
assert_eq!(old[0].call_event_json, None);1416
assert!(store.sync_state("c").unwrap().is_none());1419
assert!(store.sync_state("c").unwrap().is_none());@@ -1418,3 +1421,44 @@ fn migration_to_v20_adds_the_call_event_column() {1418
store.upsert_messages(&[call_message("call", 2)]).unwrap();1421
store.upsert_messages(&[call_message("call", 2)]).unwrap();1419
assert!(store.messages("c", None, 10).unwrap()[1].call_event_json.is_some());1422
assert!(store.messages("c", None, 10).unwrap()[1].call_event_json.is_some());1420
}1423
}1424
1425
#[test]1426
fn migration_to_v21_refetches_chats_and_channels_for_recordings() {1427
let directory = tempfile::tempdir().unwrap();1428
let path = directory.path().join("old.sqlite3");1429
{1430
let store = Store::open(&path).unwrap();1431
store.upsert_chats(&[chat("c", "Chat", Some(at(1)))]).unwrap();1432
store1433
.upsert_teams(&[TeamRecord {1434
id: "team".to_owned(),1435
name: "Team".to_owned(),1436
}])1437
.unwrap();1438
store1439
.upsert_channels(&[ChannelRecord {1440
id: "channel".to_owned(),1441
team_id: "team".to_owned(),1442
name: "General".to_owned(),1443
membership_type: None,1444
last_message_at: None,1445
unread: false,1446
}])1447
.unwrap();1448
for conversation_id in ["c", "channel", "other"] {1449
store1450
.set_sync_state(conversation_id, &SyncState::default())1451
.unwrap();1452
}1453
drop(store);1454
Connection::open(&path)1455
.unwrap()1456
.execute_batch("PRAGMA user_version = 20")1457
.unwrap();1458
}1459
let store = Store::open(&path).unwrap();1460
assert_eq!(store.schema_version().unwrap(), 21);1461
assert!(store.sync_state("c").unwrap().is_none());1462
assert!(store.sync_state("channel").unwrap().is_none());1463
assert!(store.sync_state("other").unwrap().is_some());1464
}@@ -25,6 +25,8 @@ const BOTTOM_FADE_TRANSITION: Duration = Duration::from_millis(200);
25
25
/// [`MessageScroller::new`].
26
26
pub struct MessageScrollerState {
27
27
list_state: ListState,
28
top_inset: gpui::Pixels,
29
inset_scroll_pending: bool,
28
30
}
29
31
30
32
impl MessageScrollerState {
@@ -46,7 +48,11 @@ impl MessageScrollerState {
46
48
});
47
49
});
48
50
49
Self { list_state }
51
Self {
52
list_state,
53
top_inset: px(0.),
54
inset_scroll_pending: false,
55
}
50
56
}
51
57
52
58
/// Return the current number of rows known by the virtual list.
@@ -135,7 +141,7 @@ impl MessageScrollerState {
135
141
true
136
142
}
137
143
138
/// Scroll to the row at `index`, if it exists.
144
/// Scroll to the row at `index`, if it exists, below the top inset.
139
145
pub fn scroll_to_item(&mut self, index: usize, cx: &mut Context<Self>) -> bool {
140
146
if index >= self.list_state.item_count() {
141
147
return false;
@@ -145,10 +151,30 @@ impl MessageScrollerState {
145
151
item_ix: index,
146
152
offset_in_item: px(0.),
147
153
});
154
self.inset_scroll_pending = index > 0 && self.top_inset > px(0.);
148
155
cx.notify();
149
156
true
150
157
}
151
158
159
/// Return the space kept free above the first row.
160
pub fn top_inset(&self) -> gpui::Pixels {
161
self.top_inset
162
}
163
164
fn sync_top_inset(&mut self, inset: gpui::Pixels) {
165
if self.top_inset == inset {
166
return;
167
}
168
self.top_inset = inset;
169
if self.list_state.item_count() > 0 {
170
self.list_state.remeasure_items(0..1);
171
}
172
}
173
174
fn take_inset_scroll(&mut self) -> Option<gpui::Pixels> {
175
std::mem::take(&mut self.inset_scroll_pending).then_some(self.top_inset)
176
}
177
152
178
/// Stop following the tail until the next reset or `scroll_to_end`.
153
179
pub fn stop_following(&mut self) {
154
180
self.list_state.set_follow_mode(FollowMode::Normal);
@@ -180,6 +206,7 @@ pub struct MessageScroller {
180
206
jump_button_renderer: Option<Box<dyn FnOnce(Button) -> Button>>,
181
207
jump_button_transition: Duration,
182
208
bottom_fade: Option<Hsla>,
209
top_inset: gpui::Pixels,
183
210
scrollbar: bool,
184
211
jump_button: bool,
185
212
force_jump_button: bool,
@@ -212,6 +239,7 @@ impl MessageScroller {
212
239
jump_button_renderer: None,
213
240
jump_button_transition: JUMP_BUTTON_TRANSITION,
214
241
bottom_fade: None,
242
top_inset: px(0.),
215
243
scrollbar: true,
216
244
jump_button: true,
217
245
force_jump_button: false,
@@ -306,6 +334,16 @@ impl MessageScroller {
306
334
self.bottom_fade = Some(color.into());
307
335
self
308
336
}
337
338
/// Keep `inset` free above the first row for an overlay at the top.
339
///
340
/// The rows scroll behind the overlay, and the inset scrolls with the
341
/// content, so the first row can still be scrolled out from under it.
342
/// [`MessageScrollerState::scroll_to_item`] lands rows below the inset.
343
pub fn with_top_inset(mut self, inset: gpui::Pixels) -> Self {
344
self.top_inset = inset;
345
self
346
}
309
347
}
310
348
311
349
impl Styled for MessageScroller {
@@ -346,6 +384,21 @@ impl RenderOnce for MessageScroller {
346
384
} else {
347
385
0.
348
386
};
387
let top_inset = self.top_inset;
388
let inset_scroll = self.state.update(cx, |state, _| {
389
state.sync_top_inset(top_inset);
390
state.take_inset_scroll()
391
});
392
// The rows above the target are only measured by the layout of this
393
// frame, so the step back by the inset waits for the next one.
394
if let Some(inset) = inset_scroll {
395
let list_state = list_state.clone();
396
let state = self.state.clone();
397
window.on_next_frame(move |_, cx| {
398
list_state.scroll_by(-inset);
399
state.update(cx, |_, cx| cx.notify());
400
});
401
}
349
402
let tokens = cx.theme().semantic_tokens();
350
403
let row_style = self.row_style;
351
404
let jump_button_style = self.jump_button_style;
@@ -374,6 +427,7 @@ impl RenderOnce for MessageScroller {
374
427
.when_some(row_inset_left, |this, left| this.pl(left))
375
428
.when_some(row_inset_right, |this, right| this.pr(right))
376
429
.refine_style(&row_style)
430
.when(index == 0 && top_inset > px(0.), |this| this.pt(top_inset))
377
431
.child(renderer(index, window, cx))
378
432
.into_any_element()
379
433
})
@@ -495,6 +549,15 @@ mod tests {
495
549
assert!(state.remeasure_items(0..6, cx));
496
550
assert!(!state.remeasure_items(6..7, cx));
497
551
assert!(state.scroll_to_item(2, cx));
552
assert_eq!(state.take_inset_scroll(), None);
553
state.sync_top_inset(px(48.));
554
assert_eq!(state.top_inset(), px(48.));
555
assert!(state.scroll_to_item(2, cx));
556
assert_eq!(state.take_inset_scroll(), Some(px(48.)));
557
assert_eq!(state.take_inset_scroll(), None);
558
assert!(state.scroll_to_item(0, cx));
559
assert_eq!(state.take_inset_scroll(), None);
560
assert!(state.scroll_to_item(2, cx));
498
561
assert!(!state.is_scrolled_up());
499
562
assert!(!state.is_following_tail());
500
563
state.scroll_to_end(cx);
@@ -519,7 +582,8 @@ mod tests {
519
582
.with_jump_button_style(StyleRefinement::default())
520
583
.with_jump_button_renderer(|button| button.large())
521
584
.with_jump_button_transition(Duration::from_millis(300))
522
.with_bottom_fade(gpui::white());
585
.with_bottom_fade(gpui::white())
586
.with_top_inset(px(48.));
523
587
524
588
assert!(!scroller.scrollbar);
525
589
assert!(!scroller.jump_button);
@@ -527,5 +591,6 @@ mod tests {
527
591
assert!(scroller.jump_button_renderer.is_some());
528
592
assert_eq!(scroller.jump_button_transition, Duration::from_millis(300));
529
593
assert_eq!(scroller.bottom_fade, Some(gpui::white()));
594
assert_eq!(scroller.top_inset, px(48.));
530
595
}
531
596
}
@@ -25,6 +25,8 @@ const BOTTOM_FADE_TRANSITION: Duration = Duration::from_millis(200);25
/// [`MessageScroller::new`].25
/// [`MessageScroller::new`].26
pub struct MessageScrollerState {26
pub struct MessageScrollerState {27
list_state: ListState,27
list_state: ListState,28
top_inset: gpui::Pixels,29
inset_scroll_pending: bool,28
}30
}29
31
30
impl MessageScrollerState {32
impl MessageScrollerState {@@ -46,7 +48,11 @@ impl MessageScrollerState {46
});48
});47
});49
});48
50
49
Self { list_state }51
Self {52
list_state,53
top_inset: px(0.),54
inset_scroll_pending: false,55
}50
}56
}51
57
52
/// Return the current number of rows known by the virtual list.58
/// Return the current number of rows known by the virtual list.@@ -135,7 +141,7 @@ impl MessageScrollerState {135
true141
true136
}142
}137
143
138
/// Scroll to the row at `index`, if it exists.144
/// Scroll to the row at `index`, if it exists, below the top inset.139
pub fn scroll_to_item(&mut self, index: usize, cx: &mut Context<Self>) -> bool {145
pub fn scroll_to_item(&mut self, index: usize, cx: &mut Context<Self>) -> bool {140
if index >= self.list_state.item_count() {146
if index >= self.list_state.item_count() {141
return false;147
return false;@@ -145,10 +151,30 @@ impl MessageScrollerState {145
item_ix: index,151
item_ix: index,146
offset_in_item: px(0.),152
offset_in_item: px(0.),147
});153
});154
self.inset_scroll_pending = index > 0 && self.top_inset > px(0.);148
cx.notify();155
cx.notify();149
true156
true150
}157
}151
158
159
/// Return the space kept free above the first row.160
pub fn top_inset(&self) -> gpui::Pixels {161
self.top_inset162
}163
164
fn sync_top_inset(&mut self, inset: gpui::Pixels) {165
if self.top_inset == inset {166
return;167
}168
self.top_inset = inset;169
if self.list_state.item_count() > 0 {170
self.list_state.remeasure_items(0..1);171
}172
}173
174
fn take_inset_scroll(&mut self) -> Option<gpui::Pixels> {175
std::mem::take(&mut self.inset_scroll_pending).then_some(self.top_inset)176
}177
152
/// Stop following the tail until the next reset or `scroll_to_end`.178
/// Stop following the tail until the next reset or `scroll_to_end`.153
pub fn stop_following(&mut self) {179
pub fn stop_following(&mut self) {154
self.list_state.set_follow_mode(FollowMode::Normal);180
self.list_state.set_follow_mode(FollowMode::Normal);@@ -180,6 +206,7 @@ pub struct MessageScroller {180
jump_button_renderer: Option<Box<dyn FnOnce(Button) -> Button>>,206
jump_button_renderer: Option<Box<dyn FnOnce(Button) -> Button>>,181
jump_button_transition: Duration,207
jump_button_transition: Duration,182
bottom_fade: Option<Hsla>,208
bottom_fade: Option<Hsla>,209
top_inset: gpui::Pixels,183
scrollbar: bool,210
scrollbar: bool,184
jump_button: bool,211
jump_button: bool,185
force_jump_button: bool,212
force_jump_button: bool,@@ -212,6 +239,7 @@ impl MessageScroller {212
jump_button_renderer: None,239
jump_button_renderer: None,213
jump_button_transition: JUMP_BUTTON_TRANSITION,240
jump_button_transition: JUMP_BUTTON_TRANSITION,214
bottom_fade: None,241
bottom_fade: None,242
top_inset: px(0.),215
scrollbar: true,243
scrollbar: true,216
jump_button: true,244
jump_button: true,217
force_jump_button: false,245
force_jump_button: false,@@ -306,6 +334,16 @@ impl MessageScroller {306
self.bottom_fade = Some(color.into());334
self.bottom_fade = Some(color.into());307
self335
self308
}336
}337
338
/// Keep `inset` free above the first row for an overlay at the top.339
///340
/// The rows scroll behind the overlay, and the inset scrolls with the341
/// content, so the first row can still be scrolled out from under it.342
/// [`MessageScrollerState::scroll_to_item`] lands rows below the inset.343
pub fn with_top_inset(mut self, inset: gpui::Pixels) -> Self {344
self.top_inset = inset;345
self346
}309
}347
}310
348
311
impl Styled for MessageScroller {349
impl Styled for MessageScroller {@@ -346,6 +384,21 @@ impl RenderOnce for MessageScroller {346
} else {384
} else {347
0.385
0.348
};386
};387
let top_inset = self.top_inset;388
let inset_scroll = self.state.update(cx, |state, _| {389
state.sync_top_inset(top_inset);390
state.take_inset_scroll()391
});392
// The rows above the target are only measured by the layout of this393
// frame, so the step back by the inset waits for the next one.394
if let Some(inset) = inset_scroll {395
let list_state = list_state.clone();396
let state = self.state.clone();397
window.on_next_frame(move |_, cx| {398
list_state.scroll_by(-inset);399
state.update(cx, |_, cx| cx.notify());400
});401
}349
let tokens = cx.theme().semantic_tokens();402
let tokens = cx.theme().semantic_tokens();350
let row_style = self.row_style;403
let row_style = self.row_style;351
let jump_button_style = self.jump_button_style;404
let jump_button_style = self.jump_button_style;@@ -374,6 +427,7 @@ impl RenderOnce for MessageScroller {374
.when_some(row_inset_left, |this, left| this.pl(left))427
.when_some(row_inset_left, |this, left| this.pl(left))375
.when_some(row_inset_right, |this, right| this.pr(right))428
.when_some(row_inset_right, |this, right| this.pr(right))376
.refine_style(&row_style)429
.refine_style(&row_style)430
.when(index == 0 && top_inset > px(0.), |this| this.pt(top_inset))377
.child(renderer(index, window, cx))431
.child(renderer(index, window, cx))378
.into_any_element()432
.into_any_element()379
})433
})@@ -495,6 +549,15 @@ mod tests {495
assert!(state.remeasure_items(0..6, cx));549
assert!(state.remeasure_items(0..6, cx));496
assert!(!state.remeasure_items(6..7, cx));550
assert!(!state.remeasure_items(6..7, cx));497
assert!(state.scroll_to_item(2, cx));551
assert!(state.scroll_to_item(2, cx));552
assert_eq!(state.take_inset_scroll(), None);553
state.sync_top_inset(px(48.));554
assert_eq!(state.top_inset(), px(48.));555
assert!(state.scroll_to_item(2, cx));556
assert_eq!(state.take_inset_scroll(), Some(px(48.)));557
assert_eq!(state.take_inset_scroll(), None);558
assert!(state.scroll_to_item(0, cx));559
assert_eq!(state.take_inset_scroll(), None);560
assert!(state.scroll_to_item(2, cx));498
assert!(!state.is_scrolled_up());561
assert!(!state.is_scrolled_up());499
assert!(!state.is_following_tail());562
assert!(!state.is_following_tail());500
state.scroll_to_end(cx);563
state.scroll_to_end(cx);@@ -519,7 +582,8 @@ mod tests {519
.with_jump_button_style(StyleRefinement::default())582
.with_jump_button_style(StyleRefinement::default())520
.with_jump_button_renderer(|button| button.large())583
.with_jump_button_renderer(|button| button.large())521
.with_jump_button_transition(Duration::from_millis(300))584
.with_jump_button_transition(Duration::from_millis(300))522
.with_bottom_fade(gpui::white());585
.with_bottom_fade(gpui::white())586
.with_top_inset(px(48.));523
587
524
assert!(!scroller.scrollbar);588
assert!(!scroller.scrollbar);525
assert!(!scroller.jump_button);589
assert!(!scroller.jump_button);@@ -527,5 +591,6 @@ mod tests {527
assert!(scroller.jump_button_renderer.is_some());591
assert!(scroller.jump_button_renderer.is_some());528
assert_eq!(scroller.jump_button_transition, Duration::from_millis(300));592
assert_eq!(scroller.jump_button_transition, Duration::from_millis(300));529
assert_eq!(scroller.bottom_fade, Some(gpui::white()));593
assert_eq!(scroller.bottom_fade, Some(gpui::white()));594
assert_eq!(scroller.top_inset, px(48.));530
}595
}531
}596
}