2020-06-08 23:37:11 +02:00
|
|
|
defmodule OpenpodWeb.FeedController do
|
|
|
|
use OpenpodWeb, :controller
|
|
|
|
alias Openpod.Boundary.ArchiveServer
|
2020-06-07 21:37:41 +02:00
|
|
|
|
|
|
|
def by_identifier(conn, %{"identifier" => identifier, "reload" => _}) do
|
2020-06-07 23:09:53 +02:00
|
|
|
do_by_identifier(conn, identifier, fn -> ArchiveServer.reload(identifier) end)
|
2020-06-07 21:37:41 +02:00
|
|
|
end
|
2020-05-22 22:04:15 +02:00
|
|
|
|
2020-05-23 23:56:20 +02:00
|
|
|
def by_identifier(conn, %{"identifier" => identifier}) do
|
2020-06-07 23:09:53 +02:00
|
|
|
do_by_identifier(conn, identifier, fn -> ArchiveServer.get_feed(identifier) end)
|
2020-06-07 21:37:41 +02:00
|
|
|
end
|
|
|
|
|
2020-06-07 23:09:53 +02:00
|
|
|
defp do_by_identifier(conn, identifier, fetcher) do
|
2020-06-07 21:37:41 +02:00
|
|
|
%{podcast: podcast, items: items} = fetcher.()
|
2020-05-23 23:56:20 +02:00
|
|
|
conn
|
|
|
|
|> put_resp_content_type("text/xml")
|
2020-06-07 23:09:53 +02:00
|
|
|
|> render("feed.xml", identifier: identifier, podcast: podcast, items: items)
|
2020-05-23 23:56:20 +02:00
|
|
|
end
|
2020-05-22 22:04:15 +02:00
|
|
|
end
|