Transmogrifier: fix incoming objects with invalid likes

This commit is contained in:
href 2019-01-27 19:27:16 +01:00
parent 6383fa3a5d
commit 77f2137383
No known key found for this signature in database
GPG Key ID: EE8296C1A152C325
1 changed files with 5 additions and 5 deletions

View File

@ -141,11 +141,11 @@ def fix_actor(%{"attributedTo" => actor} = object) do
|> Map.put("actor", get_actor(%{"actor" => actor}))
end
def fix_likes(%{"likes" => likes} = object)
when is_bitstring(likes) do
# Check for standardisation
# This is what Peertube does
# curl -H 'Accept: application/activity+json' $likes | jq .totalItems
# Prismo returns only an integer (count) as "likes"
def fix_likes(%{"likes" => likes} = object) when not is_map(likes) do
object
|> Map.put("likes", [])
|> Map.put("like_count", 0)