mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-25 09:22:22 +00:00
e97be0b814
And remove useless Fallbacks in Fallback controller Signed-off-by: Thomas Citharel <tcit@tcit.fr>
67 lines
1.8 KiB
Elixir
67 lines
1.8 KiB
Elixir
defmodule MobilizonWeb.FeedController do
|
|
@moduledoc """
|
|
Controller to serve RSS, ATOM and iCal Feeds
|
|
"""
|
|
use MobilizonWeb, :controller
|
|
action_fallback(MobilizonWeb.FallbackController)
|
|
|
|
def actor(conn, %{"name" => name, "format" => "atom"}) do
|
|
with {status, data} when status in [:ok, :commit] <-
|
|
Cachex.fetch(:feed, "actor_" <> name) do
|
|
conn
|
|
|> put_resp_content_type("application/atom+xml")
|
|
|> send_resp(200, data)
|
|
else
|
|
_err ->
|
|
{:error, :not_found}
|
|
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 ->
|
|
{:error, :not_found}
|
|
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 ->
|
|
{:error, :not_found}
|
|
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 ->
|
|
{:error, :not_found}
|
|
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 ->
|
|
{:error, :not_found}
|
|
end
|
|
end
|
|
end
|