mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
also suppress link previews from posts marked #nsfw
This commit is contained in:
parent
0da1233e8e
commit
dc08159538
3 changed files with 26 additions and 3 deletions
|
@ -157,6 +157,7 @@ defmodule Pleroma.Web.CommonAPI do
|
||||||
{to, cc} <- to_for_user_and_mentions(user, mentions, in_reply_to, visibility),
|
{to, cc} <- to_for_user_and_mentions(user, mentions, in_reply_to, visibility),
|
||||||
context <- make_context(in_reply_to),
|
context <- make_context(in_reply_to),
|
||||||
cw <- data["spoiler_text"] || "",
|
cw <- data["spoiler_text"] || "",
|
||||||
|
sensitive <- data["sensitive"] || Enum.member?(tags, {"#nsfw", "nsfw"}),
|
||||||
full_payload <- String.trim(status <> cw),
|
full_payload <- String.trim(status <> cw),
|
||||||
length when length in 1..limit <- String.length(full_payload),
|
length when length in 1..limit <- String.length(full_payload),
|
||||||
object <-
|
object <-
|
||||||
|
@ -169,7 +170,8 @@ defmodule Pleroma.Web.CommonAPI do
|
||||||
in_reply_to,
|
in_reply_to,
|
||||||
tags,
|
tags,
|
||||||
cw,
|
cw,
|
||||||
cc
|
cc,
|
||||||
|
sensitive
|
||||||
),
|
),
|
||||||
object <-
|
object <-
|
||||||
Map.put(
|
Map.put(
|
||||||
|
|
|
@ -223,7 +223,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
||||||
in_reply_to,
|
in_reply_to,
|
||||||
tags,
|
tags,
|
||||||
cw \\ nil,
|
cw \\ nil,
|
||||||
cc \\ []
|
cc \\ [],
|
||||||
|
sensitive \\ false
|
||||||
) do
|
) do
|
||||||
object = %{
|
object = %{
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
|
@ -231,6 +232,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
||||||
"cc" => cc,
|
"cc" => cc,
|
||||||
"content" => content_html,
|
"content" => content_html,
|
||||||
"summary" => cw,
|
"summary" => cw,
|
||||||
|
"sensitive" => sensitive,
|
||||||
"context" => context,
|
"context" => context,
|
||||||
"attachment" => attachments,
|
"attachment" => attachments,
|
||||||
"actor" => actor,
|
"actor" => actor,
|
||||||
|
|
|
@ -67,7 +67,26 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
CommonAPI.post(user, %{
|
CommonAPI.post(user, %{
|
||||||
"status" => "http://example.com/ogp",
|
"status" => "http://example.com/ogp",
|
||||||
"spoiler_text" => "."
|
"sensitive" => true
|
||||||
|
})
|
||||||
|
|
||||||
|
%Object{} = object = Object.normalize(activity)
|
||||||
|
|
||||||
|
assert object.data["sensitive"]
|
||||||
|
|
||||||
|
Pleroma.Config.put([:rich_media, :enabled], true)
|
||||||
|
|
||||||
|
assert %{} = Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)
|
||||||
|
|
||||||
|
Pleroma.Config.put([:rich_media, :enabled], false)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "refuses to crawl URLs from posts tagged NSFW" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, activity} =
|
||||||
|
CommonAPI.post(user, %{
|
||||||
|
"status" => "http://example.com/ogp #nsfw"
|
||||||
})
|
})
|
||||||
|
|
||||||
%Object{} = object = Object.normalize(activity)
|
%Object{} = object = Object.normalize(activity)
|
||||||
|
|
Loading…
Reference in a new issue