aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/controller_helper.ex
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-04-15 14:41:43 +0200
committerlain <lain@soykaf.club>2020-04-15 14:41:43 +0200
commit44bfb491eae00d541e6d11c8b52b5de5bc0bd34e (patch)
tree0fae87b11ceb4696075927c7f77228e59bb6926c /lib/pleroma/web/controller_helper.ex
parent64c78581fe397b6d9356c52cf3f43becd2ff3b4e (diff)
parentad8630b95a691d01ec49344fd1a7578860728d63 (diff)
downloadpleroma-44bfb491eae00d541e6d11c8b52b5de5bc0bd34e.tar.gz
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
Diffstat (limited to 'lib/pleroma/web/controller_helper.ex')
-rw-r--r--lib/pleroma/web/controller_helper.ex24
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