diff options
author | Alex Gleason <alex@alexgleason.me> | 2020-04-20 10:13:56 -0500 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2020-04-20 10:15:40 -0500 |
commit | bedc558809832ce6ef6063fe91656a0fff0e222c (patch) | |
tree | f844a11ae25f1866bffb79d9eaf0d66aa2babcd6 /lib/pleroma/web/controller_helper.ex | |
parent | b54c8813d632cb44c7deb207e91bd32f01f33794 (diff) | |
parent | 28165dad3ac02a6d3ba4b0cda51992a1831515dd (diff) | |
download | pleroma-bedc558809832ce6ef6063fe91656a0fff0e222c.tar.gz |
Merge remote-tracking branch 'upstream/develop' into accept-deletes
Diffstat (limited to 'lib/pleroma/web/controller_helper.ex')
-rw-r--r-- | lib/pleroma/web/controller_helper.ex | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/pleroma/web/controller_helper.ex b/lib/pleroma/web/controller_helper.ex index b49523ec3..4780081b2 100644 --- a/lib/pleroma/web/controller_helper.ex +++ b/lib/pleroma/web/controller_helper.ex @@ -5,10 +5,18 @@ defmodule Pleroma.Web.ControllerHelper do use Pleroma.Web, :controller - # As in MastoAPI, per https://api.rubyonrails.org/classes/ActiveModel/Type/Boolean.html + alias Pleroma.Config + + # As in Mastodon API, per https://api.rubyonrails.org/classes/ActiveModel/Type/Boolean.html @falsy_param_values [false, 0, "0", "f", "F", "false", "False", "FALSE", "off", "OFF"] - def truthy_param?(blank_value) when blank_value in [nil, ""], do: nil - def truthy_param?(value), do: value not in @falsy_param_values + + def explicitly_falsy_param?(value), do: value in @falsy_param_values + + # Note: `nil` and `""` are considered falsy values in Pleroma + def falsy_param?(value), + do: explicitly_falsy_param?(value) or value in [nil, ""] + + def truthy_param?(value), do: not falsy_param?(value) def json_response(conn, status, json) do conn @@ -96,4 +104,14 @@ defmodule Pleroma.Web.ControllerHelper do def put_if_exist(map, _key, nil), do: map def put_if_exist(map, key, value), do: Map.put(map, key, value) + + @doc "Whether to skip rendering `[:account][:pleroma][:relationship]`for statuses/notifications" + def skip_relationships?(params) do + if Config.get([:extensions, :output_relationships_in_statuses_by_default]) do + false + else + # BREAKING: older PleromaFE versions do not send this param but _do_ expect relationships. + not truthy_param?(params["with_relationships"]) + end + end end |