Commit 539340d9 authored by lain's avatar lain
Browse files

Handle sensitive property.

parent 20e6190e
Pipeline #743 failed with stage
in 4 minutes and 11 seconds
......@@ -58,7 +58,7 @@ def render("status.json", %{activity: %{data: %{"object" => object}} = activity}
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)
......
......@@ -133,7 +133,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")
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
......
......@@ -36,7 +36,7 @@
"inReplyTo": null,
"inReplyToAtomUri": null,
"published": "2018-02-12T14:08:20Z",
"sensitive": false,
"sensitive": true,
"summary": "cw",
"tag": [
{
......
......@@ -33,6 +33,7 @@ test "it works for incoming notices" 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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment