소스 검색

Get the nodeinfo address from the well-known

object-id-column
Ekaterina Vaartis 4 년 전
부모
커밋
b585134c90
2개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. +7
    -1
      lib/pleroma/web/pleroma_api/emoji_api_controller.ex
  2. +6
    -0
      test/web/emoji_api_controller_test.exs

+ 7
- 1
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!()


+ 6
- 0
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"]}})



불러오는 중...
취소
저장