Add backend and endpoints for Feed Tokens
Closes #19 #86 #87 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -45,4 +45,32 @@ defmodule MobilizonWeb.FeedController do
|
||||
|> send_file(404, "priv/static/index.html")
|
||||
end
|
||||
end
|
||||
|
||||
def going(conn, %{"token" => token, "format" => "ics"}) do
|
||||
with {status, data} when status in [:ok, :commit] <-
|
||||
Cachex.fetch(:ics, "token_" <> token) 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 going(conn, %{"token" => token, "format" => "atom"}) do
|
||||
with {status, data} when status in [:ok, :commit] <-
|
||||
Cachex.fetch(:feed, "token_" <> token) do
|
||||
conn
|
||||
|> put_resp_content_type("application/atom+xml")
|
||||
|> send_resp(200, data)
|
||||
else
|
||||
_err ->
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|> send_file(404, "priv/static/index.html")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,6 +64,7 @@ defmodule MobilizonWeb.Router do
|
||||
|
||||
get("/@:name/feed/:format", FeedController, :actor)
|
||||
get("/events/:uuid/export/:format", FeedController, :event)
|
||||
get("/events/going/:token/:format", FeedController, :going)
|
||||
end
|
||||
|
||||
scope "/", MobilizonWeb do
|
||||
|
||||
Reference in New Issue
Block a user