Handle feeds with unknown formats properly

Closes #660

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-03-29 18:22:14 +02:00
parent da1fee2cc7
commit 4d4ee80b8c
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -7,9 +7,7 @@ defmodule Mobilizon.Web.FeedController do
action_fallback(Mobilizon.Web.FallbackController) action_fallback(Mobilizon.Web.FallbackController)
alias Mobilizon.Config alias Mobilizon.Config
@formats ["ics", "atom"] def instance(conn, %{"format" => format}) do
def instance(conn, %{"format" => format}) when format in @formats do
if Config.get([:instance, :enable_instance_feeds], false) do if Config.get([:instance, :enable_instance_feeds], false) do
return_data(conn, format, "instance", Config.instance_name()) return_data(conn, format, "instance", Config.instance_name())
else else
@ -17,7 +15,7 @@ defmodule Mobilizon.Web.FeedController do
end end
end end
def actor(conn, %{"format" => format, "name" => name}) when format in @formats do def actor(conn, %{"format" => format, "name" => name}) do
return_data(conn, format, "actor_" <> name, name) return_data(conn, format, "actor_" <> name, name)
end end
@ -33,7 +31,7 @@ defmodule Mobilizon.Web.FeedController do
{:error, :not_found} {:error, :not_found}
end end
def going(conn, %{"token" => token, "format" => format}) when format in @formats do def going(conn, %{"token" => token, "format" => format}) do
return_data(conn, format, "token_" <> token, "events") return_data(conn, format, "token_" <> token, "events")
end end
@ -72,4 +70,8 @@ defmodule Mobilizon.Web.FeedController do
{:error, :not_found} {:error, :not_found}
end end
end end
defp return_data(_conn, _, _, _) do
{:error, :not_found}
end
end end