Merge branch 'feature/webfinger-mime-ld-json' into 'develop'
webfinger: handle application/ld+json links See merge request pleroma/pleroma!159
This commit is contained in:
commit
7831b38705
4 changed files with 29 additions and 0 deletions
|
@ -86,6 +86,11 @@ def represent_user(user, "JSON") do
|
|||
"href" => "data:application/magic-public-key,#{magic_key}"
|
||||
},
|
||||
%{"rel" => "self", "type" => "application/activity+json", "href" => user.ap_id},
|
||||
%{
|
||||
"rel" => "self",
|
||||
"type" => "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"",
|
||||
"href" => user.ap_id
|
||||
},
|
||||
%{
|
||||
"rel" => "http://ostatus.org/schema/1.0/subscribe",
|
||||
"template" => OStatus.remote_follow_path()
|
||||
|
@ -183,6 +188,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)
|
||||
|
|
1
test/fixtures/httpoison_mock/kaniini@gerzilla.de.json
vendored
Normal file
1
test/fixtures/httpoison_mock/kaniini@gerzilla.de.json
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"subject":"acct:kaniini","aliases":["https:\/\/gerzilla.de\/channel\/kaniini","https:\/\/gerzilla.de\/~kaniini","acct:kaniini@gerzilla.de"],"properties":{"http:\/\/webfinger.net\/ns\/name":"kaniini","http:\/\/xmlns.com\/foaf\/0.1\/name":"kaniini","https:\/\/w3id.org\/security\/v1#publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvXCDkQPw+1N8B2CUd5s2\nbYvjHt+t7soMNfUiRy0qGbgW46S45k5lCq1KpbFIX3sgGZ4OWjnXVbvjCJi4kl5M\nfm5DBXzpuu05AmjVl8hqk4GejajiE\/1Nq0uWHPiOSFWispUjCzzCu65V+IsiE5JU\nvcL6WEf\/pYNRq7gYqyT693F7+cO5\/rVv9OScx5UOxbIuU1VXYhdHCqAMDJWadC89\nhePrcD3HOQKl06W2tDxHcWk6QjrdsUQGbNOgK\/QIN9gSxA+rCFEvH5O0HAhI0aXq\ncOB+vysJUFLeQOAqmAKvKS5V6RqE1GqqT0pDWHack4EmQi0gkgVzo+45xoP6wfDl\nWwG88w21LNxGvGHuN4I8mg6cEoApqKQBSOj086UtfDfSlPC1B+PRD2phE5etucHd\nF\/RIWN3SxVzU9BKIiaDm2gwOpvI8QuorQb6HDtZFO5NsSN3PnMnSywPe7kXl\/469\nuQRYXrseqyOVIi6WjhvXkyWVKVE5CBz+S8wXHfKph+9YOyUcJeAVMijp9wrjBlMc\noSzOGu79oM7tpMSq\/Xo6ePJ\/glNOwZR+OKrg92Qp9BGTKDNwGrxuxP\/9KwWtGLNf\nOMTtIkxtC3ubhxL3lBxOd7l+Bmum0UJV2f8ogkCgvTpIz05jMoyU8qWl6kkWNQlY\nDropXWaOfy7Lac+G4qlfSgsCAwEAAQ==\n-----END PUBLIC KEY-----\n","http:\/\/purl.org\/zot\/federation":"zot,activitypub"},"links":[{"rel":"http:\/\/webfinger.net\/rel\/avatar","type":"image\/png","href":"https:\/\/gerzilla.de\/photo\/profile\/l\/281"},{"rel":"http:\/\/microformats.org\/profile\/hcard","type":"text\/html","href":"https:\/\/gerzilla.de\/hcard\/kaniini"},{"rel":"http:\/\/webfinger.net\/rel\/profile-page","href":"https:\/\/gerzilla.de\/profile\/kaniini"},{"rel":"http:\/\/schemas.google.com\/g\/2010#updates-from","type":"application\/atom+xml","href":"https:\/\/gerzilla.de\/ofeed\/kaniini"},{"rel":"http:\/\/webfinger.net\/rel\/blog","href":"https:\/\/gerzilla.de\/channel\/kaniini"},{"rel":"http:\/\/ostatus.org\/schema\/1.0\/subscribe","template":"https:\/\/gerzilla.de\/follow?f=&url={uri}"},{"rel":"http:\/\/purl.org\/zot\/protocol","href":"https:\/\/gerzilla.de\/.well-known\/zot-info?address=kaniini@gerzilla.de"},{"rel":"http:\/\/purl.org\/openwebauth\/v1","type":"application\/x-zot+json","href":"https:\/\/gerzilla.de\/owa"},{"rel":"magic-public-key","href":"data:application\/magic-public-key,RSA.AL1wg5ED8PtTfAdglHebNm2L4x7fre7KDDX1IkctKhm4FuOkuOZOZQqtSqWxSF97IBmeDlo511W74wiYuJJeTH5uQwV86brtOQJo1ZfIapOBno2o4hP9TatLlhz4jkhVorKVIws8wruuVfiLIhOSVL3C-lhH_6WDUau4GKsk-vdxe_nDuf61b_TknMeVDsWyLlNVV2IXRwqgDAyVmnQvPYXj63A9xzkCpdOltrQ8R3FpOkI63bFEBmzToCv0CDfYEsQPqwhRLx-TtBwISNGl6nDgfr8rCVBS3kDgKpgCrykuVekahNRqqk9KQ1h2nJOBJkItIJIFc6PuOcaD-sHw5VsBvPMNtSzcRrxh7jeCPJoOnBKAKaikAUjo9POlLXw30pTwtQfj0Q9qYROXrbnB3Rf0SFjd0sVc1PQSiImg5toMDqbyPELqK0G-hw7WRTuTbEjdz5zJ0ssD3u5F5f-OvbkEWF67HqsjlSIulo4b15MllSlROQgc_kvMFx3yqYfvWDslHCXgFTIo6fcK4wZTHKEszhru_aDO7aTEqv16Onjyf4JTTsGUfjiq4PdkKfQRkygzcBq8bsT__SsFrRizXzjE7SJMbQt7m4cS95QcTne5fgZrptFCVdn_KIJAoL06SM9OYzKMlPKlpepJFjUJWA66KV1mjn8uy2nPhuKpX0oL.AQAB"},{"rel":"self","type":"application\/ld+json; profile=\"https:\/\/www.w3.org\/ns\/activitystreams\"","href":"https:\/\/gerzilla.de\/channel\/kaniini"}]}
|
|
@ -3,6 +3,18 @@ defmodule HTTPoisonMock do
|
|||
|
||||
def get(url, body \\ [], headers \\ [])
|
||||
|
||||
def get(
|
||||
"http://gerzilla.de/.well-known/webfinger?resource=acct:kaniini@gerzilla.de",
|
||||
[Accept: "application/xrd+xml,application/jrd+json"],
|
||||
follow_redirect: true
|
||||
) do
|
||||
{:ok,
|
||||
%Response{
|
||||
status_code: 200,
|
||||
body: File.read!("test/fixtures/httpoison_mock/kaniini@gerzilla.de.json")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(
|
||||
"http://framatube.org/.well-known/webfinger?resource=acct:framasoft@framatube.org",
|
||||
[Accept: "application/xrd+xml,application/jrd+json"],
|
||||
|
|
|
@ -49,6 +49,14 @@ test "returns the ActivityPub actor URI for an ActivityPub user" do
|
|||
{:ok, _data} = WebFinger.finger(user)
|
||||
end
|
||||
|
||||
test "returns the ActivityPub actor URI 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"
|
||||
end
|
||||
|
||||
test "returns the correctly for json ostatus users" do
|
||||
user = "winterdienst@gnusocial.de"
|
||||
|
||||
|
|
Loading…
Reference in a new issue