From: lain Date: Sun, 18 Feb 2018 13:14:16 +0000 (+0100) Subject: Handle sensitive property. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=539340d914e5c124d3583abe1ee4e6a69620b873;p=akkoma Handle sensitive property. --- diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index e205a420d..d859fc851 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -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) diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex index 1f11bc9ac..f9f9bd7b4 100644 --- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex @@ -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 diff --git a/test/fixtures/mastodon-post-activity.json b/test/fixtures/mastodon-post-activity.json index 448310b0b..693e0ce39 100644 --- a/test/fixtures/mastodon-post-activity.json +++ b/test/fixtures/mastodon-post-activity.json @@ -36,7 +36,7 @@ "inReplyTo": null, "inReplyToAtomUri": null, "published": "2018-02-12T14:08:20Z", - "sensitive": false, + "sensitive": true, "summary": "cw", "tag": [ { diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 6271e200e..08f8e8206 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -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