Merge branch 'develop' into 'develop'
authorlain <lain@soykaf.club>
Mon, 21 Dec 2020 17:13:52 +0000 (17:13 +0000)
committerlain <lain@soykaf.club>
Mon, 21 Dec 2020 17:13:52 +0000 (17:13 +0000)
WebFinger: add subscribe_address in return data of JSON responses

See merge request pleroma/pleroma!3206

lib/pleroma/web/web_finger.ex
test/pleroma/web/web_finger_test.exs

index 6629f5356fb9038ae389aee5beeded159cbd2803..2e39ae0484bb0edd0a1a8839b91f2654d87cedcd 100644 (file)
@@ -116,6 +116,9 @@ defmodule Pleroma.Web.WebFinger do
           {"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", "self"} ->
             Map.put(data, "ap_id", link["href"])
 
+          {nil, "http://ostatus.org/schema/1.0/subscribe"} ->
+            Map.put(data, "subscribe_address", link["template"])
+
           _ ->
             Logger.debug("Unhandled type: #{inspect(link["type"])}")
             data
index 96fc0bbaa7b1419fe1230468d262c16df41cfca3..19f33a975b98e5260cfb7fb5336241dced026890 100644 (file)
@@ -56,12 +56,13 @@ defmodule Pleroma.Web.WebFingerTest do
       {:ok, _data} = WebFinger.finger(user)
     end
 
-    test "returns the ActivityPub actor URI for an ActivityPub user with the ld+json mimetype" do
+    test "returns the ActivityPub actor URI and subscribe address for an ActivityPub user with the ld+json mimetype" do
       user = "kaniini@gerzilla.de"
 
       {:ok, data} = WebFinger.finger(user)
 
       assert data["ap_id"] == "https://gerzilla.de/channel/kaniini"
+      assert data["subscribe_address"] == "https://gerzilla.de/follow?f=&url={uri}"
     end
 
     test "it work for AP-only user" do