Handle sensitive property.
authorlain <lain@soykaf.club>
Sun, 18 Feb 2018 13:14:16 +0000 (14:14 +0100)
committerlain <lain@soykaf.club>
Sun, 18 Feb 2018 13:14:16 +0000 (14:14 +0100)
lib/pleroma/web/mastodon_api/views/status_view.ex
lib/pleroma/web/twitter_api/representers/activity_representer.ex
test/fixtures/mastodon-post-activity.json
test/web/activity_pub/transmogrifier_test.exs

index e205a420db03ca659315d96c735204916288a55f..d859fc851ed415cff4141a014053dfa803f02f45 100644 (file)
@@ -58,7 +58,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
     announcement_count = object["announcement_count"] || 0
 
     tags = object["tag"] || []
-    sensitive = Enum.member?(tags, "nsfw")
+    sensitive = object["sensitive"] || Enum.member?(tags, "nsfw")
 
     mentions = activity.data["to"]
     |> Enum.map(fn (ap_id) -> User.get_cached_by_ap_id(ap_id) end)
index 1f11bc9ac5ba09a7f027b327ee49ef1f5d712544..f9f9bd7b4bee118988f08da10231219e330ef2b0 100644 (file)
@@ -133,7 +133,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
     conversation_id = conversation_id(activity)
 
     tags = activity.data["object"]["tag"] || []
-    possibly_sensitive = Enum.member?(tags, "nsfw")
+    possibly_sensitive = activity.data["object"]["sensitive"] || Enum.member?(tags, "nsfw")
+
+    tags = if possibly_sensitive, do: ["nsfw" | tags], else: tags
 
     summary = activity.data["object"]["summary"]
     content = if !!summary and summary != "" do
index 448310b0b09f6f0861f407e0be1d843036f587de..693e0ce393f914f9987df3ca6aaca5d45da528b0 100644 (file)
@@ -36,7 +36,7 @@
         "inReplyTo": null,
         "inReplyToAtomUri": null,
         "published": "2018-02-12T14:08:20Z",
-        "sensitive": false,
+        "sensitive": true,
         "summary": "cw",
         "tag": [
             {
index 6271e200edfdac094119c99ef32ad1071d3d9858..08f8e8206962089a3b2c38663e7a9439851bf3c1 100644 (file)
@@ -33,6 +33,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       ]
       assert object["actor"] == "http://mastodon.example.org/users/admin"
       assert object["attributedTo"] == "http://mastodon.example.org/users/admin"
+      assert object["sensitive"] == true
     end
 
     test "it works for incoming follow requests" do