1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-29 11:25:39 +00:00
mobilizon/lib/mobilizon_web/controllers/feed_controller.ex

69 lines
1.6 KiB
Elixir
Raw Normal View History

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
2019-09-17 21:39:26 +00:00
{:commit, data} ->
conn
|> put_resp_content_type("application/atom+xml")
|> send_resp(200, data)
2019-09-17 21:39:26 +00:00
_ ->
{:error, :not_found}
end
end
def actor(conn, %{"name" => name, "format" => "ics"}) do
case Cachex.fetch(:ics, "actor_" <> name) do
2019-09-17 21:39:26 +00:00
{:commit, data} ->
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
2019-09-17 21:39:26 +00:00
_ ->
{:error, :not_found}
end
end
def event(conn, %{"uuid" => uuid, "format" => "ics"}) do
case Cachex.fetch(:ics, "event_" <> uuid) do
2019-09-17 21:39:26 +00:00
{:commit, data} ->
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
2019-09-17 21:39:26 +00:00
_ ->
{:error, :not_found}
end
end
def going(conn, %{"token" => token, "format" => "ics"}) do
case Cachex.fetch(:ics, "token_" <> token) do
2019-09-17 21:39:26 +00:00
{:commit, data} ->
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
2019-09-17 21:39:26 +00:00
_ ->
{:error, :not_found}
end
end
def going(conn, %{"token" => token, "format" => "atom"}) do
case Cachex.fetch(:feed, "token_" <> token) do
2019-09-17 21:39:26 +00:00
{:commit, data} ->
conn
|> put_resp_content_type("application/atom+xml")
|> send_resp(200, data)
2019-09-17 21:39:26 +00:00
{:ignore, _} ->
{:error, :not_found}
end
end
end