webfinger: interpret application/ld+json links as an alternate to application/activit...
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 19 May 2018 05:46:13 +0000 (05:46 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sat, 19 May 2018 06:28:12 +0000 (01:28 -0500)
lib/pleroma/web/web_finger/web_finger.ex

index 241dfb4c8f84bfca356dccdf28d046d8bb332397..b955bc43f9ca7c625661fdcba7bd62f4e76f1444 100644 (file)
@@ -166,6 +166,14 @@ defmodule Pleroma.Web.WebFinger do
         doc
       )
 
+    if ap_id == nil do
+      ap_id =
+        XML.string_from_xpath(
+          ~s{//Link[@rel="self" and @type="application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""]/@href},
+          doc
+        )
+    end
+
     data = %{
       "magic_key" => magic_key,
       "topic" => topic,
@@ -185,6 +193,9 @@ defmodule Pleroma.Web.WebFinger do
           {"application/activity+json", "self"} ->
             Map.put(data, "ap_id", link["href"])
 
+          {"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", "self"} ->
+            Map.put(data, "ap_id", link["href"])
+
           {_, "magic-public-key"} ->
             "data:application/magic-public-key," <> magic_key = link["href"]
             Map.put(data, "magic_key", magic_key)