fix(activity): app notifications open their meeting chat or tap link
- Meeting Recaps items: open the meeting chat named in the activity, else the customTapAction link in the browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -158,6 +158,7 @@ pub struct Entry {
158
158
pub read: bool,
159
159
pub counts_for_bell: bool,
160
160
pub source_label: Option<String>,
161
pub link: Option<String>,
161
162
}
162
163
163
164
impl Entry {
@@ -158,6 +158,7 @@ pub struct Entry {158
pub read: bool,158
pub read: bool,159
pub counts_for_bell: bool,159
pub counts_for_bell: bool,160
pub source_label: Option<String>,160
pub source_label: Option<String>,161
pub link: Option<String>,161
}162
}162
163
163
impl Entry {164
impl Entry {@@ -27,9 +27,13 @@ pub fn feed_of(snapshot: &ActivitySnapshot, seen_locally_ms: i64) -> Feed {
27
27
28
28
fn entry_of(item: &ActivityItem) -> Entry {
29
29
let kind = kind_of(item);
30
let conversation_id = match (&item.meeting_thread_id, item.source_thread_id.is_empty()) {
31
(Some(meeting_thread_id), true) => meeting_thread_id.clone(),
32
_ => item.source_thread_id.clone(),
33
};
30
34
Entry {
31
35
id: item.message_id.clone(),
32
conversation_id: item.source_thread_id.clone(),
36
conversation_id,
33
37
kind,
34
38
activity_type: item.activity_type.clone(),
35
39
subtype: item.activity_subtype.clone(),
@@ -54,6 +58,7 @@ fn entry_of(item: &ActivityItem) -> Entry {
54
58
read: false,
55
59
counts_for_bell: false,
56
60
source_label: item.source_app_name.clone().or_else(|| item.thread_topic.clone()),
61
link: item.tap_url.clone(),
57
62
}
58
63
}
59
64
@@ -163,6 +168,19 @@ mod tests {
163
168
assert_eq!(chat.actors[0].user_id.as_deref(), Some("user-1"));
164
169
}
165
170
171
#[test]
172
fn a_recap_opens_the_meeting_chat_it_names() {
173
let recap = entry_of(&ActivityItem {
174
source_thread_id: String::new(),
175
meeting_thread_id: Some("19:meeting_Zm9v@thread.v2".into()),
176
tap_url: Some("https://teams.microsoft.com/l/entity/x".into()),
177
..item("msGraph", "recapIsReadyV2")
178
});
179
assert_eq!(recap.conversation_id, "19:meeting_Zm9v@thread.v2");
180
assert_eq!(recap.message_id, "");
181
assert_eq!(recap.link.as_deref(), Some("https://teams.microsoft.com/l/entity/x"));
182
}
183
166
184
#[test]
167
185
fn previews_follow_the_teams_template() {
168
186
let file = entry_of(&ActivityItem {
@@ -27,9 +27,13 @@ pub fn feed_of(snapshot: &ActivitySnapshot, seen_locally_ms: i64) -> Feed {27
27
28
fn entry_of(item: &ActivityItem) -> Entry {28
fn entry_of(item: &ActivityItem) -> Entry {29
let kind = kind_of(item);29
let kind = kind_of(item);30
let conversation_id = match (&item.meeting_thread_id, item.source_thread_id.is_empty()) {31
(Some(meeting_thread_id), true) => meeting_thread_id.clone(),32
_ => item.source_thread_id.clone(),33
};30
Entry {34
Entry {31
id: item.message_id.clone(),35
id: item.message_id.clone(),32
conversation_id: item.source_thread_id.clone(),36
conversation_id,33
kind,37
kind,34
activity_type: item.activity_type.clone(),38
activity_type: item.activity_type.clone(),35
subtype: item.activity_subtype.clone(),39
subtype: item.activity_subtype.clone(),@@ -54,6 +58,7 @@ fn entry_of(item: &ActivityItem) -> Entry {54
read: false,58
read: false,55
counts_for_bell: false,59
counts_for_bell: false,56
source_label: item.source_app_name.clone().or_else(|| item.thread_topic.clone()),60
source_label: item.source_app_name.clone().or_else(|| item.thread_topic.clone()),61
link: item.tap_url.clone(),57
}62
}58
}63
}59
64
@@ -163,6 +168,19 @@ mod tests {163
assert_eq!(chat.actors[0].user_id.as_deref(), Some("user-1"));168
assert_eq!(chat.actors[0].user_id.as_deref(), Some("user-1"));164
}169
}165
170
171
#[test]172
fn a_recap_opens_the_meeting_chat_it_names() {173
let recap = entry_of(&ActivityItem {174
source_thread_id: String::new(),175
meeting_thread_id: Some("19:meeting_Zm9v@thread.v2".into()),176
tap_url: Some("https://teams.microsoft.com/l/entity/x".into()),177
..item("msGraph", "recapIsReadyV2")178
});179
assert_eq!(recap.conversation_id, "19:meeting_Zm9v@thread.v2");180
assert_eq!(recap.message_id, "");181
assert_eq!(recap.link.as_deref(), Some("https://teams.microsoft.com/l/entity/x"));182
}183
166
#[test]184
#[test]167
fn previews_follow_the_teams_template() {185
fn previews_follow_the_teams_template() {168
let file = entry_of(&ActivityItem {186
let file = entry_of(&ActivityItem {@@ -43,6 +43,7 @@ pub enum ActivityPanelEvent {
43
43
Open {
44
44
conversation_id: String,
45
45
message_id: String,
46
link: Option<String>,
46
47
},
47
48
}
48
49
@@ -100,6 +101,7 @@ impl ActivityPanel {
100
101
let event = ActivityPanelEvent::Open {
101
102
conversation_id: entry.conversation_id.clone(),
102
103
message_id: entry.message_id.clone(),
104
link: entry.link.clone(),
103
105
};
104
106
self.activity
105
107
.update(cx, |activity, cx| activity.mark_read(id, cx));
@@ -313,6 +315,7 @@ impl ActivityPanel {
313
315
cx.emit(ActivityPanelEvent::Open {
314
316
conversation_id: pending.conversation_id.clone(),
315
317
message_id: pending.jump_message_id().to_owned(),
318
link: None,
316
319
});
317
320
}
318
321
}
@@ -43,6 +43,7 @@ pub enum ActivityPanelEvent {43
Open {43
Open {44
conversation_id: String,44
conversation_id: String,45
message_id: String,45
message_id: String,46
link: Option<String>,46
},47
},47
}48
}48
49
@@ -100,6 +101,7 @@ impl ActivityPanel {100
let event = ActivityPanelEvent::Open {101
let event = ActivityPanelEvent::Open {101
conversation_id: entry.conversation_id.clone(),102
conversation_id: entry.conversation_id.clone(),102
message_id: entry.message_id.clone(),103
message_id: entry.message_id.clone(),104
link: entry.link.clone(),103
};105
};104
self.activity106
self.activity105
.update(cx, |activity, cx| activity.mark_read(id, cx));107
.update(cx, |activity, cx| activity.mark_read(id, cx));@@ -313,6 +315,7 @@ impl ActivityPanel {313
cx.emit(ActivityPanelEvent::Open {315
cx.emit(ActivityPanelEvent::Open {314
conversation_id: pending.conversation_id.clone(),316
conversation_id: pending.conversation_id.clone(),315
message_id: pending.jump_message_id().to_owned(),317
message_id: pending.jump_message_id().to_owned(),318
link: None,316
});319
});317
}320
}318
}321
}@@ -238,7 +238,14 @@ impl AppShell {
238
238
ActivityPanelEvent::Open {
239
239
conversation_id,
240
240
message_id,
241
} => this.open_message(conversation_id, message_id, cx),
241
link,
242
} => {
243
if !this.open_message(conversation_id, message_id, cx)
244
&& let Some(link) = link
245
{
246
cx.open_url(link);
247
}
248
}
242
249
},
243
250
),
244
251
cx.subscribe(&saved_panel, |this, _, event: &SavedPanelEvent, cx| {
@@ -536,9 +543,14 @@ impl AppShell {
536
543
cx.notify();
537
544
}
538
545
539
fn open_message(&mut self, conversation_id: &str, message_id: &str, cx: &mut Context<Self>) {
546
fn open_message(
547
&mut self,
548
conversation_id: &str,
549
message_id: &str,
550
cx: &mut Context<Self>,
551
) -> bool {
540
552
let Some(selection) = selection_for(&self.state.read(cx).sidebar, conversation_id) else {
541
return;
553
return false;
542
554
};
543
555
let message_id = message_id.to_owned();
544
556
self.state.update(cx, |state, cx| {
@@ -548,6 +560,7 @@ impl AppShell {
548
560
state.jump_to_message(selection, message_id, cx)
549
561
}
550
562
});
563
true
551
564
}
552
565
553
566
fn open_status_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
@@ -238,7 +238,14 @@ impl AppShell {238
ActivityPanelEvent::Open {238
ActivityPanelEvent::Open {239
conversation_id,239
conversation_id,240
message_id,240
message_id,241
} => this.open_message(conversation_id, message_id, cx),241
link,242
} => {243
if !this.open_message(conversation_id, message_id, cx)244
&& let Some(link) = link245
{246
cx.open_url(link);247
}248
}242
},249
},243
),250
),244
cx.subscribe(&saved_panel, |this, _, event: &SavedPanelEvent, cx| {251
cx.subscribe(&saved_panel, |this, _, event: &SavedPanelEvent, cx| {@@ -536,9 +543,14 @@ impl AppShell {536
cx.notify();543
cx.notify();537
}544
}538
545
539
fn open_message(&mut self, conversation_id: &str, message_id: &str, cx: &mut Context<Self>) {546
fn open_message(547
&mut self,548
conversation_id: &str,549
message_id: &str,550
cx: &mut Context<Self>,551
) -> bool {540
let Some(selection) = selection_for(&self.state.read(cx).sidebar, conversation_id) else {552
let Some(selection) = selection_for(&self.state.read(cx).sidebar, conversation_id) else {541
return;553
return false;542
};554
};543
let message_id = message_id.to_owned();555
let message_id = message_id.to_owned();544
self.state.update(cx, |state, cx| {556
self.state.update(cx, |state, cx| {@@ -548,6 +560,7 @@ impl AppShell {548
state.jump_to_message(selection, message_id, cx)560
state.jump_to_message(selection, message_id, cx)549
}561
}550
});562
});563
true551
}564
}552
565
553
fn open_status_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {566
fn open_status_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {@@ -13,6 +13,8 @@ const MAX_PAGES: usize = 3;
13
13
const READ_PROPERTY: &str = "isread";
14
14
const SEEN_PROPERTY: &str = "consumptionhorizon";
15
15
const BOOKMARK_PROPERTY: &str = "consumptionHorizonBookmark";
16
const MEETING_THREAD_PREFIX: &str = "19:meeting_";
17
const MEETING_THREAD_SUFFIX: &str = "@thread.v2";
16
18
17
19
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
18
20
pub struct ActivityItem {
@@ -34,6 +36,8 @@ pub struct ActivityItem {
34
36
pub timestamp_ms: i64,
35
37
pub version_ms: i64,
36
38
pub read_flag: bool,
39
pub tap_url: Option<String>,
40
pub meeting_thread_id: Option<String>,
37
41
}
38
42
39
43
/// `seen_ms`: the bell horizon (`consumptionhorizon`), `bookmark_ms`: Mark all as read (`consumptionHorizonBookmark`).
@@ -228,9 +232,26 @@ fn activity_item(message: &Value) -> Option<ActivityItem> {
228
232
timestamp_ms,
229
233
version_ms,
230
234
read_flag: flag(properties.get(READ_PROPERTY)),
235
tap_url: text("customTapAction"),
236
meeting_thread_id: meeting_thread_in(&activity.to_string()),
231
237
})
232
238
}
233
239
240
fn meeting_thread_in(text: &str) -> Option<String> {
241
let decoded = text
242
.replace("%3a", ":")
243
.replace("%3A", ":")
244
.replace("%40", "@");
245
let start = decoded.find(MEETING_THREAD_PREFIX)?;
246
let rest = &decoded[start..];
247
let end = rest.find(MEETING_THREAD_SUFFIX)? + MEETING_THREAD_SUFFIX.len();
248
let thread_id = &rest[..end];
249
thread_id
250
.chars()
251
.all(|character| character.is_ascii_alphanumeric() || "_:@.-=".contains(character))
252
.then(|| thread_id.to_owned())
253
}
254
234
255
fn object_property(properties: &Value, key: &str) -> Option<Value> {
235
256
match properties.get(key)? {
236
257
Value::String(text) => serde_json::from_str::<Value>(text)
@@ -352,10 +373,31 @@ mod tests {
352
373
timestamp_ms: 1791368000000,
353
374
version_ms: 1791368000500,
354
375
read_flag: false,
376
tap_url: None,
377
meeting_thread_id: None,
355
378
}]
356
379
);
357
380
}
358
381
382
#[test]
383
fn an_app_activity_keeps_its_tap_link_and_the_meeting_it_names() {
384
let body = json!({"messages": [
385
message("1", 1, json!({
386
"activityType": "msGraph", "activitySubtype": "recapIsReadyV2",
387
"customTapAction": "https://teams.microsoft.com/l/entity/x?context=%7B%22threadId%22%3A%2219%3Ameeting_Zm9v%40thread.v2%22%7D",
388
}), "false"),
389
message("2", 1, json!({
390
"activityType": "msGraph", "activitySubtype": "recapIsReadyV2",
391
"activityContext": {"templateParameters": "{\"threadId\":\"19:meeting_YmFy@thread.v2\"}"},
392
}), "false"),
393
]});
394
let items = parse_page(&body).unwrap();
395
assert!(items[0].tap_url.as_deref().unwrap().starts_with("https://teams.microsoft.com/l/entity/"));
396
assert_eq!(items[0].meeting_thread_id.as_deref(), Some("19:meeting_Zm9v@thread.v2"));
397
assert_eq!(items[1].tap_url, None);
398
assert_eq!(items[1].meeting_thread_id.as_deref(), Some("19:meeting_YmFy@thread.v2"));
399
}
400
359
401
#[test]
360
402
fn reads_both_horizons_of_the_feed_conversation() {
361
403
let conversation = json!({"properties": {
@@ -13,6 +13,8 @@ const MAX_PAGES: usize = 3;13
const READ_PROPERTY: &str = "isread";13
const READ_PROPERTY: &str = "isread";14
const SEEN_PROPERTY: &str = "consumptionhorizon";14
const SEEN_PROPERTY: &str = "consumptionhorizon";15
const BOOKMARK_PROPERTY: &str = "consumptionHorizonBookmark";15
const BOOKMARK_PROPERTY: &str = "consumptionHorizonBookmark";16
const MEETING_THREAD_PREFIX: &str = "19:meeting_";17
const MEETING_THREAD_SUFFIX: &str = "@thread.v2";16
18
17
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]19
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]18
pub struct ActivityItem {20
pub struct ActivityItem {@@ -34,6 +36,8 @@ pub struct ActivityItem {34
pub timestamp_ms: i64,36
pub timestamp_ms: i64,35
pub version_ms: i64,37
pub version_ms: i64,36
pub read_flag: bool,38
pub read_flag: bool,39
pub tap_url: Option<String>,40
pub meeting_thread_id: Option<String>,37
}41
}38
42
39
/// `seen_ms`: the bell horizon (`consumptionhorizon`), `bookmark_ms`: Mark all as read (`consumptionHorizonBookmark`).43
/// `seen_ms`: the bell horizon (`consumptionhorizon`), `bookmark_ms`: Mark all as read (`consumptionHorizonBookmark`).@@ -228,9 +232,26 @@ fn activity_item(message: &Value) -> Option<ActivityItem> {228
timestamp_ms,232
timestamp_ms,229
version_ms,233
version_ms,230
read_flag: flag(properties.get(READ_PROPERTY)),234
read_flag: flag(properties.get(READ_PROPERTY)),235
tap_url: text("customTapAction"),236
meeting_thread_id: meeting_thread_in(&activity.to_string()),231
})237
})232
}238
}233
239
240
fn meeting_thread_in(text: &str) -> Option<String> {241
let decoded = text242
.replace("%3a", ":")243
.replace("%3A", ":")244
.replace("%40", "@");245
let start = decoded.find(MEETING_THREAD_PREFIX)?;246
let rest = &decoded[start..];247
let end = rest.find(MEETING_THREAD_SUFFIX)? + MEETING_THREAD_SUFFIX.len();248
let thread_id = &rest[..end];249
thread_id250
.chars()251
.all(|character| character.is_ascii_alphanumeric() || "_:@.-=".contains(character))252
.then(|| thread_id.to_owned())253
}254
234
fn object_property(properties: &Value, key: &str) -> Option<Value> {255
fn object_property(properties: &Value, key: &str) -> Option<Value> {235
match properties.get(key)? {256
match properties.get(key)? {236
Value::String(text) => serde_json::from_str::<Value>(text)257
Value::String(text) => serde_json::from_str::<Value>(text)@@ -352,10 +373,31 @@ mod tests {352
timestamp_ms: 1791368000000,373
timestamp_ms: 1791368000000,353
version_ms: 1791368000500,374
version_ms: 1791368000500,354
read_flag: false,375
read_flag: false,376
tap_url: None,377
meeting_thread_id: None,355
}]378
}]356
);379
);357
}380
}358
381
382
#[test]383
fn an_app_activity_keeps_its_tap_link_and_the_meeting_it_names() {384
let body = json!({"messages": [385
message("1", 1, json!({386
"activityType": "msGraph", "activitySubtype": "recapIsReadyV2",387
"customTapAction": "https://teams.microsoft.com/l/entity/x?context=%7B%22threadId%22%3A%2219%3Ameeting_Zm9v%40thread.v2%22%7D",388
}), "false"),389
message("2", 1, json!({390
"activityType": "msGraph", "activitySubtype": "recapIsReadyV2",391
"activityContext": {"templateParameters": "{\"threadId\":\"19:meeting_YmFy@thread.v2\"}"},392
}), "false"),393
]});394
let items = parse_page(&body).unwrap();395
assert!(items[0].tap_url.as_deref().unwrap().starts_with("https://teams.microsoft.com/l/entity/"));396
assert_eq!(items[0].meeting_thread_id.as_deref(), Some("19:meeting_Zm9v@thread.v2"));397
assert_eq!(items[1].tap_url, None);398
assert_eq!(items[1].meeting_thread_id.as_deref(), Some("19:meeting_YmFy@thread.v2"));399
}400
359
#[test]401
#[test]360
fn reads_both_horizons_of_the_feed_conversation() {402
fn reads_both_horizons_of_the_feed_conversation() {361
let conversation = json!({"properties": {403
let conversation = json!({"properties": {