feat(nodeinfo): extract and save NodeInfo information from instances to display it on instances list

We also try to detect the application actor if it's not given by NodeInfo metadata (FEP-2677)
(guessing for Mobilizon, PeerTube & Mastodon).

Closes #1392

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-12-20 17:52:27 +01:00
parent 2fba6379f1
commit 99b2339424
25 changed files with 775 additions and 167 deletions

View File

@@ -490,19 +490,35 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
context: %{current_user: %User{role: role}}
})
when is_admin(role) do
remote_relay = Actors.get_relay(domain)
remote_relay = Instances.get_instance_actor(domain)
local_relay = Relay.get_actor()
result = %{
has_relay: !is_nil(remote_relay),
relay_address:
if(is_nil(remote_relay),
do: nil,
else: "#{remote_relay.preferred_username}@#{remote_relay.domain}"
),
follower_status: follow_status(remote_relay, local_relay),
followed_status: follow_status(local_relay, remote_relay)
}
result =
if is_nil(remote_relay) do
%{
has_relay: false,
relay_address: nil,
follower_status: nil,
followed_status: nil,
software: nil,
software_version: nil
}
else
%{
has_relay: !is_nil(remote_relay.actor),
relay_address:
if(is_nil(remote_relay.actor),
do: nil,
else: Actor.preferred_username_and_domain(remote_relay.actor)
),
follower_status: follow_status(remote_relay.actor, local_relay),
followed_status: follow_status(local_relay, remote_relay.actor),
instance_name: remote_relay.instance_name,
instance_description: remote_relay.instance_description,
software: remote_relay.software,
software_version: remote_relay.software_version
}
end
case Instances.instance(domain) do
nil -> {:error, :not_found}

View File

@@ -227,6 +227,16 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
field(:relay_address, :string,
description: "If this instance has a relay, it's federated username"
)
field(:instance_name, :string, description: "This instance's name")
field(:instance_description, :string, description: "This instance's description")
field(:software, :string, description: "The software this instance declares running")
field(:software_version, :string,
description: "The software version this instance declares running"
)
end
@desc """