summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2018-02-18 14:07:13 +0100
committerlain <lain@soykaf.club>2018-02-18 14:07:13 +0100
commit20e6190ead59eb9bd83887b8239cab73c17a961b (patch)
tree13089ee71d9964aa60abad055e357efbbb634737
parent8ca66b596120024b5141ce68c7614e762358c2a1 (diff)
downloadpleroma-20e6190ead59eb9bd83887b8239cab73c17a961b.tar.gz
pleroma-20e6190ead59eb9bd83887b8239cab73c17a961b.zip
Transmogrify outgoing nsfw.
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex6
-rw-r--r--test/web/activity_pub/transmogrifier_test.exs9
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index 17cd3b1c2..fc04cc9a1 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -100,6 +100,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
"""
def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do
object = object
+ |> set_sensitive
|> add_hashtags
|> add_mention_tags
|> add_attributed_to
@@ -144,6 +145,11 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
Map.put(object, "conversation", object["context"])
end
+ def set_sensitive(object) do
+ tags = object["tag"] || []
+ Map.put(object, "sensitive", "nsfw" in tags)
+ end
+
def add_attributed_to(object) do
attributedTo = object["attributedTo"] || object["actor"]
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs
index ec608a86a..6271e200e 100644
--- a/test/web/activity_pub/transmogrifier_test.exs
+++ b/test/web/activity_pub/transmogrifier_test.exs
@@ -120,6 +120,15 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert Enum.member?(object["tag"], expected_mention)
end
+ test "it adds the sensitive property" do
+ user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "#nsfw hey"})
+ {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+
+ assert modified["object"]["sensitive"]
+ end
+
test "it adds the json-ld context and the conversation property" do
user = insert(:user)