Implement public actor ICS endpoint and event ICS export

Closes #83 and #84

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-03-06 17:07:42 +01:00
parent 4d47eb5c78
commit d3e2f28b49
9 changed files with 208 additions and 31 deletions

View File

@@ -4,6 +4,7 @@ defmodule Mobilizon.Application do
"""
use Application
import Cachex.Spec
alias Mobilizon.Service.Export.{Feed, ICalendar}
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@@ -29,11 +30,27 @@ defmodule Mobilizon.Application do
default: :timer.minutes(60),
interval: :timer.seconds(60)
),
fallback: fallback(default: &Mobilizon.Service.Feed.create_cache/1)
fallback: fallback(default: &Feed.create_cache/1)
]
],
id: :cache_feed
),
worker(
Cachex,
[
:ics,
[
limit: 2500,
expiration:
expiration(
default: :timer.minutes(60),
interval: :timer.seconds(60)
),
fallback: fallback(default: &ICalendar.create_cache/1)
]
],
id: :cache_ics
),
worker(
Cachex,
[

View File

@@ -1,23 +0,0 @@
defmodule Mobilizon.Export.ICalendar do
@moduledoc """
Export an event to iCalendar format
"""
alias Mobilizon.Events.Event
@spec export_event(%Event{}) :: String
def export_event(%Event{} = event) do
events = [
%ICalendar.Event{
summary: event.title,
dtstart: event.begins_on,
dtend: event.ends_on,
description: event.description,
uid: event.uuid
}
]
%ICalendar{events: events}
|> ICalendar.to_ics()
end
end