forked from YokaiRick/akkoma
Get the nodeinfo address from the well-known
This commit is contained in:
parent
a1325d5fd9
commit
b585134c90
2 changed files with 13 additions and 1 deletions
|
@ -148,7 +148,13 @@ def download_shared(conn, %{"name" => name}) do
|
||||||
"""
|
"""
|
||||||
def download_from(conn, %{"instance_address" => address, "pack_name" => name} = data) do
|
def download_from(conn, %{"instance_address" => address, "pack_name" => name} = data) do
|
||||||
shareable_packs_available =
|
shareable_packs_available =
|
||||||
"#{address}/nodeinfo/2.1.json"
|
"#{address}/.well-known/nodeinfo"
|
||||||
|
|> Tesla.get!()
|
||||||
|
|> Map.get(:body)
|
||||||
|
|> Jason.decode!()
|
||||||
|
|> List.last()
|
||||||
|
|> Map.get("href")
|
||||||
|
# Get the actual nodeinfo address and fetch it
|
||||||
|> Tesla.get!()
|
|> Tesla.get!()
|
||||||
|> Map.get(:body)
|
|> Map.get(:body)
|
||||||
|> Jason.decode!()
|
|> Jason.decode!()
|
||||||
|
|
|
@ -54,9 +54,15 @@ test "downloading shared & unshared packs from another instance via download_fro
|
||||||
end)
|
end)
|
||||||
|
|
||||||
mock(fn
|
mock(fn
|
||||||
|
%{method: :get, url: "https://old-instance/.well-known/nodeinfo"} ->
|
||||||
|
json([%{href: "https://old-instance/nodeinfo/2.1.json"}])
|
||||||
|
|
||||||
%{method: :get, url: "https://old-instance/nodeinfo/2.1.json"} ->
|
%{method: :get, url: "https://old-instance/nodeinfo/2.1.json"} ->
|
||||||
json(%{metadata: %{features: []}})
|
json(%{metadata: %{features: []}})
|
||||||
|
|
||||||
|
%{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
|
||||||
|
json([%{href: "https://example.com/nodeinfo/2.1.json"}])
|
||||||
|
|
||||||
%{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
|
%{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
|
||||||
json(%{metadata: %{features: ["shareable_emoji_packs"]}})
|
json(%{metadata: %{features: ["shareable_emoji_packs"]}})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue