Handle sensitive property.
This commit is contained in:
parent
20e6190ead
commit
539340d914
4 changed files with 6 additions and 3 deletions
|
@ -58,7 +58,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||||
announcement_count = object["announcement_count"] || 0
|
announcement_count = object["announcement_count"] || 0
|
||||||
|
|
||||||
tags = object["tag"] || []
|
tags = object["tag"] || []
|
||||||
sensitive = Enum.member?(tags, "nsfw")
|
sensitive = object["sensitive"] || Enum.member?(tags, "nsfw")
|
||||||
|
|
||||||
mentions = activity.data["to"]
|
mentions = activity.data["to"]
|
||||||
|> Enum.map(fn (ap_id) -> User.get_cached_by_ap_id(ap_id) end)
|
|> Enum.map(fn (ap_id) -> User.get_cached_by_ap_id(ap_id) end)
|
||||||
|
|
|
@ -133,7 +133,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
|
||||||
conversation_id = conversation_id(activity)
|
conversation_id = conversation_id(activity)
|
||||||
|
|
||||||
tags = activity.data["object"]["tag"] || []
|
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"]
|
summary = activity.data["object"]["summary"]
|
||||||
content = if !!summary and summary != "" do
|
content = if !!summary and summary != "" do
|
||||||
|
|
2
test/fixtures/mastodon-post-activity.json
vendored
2
test/fixtures/mastodon-post-activity.json
vendored
|
@ -36,7 +36,7 @@
|
||||||
"inReplyTo": null,
|
"inReplyTo": null,
|
||||||
"inReplyToAtomUri": null,
|
"inReplyToAtomUri": null,
|
||||||
"published": "2018-02-12T14:08:20Z",
|
"published": "2018-02-12T14:08:20Z",
|
||||||
"sensitive": false,
|
"sensitive": true,
|
||||||
"summary": "cw",
|
"summary": "cw",
|
||||||
"tag": [
|
"tag": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
]
|
]
|
||||||
assert object["actor"] == "http://mastodon.example.org/users/admin"
|
assert object["actor"] == "http://mastodon.example.org/users/admin"
|
||||||
assert object["attributedTo"] == "http://mastodon.example.org/users/admin"
|
assert object["attributedTo"] == "http://mastodon.example.org/users/admin"
|
||||||
|
assert object["sensitive"] == true
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it works for incoming follow requests" do
|
test "it works for incoming follow requests" do
|
||||||
|
|
Loading…
Reference in a new issue