Fixup tags
This commit is contained in:
parent
420efb844f
commit
6a1ad8dba4
|
@ -915,12 +915,12 @@ def set_conversation(object) do
|
||||||
Map.put(object, "conversation", object["context"])
|
Map.put(object, "conversation", object["context"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_sensitive(%{"sensitive" => _} = object) do
|
def set_sensitive(%{"sensitive" => sensitive} = object) when is_boolean(sensitive) do
|
||||||
object
|
object
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_sensitive(object) do
|
def set_sensitive(object) do
|
||||||
tags = object["tag"] || []
|
tags = Object.hashtags(%Object{data: object})
|
||||||
Map.put(object, "sensitive", "nsfw" in tags)
|
Map.put(object, "sensitive", "nsfw" in tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ test "it works for incoming notices with tag not being an array (kroeg)" do
|
||||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||||
object = Object.normalize(data["object"])
|
object = Object.normalize(data["object"])
|
||||||
|
|
||||||
assert "test" in Object.tags(object)
|
|
||||||
assert Object.hashtags(object) == ["test"]
|
assert Object.hashtags(object) == ["test"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -193,7 +192,7 @@ test "it works for incoming notices with hashtags" do
|
||||||
"href" => "http://mastodon.example.org/tags/moo",
|
"href" => "http://mastodon.example.org/tags/moo",
|
||||||
"name" => "#moo",
|
"name" => "#moo",
|
||||||
"type" => "Hashtag"
|
"type" => "Hashtag"
|
||||||
} == object.data["tag"]
|
} == Enum.at(object.data["tag"], 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it works for incoming notices with contentMap" do
|
test "it works for incoming notices with contentMap" do
|
||||||
|
|
Loading…
Reference in New Issue