aboutsummaryrefslogtreecommitdiff
path: root/test
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 /test
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 'test')
-rw-r--r--test/web/rich_media/helpers_test.exs40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/web/rich_media/helpers_test.exs b/test/web/rich_media/helpers_test.exs
index 60d93768f..53b0596f5 100644
--- a/test/web/rich_media/helpers_test.exs
+++ b/test/web/rich_media/helpers_test.exs
@@ -1,6 +1,7 @@
defmodule Pleroma.Web.RichMedia.HelpersTest do
use Pleroma.DataCase
+ alias Pleroma.Object
alias Pleroma.Web.CommonAPI
import Pleroma.Factory
@@ -59,4 +60,43 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
Pleroma.Config.put([:rich_media, :enabled], false)
end
+
+ test "refuses to crawl URLs from posts marked sensitive" do
+ user = insert(:user)
+
+ {:ok, activity} =
+ CommonAPI.post(user, %{
+ "status" => "http://example.com/ogp",
+ "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)
+
+ 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
end