Transmogrifier: fix incoming objects with invalid likes
authorhref <href@random.sh>
Sun, 27 Jan 2019 18:27:16 +0000 (19:27 +0100)
committerhref <href@random.sh>
Sun, 27 Jan 2019 18:33:21 +0000 (19:33 +0100)
lib/pleroma/web/activity_pub/transmogrifier.ex

index 6656a11c6ceadbe83c885a518adcdf393ce1cc64..c2ced51d813587a6fd6478e63b3f949e12ed6f36 100644 (file)
@@ -141,11 +141,11 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier 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
+  # 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)