Set twitter-style possibly_sensitive boolena.
authorRoger Braun <roger@rogerbraun.net>
Thu, 24 Aug 2017 14:27:37 +0000 (16:27 +0200)
committerRoger Braun <roger@rogerbraun.net>
Thu, 24 Aug 2017 14:27:37 +0000 (16:27 +0200)
lib/pleroma/web/twitter_api/representers/activity_representer.ex
test/web/twitter_api/representers/activity_representer_test.exs

index 16a2f6810d1d7feb90cf0187ad37dcc544c2f22a..bc3de0e90d4b20c2478bcde1fc91d7c56430d46b 100644 (file)
@@ -112,6 +112,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
 
     conversation_id = conversation_id(activity)
 
+    tags = activity.data["object"]["tag"] || []
+    possibly_sensitive = Enum.member?(tags, "nsfw")
+
     %{
       "id" => activity.id,
       "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
@@ -129,8 +132,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
       "favorited" => to_boolean(favorited),
       "repeated" => to_boolean(repeated),
       "external_url" => object["external_url"],
-      "tags" => activity.data["object"]["tag"] || [],
-      "activity_type" => "post"
+      "tags" => tags,
+      "activity_type" => "post",
+      "possibly_sensitive" => possibly_sensitive
     }
   end
 
index f9998e614922f165354613b63de22dee8af8c7ac..4f090ee8eda575d63d58a0a533525e0d4ac008c7 100644 (file)
@@ -130,7 +130,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
       "repeated" => false,
       "external_url" => "some url",
       "tags" => ["content", "mentioning", "nsfw"],
-      "activity_type" => "post"
+      "activity_type" => "post",
+      "possibly_sensitive" => true
     }
 
     assert ActivityRepresenter.to_map(activity, %{user: user, for: follower, mentioned: [mentioned_user]}) == expected_status