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 when is_admin(role) do
has_relay = Actors.has_relay?(domain) 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() local_relay = Relay.get_actor()
result = %{ result = %{

View File

@ -1307,6 +1307,14 @@ defmodule Mobilizon.Actors do
|> Repo.exists?() |> Repo.exists?()
end 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() @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 defp delete_files_if_media_changed(%Ecto.Changeset{changes: changes, data: data} = changeset) do
Enum.each([:avatar, :banner], fn key -> Enum.each([:avatar, :banner], fn key ->