Fixup tags

This commit is contained in:
Haelwenn (lanodan) Monnier 2020-12-30 06:30:08 +01:00 committed by Egor Kislitsyn
parent 420efb844f
commit 6a1ad8dba4
No known key found for this signature in database
GPG key ID: 1B49CB15B71E7805
2 changed files with 3 additions and 4 deletions

View file

@ -915,12 +915,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
Map.put(object, "conversation", object["context"])
end
def set_sensitive(%{"sensitive" => _} = object) do
def set_sensitive(%{"sensitive" => sensitive} = object) when is_boolean(sensitive) do
object
end
def set_sensitive(object) do
tags = object["tag"] || []
tags = Object.hashtags(%Object{data: object})
Map.put(object, "sensitive", "nsfw" in tags)
end

View file

@ -39,7 +39,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
object = Object.normalize(data["object"])
assert "test" in Object.tags(object)
assert Object.hashtags(object) == ["test"]
end
@ -193,7 +192,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
"href" => "http://mastodon.example.org/tags/moo",
"name" => "#moo",
"type" => "Hashtag"
} == object.data["tag"]
} == Enum.at(object.data["tag"], 1)
end
test "it works for incoming notices with contentMap" do