activitypub transmogrifier: handle hubzilla AP actor quirks
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 19 May 2018 07:30:02 +0000 (07:30 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sat, 19 May 2018 08:28:29 +0000 (03:28 -0500)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/transmogrifier.ex

index 491ad370592faacfeeabe39ec30aee1a8a0c0df7..3e1977f967979fb209ecb6747a7d3f9e00269866 100644 (file)
@@ -401,6 +401,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
           "url" => [%{"href" => data["image"]["url"]}]
         }
 
+    data = Transmogrifier.maybe_fix_user_object(data)
+
     user_data = %{
       ap_id: data["id"],
       info: %{
index 463d1e59d53d5e10ede158d8e83af56122f2df48..c10d27dcde27e994062288c83cc5eb9eeb6de091 100644 (file)
@@ -495,4 +495,17 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
       Repo.delete_all(q)
     end
   end
+
+  def maybe_fix_user_url(data) do
+    if is_map(data["url"]) do
+      data = Map.put(data, "url", data["url"]["href"])
+    end
+
+    data
+  end
+
+  def maybe_fix_user_object(data) do
+    data
+    |> maybe_fix_user_url
+  end
 end