Merge branch 'fix-remote-follow-from-ostatus-subscribe' into 'develop'
Fix remote follow from /ostatus_subscribe Closes #1103 See merge request pleroma/pleroma!1472
This commit is contained in:
commit
19835be067
|
@ -17,7 +17,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
||||||
alias Pleroma.Web
|
alias Pleroma.Web
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
alias Pleroma.Web.OStatus
|
|
||||||
alias Pleroma.Web.WebFinger
|
alias Pleroma.Web.WebFinger
|
||||||
|
|
||||||
def help_test(conn, _params) do
|
def help_test(conn, _params) do
|
||||||
|
@ -60,7 +59,7 @@ def remote_follow(%{assigns: %{user: user}} = conn, %{"acct" => acct}) do
|
||||||
%Activity{id: activity_id} = Activity.get_create_by_object_ap_id(object.data["id"])
|
%Activity{id: activity_id} = Activity.get_create_by_object_ap_id(object.data["id"])
|
||||||
redirect(conn, to: "/notice/#{activity_id}")
|
redirect(conn, to: "/notice/#{activity_id}")
|
||||||
else
|
else
|
||||||
{err, followee} = OStatus.find_or_make_user(acct)
|
{err, followee} = User.get_or_fetch(acct)
|
||||||
avatar = User.avatar_url(followee)
|
avatar = User.avatar_url(followee)
|
||||||
name = followee.nickname
|
name = followee.nickname
|
||||||
id = followee.id
|
id = followee.id
|
||||||
|
|
|
@ -86,11 +86,17 @@ def represent_user(user, "XML") do
|
||||||
|> XmlBuilder.to_doc()
|
|> XmlBuilder.to_doc()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_magic_key(magic_key) do
|
defp get_magic_key("data:application/magic-public-key," <> magic_key) do
|
||||||
"data:application/magic-public-key," <> magic_key = magic_key
|
|
||||||
{:ok, magic_key}
|
{:ok, magic_key}
|
||||||
rescue
|
end
|
||||||
MatchError -> {:error, "Missing magic key data."}
|
|
||||||
|
defp get_magic_key(nil) do
|
||||||
|
Logger.debug("Undefined magic key.")
|
||||||
|
{:ok, nil}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp get_magic_key(_) do
|
||||||
|
{:error, "Missing magic key data."}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp webfinger_from_xml(doc) do
|
defp webfinger_from_xml(doc) do
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||||
|
<Subject>acct:kPherox@mstdn.jp</Subject>
|
||||||
|
<Alias>https://mstdn.jp/@kPherox</Alias>
|
||||||
|
<Alias>https://mstdn.jp/users/kPherox</Alias>
|
||||||
|
<Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="https://mstdn.jp/@kPherox"/>
|
||||||
|
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="https://mstdn.jp/users/kPherox.atom"/>
|
||||||
|
<Link rel="self" type="application/activity+json" href="https://mstdn.jp/users/kPherox"/>
|
||||||
|
<Link rel="http://ostatus.org/schema/1.0/subscribe" template="https://mstdn.jp/authorize_interaction?acct={uri}"/>
|
||||||
|
</XRD>
|
|
@ -940,6 +940,14 @@ def get("https://info.pleroma.site/activity3.json", _, _, _) do
|
||||||
{:ok, %Tesla.Env{status: 404, body: ""}}
|
{:ok, %Tesla.Env{status: 404, body: ""}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get("https://mstdn.jp/.well-known/webfinger?resource=acct:kpherox@mstdn.jp", _, _, _) do
|
||||||
|
{:ok,
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
body: File.read!("test/fixtures/tesla_mock/kpherox@mstdn.jp.xml")
|
||||||
|
}}
|
||||||
|
end
|
||||||
|
|
||||||
def get(url, query, body, headers) do
|
def get(url, query, body, headers) do
|
||||||
{:error,
|
{:error,
|
||||||
"Not implemented the mock response for get #{inspect(url)}, #{query}, #{inspect(body)}, #{
|
"Not implemented the mock response for get #{inspect(url)}, #{query}, #{inspect(body)}, #{
|
||||||
|
|
|
@ -86,6 +86,20 @@ test "returns the correctly for json ostatus users" do
|
||||||
assert data["subscribe_address"] == "https://gnusocial.de/main/ostatussub?profile={uri}"
|
assert data["subscribe_address"] == "https://gnusocial.de/main/ostatussub?profile={uri}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it work for AP-only user" do
|
||||||
|
user = "kpherox@mstdn.jp"
|
||||||
|
|
||||||
|
{:ok, data} = WebFinger.finger(user)
|
||||||
|
|
||||||
|
assert data["magic_key"] == nil
|
||||||
|
assert data["salmon"] == nil
|
||||||
|
|
||||||
|
assert data["topic"] == "https://mstdn.jp/users/kPherox.atom"
|
||||||
|
assert data["subject"] == "acct:kPherox@mstdn.jp"
|
||||||
|
assert data["ap_id"] == "https://mstdn.jp/users/kPherox"
|
||||||
|
assert data["subscribe_address"] == "https://mstdn.jp/authorize_interaction?acct={uri}"
|
||||||
|
end
|
||||||
|
|
||||||
test "it works for friendica" do
|
test "it works for friendica" do
|
||||||
user = "lain@squeet.me"
|
user = "lain@squeet.me"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue