From 2401abedb5eeb532135c63ff7a7eea9aaa1fede6 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 9 Nov 2021 11:46:54 +0100 Subject: [PATCH] Include organizer actor in icalendar export Closes #907 Signed-off-by: Thomas Citharel --- lib/service/export/icalendar.ex | 12 +++++++++++- test/service/export/icalendar_test.exs | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/service/export/icalendar.ex b/lib/service/export/icalendar.ex index 9a75c308a..a514648d9 100644 --- a/lib/service/export/icalendar.ex +++ b/lib/service/export/icalendar.ex @@ -3,6 +3,7 @@ defmodule Mobilizon.Service.Export.ICalendar do Export an event to iCalendar format. """ + alias Mobilizon.Actors.Actor alias Mobilizon.Addresses.Address alias Mobilizon.{Config, Events} alias Mobilizon.Events.{Event, EventOptions} @@ -119,7 +120,8 @@ defmodule Mobilizon.Service.Export.ICalendar do dtend: ends_on(event), description: HTML.strip_tags(event.description), uid: event.uuid, - url: event.url + url: event.url, + organizer: organizer(event) } icalendar_event = @@ -161,4 +163,12 @@ defmodule Mobilizon.Service.Export.ICalendar do end defp shift_tz(%DateTime{} = date, _), do: date + + defp organizer(%Event{attributed_to: %Actor{} = group}) do + Actor.display_name(group) + end + + defp organizer(%Event{organizer_actor: %Actor{} = profile}) do + Actor.display_name(profile) + end end diff --git a/test/service/export/icalendar_test.exs b/test/service/export/icalendar_test.exs index c849e7f10..0cdadc93b 100644 --- a/test/service/export/icalendar_test.exs +++ b/test/service/export/icalendar_test.exs @@ -26,6 +26,7 @@ defmodule Mobilizon.Service.ICalendarTest do DTSTART:#{Value.to_ics(event.begins_on)}Z GEO:#{event.physical_address |> Address.coords() |> Tuple.to_list() |> Enum.join(";")} LOCATION:#{Address.representation(event.physical_address)} + ORGANIZER:#{event.organizer_actor.name} SUMMARY:#{event.title} UID:#{event.uuid} URL:#{event.url}