BlueGit

ict rusty-teams

Files

rusty-teams / crates / app-state / src / call / schedule.rs

schedule.rs

schedule.rs 26.4 KiB Download Raw
1use chatsvc::{Attendee, CalendarEvent, Repeat, Reply, ResponseType};
2use chrono::{DateTime, Duration, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Timelike, Utc};
3use gpui_kit::Context;
4use tokio::sync::oneshot;
5
6use super::actions::NOT_CONNECTED_NOTICE;
7use super::agenda::demo_join_url;
8use crate::app_state::AppState;
9use crate::runtime;
10
11const AGENDA_KEYS: [&str; 4] = ["body", "bodyContent", "bodyContentType", "bodyPreview"];
12const HALF_HOUR_MINUTES: i64 = 30;
13const DEFAULT_LENGTH_MINUTES: i64 = 30;
14const READ_ONLY_MESSAGE: &str = "Meetings cannot be scheduled in read-only mode.";
15const RESPONSE_FAILED_NOTICE: &str = "Could not send your response";
16const DELETE_FAILED_NOTICE: &str = "Could not delete the meeting";
17const DELETE_READ_ONLY_NOTICE: &str = "Meetings cannot be deleted in read-only mode.";
18
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub struct Invitee {
21 pub user_id: String,
22 pub name: String,
23 pub mail: Option<String>,
24}
25
26#[derive(Debug, Clone, PartialEq, Eq)]
27pub struct MeetingDraft {
28 pub subject: String,
29 pub start: DateTime<Utc>,
30 pub end: DateTime<Utc>,
31 pub local_start: NaiveDateTime,
32 pub local_end: NaiveDateTime,
33 pub time_zone_name: Option<String>,
34 pub repeat: Repeat,
35 pub details: String,
36 pub people: Vec<Invitee>,
37}
38
39pub fn default_window(now: DateTime<Utc>, zone: &impl TimeZone) -> (NaiveDateTime, NaiveDateTime) {
40 let local = now.with_timezone(zone).naive_local();
41 let past_half_hour = i64::from(local.minute()) % HALF_HOUR_MINUTES;
42 let start = local
43 .with_second(0)
44 .and_then(|time| time.with_nanosecond(0))
45 .unwrap_or(local)
46 - Duration::minutes(past_half_hour)
47 + Duration::minutes(HALF_HOUR_MINUTES);
48 (start, start + Duration::minutes(DEFAULT_LENGTH_MINUTES))
49}
50
51fn utc_of(zone: &impl TimeZone, date: NaiveDate, time: NaiveTime) -> Option<DateTime<Utc>> {
52 zone.from_local_datetime(&date.and_time(time))
53 .earliest()
54 .map(|moment| moment.with_timezone(&Utc))
55}
56
57#[derive(Debug, Clone)]
58pub struct FormValues {
59 pub subject: String,
60 pub date: Option<NaiveDate>,
61 pub start: NaiveTime,
62 pub end: NaiveTime,
63 pub repeat: Repeat,
64 pub details: String,
65 pub people: Vec<Invitee>,
66}
67
68pub fn draft_from_form(
69 values: FormValues,
70 zone: &impl TimeZone,
71 time_zone_name: Option<String>,
72) -> Result<MeetingDraft, String> {
73 let subject = values.subject.trim();
74 if subject.is_empty() {
75 return Err("Add a title.".to_owned());
76 }
77 let date = values.date.ok_or_else(|| "Pick a date.".to_owned())?;
78 let start = utc_of(zone, date, values.start)
79 .ok_or_else(|| "That start time does not exist.".to_owned())?;
80 let end =
81 utc_of(zone, date, values.end).ok_or_else(|| "That end time does not exist.".to_owned())?;
82 if end <= start {
83 return Err("The end must be after the start.".to_owned());
84 }
85 Ok(MeetingDraft {
86 subject: subject.to_owned(),
87 start,
88 end,
89 local_start: date.and_time(values.start),
90 local_end: date.and_time(values.end),
91 time_zone_name,
92 repeat: values.repeat,
93 details: values.details.trim().to_owned(),
94 people: values.people,
95 })
96}
97
98pub fn attendee_for(invitee: &Invitee, looked_up: Option<String>) -> Result<Attendee, String> {
99 let address = invitee
100 .mail
101 .clone()
102 .or(looked_up)
103 .ok_or_else(|| format!("No email address found for {}.", invitee.name))?;
104 Ok(Attendee {
105 name: invitee.name.clone(),
106 address,
107 })
108}
109
110pub fn response_for(reply: Reply) -> ResponseType {
111 match reply {
112 Reply::Accept => ResponseType::Accepted,
113 Reply::Tentative => ResponseType::Tentative,
114 Reply::Decline => ResponseType::Declined,
115 }
116}
117
118fn demo_event(draft: &MeetingDraft, serial: u64) -> CalendarEvent {
119 CalendarEvent {
120 object_id: format!("demo-new-{serial}"),
121 subject: draft.subject.clone(),
122 start: draft.start,
123 end: draft.end,
124 all_day: false,
125 cancelled: false,
126 online: true,
127 join_url: Some(demo_join_url("demo-new")),
128 thread_id: None,
129 organizer_name: Some("You".to_owned()),
130 organizer_address: None,
131 ical_uid: None,
132 show_as: Default::default(),
133 dial_in: None,
134 response: ResponseType::Organizer,
135 ..Default::default()
136 }
137}
138
139impl AppState {
140 pub fn load_own_time_zone(&mut self, cx: &mut Context<Self>) {
141 if self.own_time_zone.is_some() || self.own_time_zone_requested || self.own_email.is_empty()
142 {
143 return;
144 }
145 let Some(launcher) = self.call_launcher.clone() else {
146 return;
147 };
148 self.own_time_zone_requested = true;
149 let mail = self.own_email.clone();
150 let looked_up = runtime::spawn(async move { launcher.time_zone_name(&mail).await });
151 cx.spawn(async move |this, cx| {
152 let time_zone_name = looked_up.await.ok().flatten();
153 this.update(cx, |state, _| {
154 state.own_time_zone_requested = time_zone_name.is_some();
155 state.own_time_zone = time_zone_name;
156 })
157 .ok();
158 })
159 .detach();
160 }
161
162 pub fn create_meeting(
163 &mut self,
164 draft: MeetingDraft,
165 cx: &mut Context<Self>,
166 ) -> oneshot::Receiver<Result<(), String>> {
167 let (sender, receiver) = oneshot::channel();
168 if self.mode.demo {
169 let event = demo_event(&draft, self.demo_meetings.len() as u64 + 1);
170 self.demo_meetings.push(event);
171 self.refresh_calendar(cx);
172 let _ = sender.send(Ok(()));
173 return receiver;
174 }
175 if self.mode.read_only {
176 let _ = sender.send(Err(READ_ONLY_MESSAGE.to_owned()));
177 return receiver;
178 }
179 let Some(launcher) = self.call_launcher.clone() else {
180 let _ = sender.send(Err(NOT_CONNECTED_NOTICE.to_owned()));
181 return receiver;
182 };
183 let accounts = store::load_calendar_accounts(&self.store);
184 let store = self.store.clone();
185 let created = runtime::spawn(async move {
186 super::meeting_create::create_across_targets(launcher, draft, accounts, store).await
187 });
188 cx.spawn(async move |this, cx| {
189 let outcome = created
190 .await
191 .unwrap_or_else(|_| Err("The request was cancelled.".to_owned()))
192 .map(|_| ());
193 if outcome.is_ok() {
194 this.update(cx, |state, cx| state.refresh_calendar(cx)).ok();
195 }
196 let _ = sender.send(outcome);
197 })
198 .detach();
199 receiver
200 }
201
202 pub fn toggle_rsvp_send_response(&mut self, cx: &mut Context<Self>) {
203 self.rsvp_send_response = !self.rsvp_send_response;
204 cx.notify();
205 }
206
207 fn set_event_response(&mut self, event_id: &str, response: ResponseType) {
208 for event in self
209 .calendar_events
210 .iter_mut()
211 .chain(self.calendar_week.events.iter_mut())
212 .filter(|event| event.object_id == event_id)
213 {
214 event.response = response;
215 }
216 self.calls_list.invalidate();
217 }
218
219 fn remove_calendar_event(&mut self, event_id: &str) -> Option<CalendarEvent> {
220 let mut removed = None;
221 if let Some(index) = self
222 .calendar_week
223 .events
224 .iter()
225 .position(|event| event.object_id == event_id)
226 {
227 removed = Some(self.calendar_week.events.remove(index));
228 }
229 if let Some(index) = self
230 .calendar_events
231 .iter()
232 .position(|event| event.object_id == event_id)
233 {
234 let event = self.calendar_events.remove(index);
235 if removed.is_none() {
236 removed = Some(event);
237 }
238 }
239 self.calls_list.invalidate();
240 removed
241 }
242
243 fn restore_calendar_event(&mut self, event: CalendarEvent) {
244 if !self
245 .calendar_week
246 .events
247 .iter()
248 .any(|existing| existing.object_id == event.object_id)
249 {
250 self.calendar_week.events.push(event.clone());
251 self.calendar_week
252 .events
253 .sort_by_key(|item| (item.start, item.end));
254 }
255 if !self
256 .calendar_events
257 .iter()
258 .any(|existing| existing.object_id == event.object_id)
259 {
260 self.calendar_events.push(event);
261 self.calendar_events
262 .sort_by_key(|item| (item.start, item.end));
263 }
264 self.calls_list.invalidate();
265 }
266
267 pub fn delete_calendar_event(&mut self, event_key: &str, cx: &mut Context<Self>) {
268 if self.mode.read_only {
269 self.raise_notice(DELETE_READ_ONLY_NOTICE.to_owned(), None, cx);
270 return;
271 }
272 let Some(event) = self
273 .calendar_events
274 .iter()
275 .chain(&self.calendar_week.events)
276 .find(|event| event.object_id == event_key)
277 .cloned()
278 else {
279 return;
280 };
281 let snapshot = event.clone();
282 let (event_id, ical_uid) = (event.object_id.clone(), event.ical_uid.clone());
283 let source = event.source;
284 let account_id = event.account_id.clone();
285 let calendar_id = event.calendar_id.clone();
286 let series = event.series;
287 let occurrence_start = event.start;
288 self.remove_calendar_event(&event_id);
289 cx.notify();
290 let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);
291 let Some(launcher) = launcher else {
292 return;
293 };
294 let send_updates = self.rsvp_send_response;
295 let store = self.store.clone();
296 let deleted = runtime::spawn({
297 let event_id = event_id.clone();
298 async move {
299 match source {
300 chatsvc::CalendarSource::Outlook => {
301 launcher
302 .delete_calendar_event(&event_id, ical_uid.as_deref())
303 .await
304 }
305 chatsvc::CalendarSource::Google => {
306 let mut accounts = store::load_calendar_accounts(&store);
307 let account =
308 account_id.ok_or_else(|| "Google account missing".to_owned())?;
309 let calendar = calendar_id.unwrap_or_else(|| "primary".to_owned());
310 let result = crate::google_calendar_sync::delete_google_event(
311 &mut accounts,
312 &account,
313 &calendar,
314 &event_id,
315 send_updates,
316 )
317 .await;
318 let _ = store::save_calendar_accounts(&store, &accounts);
319 result
320 }
321 chatsvc::CalendarSource::CalDav => {
322 let mut accounts = store::load_calendar_accounts(&store);
323 let account =
324 account_id.ok_or_else(|| "CalDAV account missing".to_owned())?;
325 let result = crate::caldav_sync::delete_caldav_event(
326 &mut accounts,
327 &account,
328 &event_id,
329 series,
330 occurrence_start,
331 )
332 .await;
333 let _ = store::save_calendar_accounts(&store, &accounts);
334 result
335 }
336 chatsvc::CalendarSource::Ics => {
337 Err("Read-only ICS subscriptions cannot delete events".into())
338 }
339 }
340 }
341 });
342 cx.spawn(async move |this, cx| {
343 let ok = deleted.await.is_ok_and(|result| result.is_ok());
344 this.update(cx, |state, cx| {
345 if ok {
346 // refresh_calendar nudges agenda poll + reloads the week grid.
347 state.refresh_calendar(cx);
348 return;
349 }
350 state.restore_calendar_event(snapshot);
351 state.raise_notice(DELETE_FAILED_NOTICE.to_owned(), None, cx);
352 })
353 .ok();
354 })
355 .detach();
356 }
357
358 pub fn request_calendar_event_peek(&mut self, event: CalendarEvent, cx: &mut Context<Self>) {
359 self.calendar_event_peek_request = Some(event);
360 cx.emit(crate::app_state::AppEvent::CalendarEventPeek);
361 cx.notify();
362 }
363
364 pub fn take_calendar_event_peek_request(&mut self) -> Option<CalendarEvent> {
365 self.calendar_event_peek_request.take()
366 }
367
368 pub fn apply_calendar_event_details(
369 &mut self,
370 event_key: &str,
371 details: &serde_json::Value,
372 cx: &mut Context<Self>,
373 ) {
374 for event in self
375 .calendar_week
376 .events
377 .iter_mut()
378 .chain(self.calendar_events.iter_mut())
379 {
380 if event.object_id == event_key {
381 chatsvc::apply_event_details(event, details);
382 }
383 }
384 cx.notify();
385 }
386
387 pub fn enrich_calendar_event(&mut self, event_key: &str, cx: &mut Context<Self>) {
388 let Some(event) = self
389 .calendar_events
390 .iter()
391 .chain(&self.calendar_week.events)
392 .find(|event| event.object_id == event_key)
393 .cloned()
394 else {
395 return;
396 };
397 if event.source != chatsvc::CalendarSource::Outlook {
398 return;
399 }
400 let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);
401 let Some(launcher) = launcher else {
402 return;
403 };
404 let (event_id, ical_uid) = (event.object_id.clone(), event.ical_uid.clone());
405 let fetched = runtime::spawn({
406 let event_id = event_id.clone();
407 async move {
408 launcher
409 .calendar_event_details(&event_id, ical_uid.as_deref())
410 .await
411 }
412 });
413 cx.spawn(async move |this, cx| {
414 let details = match fetched.await {
415 Ok(Ok(details)) => details,
416 Ok(Err(error)) => {
417 crate::diagnostics::record(format!(
418 "calendar peek: details failed for {event_id}: {error}"
419 ));
420 return;
421 }
422 Err(_) => {
423 crate::diagnostics::record(format!(
424 "calendar peek: details task join failed for {event_id}"
425 ));
426 return;
427 }
428 };
429 let preview_chars = details
430 .get("bodyPreview")
431 .and_then(|value| value.as_str())
432 .map(str::len)
433 .or_else(|| {
434 details
435 .pointer("/body/content")
436 .and_then(|value| value.as_str())
437 .map(str::len)
438 })
439 .or_else(|| {
440 details
441 .get("bodyContent")
442 .and_then(|value| value.as_str())
443 .map(str::len)
444 })
445 .unwrap_or(0);
446 crate::diagnostics::record(format!(
447 "calendar peek: details ok for {event_id}, preview_chars={preview_chars}"
448 ));
449 this.update(cx, |state, cx| {
450 state.apply_calendar_event_details(&event_id, &details, cx);
451 })
452 .ok();
453 // Series occurrences often ship empty body/bodyPreview; pull the master agenda.
454 let master_id = this
455 .update(cx, |state, _| {
456 state
457 .calendar_week
458 .events
459 .iter()
460 .chain(state.calendar_events.iter())
461 .find(|event| event.object_id == event_id)
462 .and_then(|event| {
463 event
464 .body_html
465 .is_none()
466 .then(|| event.series_master_id.clone())
467 .flatten()
468 })
469 })
470 .ok()
471 .flatten();
472 let Some(master_id) = master_id else {
473 return;
474 };
475 let Some(launcher) = this
476 .update(cx, |state, _| state.call_launcher.clone())
477 .ok()
478 .flatten()
479 else {
480 return;
481 };
482 let master =
483 runtime::spawn(
484 async move { launcher.calendar_event_details(&master_id, None).await },
485 );
486 let Ok(Ok(master_details)) = master.await else {
487 return;
488 };
489 let master_agenda: serde_json::Value = AGENDA_KEYS
490 .iter()
491 .filter_map(|key| Some(((*key).to_owned(), master_details.get(*key)?.clone())))
492 .collect::<serde_json::Map<_, _>>()
493 .into();
494 this.update(cx, |state, cx| {
495 state.apply_calendar_event_details(&event_id, &master_agenda, cx);
496 })
497 .ok();
498 })
499 .detach();
500 }
501
502 pub fn respond_to_event(
503 &mut self,
504 event_key: &str,
505 reply: Reply,
506 comment: &str,
507 cx: &mut Context<Self>,
508 ) {
509 if self.mode.read_only {
510 self.raise_notice(RESPONSE_FAILED_NOTICE.to_owned(), None, cx);
511 return;
512 }
513 let Some(event) = self
514 .calendar_events
515 .iter()
516 .chain(&self.calendar_week.events)
517 .find(|event| event.object_id == event_key)
518 else {
519 return;
520 };
521 let previous = event.response;
522 let (event_id, ical_uid) = (event.object_id.clone(), event.ical_uid.clone());
523 let source = event.source;
524 let account_id = event.account_id.clone();
525 let calendar_id = event.calendar_id.clone();
526 self.set_event_response(&event_id, response_for(reply));
527 cx.notify();
528 let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);
529 let Some(launcher) = launcher else {
530 return;
531 };
532 let send_response = self.rsvp_send_response;
533 let comment = comment.to_owned();
534 let store = self.store.clone();
535 let answered = runtime::spawn({
536 let event_id = event_id.clone();
537 async move {
538 match source {
539 chatsvc::CalendarSource::Outlook => {
540 launcher
541 .respond_to_event(
542 &event_id,
543 ical_uid.as_deref(),
544 reply,
545 send_response,
546 &comment,
547 )
548 .await
549 }
550 chatsvc::CalendarSource::Google => {
551 let mut accounts = store::load_calendar_accounts(&store);
552 let account =
553 account_id.ok_or_else(|| "Google account missing".to_owned())?;
554 let calendar = calendar_id.unwrap_or_else(|| "primary".to_owned());
555 let result = crate::google_calendar_sync::respond_google_event(
556 &mut accounts,
557 &account,
558 &calendar,
559 &event_id,
560 reply,
561 send_response,
562 )
563 .await;
564 let _ = store::save_calendar_accounts(&store, &accounts);
565 result
566 }
567 chatsvc::CalendarSource::CalDav => {
568 let mut accounts = store::load_calendar_accounts(&store);
569 let account =
570 account_id.ok_or_else(|| "CalDAV account missing".to_owned())?;
571 let href = chatsvc::href_from_object_id(&event_id).to_owned();
572 let result = crate::caldav_sync::respond_caldav_event(
573 &mut accounts,
574 &account,
575 &href,
576 reply,
577 )
578 .await
579 .map(|_| ());
580 let _ = store::save_calendar_accounts(&store, &accounts);
581 result
582 }
583 chatsvc::CalendarSource::Ics => {
584 Err("Read-only ICS subscriptions cannot RSVP".into())
585 }
586 }
587 }
588 });
589 cx.spawn(async move |this, cx| {
590 let sent = answered.await.is_ok_and(|result| result.is_ok());
591 this.update(cx, |state, cx| {
592 if sent {
593 state.refresh_calendar(cx);
594 return;
595 }
596 state.set_event_response(&event_id, previous);
597 state.raise_notice(RESPONSE_FAILED_NOTICE.to_owned(), None, cx);
598 })
599 .ok();
600 })
601 .detach();
602 }
603}
604
605#[cfg(test)]
606mod tests {
607 use chrono::FixedOffset;
608
609 use super::*;
610
611 fn utc(hour: u32, minute: u32, second: u32) -> DateTime<Utc> {
612 Utc.with_ymd_and_hms(2026, 10, 13, hour, minute, second)
613 .unwrap()
614 }
615
616 fn plus_two() -> FixedOffset {
617 FixedOffset::east_opt(2 * 3600).unwrap()
618 }
619
620 fn time(hour: u32, minute: u32) -> NaiveTime {
621 NaiveTime::from_hms_opt(hour, minute, 0).unwrap()
622 }
623
624 fn day() -> Option<NaiveDate> {
625 NaiveDate::from_ymd_opt(2026, 10, 14)
626 }
627
628 fn invitee(name: &str, mail: Option<&str>) -> Invitee {
629 Invitee {
630 user_id: format!("id-{name}"),
631 name: name.to_owned(),
632 mail: mail.map(str::to_owned),
633 }
634 }
635
636 #[test]
637 fn the_default_window_starts_at_the_next_half_hour_and_lasts_thirty_minutes() {
638 let (start, end) = default_window(utc(8, 12, 40), &plus_two());
639 assert_eq!(start.to_string(), "2026-10-13 10:30:00");
640 assert_eq!(end.to_string(), "2026-10-13 11:00:00");
641 let (start, _) = default_window(utc(8, 40, 0), &plus_two());
642 assert_eq!(start.to_string(), "2026-10-13 11:00:00");
643 }
644
645 #[test]
646 fn a_time_on_the_half_hour_moves_to_the_following_one() {
647 let (start, _) = default_window(utc(8, 30, 0), &plus_two());
648 assert_eq!(start.to_string(), "2026-10-13 11:00:00");
649 let (start, _) = default_window(utc(8, 0, 0), &plus_two());
650 assert_eq!(start.to_string(), "2026-10-13 10:30:00");
651 }
652
653 #[test]
654 fn the_late_evening_default_rolls_into_the_next_day() {
655 let (start, end) = default_window(utc(21, 45, 0), &plus_two());
656 assert_eq!(start.to_string(), "2026-10-14 00:00:00");
657 assert_eq!(end.to_string(), "2026-10-14 00:30:00");
658 }
659
660 #[test]
661 fn the_form_turns_local_times_into_utc() {
662 let draft = draft_from_form(
663 FormValues {
664 subject: " Planning ".into(),
665 date: day(),
666 start: time(11, 0),
667 end: time(11, 30),
668 repeat: Repeat::Weekly,
669 details: " Agenda ".into(),
670 people: Vec::new(),
671 },
672 &plus_two(),
673 Some("W. Europe Standard Time".into()),
674 )
675 .unwrap();
676 assert_eq!(draft.subject, "Planning");
677 assert_eq!(draft.details, "Agenda");
678 assert_eq!(
679 draft.start,
680 Utc.with_ymd_and_hms(2026, 10, 14, 9, 0, 0).unwrap()
681 );
682 assert_eq!(
683 draft.end,
684 Utc.with_ymd_and_hms(2026, 10, 14, 9, 30, 0).unwrap()
685 );
686 assert_eq!(draft.repeat, Repeat::Weekly);
687 assert_eq!(draft.local_start.to_string(), "2026-10-14 11:00:00");
688 assert_eq!(draft.local_end.to_string(), "2026-10-14 11:30:00");
689 assert_eq!(
690 draft.time_zone_name.as_deref(),
691 Some("W. Europe Standard Time")
692 );
693 }
694
695 #[test]
696 fn the_form_rejects_a_missing_title_date_or_backwards_times() {
697 let build = |subject: &str, date, start, end| {
698 let values = FormValues {
699 subject: subject.into(),
700 date,
701 start,
702 end,
703 repeat: Repeat::Never,
704 details: String::new(),
705 people: Vec::new(),
706 };
707 draft_from_form(values, &plus_two(), None)
708 };
709 assert_eq!(
710 build(" ", day(), time(9, 0), time(10, 0)).unwrap_err(),
711 "Add a title."
712 );
713 assert_eq!(
714 build("x", None, time(9, 0), time(10, 0)).unwrap_err(),
715 "Pick a date."
716 );
717 assert_eq!(
718 build("x", day(), time(10, 0), time(10, 0)).unwrap_err(),
719 "The end must be after the start."
720 );
721 assert!(build("x", day(), time(11, 0), time(10, 0)).is_err());
722 }
723
724 #[test]
725 fn an_invitee_uses_the_known_address_before_a_looked_up_one() {
726 let known = invitee("Mara", Some("mara@example.invalid"));
727 let attendee = attendee_for(&known, Some("other@example.invalid".into())).unwrap();
728 assert_eq!(attendee.address, "mara@example.invalid");
729 let unknown = invitee("Jonas", None);
730 let attendee = attendee_for(&unknown, Some("jonas@example.invalid".into())).unwrap();
731 assert_eq!(attendee.address, "jonas@example.invalid");
732 assert_eq!(attendee.name, "Jonas");
733 }
734
735 #[test]
736 fn an_invitee_without_any_address_is_an_error_naming_the_person() {
737 let error = attendee_for(&invitee("Jonas", None), None).unwrap_err();
738 assert_eq!(error, "No email address found for Jonas.");
739 }
740
741 #[test]
742 fn replies_map_to_the_shown_response() {
743 assert_eq!(response_for(Reply::Accept), ResponseType::Accepted);
744 assert_eq!(response_for(Reply::Tentative), ResponseType::Tentative);
745 assert_eq!(response_for(Reply::Decline), ResponseType::Declined);
746 }
747}