Scrape instance nodeinfo #251
4 changed files with 9 additions and 4 deletions
commit
053771900c
|
|
@ -3047,13 +3047,13 @@ config :pleroma, :config_description, [
|
|||
}
|
||||
]
|
||||
},
|
||||
%{
|
||||
%{
|
||||
group: :pleroma,
|
||||
key: :instances_nodeinfo,
|
||||
type: :group,
|
||||
description: "Control favicons for instances",
|
||||
children: [
|
||||
%{
|
||||
%{
|
||||
key: :enabled,
|
||||
type: :boolean,
|
||||
description: "Allow/disallow getting instance nodeinfo"
|
||||
|
|
|
|||
|
|
@ -301,6 +301,7 @@ defmodule Pleroma.Instances.Instance do
|
|||
|
||||
def get_cached_by_url(url_or_host) do
|
||||
url = host(url_or_host)
|
||||
|
||||
@cachex.fetch!(:instances_cache, "instances:#{url}", fn _ ->
|
||||
with %Instance{} = instance <- get_by_url(url) do
|
||||
{:commit, {:ok, instance}}
|
||||
|
|
|
|||
|
|
@ -237,13 +237,13 @@ defmodule Pleroma.Instances.InstanceTest do
|
|||
%{url: "https://bad-nodeinfo.example.org/.well-known/nodeinfo"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
"oepsie woepsie de nodeinfo is kapotie uwu"
|
||||
body: "oepsie woepsie de nodeinfo is kapotie uwu"
|
||||
}
|
||||
end)
|
||||
|
||||
assert {:ok, true} ==
|
||||
Instance.update_metadata(URI.parse("https://bad-nodeinfo.example.org/"))
|
||||
|
||||
{:ok, instance} = Instance.get_cached_by_url("https://bad-nodeinfo.example.org/")
|
||||
assert instance.nodeinfo == nil
|
||||
end
|
||||
|
|
@ -279,12 +279,14 @@ defmodule Pleroma.Instances.InstanceTest do
|
|||
|
||||
assert {:ok, true} ==
|
||||
Instance.update_metadata(URI.parse("https://bad-nodeinfo.example.org/"))
|
||||
|
||||
{:ok, instance} = Instance.get_cached_by_url("https://bad-nodeinfo.example.org/")
|
||||
assert instance.nodeinfo == nil
|
||||
end
|
||||
|
||||
test "doesn't store incredibly long json nodeinfo" do
|
||||
too_long = String.duplicate("a", 50_000)
|
||||
|
||||
Tesla.Mock.mock(fn
|
||||
%{url: "https://bad-nodeinfo.example.org/"} ->
|
||||
%Tesla.Env{
|
||||
|
|
@ -315,6 +317,7 @@ defmodule Pleroma.Instances.InstanceTest do
|
|||
|
||||
assert {:ok, true} ==
|
||||
Instance.update_metadata(URI.parse("https://bad-nodeinfo.example.org/"))
|
||||
|
||||
{:ok, instance} = Instance.get_cached_by_url("https://bad-nodeinfo.example.org/")
|
||||
assert instance.nodeinfo == nil
|
||||
end
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
|
||||
test "is parsed when :instance_favicons is enabled", %{user: user, instance: instance} do
|
||||
clear_config([:instances_favicons, :enabled], true)
|
||||
|
||||
assert %{
|
||||
pleroma: %{
|
||||
favicon: "https://example.com/favicon.ico"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue