From 67bfa19b35af6ae4a064b02f3888dd11a218f6fb Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 24 Aug 2017 16:27:37 +0200 Subject: [PATCH] Set twitter-style possibly_sensitive boolena. --- .../web/twitter_api/representers/activity_representer.ex | 8 ++++++-- .../representers/activity_representer_test.exs | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index 16a2f6810..bc3de0e90 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -112,6 +112,9 @@ def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = ac 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 @@ def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = ac "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 diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index f9998e614..4f090ee8e 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -130,7 +130,8 @@ test "an activity" 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