aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-05-18 07:13:18 +0000
committerrinpatch <rinpatch@sdf.org>2019-05-18 07:13:18 +0000
commit8e9a764dfcde315afd055c8e63543bfca24cc41b (patch)
tree5ff567a79c9d20c78c0cdcbfd3ab3f644bf765bc /lib/pleroma/web/common_api
parentcd7a6a25d28308fba18254be357be0f6b4d888f2 (diff)
parentc4a55e167afcfd25cf4c1efb46886f2defe72c22 (diff)
downloadpleroma-8e9a764dfcde315afd055c8e63543bfca24cc41b.tar.gz
Merge branch 'feature/mrf-always-nsfw' into 'develop'
suppress link previews from posts marked sensitive Closes #865 See merge request pleroma/pleroma!1173
Diffstat (limited to 'lib/pleroma/web/common_api')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex4
-rw-r--r--lib/pleroma/web/common_api/utils.ex4
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index a599ffee5..5a312d673 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -157,6 +157,7 @@ defmodule Pleroma.Web.CommonAPI do
{to, cc} <- to_for_user_and_mentions(user, mentions, in_reply_to, visibility),
context <- make_context(in_reply_to),
cw <- data["spoiler_text"] || "",
+ sensitive <- data["sensitive"] || Enum.member?(tags, {"#nsfw", "nsfw"}),
full_payload <- String.trim(status <> cw),
length when length in 1..limit <- String.length(full_payload),
object <-
@@ -169,7 +170,8 @@ defmodule Pleroma.Web.CommonAPI do
in_reply_to,
tags,
cw,
- cc
+ cc,
+ sensitive
),
object <-
Map.put(
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index bee2fd159..d93c0d46e 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -223,7 +223,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
in_reply_to,
tags,
cw \\ nil,
- cc \\ []
+ cc \\ [],
+ sensitive \\ false
) do
object = %{
"type" => "Note",
@@ -231,6 +232,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
"cc" => cc,
"content" => content_html,
"summary" => cw,
+ "sensitive" => !Enum.member?(["false", "False", "0", false], sensitive),
"context" => context,
"attachment" => attachments,
"actor" => actor,