Allow to get Mastodon instance relays

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-05-06 16:58:33 +02:00
parent aff1959030
commit 3982977121
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
2 changed files with 9 additions and 1 deletions

View file

@ -469,7 +469,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
})
when is_admin(role) do
has_relay = Actors.has_relay?(domain)
remote_relay = Actors.get_actor_by_name("relay@#{domain}")
remote_relay = Actors.get_relay(domain)
local_relay = Relay.get_actor()
result = %{

View file

@ -1307,6 +1307,14 @@ defmodule Mobilizon.Actors do
|> Repo.exists?()
end
@doc """
Returns a relay actor, either `relay@domain` (Mobilizon) or `domain@domain` (Mastodon)
"""
@spec get_relay(String.t()) :: Actor.t() | nil
def get_relay(domain) do
get_actor_by_name("relay@#{domain}") || get_actor_by_name("#{domain}@#{domain}")
end
@spec delete_files_if_media_changed(Ecto.Changeset.t()) :: Ecto.Changeset.t()
defp delete_files_if_media_changed(%Ecto.Changeset{changes: changes, data: data} = changeset) do
Enum.each([:avatar, :banner], fn key ->