Merge branch 'develop' into 'develop'

WebFinger: add subscribe_address in return data of JSON responses

See merge request pleroma/pleroma!3206
This commit is contained in:
lain 2020-12-21 17:13:52 +00:00
commit 8e1f32e715
2 changed files with 5 additions and 1 deletions

View File

@ -116,6 +116,9 @@ defmodule Pleroma.Web.WebFinger do
{"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", "self"} -> {"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", "self"} ->
Map.put(data, "ap_id", link["href"]) 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"])}") Logger.debug("Unhandled type: #{inspect(link["type"])}")
data data

View File

@ -56,12 +56,13 @@ defmodule Pleroma.Web.WebFingerTest do
{:ok, _data} = WebFinger.finger(user) {:ok, _data} = WebFinger.finger(user)
end 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" user = "kaniini@gerzilla.de"
{:ok, data} = WebFinger.finger(user) {:ok, data} = WebFinger.finger(user)
assert data["ap_id"] == "https://gerzilla.de/channel/kaniini" assert data["ap_id"] == "https://gerzilla.de/channel/kaniini"
assert data["subscribe_address"] == "https://gerzilla.de/follow?f=&url={uri}"
end end
test "it work for AP-only user" do test "it work for AP-only user" do