debianize-mobilizon/lib/mobilizon_web/controllers/feed_controller.ex
Thomas Citharel c3cca5d613
Fix credo style reports following it's update
Mainly transform `with` into `case`

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2019-07-23 18:12:26 +02:00

69 lines
1.8 KiB
Elixir

defmodule MobilizonWeb.FeedController do
@moduledoc """
Controller to serve RSS, ATOM and iCal Feeds
"""
use MobilizonWeb, :controller
plug(:put_layout, false)
action_fallback(MobilizonWeb.FallbackController)
def actor(conn, %{"name" => name, "format" => "atom"}) do
case Cachex.fetch(:feed, "actor_" <> name) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("application/atom+xml")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end
end
def actor(conn, %{"name" => name, "format" => "ics"}) do
case Cachex.fetch(:ics, "actor_" <> name) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end
end
def event(conn, %{"uuid" => uuid, "format" => "ics"}) do
case Cachex.fetch(:ics, "event_" <> uuid) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end
end
def going(conn, %{"token" => token, "format" => "ics"}) do
case Cachex.fetch(:ics, "token_" <> token) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end
end
def going(conn, %{"token" => token, "format" => "atom"}) do
case Cachex.fetch(:feed, "token_" <> token) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("application/atom+xml")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end
end
end