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:
@@ -17,4 +17,32 @@ defmodule MobilizonWeb.FeedController do
|
||||
|> send_file(404, "priv/static/index.html")
|
||||
end
|
||||
end
|
||||
|
||||
def actor(conn, %{"name" => name, "format" => "ics"}) do
|
||||
with {status, data} when status in [:ok, :commit] <-
|
||||
Cachex.fetch(:ics, "actor_" <> name) do
|
||||
conn
|
||||
|> put_resp_content_type("text/calendar")
|
||||
|> send_resp(200, data)
|
||||
else
|
||||
_err ->
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|> send_file(404, "priv/static/index.html")
|
||||
end
|
||||
end
|
||||
|
||||
def event(conn, %{"uuid" => uuid, "format" => "ics"}) do
|
||||
with {status, data} when status in [:ok, :commit] <-
|
||||
Cachex.fetch(:ics, "event_" <> uuid) do
|
||||
conn
|
||||
|> put_resp_content_type("text/calendar")
|
||||
|> send_resp(200, data)
|
||||
else
|
||||
_err ->
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|> send_file(404, "priv/static/index.html")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,8 +26,8 @@ defmodule MobilizonWeb.Router do
|
||||
plug(:accepts, ["html", "activity-json"])
|
||||
end
|
||||
|
||||
pipeline :rss do
|
||||
plug(:accepts, ["atom", "html"])
|
||||
pipeline :atom_and_ical do
|
||||
plug(:accepts, ["atom", "ics", "html"])
|
||||
end
|
||||
|
||||
pipeline :browser do
|
||||
@@ -60,9 +60,10 @@ defmodule MobilizonWeb.Router do
|
||||
end
|
||||
|
||||
scope "/", MobilizonWeb do
|
||||
pipe_through(:rss)
|
||||
pipe_through(:atom_and_ical)
|
||||
|
||||
get("/@:name/feed/:format", FeedController, :actor)
|
||||
get("/events/:uuid/export/:format", FeedController, :event)
|
||||
end
|
||||
|
||||
scope "/", MobilizonWeb do
|
||||
|
||||
Reference in New Issue
Block a user