From d1f6ecf607954e725e72b8e91be5f969eebe997f Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 19 May 2018 05:46:13 +0000 Subject: [PATCH] webfinger: interpret application/ld+json links as an alternate to application/activity+json --- lib/pleroma/web/web_finger/web_finger.ex | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex index 241dfb4c8..b955bc43f 100644 --- a/lib/pleroma/web/web_finger/web_finger.ex +++ b/lib/pleroma/web/web_finger/web_finger.ex @@ -166,6 +166,14 @@ defp webfinger_from_xml(doc) 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 @@ defp webfinger_from_json(doc) 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)