1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-21 23:44:30 +00:00

Only add address and tags to event icalendar export if present

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-11-04 12:41:32 +01:00
parent f6aaf493c0
commit 52e90fb320
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -112,18 +112,35 @@ defmodule Mobilizon.Service.Export.ICalendar do
@spec do_export_event(Event.t()) :: ICalendar.Event.t() @spec do_export_event(Event.t()) :: ICalendar.Event.t()
defp do_export_event(%Event{} = event) do defp do_export_event(%Event{} = event) do
%ICalendar.Event{ icalendar_event = %ICalendar.Event{
summary: event.title, summary: event.title,
dtstart: begins_on(event), dtstart: begins_on(event),
dtstamp: event.publish_at || DateTime.utc_now(), dtstamp: event.publish_at || DateTime.utc_now(),
dtend: ends_on(event), dtend: ends_on(event),
description: HTML.strip_tags(event.description), description: HTML.strip_tags(event.description),
uid: event.uuid, uid: event.uuid,
url: event.url, url: event.url
geo: Address.coords(event.physical_address),
location: Address.representation(event.physical_address),
categories: event.tags |> Enum.map(& &1.title)
} }
icalendar_event =
if event.physical_address do
%ICalendar.Event{
icalendar_event
| geo: Address.coords(event.physical_address),
location: Address.representation(event.physical_address)
}
else
icalendar_event
end
icalendar_event =
if length(event.tags) > 0 do
%ICalendar.Event{icalendar_event | categories: event.tags |> Enum.map(& &1.title)}
else
icalendar_event
end
icalendar_event
end end
@spec vendor :: String.t() @spec vendor :: String.t()