diff options
author | Ekaterina Vaartis <vaartis@cock.li> | 2019-09-18 19:48:25 +0300 |
---|---|---|
committer | Ekaterina Vaartis <vaartis@cock.li> | 2019-09-19 00:16:34 +0300 |
commit | b585134c9092b49e7b5c24e04d6d6315d45dd0a2 (patch) | |
tree | 4a60a455bbbfdcaa9d3a8fd0dd8330cd0b11fff2 | |
parent | a1325d5fd9b540017cbffbb73db85ee9fa9f12d0 (diff) | |
download | pleroma-b585134c9092b49e7b5c24e04d6d6315d45dd0a2.tar.gz |
Get the nodeinfo address from the well-known
-rw-r--r-- | lib/pleroma/web/pleroma_api/emoji_api_controller.ex | 8 | ||||
-rw-r--r-- | test/web/emoji_api_controller_test.exs | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/pleroma/web/pleroma_api/emoji_api_controller.ex b/lib/pleroma/web/pleroma_api/emoji_api_controller.ex index 391c317e7..6beca426a 100644 --- a/lib/pleroma/web/pleroma_api/emoji_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/emoji_api_controller.ex @@ -148,7 +148,13 @@ keeping it in cache for #{div(cache_ms, 1000)}s") """ def download_from(conn, %{"instance_address" => address, "pack_name" => name} = data) do 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!() |> Map.get(:body) |> Jason.decode!() diff --git a/test/web/emoji_api_controller_test.exs b/test/web/emoji_api_controller_test.exs index 297dc092f..c5a553692 100644 --- a/test/web/emoji_api_controller_test.exs +++ b/test/web/emoji_api_controller_test.exs @@ -54,9 +54,15 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do end) 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"} -> 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"} -> json(%{metadata: %{features: ["shareable_emoji_packs"]}}) |