BlueGit

ict rusty-teams

fix(calendar): guard link schemes centrally, keep occurrence details, DST-aware peek time

- links open only for http, https, mailto, tel and msteams (chat, peek, View source)
- peek links go through the link hook (preferred browser)
- a series master only fills the agenda of an occurrence
- peek time follows the DST of the event date, all-day dates are localized

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-14 · 2 weeks ago

Hash
5733eb64fcae61676a2f706eeb97d85756cafefc
Parent
650bf757
11 files changed +146 −102
crates/app-base/src/release_feed.rs +0 −1
@@ -291,7 +291,6 @@ pub fn fetch_update(
291 291
292 292 #[cfg(test)]
293 293 mod tests {
294 use std::path::Path;
295 294
296 295 use super::*;
297 296
@@ -291,7 +291,6 @@ pub fn fetch_update(
291
291
292#[cfg(test)]
292#[cfg(test)]
293mod tests {
293mod tests {
294 use std::path::Path;
295
294
296 use super::*;
295 use super::*;
297
296
crates/app-state/src/call/schedule.rs +12 −9
@@ -8,6 +8,7 @@ use super::agenda::demo_join_url;
8 8 use crate::app_state::AppState;
9 9 use crate::runtime;
10 10
11 const AGENDA_KEYS: [&str; 4] = ["body", "bodyContent", "bodyContentType", "bodyPreview"];
11 12 const HALF_HOUR_MINUTES: i64 = 30;
12 13 const DEFAULT_LENGTH_MINUTES: i64 = 30;
13 14 const READ_ONLY_MESSAGE: &str = "Meetings cannot be scheduled in read-only mode.";
@@ -334,11 +335,7 @@ impl AppState {
334 335 .detach();
335 336 }
336 337
337 pub fn request_calendar_event_peek(
338 &mut self,
339 event: CalendarEvent,
340 cx: &mut Context<Self>,
341 ) {
338 pub fn request_calendar_event_peek(&mut self, event: CalendarEvent, cx: &mut Context<Self>) {
342 339 self.calendar_event_peek_request = Some(event);
343 340 cx.emit(crate::app_state::AppEvent::CalendarEventPeek);
344 341 cx.notify();
@@ -471,14 +468,20 @@ impl AppState {
471 468 else {
472 469 return;
473 470 };
474 let master = runtime::spawn(async move {
475 launcher.calendar_event_details(&master_id, None).await
476 });
471 let master =
472 runtime::spawn(
473 async move { launcher.calendar_event_details(&master_id, None).await },
474 );
477 475 let Ok(Ok(master_details)) = master.await else {
478 476 return;
479 477 };
478 let master_agenda: serde_json::Value = AGENDA_KEYS
479 .iter()
480 .filter_map(|key| Some(((*key).to_owned(), master_details.get(*key)?.clone())))
481 .collect::<serde_json::Map<_, _>>()
482 .into();
480 483 this.update(cx, |state, cx| {
481 state.apply_calendar_event_details(&event_id, &master_details, cx);
484 state.apply_calendar_event_details(&event_id, &master_agenda, cx);
482 485 })
483 486 .ok();
484 487 })
@@ -8,6 +8,7 @@ use super::agenda::demo_join_url;
8use crate::app_state::AppState;
8use crate::app_state::AppState;
9use crate::runtime;
9use crate::runtime;
10
10
11const AGENDA_KEYS: [&str; 4] = ["body", "bodyContent", "bodyContentType", "bodyPreview"];
11const HALF_HOUR_MINUTES: i64 = 30;
12const HALF_HOUR_MINUTES: i64 = 30;
12const DEFAULT_LENGTH_MINUTES: i64 = 30;
13const DEFAULT_LENGTH_MINUTES: i64 = 30;
13const READ_ONLY_MESSAGE: &str = "Meetings cannot be scheduled in read-only mode.";
14const READ_ONLY_MESSAGE: &str = "Meetings cannot be scheduled in read-only mode.";
@@ -334,11 +335,7 @@ impl AppState {
334 .detach();
335 .detach();
335 }
336 }
336
337
337 pub fn request_calendar_event_peek(
338 pub fn request_calendar_event_peek(&mut self, event: CalendarEvent, cx: &mut Context<Self>) {
338 &mut self,
339 event: CalendarEvent,
340 cx: &mut Context<Self>,
341 ) {
342 self.calendar_event_peek_request = Some(event);
339 self.calendar_event_peek_request = Some(event);
343 cx.emit(crate::app_state::AppEvent::CalendarEventPeek);
340 cx.emit(crate::app_state::AppEvent::CalendarEventPeek);
344 cx.notify();
341 cx.notify();
@@ -471,14 +468,20 @@ impl AppState {
471 else {
468 else {
472 return;
469 return;
473 };
470 };
474 let master = runtime::spawn(async move {
471 let master =
475 launcher.calendar_event_details(&master_id, None).await
472 runtime::spawn(
476 });
473 async move { launcher.calendar_event_details(&master_id, None).await },
474 );
477 let Ok(Ok(master_details)) = master.await else {
475 let Ok(Ok(master_details)) = master.await else {
478 return;
476 return;
479 };
477 };
478 let master_agenda: serde_json::Value = AGENDA_KEYS
479 .iter()
480 .filter_map(|key| Some(((*key).to_owned(), master_details.get(*key)?.clone())))
481 .collect::<serde_json::Map<_, _>>()
482 .into();
480 this.update(cx, |state, cx| {
483 this.update(cx, |state, cx| {
481 state.apply_calendar_event_details(&event_id, &master_details, cx);
484 state.apply_calendar_event_details(&event_id, &master_agenda, cx);
482 })
485 })
483 .ok();
486 .ok();
484 })
487 })
crates/app-ui-kit/src/render/hooks.rs +29 −0
@@ -17,7 +17,19 @@ pub fn open_profile_link(url: &str, position: Point<Pixels>, cx: &mut App) -> bo
17 17 }
18 18 }
19 19
20 const OPENABLE_SCHEMES: [&str; 5] = ["https://", "http://", "mailto:", "tel:", "msteams:"];
21
22 pub fn is_openable_link(url: &str) -> bool {
23 let lower = url.trim_start().to_ascii_lowercase();
24 OPENABLE_SCHEMES
25 .iter()
26 .any(|scheme| lower.starts_with(scheme))
27 }
28
20 29 pub fn open_link(url: &str, cx: &mut App) {
30 if !is_openable_link(url) {
31 return;
32 }
21 33 match cx.try_global::<RenderHooks>().copied() {
22 34 Some(hooks) => (hooks.open_link)(url, cx),
23 35 None => cx.open_url(url),
@@ -34,3 +46,20 @@ pub fn inline_image(url: &str, cx: &App) -> Option<std::path::PathBuf> {
34 46 let hooks = cx.try_global::<RenderHooks>().copied()?;
35 47 (hooks.inline_image)(url, cx)
36 48 }
49
50 #[cfg(test)]
51 mod tests {
52 use super::is_openable_link;
53
54 #[test]
55 fn only_web_mail_phone_and_teams_links_open() {
56 assert!(is_openable_link("https://example.test/a"));
57 assert!(is_openable_link(" HTTP://example.test"));
58 assert!(is_openable_link("mailto:someone@example.test"));
59 assert!(is_openable_link("msteams:/l/chat/0/0"));
60 assert!(!is_openable_link("file:///etc/passwd"));
61 assert!(!is_openable_link("search-ms:query=x"));
62 assert!(!is_openable_link("javascript:alert(1)"));
63 assert!(!is_openable_link("//example.test"));
64 }
65 }
@@ -17,7 +17,19 @@ pub fn open_profile_link(url: &str, position: Point<Pixels>, cx: &mut App) -> bo
17 }
17 }
18}
18}
19
19
20const OPENABLE_SCHEMES: [&str; 5] = ["https://", "http://", "mailto:", "tel:", "msteams:"];
21
22pub fn is_openable_link(url: &str) -> bool {
23 let lower = url.trim_start().to_ascii_lowercase();
24 OPENABLE_SCHEMES
25 .iter()
26 .any(|scheme| lower.starts_with(scheme))
27}
28
20pub fn open_link(url: &str, cx: &mut App) {
29pub fn open_link(url: &str, cx: &mut App) {
30 if !is_openable_link(url) {
31 return;
32 }
21 match cx.try_global::<RenderHooks>().copied() {
33 match cx.try_global::<RenderHooks>().copied() {
22 Some(hooks) => (hooks.open_link)(url, cx),
34 Some(hooks) => (hooks.open_link)(url, cx),
23 None => cx.open_url(url),
35 None => cx.open_url(url),
@@ -34,3 +46,20 @@ pub fn inline_image(url: &str, cx: &App) -> Option<std::path::PathBuf> {
34 let hooks = cx.try_global::<RenderHooks>().copied()?;
46 let hooks = cx.try_global::<RenderHooks>().copied()?;
35 (hooks.inline_image)(url, cx)
47 (hooks.inline_image)(url, cx)
36}
48}
49
50#[cfg(test)]
51mod tests {
52 use super::is_openable_link;
53
54 #[test]
55 fn only_web_mail_phone_and_teams_links_open() {
56 assert!(is_openable_link("https://example.test/a"));
57 assert!(is_openable_link(" HTTP://example.test"));
58 assert!(is_openable_link("mailto:someone@example.test"));
59 assert!(is_openable_link("msteams:/l/chat/0/0"));
60 assert!(!is_openable_link("file:///etc/passwd"));
61 assert!(!is_openable_link("search-ms:query=x"));
62 assert!(!is_openable_link("javascript:alert(1)"));
63 assert!(!is_openable_link("//example.test"));
64 }
65}
crates/app/src/i18n.rs +4 −1
@@ -122,7 +122,10 @@ mod tests {
122 122 tr("calendar.peek.email_organizer"),
123 123 "E-Mail an den Organisator"
124 124 );
125 assert_eq!(tr("calendar.peek.teams_meeting"), "Microsoft Teams-Besprechung");
125 assert_eq!(
126 tr("calendar.peek.teams_meeting"),
127 "Microsoft Teams-Besprechung"
128 );
126 129 assert_eq!(tr("calendar.peek.google_meet"), "Google Meet");
127 130 assert_eq!(tr("calendar.peek.accept"), "Annehmen");
128 131 }
@@ -122,7 +122,10 @@ mod tests {
122 tr("calendar.peek.email_organizer"),
122 tr("calendar.peek.email_organizer"),
123 "E-Mail an den Organisator"
123 "E-Mail an den Organisator"
124 );
124 );
125 assert_eq!(tr("calendar.peek.teams_meeting"), "Microsoft Teams-Besprechung");
125 assert_eq!(
126 tr("calendar.peek.teams_meeting"),
127 "Microsoft Teams-Besprechung"
128 );
126 assert_eq!(tr("calendar.peek.google_meet"), "Google Meet");
129 assert_eq!(tr("calendar.peek.google_meet"), "Google Meet");
127 assert_eq!(tr("calendar.peek.accept"), "Annehmen");
130 assert_eq!(tr("calendar.peek.accept"), "Annehmen");
128 }
131 }
crates/app/src/views/calendar_event_dialog.rs +56 −37
@@ -1,11 +1,13 @@
1 1 use std::collections::HashMap;
2 2
3 use app_base::format::Zone;
3 4 use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, SIDEBAR_WIDTH};
5 use app_ui_kit::render::hooks::open_link;
4 6 use app_ui_kit::render::{Block, layout_blocks, render_blocks, strip_image_placeholders};
5 7 use chatsvc::{
6 8 CalendarEvent, CalendarSource, DialIn, EventAttendee, Reply, ResponseType, join_info_text,
7 9 };
8 use chrono::{Datelike, Local, Offset, Weekday};
10 use chrono::{Datelike, Weekday};
9 11 use gpui_kit::assets::IconName;
10 12 use gpui_kit::component::Sizable as _;
11 13 use gpui_kit::component::button::{Button, ButtonVariants as _};
@@ -140,7 +142,11 @@ impl EventPeek {
140 142 self.agenda = None;
141 143 return;
142 144 };
143 if self.agenda.as_ref().is_some_and(|(source, _)| source == html) {
145 if self
146 .agenda
147 .as_ref()
148 .is_some_and(|(source, _)| source == html)
149 {
144 150 return;
145 151 }
146 152 let blocks = strip_image_placeholders(layout_blocks(&teams_core::html_to_spans(html)));
@@ -148,7 +154,11 @@ impl EventPeek {
148 154 }
149 155
150 156 fn agenda_element(&self, cx: &App) -> Option<AnyElement> {
151 if let Some((_, blocks)) = self.agenda.as_ref().filter(|(_, blocks)| !blocks.is_empty()) {
157 if let Some((_, blocks)) = self
158 .agenda
159 .as_ref()
160 .filter(|(_, blocks)| !blocks.is_empty())
161 {
152 162 return Some(
153 163 div()
154 164 .w_full()
@@ -159,7 +169,11 @@ impl EventPeek {
159 169 .into_any_element(),
160 170 );
161 171 }
162 let preview = self.event.body_preview.clone().filter(|value| !value.is_empty())?;
172 let preview = self
173 .event
174 .body_preview
175 .clone()
176 .filter(|value| !value.is_empty())?;
163 177 Some(
164 178 div()
165 179 .w_full()
@@ -204,8 +218,9 @@ impl EventPeek {
204 218 } else {
205 219 String::new()
206 220 };
207 self.state
208 .update(cx, |state, cx| state.respond_to_event(&key, reply, &comment, cx));
221 self.state.update(cx, |state, cx| {
222 state.respond_to_event(&key, reply, &comment, cx)
223 });
209 224 self.close(cx);
210 225 }
211 226
@@ -220,8 +235,9 @@ impl EventPeek {
220 235 } else {
221 236 String::new()
222 237 };
223 self.state
224 .update(cx, |state, cx| state.respond_to_event(&master, reply, &comment, cx));
238 self.state.update(cx, |state, cx| {
239 state.respond_to_event(&master, reply, &comment, cx)
240 });
225 241 self.close(cx);
226 242 }
227 243
@@ -329,7 +345,11 @@ impl EventPeek {
329 345 if self.event.source != CalendarSource::Google {
330 346 return None;
331 347 }
332 let name = self.event.calendar_name.clone().filter(|value| !value.is_empty())?;
348 let name = self
349 .event
350 .calendar_name
351 .clone()
352 .filter(|value| !value.is_empty())?;
333 353 Some(
334 354 h_flex()
335 355 .gap(px(ROW_GAP))
@@ -392,7 +412,7 @@ impl EventPeek {
392 412 .text_color(theme::accent_text())
393 413 .cursor_pointer()
394 414 .child(tr("calendar.peek.view_source"))
395 .on_click(move |_, _, cx| cx.open_url(&open)),
415 .on_click(move |_, _, cx| open_link(&open, cx)),
396 416 ),
397 417 )
398 418 .into_any_element(),
@@ -500,7 +520,7 @@ impl EventPeek {
500 520 .outline()
501 521 .icon(IconName::ExternalLink)
502 522 .label(tr("calendar.peek.open_in_google"))
503 .on_click(move |_, _, cx| cx.open_url(&url))
523 .on_click(move |_, _, cx| open_link(&url, cx))
504 524 .into_any_element(),
505 525 );
506 526 }
@@ -524,7 +544,7 @@ impl EventPeek {
524 544 .outline()
525 545 .icon(IconName::Mail)
526 546 .label(tr("calendar.peek.email_guests"))
527 .on_click(move |_, _, cx| cx.open_url(&mailto))
547 .on_click(move |_, _, cx| open_link(&mailto, cx))
528 548 .into_any_element(),
529 549 );
530 550 }
@@ -984,11 +1004,11 @@ fn event_detail_score(event: &CalendarEvent) -> u8 {
984 1004 u8::from(event.body_html.is_some()) * 32
985 1005 + u8::from(!event.attendees.is_empty()) * 16
986 1006 + u8::from(
987 event
988 .body_preview
989 .as_ref()
990 .is_some_and(|value| !value.is_empty()),
991 ) * 8
1007 event
1008 .body_preview
1009 .as_ref()
1010 .is_some_and(|value| !value.is_empty()),
1011 ) * 8
992 1012 + u8::from(
993 1013 event
994 1014 .location
@@ -1000,26 +1020,27 @@ fn event_detail_score(event: &CalendarEvent) -> u8 {
1000 1020 }
1001 1021
1002 1022 fn peek_when_label(event: &CalendarEvent) -> String {
1003 let offset = Local::now().offset().fix();
1004 if is_effective_all_day(event, offset) {
1005 let start = event.start.with_timezone(&offset).date_naive();
1006 let end = event.end.with_timezone(&offset).date_naive();
1023 let start = Zone::Local.at(event.start);
1024 let end = Zone::Local.at(event.end);
1025 if is_effective_all_day(event, *start.offset()) {
1026 let day_label = |date: chrono::NaiveDate| {
1027 format!(
1028 "{} {}",
1029 localized_weekday(date.weekday()),
1030 format_peek_date(date)
1031 )
1032 };
1033 let (start, end) = (start.date_naive(), end.date_naive());
1007 1034 if end > start + chrono::Duration::days(1) {
1008 1035 return format!(
1009 "{} · {} – {}",
1036 "{} · {} - {}",
1010 1037 tr("calendar.peek.all_day"),
1011 start.format("%a, %b %-d"),
1012 (end - chrono::Duration::days(1)).format("%a, %b %-d, %Y")
1038 day_label(start),
1039 day_label(end - chrono::Duration::days(1))
1013 1040 );
1014 1041 }
1015 return format!(
1016 "{} · {}",
1017 tr("calendar.peek.all_day"),
1018 start.format("%a, %b %-d, %Y")
1019 );
1042 return format!("{} · {}", tr("calendar.peek.all_day"), day_label(start));
1020 1043 }
1021 let start = event.start.with_timezone(&offset);
1022 let end = event.end.with_timezone(&offset);
1023 1044 let weekday = localized_weekday(start.weekday());
1024 1045 let date = format_peek_date(start.date_naive());
1025 1046 let clock = app_base::format::clock_format();
@@ -1113,11 +1134,7 @@ fn localized_weekday(weekday: Weekday) -> &'static str {
1113 1134 }
1114 1135
1115 1136 fn location_label(event: &CalendarEvent) -> String {
1116 if let Some(location) = event
1117 .location
1118 .clone()
1119 .filter(|value| !value.is_empty())
1120 {
1137 if let Some(location) = event.location.clone().filter(|value| !value.is_empty()) {
1121 1138 return location;
1122 1139 }
1123 1140 if !event.online {
@@ -1167,7 +1184,9 @@ fn rsvp_button(
1167 1184 has_master: bool,
1168 1185 peek: Entity<EventPeek>,
1169 1186 ) -> AnyElement {
1170 let button = Button::new(id).label(label).when(chosen, |button| button.primary());
1187 let button = Button::new(id)
1188 .label(label)
1189 .when(chosen, |button| button.primary());
1171 1190 let button = match reply {
1172 1191 Reply::Accept => button.icon(IconName::Check),
1173 1192 Reply::Decline => button.icon(IconName::X),
@@ -1,11 +1,13 @@
1use std::collections::HashMap;
1use std::collections::HashMap;
2
2
3use app_base::format::Zone;
3use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, SIDEBAR_WIDTH};
4use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, SIDEBAR_WIDTH};
5use app_ui_kit::render::hooks::open_link;
4use app_ui_kit::render::{Block, layout_blocks, render_blocks, strip_image_placeholders};
6use app_ui_kit::render::{Block, layout_blocks, render_blocks, strip_image_placeholders};
5use chatsvc::{
7use chatsvc::{
6 CalendarEvent, CalendarSource, DialIn, EventAttendee, Reply, ResponseType, join_info_text,
8 CalendarEvent, CalendarSource, DialIn, EventAttendee, Reply, ResponseType, join_info_text,
7};
9};
8use chrono::{Datelike, Local, Offset, Weekday};
10use chrono::{Datelike, Weekday};
9use gpui_kit::assets::IconName;
11use gpui_kit::assets::IconName;
10use gpui_kit::component::Sizable as _;
12use gpui_kit::component::Sizable as _;
11use gpui_kit::component::button::{Button, ButtonVariants as _};
13use gpui_kit::component::button::{Button, ButtonVariants as _};
@@ -140,7 +142,11 @@ impl EventPeek {
140 self.agenda = None;
142 self.agenda = None;
141 return;
143 return;
142 };
144 };
143 if self.agenda.as_ref().is_some_and(|(source, _)| source == html) {
145 if self
146 .agenda
147 .as_ref()
148 .is_some_and(|(source, _)| source == html)
149 {
144 return;
150 return;
145 }
151 }
146 let blocks = strip_image_placeholders(layout_blocks(&teams_core::html_to_spans(html)));
152 let blocks = strip_image_placeholders(layout_blocks(&teams_core::html_to_spans(html)));
@@ -148,7 +154,11 @@ impl EventPeek {
148 }
154 }
149
155
150 fn agenda_element(&self, cx: &App) -> Option<AnyElement> {
156 fn agenda_element(&self, cx: &App) -> Option<AnyElement> {
151 if let Some((_, blocks)) = self.agenda.as_ref().filter(|(_, blocks)| !blocks.is_empty()) {
157 if let Some((_, blocks)) = self
158 .agenda
159 .as_ref()
160 .filter(|(_, blocks)| !blocks.is_empty())
161 {
152 return Some(
162 return Some(
153 div()
163 div()
154 .w_full()
164 .w_full()
@@ -159,7 +169,11 @@ impl EventPeek {
159 .into_any_element(),
169 .into_any_element(),
160 );
170 );
161 }
171 }
162 let preview = self.event.body_preview.clone().filter(|value| !value.is_empty())?;
172 let preview = self
173 .event
174 .body_preview
175 .clone()
176 .filter(|value| !value.is_empty())?;
163 Some(
177 Some(
164 div()
178 div()
165 .w_full()
179 .w_full()
@@ -204,8 +218,9 @@ impl EventPeek {
204 } else {
218 } else {
205 String::new()
219 String::new()
206 };
220 };
207 self.state
221 self.state.update(cx, |state, cx| {
208 .update(cx, |state, cx| state.respond_to_event(&key, reply, &comment, cx));
222 state.respond_to_event(&key, reply, &comment, cx)
223 });
209 self.close(cx);
224 self.close(cx);
210 }
225 }
211
226
@@ -220,8 +235,9 @@ impl EventPeek {
220 } else {
235 } else {
221 String::new()
236 String::new()
222 };
237 };
223 self.state
238 self.state.update(cx, |state, cx| {
224 .update(cx, |state, cx| state.respond_to_event(&master, reply, &comment, cx));
239 state.respond_to_event(&master, reply, &comment, cx)
240 });
225 self.close(cx);
241 self.close(cx);
226 }
242 }
227
243
@@ -329,7 +345,11 @@ impl EventPeek {
329 if self.event.source != CalendarSource::Google {
345 if self.event.source != CalendarSource::Google {
330 return None;
346 return None;
331 }
347 }
332 let name = self.event.calendar_name.clone().filter(|value| !value.is_empty())?;
348 let name = self
349 .event
350 .calendar_name
351 .clone()
352 .filter(|value| !value.is_empty())?;
333 Some(
353 Some(
334 h_flex()
354 h_flex()
335 .gap(px(ROW_GAP))
355 .gap(px(ROW_GAP))
@@ -392,7 +412,7 @@ impl EventPeek {
392 .text_color(theme::accent_text())
412 .text_color(theme::accent_text())
393 .cursor_pointer()
413 .cursor_pointer()
394 .child(tr("calendar.peek.view_source"))
414 .child(tr("calendar.peek.view_source"))
395 .on_click(move |_, _, cx| cx.open_url(&open)),
415 .on_click(move |_, _, cx| open_link(&open, cx)),
396 ),
416 ),
397 )
417 )
398 .into_any_element(),
418 .into_any_element(),
@@ -500,7 +520,7 @@ impl EventPeek {
500 .outline()
520 .outline()
501 .icon(IconName::ExternalLink)
521 .icon(IconName::ExternalLink)
502 .label(tr("calendar.peek.open_in_google"))
522 .label(tr("calendar.peek.open_in_google"))
503 .on_click(move |_, _, cx| cx.open_url(&url))
523 .on_click(move |_, _, cx| open_link(&url, cx))
504 .into_any_element(),
524 .into_any_element(),
505 );
525 );
506 }
526 }
@@ -524,7 +544,7 @@ impl EventPeek {
524 .outline()
544 .outline()
525 .icon(IconName::Mail)
545 .icon(IconName::Mail)
526 .label(tr("calendar.peek.email_guests"))
546 .label(tr("calendar.peek.email_guests"))
527 .on_click(move |_, _, cx| cx.open_url(&mailto))
547 .on_click(move |_, _, cx| open_link(&mailto, cx))
528 .into_any_element(),
548 .into_any_element(),
529 );
549 );
530 }
550 }
@@ -984,11 +1004,11 @@ fn event_detail_score(event: &CalendarEvent) -> u8 {
984 u8::from(event.body_html.is_some()) * 32
1004 u8::from(event.body_html.is_some()) * 32
985 + u8::from(!event.attendees.is_empty()) * 16
1005 + u8::from(!event.attendees.is_empty()) * 16
986 + u8::from(
1006 + u8::from(
987 event
1007 event
988 .body_preview
1008 .body_preview
989 .as_ref()
1009 .as_ref()
990 .is_some_and(|value| !value.is_empty()),
1010 .is_some_and(|value| !value.is_empty()),
991 ) * 8
1011 ) * 8
992 + u8::from(
1012 + u8::from(
993 event
1013 event
994 .location
1014 .location
@@ -1000,26 +1020,27 @@ fn event_detail_score(event: &CalendarEvent) -> u8 {
1000}
1020}
1001
1021
1002fn peek_when_label(event: &CalendarEvent) -> String {
1022fn peek_when_label(event: &CalendarEvent) -> String {
1003 let offset = Local::now().offset().fix();
1023 let start = Zone::Local.at(event.start);
1004 if is_effective_all_day(event, offset) {
1024 let end = Zone::Local.at(event.end);
1005 let start = event.start.with_timezone(&offset).date_naive();
1025 if is_effective_all_day(event, *start.offset()) {
1006 let end = event.end.with_timezone(&offset).date_naive();
1026 let day_label = |date: chrono::NaiveDate| {
1027 format!(
1028 "{} {}",
1029 localized_weekday(date.weekday()),
1030 format_peek_date(date)
1031 )
1032 };
1033 let (start, end) = (start.date_naive(), end.date_naive());
1007 if end > start + chrono::Duration::days(1) {
1034 if end > start + chrono::Duration::days(1) {
1008 return format!(
1035 return format!(
1009 "{} · {} – {}",
1036 "{} · {} - {}",
1010 tr("calendar.peek.all_day"),
1037 tr("calendar.peek.all_day"),
1011 start.format("%a, %b %-d"),
1038 day_label(start),
1012 (end - chrono::Duration::days(1)).format("%a, %b %-d, %Y")
1039 day_label(end - chrono::Duration::days(1))
1013 );
1040 );
1014 }
1041 }
1015 return format!(
1042 return format!("{} · {}", tr("calendar.peek.all_day"), day_label(start));
1016 "{} · {}",
1017 tr("calendar.peek.all_day"),
1018 start.format("%a, %b %-d, %Y")
1019 );
1020 }
1043 }
1021 let start = event.start.with_timezone(&offset);
1022 let end = event.end.with_timezone(&offset);
1023 let weekday = localized_weekday(start.weekday());
1044 let weekday = localized_weekday(start.weekday());
1024 let date = format_peek_date(start.date_naive());
1045 let date = format_peek_date(start.date_naive());
1025 let clock = app_base::format::clock_format();
1046 let clock = app_base::format::clock_format();
@@ -1113,11 +1134,7 @@ fn localized_weekday(weekday: Weekday) -> &'static str {
1113}
1134}
1114
1135
1115fn location_label(event: &CalendarEvent) -> String {
1136fn location_label(event: &CalendarEvent) -> String {
1116 if let Some(location) = event
1137 if let Some(location) = event.location.clone().filter(|value| !value.is_empty()) {
1117 .location
1118 .clone()
1119 .filter(|value| !value.is_empty())
1120 {
1121 return location;
1138 return location;
1122 }
1139 }
1123 if !event.online {
1140 if !event.online {
@@ -1167,7 +1184,9 @@ fn rsvp_button(
1167 has_master: bool,
1184 has_master: bool,
1168 peek: Entity<EventPeek>,
1185 peek: Entity<EventPeek>,
1169) -> AnyElement {
1186) -> AnyElement {
1170 let button = Button::new(id).label(label).when(chosen, |button| button.primary());
1187 let button = Button::new(id)
1188 .label(label)
1189 .when(chosen, |button| button.primary());
1171 let button = match reply {
1190 let button = match reply {
1172 Reply::Accept => button.icon(IconName::Check),
1191 Reply::Accept => button.icon(IconName::Check),
1173 Reply::Decline => button.icon(IconName::X),
1192 Reply::Decline => button.icon(IconName::X),
crates/app/src/views/calendar_view.rs +1 −2
@@ -435,8 +435,7 @@ impl CalendarView {
435 435 let look = event_look(event);
436 436 // Join on the block whenever a Teams link exists (same as detail dialog).
437 437 // Skip on tiny blocks — the button would crush the title.
438 let can_join =
439 !compact && event.online && !event.cancelled && event.join_url.is_some();
438 let can_join = !compact && event.online && !event.cancelled && event.join_url.is_some();
440 439 let open_state = self.state.clone();
441 440 let open_event = event.clone();
442 441 let (menu_state, menu_event) = (self.state.clone(), event.clone());
@@ -435,8 +435,7 @@ impl CalendarView {
435 let look = event_look(event);
435 let look = event_look(event);
436 // Join on the block whenever a Teams link exists (same as detail dialog).
436 // Join on the block whenever a Teams link exists (same as detail dialog).
437 // Skip on tiny blocks — the button would crush the title.
437 // Skip on tiny blocks — the button would crush the title.
438 let can_join =
438 let can_join = !compact && event.online && !event.cancelled && event.join_url.is_some();
439 !compact && event.online && !event.cancelled && event.join_url.is_some();
440 let open_state = self.state.clone();
439 let open_state = self.state.clone();
441 let open_event = event.clone();
440 let open_event = event.clone();
442 let (menu_state, menu_event) = (self.state.clone(), event.clone());
441 let (menu_state, menu_event) = (self.state.clone(), event.clone());
crates/app/src/views/shell.rs +5 −10
@@ -709,7 +709,6 @@ impl AppShell {
709 709 cx.notify();
710 710 }
711 711
712
713 712 fn open_calendar_event_peek(&mut self, window: &mut Window, cx: &mut Context<Self>) {
714 713 let Some(event) = self
715 714 .state
@@ -720,15 +719,11 @@ impl AppShell {
720 719 self.switcher = None;
721 720 let app = self.state.clone();
722 721 let peek = cx.new(|cx| EventPeek::new(app, event, window, cx));
723 cx.subscribe_in(
724 &peek,
725 window,
726 |this, _, _: &EventPeekEvent, window, cx| {
727 this.calendar_event_peek = None;
728 this.restore_focus(window, cx);
729 cx.notify();
730 },
731 )
722 cx.subscribe_in(&peek, window, |this, _, _: &EventPeekEvent, window, cx| {
723 this.calendar_event_peek = None;
724 this.restore_focus(window, cx);
725 cx.notify();
726 })
732 727 .detach();
733 728 self.calendar_event_peek = Some(peek);
734 729 cx.notify();
@@ -709,7 +709,6 @@ impl AppShell {
709 cx.notify();
709 cx.notify();
710 }
710 }
711
711
712
713 fn open_calendar_event_peek(&mut self, window: &mut Window, cx: &mut Context<Self>) {
712 fn open_calendar_event_peek(&mut self, window: &mut Window, cx: &mut Context<Self>) {
714 let Some(event) = self
713 let Some(event) = self
715 .state
714 .state
@@ -720,15 +719,11 @@ impl AppShell {
720 self.switcher = None;
719 self.switcher = None;
721 let app = self.state.clone();
720 let app = self.state.clone();
722 let peek = cx.new(|cx| EventPeek::new(app, event, window, cx));
721 let peek = cx.new(|cx| EventPeek::new(app, event, window, cx));
723 cx.subscribe_in(
722 cx.subscribe_in(&peek, window, |this, _, _: &EventPeekEvent, window, cx| {
724 &peek,
723 this.calendar_event_peek = None;
725 window,
724 this.restore_focus(window, cx);
726 |this, _, _: &EventPeekEvent, window, cx| {
725 cx.notify();
727 this.calendar_event_peek = None;
726 })
728 this.restore_focus(window, cx);
729 cx.notify();
730 },
731 )
732 .detach();
727 .detach();
733 self.calendar_event_peek = Some(peek);
728 self.calendar_event_peek = Some(peek);
734 cx.notify();
729 cx.notify();
crates/chatsvc/src/calendar.rs +21 −27
@@ -66,10 +66,7 @@ pub struct AttendeeResponseCounts {
66 66
67 67 impl AttendeeResponseCounts {
68 68 pub fn is_empty(self) -> bool {
69 self.accepted == 0
70 && self.declined == 0
71 && self.tentative == 0
72 && self.not_responded == 0
69 self.accepted == 0 && self.declined == 0 && self.tentative == 0 && self.not_responded == 0
73 70 }
74 71 }
75 72
@@ -472,9 +469,7 @@ fn sanitize_html_hrefs(html: &str) -> String {
472 469 fn url_is_safe_href(url: &str) -> bool {
473 470 let trimmed = url.trim();
474 471 let lower = trimmed.to_ascii_lowercase();
475 lower.starts_with("https://")
476 || lower.starts_with("http://")
477 || lower.starts_with("mailto:")
472 lower.starts_with("https://") || lower.starts_with("http://") || lower.starts_with("mailto:")
478 473 }
479 474
480 475 fn attendee_response(label: &str) -> ResponseType {
@@ -546,7 +541,10 @@ pub fn strip_html(input: &str) -> String {
546 541 _ => {}
547 542 }
548 543 }
549 html_entities(&out).split_whitespace().collect::<Vec<_>>().join(" ")
544 html_entities(&out)
545 .split_whitespace()
546 .collect::<Vec<_>>()
547 .join(" ")
550 548 }
551 549
552 550 fn html_entities(input: &str) -> String {
@@ -580,8 +578,13 @@ fn series_flag(entry: &Value) -> bool {
580 578 .as_deref()
581 579 {
582 580 Some("occurrence" | "exception" | "seriesMaster") => true,
583 _ => entry.get("seriesMasterId").and_then(Value::as_str).is_some()
584 || entry.get("recurrence").is_some(),
581 _ => {
582 entry
583 .get("seriesMasterId")
584 .and_then(Value::as_str)
585 .is_some()
586 || entry.get("recurrence").is_some()
587 }
585 588 }
586 589 }
587 590
@@ -797,10 +800,7 @@ mod tests {
797 800 standup.thread_id.as_deref(),
798 801 Some("19:meeting_demo1@thread.v2")
799 802 );
800 assert_eq!(
801 standup.location.as_deref(),
802 Some("Microsoft Teams Meeting")
803 );
803 assert_eq!(standup.location.as_deref(), Some("Microsoft Teams Meeting"));
804 804 assert_eq!(
805 805 standup.body_preview.as_deref(),
806 806 Some("Daily agenda and blockers")
@@ -818,14 +818,8 @@ mod tests {
818 818
819 819 #[test]
820 820 fn strip_html_flattens_markup_for_peek_preview() {
821 assert_eq!(
822 strip_html("<p>Hello&nbsp;<b>team</b></p>"),
823 "Hello team"
824 );
825 assert_eq!(
826 strip_html("<p>NEUE</p><p>Agenda</p>"),
827 "NEUE Agenda"
828 );
821 assert_eq!(strip_html("<p>Hello&nbsp;<b>team</b></p>"), "Hello team");
822 assert_eq!(strip_html("<p>NEUE</p><p>Agenda</p>"), "NEUE Agenda");
829 823 assert_eq!(truncate_preview(&"x".repeat(4_100)).chars().count(), 4_001);
830 824 }
831 825
@@ -855,7 +849,10 @@ mod tests {
855 849 assert_eq!(event.location.as_deref(), Some("Room A"));
856 850 assert!(event.series);
857 851 assert_eq!(event.series_master_id.as_deref(), Some("master"));
858 assert_eq!(event.join_url.as_deref(), Some("https://teams.microsoft.com/l/meetup-join/z"));
852 assert_eq!(
853 event.join_url.as_deref(),
854 Some("https://teams.microsoft.com/l/meetup-join/z")
855 );
859 856 let counts = event.response_counts.expect("counts");
860 857 assert_eq!(counts.accepted, 1);
861 858 assert_eq!(counts.tentative, 1);
@@ -899,10 +896,7 @@ mod tests {
899 896 "body": {"contentType": "text", "content": "Line1\rLine2\r\nLine3"}
900 897 }),
901 898 );
902 assert_eq!(
903 event.body_html.as_deref(),
904 Some("Line1<br>Line2<br>Line3")
905 );
899 assert_eq!(event.body_html.as_deref(), Some("Line1<br>Line2<br>Line3"));
906 900 }
907 901
908 902 #[test]
@@ -66,10 +66,7 @@ pub struct AttendeeResponseCounts {
66
66
67impl AttendeeResponseCounts {
67impl AttendeeResponseCounts {
68 pub fn is_empty(self) -> bool {
68 pub fn is_empty(self) -> bool {
69 self.accepted == 0
69 self.accepted == 0 && self.declined == 0 && self.tentative == 0 && self.not_responded == 0
70 && self.declined == 0
71 && self.tentative == 0
72 && self.not_responded == 0
73 }
70 }
74}
71}
75
72
@@ -472,9 +469,7 @@ fn sanitize_html_hrefs(html: &str) -> String {
472fn url_is_safe_href(url: &str) -> bool {
469fn url_is_safe_href(url: &str) -> bool {
473 let trimmed = url.trim();
470 let trimmed = url.trim();
474 let lower = trimmed.to_ascii_lowercase();
471 let lower = trimmed.to_ascii_lowercase();
475 lower.starts_with("https://")
472 lower.starts_with("https://") || lower.starts_with("http://") || lower.starts_with("mailto:")
476 || lower.starts_with("http://")
477 || lower.starts_with("mailto:")
478}
473}
479
474
480fn attendee_response(label: &str) -> ResponseType {
475fn attendee_response(label: &str) -> ResponseType {
@@ -546,7 +541,10 @@ pub fn strip_html(input: &str) -> String {
546 _ => {}
541 _ => {}
547 }
542 }
548 }
543 }
549 html_entities(&out).split_whitespace().collect::<Vec<_>>().join(" ")
544 html_entities(&out)
545 .split_whitespace()
546 .collect::<Vec<_>>()
547 .join(" ")
550}
548}
551
549
552fn html_entities(input: &str) -> String {
550fn html_entities(input: &str) -> String {
@@ -580,8 +578,13 @@ fn series_flag(entry: &Value) -> bool {
580 .as_deref()
578 .as_deref()
581 {
579 {
582 Some("occurrence" | "exception" | "seriesMaster") => true,
580 Some("occurrence" | "exception" | "seriesMaster") => true,
583 _ => entry.get("seriesMasterId").and_then(Value::as_str).is_some()
581 _ => {
584 || entry.get("recurrence").is_some(),
582 entry
583 .get("seriesMasterId")
584 .and_then(Value::as_str)
585 .is_some()
586 || entry.get("recurrence").is_some()
587 }
585 }
588 }
586}
589}
587
590
@@ -797,10 +800,7 @@ mod tests {
797 standup.thread_id.as_deref(),
800 standup.thread_id.as_deref(),
798 Some("19:meeting_demo1@thread.v2")
801 Some("19:meeting_demo1@thread.v2")
799 );
802 );
800 assert_eq!(
803 assert_eq!(standup.location.as_deref(), Some("Microsoft Teams Meeting"));
801 standup.location.as_deref(),
802 Some("Microsoft Teams Meeting")
803 );
804 assert_eq!(
804 assert_eq!(
805 standup.body_preview.as_deref(),
805 standup.body_preview.as_deref(),
806 Some("Daily agenda and blockers")
806 Some("Daily agenda and blockers")
@@ -818,14 +818,8 @@ mod tests {
818
818
819 #[test]
819 #[test]
820 fn strip_html_flattens_markup_for_peek_preview() {
820 fn strip_html_flattens_markup_for_peek_preview() {
821 assert_eq!(
821 assert_eq!(strip_html("<p>Hello&nbsp;<b>team</b></p>"), "Hello team");
822 strip_html("<p>Hello&nbsp;<b>team</b></p>"),
822 assert_eq!(strip_html("<p>NEUE</p><p>Agenda</p>"), "NEUE Agenda");
823 "Hello team"
824 );
825 assert_eq!(
826 strip_html("<p>NEUE</p><p>Agenda</p>"),
827 "NEUE Agenda"
828 );
829 assert_eq!(truncate_preview(&"x".repeat(4_100)).chars().count(), 4_001);
823 assert_eq!(truncate_preview(&"x".repeat(4_100)).chars().count(), 4_001);
830 }
824 }
831
825
@@ -855,7 +849,10 @@ mod tests {
855 assert_eq!(event.location.as_deref(), Some("Room A"));
849 assert_eq!(event.location.as_deref(), Some("Room A"));
856 assert!(event.series);
850 assert!(event.series);
857 assert_eq!(event.series_master_id.as_deref(), Some("master"));
851 assert_eq!(event.series_master_id.as_deref(), Some("master"));
858 assert_eq!(event.join_url.as_deref(), Some("https://teams.microsoft.com/l/meetup-join/z"));
852 assert_eq!(
853 event.join_url.as_deref(),
854 Some("https://teams.microsoft.com/l/meetup-join/z")
855 );
859 let counts = event.response_counts.expect("counts");
856 let counts = event.response_counts.expect("counts");
860 assert_eq!(counts.accepted, 1);
857 assert_eq!(counts.accepted, 1);
861 assert_eq!(counts.tentative, 1);
858 assert_eq!(counts.tentative, 1);
@@ -899,10 +896,7 @@ mod tests {
899 "body": {"contentType": "text", "content": "Line1\rLine2\r\nLine3"}
896 "body": {"contentType": "text", "content": "Line1\rLine2\r\nLine3"}
900 }),
897 }),
901 );
898 );
902 assert_eq!(
899 assert_eq!(event.body_html.as_deref(), Some("Line1<br>Line2<br>Line3"));
903 event.body_html.as_deref(),
904 Some("Line1<br>Line2<br>Line3")
905 );
906 }
900 }
907
901
908 #[test]
902 #[test]
crates/chatsvc/src/calendar/schedule.rs +7 −8
@@ -202,8 +202,7 @@ fn event_item_url(event_id: &str) -> String {
202 202
203 203 // Include `body` — series occurrences often have an empty bodyPreview while the
204 204 // full HTML agenda lives in body.content (body_preview_text already falls back).
205 const EVENT_DETAIL_SELECT: &str =
206 "id,subject,body,bodyPreview,location,attendees,type,seriesMasterId,isOnlineMeeting,onlineMeeting,organizer,isAllDay,isCancelled";
205 const EVENT_DETAIL_SELECT: &str = "id,subject,body,bodyPreview,location,attendees,type,seriesMasterId,isOnlineMeeting,onlineMeeting,organizer,isAllDay,isCancelled";
207 206
208 207 fn event_details_url(event_id: &str) -> String {
209 208 format!(
@@ -254,7 +253,11 @@ fn merge_detail_bodies(mut graph: Value, teams: Value) -> Value {
254 253 }
255 254 }
256 255 if let Some(attendees) = teams.get("attendees").cloned() {
257 if graph.get("attendees").and_then(Value::as_array).is_none_or(|a| a.is_empty()) {
256 if graph
257 .get("attendees")
258 .and_then(Value::as_array)
259 .is_none_or(|a| a.is_empty())
260 {
258 261 if let Some(map) = graph.as_object_mut() {
259 262 map.insert("attendees".into(), attendees);
260 263 }
@@ -323,11 +326,7 @@ impl<T: CardTransport> Calendar<T> {
323 326 Err(api_error(retried, &reply_url(&graph_id, reply)))
324 327 }
325 328
326 pub async fn event_details(
327 &self,
328 event_id: &str,
329 ical_uid: Option<&str>,
330 ) -> Result<Value> {
329 pub async fn event_details(&self, event_id: &str, ical_uid: Option<&str>) -> Result<Value> {
331 330 let answer = self.fetch_event(event_id).await?;
332 331 if answer.is_success() {
333 332 if details_have_agenda(&answer.body) {
@@ -202,8 +202,7 @@ fn event_item_url(event_id: &str) -> String {
202
202
203// Include `body` — series occurrences often have an empty bodyPreview while the
203// Include `body` — series occurrences often have an empty bodyPreview while the
204// full HTML agenda lives in body.content (body_preview_text already falls back).
204// full HTML agenda lives in body.content (body_preview_text already falls back).
205const EVENT_DETAIL_SELECT: &str =
205const EVENT_DETAIL_SELECT: &str = "id,subject,body,bodyPreview,location,attendees,type,seriesMasterId,isOnlineMeeting,onlineMeeting,organizer,isAllDay,isCancelled";
206 "id,subject,body,bodyPreview,location,attendees,type,seriesMasterId,isOnlineMeeting,onlineMeeting,organizer,isAllDay,isCancelled";
207
206
208fn event_details_url(event_id: &str) -> String {
207fn event_details_url(event_id: &str) -> String {
209 format!(
208 format!(
@@ -254,7 +253,11 @@ fn merge_detail_bodies(mut graph: Value, teams: Value) -> Value {
254 }
253 }
255 }
254 }
256 if let Some(attendees) = teams.get("attendees").cloned() {
255 if let Some(attendees) = teams.get("attendees").cloned() {
257 if graph.get("attendees").and_then(Value::as_array).is_none_or(|a| a.is_empty()) {
256 if graph
257 .get("attendees")
258 .and_then(Value::as_array)
259 .is_none_or(|a| a.is_empty())
260 {
258 if let Some(map) = graph.as_object_mut() {
261 if let Some(map) = graph.as_object_mut() {
259 map.insert("attendees".into(), attendees);
262 map.insert("attendees".into(), attendees);
260 }
263 }
@@ -323,11 +326,7 @@ impl<T: CardTransport> Calendar<T> {
323 Err(api_error(retried, &reply_url(&graph_id, reply)))
326 Err(api_error(retried, &reply_url(&graph_id, reply)))
324 }
327 }
325
328
326 pub async fn event_details(
329 pub async fn event_details(&self, event_id: &str, ical_uid: Option<&str>) -> Result<Value> {
327 &self,
328 event_id: &str,
329 ical_uid: Option<&str>,
330 ) -> Result<Value> {
331 let answer = self.fetch_event(event_id).await?;
330 let answer = self.fetch_event(event_id).await?;
332 if answer.is_success() {
331 if answer.is_success() {
333 if details_have_agenda(&answer.body) {
332 if details_have_agenda(&answer.body) {
crates/chatsvc/src/google_calendar/parse.rs +9 −5
@@ -227,7 +227,10 @@ fn reminder_minutes_from(list: Option<&Value>) -> Vec<u32> {
227 227 let mut minutes: Vec<u32> = items
228 228 .iter()
229 229 .filter_map(|item| {
230 let method = item.get("method").and_then(Value::as_str).unwrap_or("popup");
230 let method = item
231 .get("method")
232 .and_then(Value::as_str)
233 .unwrap_or("popup");
231 234 if method != "popup" && method != "email" {
232 235 return None;
233 236 }
@@ -439,9 +442,7 @@ mod tests {
439 442 r#"Click <a href="javascript:alert(1)">here</a> or https://safe.example/x"#,
440 443 );
441 444 assert!(!html.to_ascii_lowercase().contains("javascript:"));
442 assert!(html.contains(
443 r#"<a href="https://safe.example/x">https://safe.example/x</a>"#
444 ));
445 assert!(html.contains(r#"<a href="https://safe.example/x">https://safe.example/x</a>"#));
445 446 assert!(html.contains("Click here or"));
446 447 }
447 448
@@ -494,7 +495,10 @@ mod tests {
494 495 let events = parse_google_events(&body, None, None);
495 496 assert_eq!(events[0].reminders, vec![5, 15, 30]);
496 497 assert_eq!(
497 events[0].source_link.as_ref().map(|(t, u)| (t.as_str(), u.as_str())),
498 events[0]
499 .source_link
500 .as_ref()
501 .map(|(t, u)| (t.as_str(), u.as_str())),
498 502 Some(("[Mail] KubeCon", "https://mail.example/1"))
499 503 );
500 504 assert_eq!(
@@ -227,7 +227,10 @@ fn reminder_minutes_from(list: Option<&Value>) -> Vec<u32> {
227 let mut minutes: Vec<u32> = items
227 let mut minutes: Vec<u32> = items
228 .iter()
228 .iter()
229 .filter_map(|item| {
229 .filter_map(|item| {
230 let method = item.get("method").and_then(Value::as_str).unwrap_or("popup");
230 let method = item
231 .get("method")
232 .and_then(Value::as_str)
233 .unwrap_or("popup");
231 if method != "popup" && method != "email" {
234 if method != "popup" && method != "email" {
232 return None;
235 return None;
233 }
236 }
@@ -439,9 +442,7 @@ mod tests {
439 r#"Click <a href="javascript:alert(1)">here</a> or https://safe.example/x"#,
442 r#"Click <a href="javascript:alert(1)">here</a> or https://safe.example/x"#,
440 );
443 );
441 assert!(!html.to_ascii_lowercase().contains("javascript:"));
444 assert!(!html.to_ascii_lowercase().contains("javascript:"));
442 assert!(html.contains(
445 assert!(html.contains(r#"<a href="https://safe.example/x">https://safe.example/x</a>"#));
443 r#"<a href="https://safe.example/x">https://safe.example/x</a>"#
444 ));
445 assert!(html.contains("Click here or"));
446 assert!(html.contains("Click here or"));
446 }
447 }
447
448
@@ -494,7 +495,10 @@ mod tests {
494 let events = parse_google_events(&body, None, None);
495 let events = parse_google_events(&body, None, None);
495 assert_eq!(events[0].reminders, vec![5, 15, 30]);
496 assert_eq!(events[0].reminders, vec![5, 15, 30]);
496 assert_eq!(
497 assert_eq!(
497 events[0].source_link.as_ref().map(|(t, u)| (t.as_str(), u.as_str())),
498 events[0]
499 .source_link
500 .as_ref()
501 .map(|(t, u)| (t.as_str(), u.as_str())),
498 Some(("[Mail] KubeCon", "https://mail.example/1"))
502 Some(("[Mail] KubeCon", "https://mail.example/1"))
499 );
503 );
500 assert_eq!(
504 assert_eq!(
crates/chatsvc/src/lib.rs +2 −2
@@ -57,8 +57,8 @@ pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};
57 57 pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};
58 58 pub use calendar::{
59 59 Attendee, AttendeeResponseCounts, BusyTime, Calendar, CalendarEvent, CalendarSource,
60 CreatedEvent, DialIn, EventAttendee, NewEvent, PersonSchedule, Reminder, Repeat, Reply, ResponseType, ShowAs,
61 apply_event_details, join_info_text, meet_now_join_url, new_event_body,
60 CreatedEvent, DialIn, EventAttendee, NewEvent, PersonSchedule, Reminder, Repeat, Reply,
61 ResponseType, ShowAs, apply_event_details, join_info_text, meet_now_join_url, new_event_body,
62 62 new_event_body_with_join, parse_calendar_events, parse_created_event, strip_html,
63 63 truncate_preview,
64 64 };
@@ -57,8 +57,8 @@ pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};
57pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};
57pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};
58pub use calendar::{
58pub use calendar::{
59 Attendee, AttendeeResponseCounts, BusyTime, Calendar, CalendarEvent, CalendarSource,
59 Attendee, AttendeeResponseCounts, BusyTime, Calendar, CalendarEvent, CalendarSource,
60 CreatedEvent, DialIn, EventAttendee, NewEvent, PersonSchedule, Reminder, Repeat, Reply, ResponseType, ShowAs,
60 CreatedEvent, DialIn, EventAttendee, NewEvent, PersonSchedule, Reminder, Repeat, Reply,
61 apply_event_details, join_info_text, meet_now_join_url, new_event_body,
61 ResponseType, ShowAs, apply_event_details, join_info_text, meet_now_join_url, new_event_body,
62 new_event_body_with_join, parse_calendar_events, parse_created_event, strip_html,
62 new_event_body_with_join, parse_calendar_events, parse_created_event, strip_html,
63 truncate_preview,
63 truncate_preview,
64};
64};