fixes invisible error message for comment rate limit, weird nesting error for tag updates, e.g. derpibooru/philomena#169

This commit is contained in:
byte[] 2020-08-11 01:14:00 -04:00
parent 5249deb47f
commit 02bbf5e2f1

View file

@ -45,6 +45,12 @@ defmodule PhilomenaWeb.LimitPlug do
is_staff(conn.assigns.current_user) ->
conn
ajax?(conn) ->
conn
|> Controller.put_flash(:error, error)
|> Conn.send_resp(:multiple_choices, "")
|> Conn.halt()
true ->
conn
|> Controller.put_flash(:error, error)
@ -60,4 +66,11 @@ defmodule PhilomenaWeb.LimitPlug do
defp current_user_id(%{id: id}), do: id
defp current_user_id(_), do: nil
defp ajax?(conn) do
case Conn.get_req_header(conn, "x-requested-with") do
[value] -> String.downcase(value) == "xmlhttprequest"
_ -> false
end
end
end