Allow to get Mastodon instance relays

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
chapril
Thomas Citharel 7 months ago
parent aff1959030
commit 3982977121
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
  1. 2
      lib/graphql/resolvers/admin.ex
  2. 8
      lib/mobilizon/actors/actors.ex

@ -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 = %{

@ -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 ->

Loading…
Cancel
Save