Merge branch 'add-task-to-refresh-instance-relay' into 'master'

Add task to refresh an instance relay

See merge request framasoft/mobilizon!628
This commit is contained in:
Thomas Citharel 2020-10-21 11:19:06 +02:00
commit f05e26e28a
2 changed files with 23 additions and 1 deletions

View File

@ -12,7 +12,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
alias Mobilizon.Actors.{Actor, Follower}
alias Mobilizon.Federation.ActivityPub
alias Mobilizon.Federation.ActivityPub.{Activity, Transmogrifier}
alias Mobilizon.Federation.ActivityPub.{Activity, Refresher, Transmogrifier}
alias Mobilizon.Federation.WebFinger
alias Mobilizon.GraphQL.API.Follows
@ -90,6 +90,15 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
end
end
def refresh(address) do
Logger.debug("We're trying to refresh a remote instance")
with {:ok, target_instance} <- fetch_actor(address),
{:ok, %Actor{} = target_actor} <- ActivityPub.get_or_fetch_actor_by_url(target_instance) do
Refresher.refresh_profile(target_actor)
end
end
@doc """
Publish an activity to all relays following this instance
"""

View File

@ -65,4 +65,17 @@ defmodule Mix.Tasks.Mobilizon.Relay do
IO.puts(:stderr, "Error while accept #{target} follow: #{inspect(e)}")
end
end
def run(["refresh", target]) do
Common.start_mobilizon()
IO.puts("Refreshing #{target}, this can take a while.")
case Relay.refresh(target) do
:ok ->
IO.puts("Refreshed #{target}")
err ->
IO.puts(:stderr, "Error while refreshing #{target}: #{inspect(err)}")
end
end
end