diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-14 11:58:38 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-14 11:58:38 +0300 |
commit | 650853fc895fb2e21eac347e056eab98b842a3b7 (patch) | |
tree | 7df844177fb8aa12057c6a0693b2bd04ca17807a /lib/pleroma/web/controller_helper.ex | |
parent | 99b0bc198921099816a5f809f11a7579b3993274 (diff) | |
parent | 60cc7d6c9a2ec60c3a98f0fe51d68d3dbd5d21c2 (diff) | |
download | pleroma-650853fc895fb2e21eac347e056eab98b842a3b7.tar.gz |
Merge remote-tracking branch 'remotes/origin/develop' into 1364-no-pushes-from-blocked-domains-users
# Conflicts:
# lib/pleroma/notification.ex
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 |