feat: add conference URL support for virtual meetings
This commit is contained in:
@@ -182,6 +182,12 @@ let collect_description rem ev : (Remind.rem, error) result =
|
||||
| Some desc -> Ok { rem with Remind.description = Some desc }
|
||||
| None -> Ok rem
|
||||
|
||||
let collect_conference_url rem ev : (Remind.rem, error) result =
|
||||
let conference_url_opt = Utils.get_conference_url ev in
|
||||
match conference_url_opt with
|
||||
| Some url -> Ok { rem with Remind.conference_url = Some url }
|
||||
| None -> Ok rem
|
||||
|
||||
let collect_start_end_duration rem ev : (Remind.rem, error) result =
|
||||
let _, dtstart = ev.dtstart in
|
||||
match dtstart with
|
||||
@@ -431,6 +437,7 @@ let all_collectors : collector list =
|
||||
collect_summary;
|
||||
collect_location;
|
||||
collect_description;
|
||||
collect_conference_url;
|
||||
collect_start_end_duration;
|
||||
collect_exdates;
|
||||
collect_overrides;
|
||||
|
||||
@@ -34,6 +34,7 @@ type rem = {
|
||||
summary : string; (** Summary or title of the reminder *)
|
||||
location : string option; (** Optional location of the event *)
|
||||
description : string option; (** Optional description of the event *)
|
||||
conference_url : string option; (** Optional conference URL for virtual meetings *)
|
||||
date : Timedesc.Date.t; (** Date specification (day, month, year) *)
|
||||
end_date : Timedesc.Date.t option; (** Optional end date for a date range *)
|
||||
time : Timedesc.Time.t option; (** Optional time specification (hour, minute) *)
|
||||
@@ -58,6 +59,7 @@ let empty =
|
||||
summary = "";
|
||||
location = None;
|
||||
description = None;
|
||||
conference_url = None;
|
||||
date = Timedesc.Date.Ymd.make_exn ~year:1970 ~month:1 ~day:1;
|
||||
end_date = None;
|
||||
time = None;
|
||||
@@ -194,6 +196,21 @@ let add_description b desc =
|
||||
Buffer.add_string b (spf "\\\n INFO \"Description: %s\" " (escape_msg desc))
|
||||
| None -> ()
|
||||
|
||||
let add_url b url =
|
||||
match url with
|
||||
| Some url ->
|
||||
let url = String.trim url in
|
||||
Buffer.add_string b (spf "\\\n INFO \"Url: %s\" " (escape_msg url))
|
||||
| None -> ()
|
||||
|
||||
let add_common_part b rem =
|
||||
add_rem b;
|
||||
add_uid b rem.original_uuid;
|
||||
add_source b rem.source;
|
||||
add_location b rem.location;
|
||||
add_description b rem.description;
|
||||
add_url b rem.conference_url
|
||||
|
||||
let date_of_date_or_datetime (d : Icalendar.date_or_datetime) : Timedesc.Date.t =
|
||||
match d with
|
||||
| `Date (year, month, day) -> Timedesc.Date.Ymd.make_exn ~year ~month ~day
|
||||
@@ -220,11 +237,7 @@ let add_skip b exdates = if exdates <> [] then Buffer.add_string b "SKIP "
|
||||
let render_daily rem (d : simple_daily) =
|
||||
let b = Buffer.create 256 in
|
||||
add_omit_context b rem.exdate;
|
||||
add_rem b;
|
||||
add_uid b rem.original_uuid;
|
||||
add_source b rem.source;
|
||||
add_location b rem.location;
|
||||
add_description b rem.description;
|
||||
add_common_part b rem;
|
||||
add_date b rem.date;
|
||||
Buffer.add_char b ' ';
|
||||
add_interval_daily b d;
|
||||
@@ -241,11 +254,7 @@ let render_weekly rem (w : simple_weekly) =
|
||||
add_omit_context b rem.exdate;
|
||||
List.iter
|
||||
(fun wd ->
|
||||
add_rem b;
|
||||
add_uid b rem.original_uuid;
|
||||
add_source b rem.source;
|
||||
add_location b rem.location;
|
||||
add_description b rem.description;
|
||||
add_common_part b rem;
|
||||
add_weekday b wd;
|
||||
add_date b rem.date;
|
||||
Buffer.add_char b ' ';
|
||||
@@ -262,11 +271,7 @@ let render_weekly rem (w : simple_weekly) =
|
||||
let render_monthly rem (m : simple_monthly) =
|
||||
let b = Buffer.create 256 in
|
||||
add_omit_context b rem.exdate;
|
||||
add_rem b;
|
||||
add_uid b rem.original_uuid;
|
||||
add_source b rem.source;
|
||||
add_location b rem.location;
|
||||
add_description b rem.description;
|
||||
add_common_part b rem;
|
||||
(match m.pattern with
|
||||
| By_month_day day -> Buffer.add_string b (spf "%d " day)
|
||||
| By_nth_weekday (n, wd) when n > 0 ->
|
||||
@@ -288,11 +293,7 @@ let render_monthly rem (m : simple_monthly) =
|
||||
|
||||
let render_single rem =
|
||||
let b = Buffer.create 256 in
|
||||
add_rem b;
|
||||
add_uid b rem.original_uuid;
|
||||
add_source b rem.source;
|
||||
add_location b rem.location;
|
||||
add_description b rem.description;
|
||||
add_common_part b rem;
|
||||
add_date b rem.date;
|
||||
add_at b rem.time;
|
||||
add_duration b rem.duration;
|
||||
@@ -302,11 +303,7 @@ let render_single rem =
|
||||
|
||||
let render_yearly rem month day =
|
||||
let b = Buffer.create 64 in
|
||||
add_rem b;
|
||||
add_uid b rem.original_uuid;
|
||||
add_source b rem.source;
|
||||
add_location b rem.location;
|
||||
add_description b rem.description;
|
||||
add_common_part b rem;
|
||||
Buffer.add_string b (spf "%s %d" (month_of_int month |> string_of_month) day);
|
||||
add_msg b rem.summary;
|
||||
Buffer.contents b
|
||||
|
||||
@@ -215,6 +215,15 @@ let get_description ev =
|
||||
| _ -> None)
|
||||
ev.props
|
||||
|
||||
let get_conference_url ev =
|
||||
List.find_map
|
||||
(fun prop ->
|
||||
match prop with
|
||||
| `Xprop (("", "GOOGLE-CONFERENCE"), _, url) -> Some url
|
||||
| `Xprop (("", "MICROSOFT-SKYPETEAMSMEETINGURL"), _, url) -> Some url
|
||||
| _ -> None)
|
||||
ev.props
|
||||
|
||||
let separate_master_and_recurrence (events : Icalendar.event list) : Icalendar.event * Icalendar.event list =
|
||||
(* List.iteri (fun i e -> Printf.eprintf "%02d: %s\n" (i + 1) (Icalendar.show_component (`Event e))) events; *)
|
||||
let recur_ids = List.map (fun ev -> (ev, get_recurrence_id ev)) events in
|
||||
|
||||
Reference in New Issue
Block a user