aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-06-26 16:27:39 +0200
committerlain <lain@soykaf.club>2020-06-26 16:27:39 +0200
commita5bbfa21a1fabe97bfff1cc80348d2944319f3ad (patch)
treefea8447a7e51412a26e98dcb621b5df4e5054923 /lib/pleroma
parent6db9f7cdb3adeda547b6e3e9ca887b685344351a (diff)
downloadpleroma-a5bbfa21a1fabe97bfff1cc80348d2944319f3ad.tar.gz
StaticFE: Prioritize json in requests.
Diffstat (limited to 'lib/pleroma')
-rw-r--r--lib/pleroma/plugs/static_fe_plug.ex11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/pleroma/plugs/static_fe_plug.ex b/lib/pleroma/plugs/static_fe_plug.ex
index 156e6788e..7c69b2dac 100644
--- a/lib/pleroma/plugs/static_fe_plug.ex
+++ b/lib/pleroma/plugs/static_fe_plug.ex
@@ -9,7 +9,7 @@ defmodule Pleroma.Plugs.StaticFEPlug do
def init(options), do: options
def call(conn, _) do
- if enabled?() and accepts_html?(conn) do
+ if enabled?() and requires_html?(conn) do
conn
|> StaticFEController.call(:show)
|> halt()
@@ -20,10 +20,13 @@ defmodule Pleroma.Plugs.StaticFEPlug do
defp enabled?, do: Pleroma.Config.get([:static_fe, :enabled], false)
- defp accepts_html?(conn) do
+ defp requires_html?(conn) do
case get_req_header(conn, "accept") do
- [accept | _] -> String.contains?(accept, "text/html")
- _ -> false
+ [accept | _] ->
+ !String.contains?(accept, "json") && String.contains?(accept, "text/html")
+
+ _ ->
+ false
end
end
end