fix(activitypub): refresh NodeInfo metadata straight away when adding a new instance to follow

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-12-22 16:27:46 +01:00
parent 6d2f08f3c1
commit 2f4b8feeba
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
2 changed files with 7 additions and 10 deletions

View file

@ -16,6 +16,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
alias Mobilizon.Reports.{Note, Report}
alias Mobilizon.Service.Auth.Authenticator
alias Mobilizon.Service.Statistics
alias Mobilizon.Service.Workers.RefreshInstances
alias Mobilizon.Storage.Page
alias Mobilizon.Users.User
alias Mobilizon.Web.Email
@ -546,6 +547,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
case Relay.follow(domain) do
{:ok, _activity, _follow} ->
Instances.refresh()
RefreshInstances.refresh_instance_actor(domain)
get_instance(parent, args, resolution)
{:error, :follow_pending} ->

View file

@ -20,21 +20,16 @@ defmodule Mobilizon.Service.Workers.RefreshInstances do
Instances.refresh()
Instances.all_domains()
|> Enum.each(&refresh_instance_actor/1)
|> Enum.each(fn %Instance{domain: domain} -> refresh_instance_actor(domain) end)
end
@spec refresh_instance_actor(Instance.t()) ::
{:ok, Mobilizon.Actors.Actor.t()}
| {:error,
ActivityPubActor.make_actor_errors()
| Mobilizon.Federation.WebFinger.finger_errors()}
def refresh_instance_actor(%Instance{domain: nil}) do
@spec refresh_instance_actor(String.t() | nil) ::
{:ok, Mobilizon.Actors.Actor.t()} | {:error, Ecto.Changeset.t()} | {:error, atom}
def refresh_instance_actor(nil) do
{:error, :not_remote_instance}
end
@spec refresh_instance_actor(Instance.t()) ::
{:ok, InstanceActor.t()} | {:error, Ecto.Changeset.t()} | {:error, atom}
def refresh_instance_actor(%Instance{domain: domain}) do
def refresh_instance_actor(domain) do
%Actor{url: url} = Relay.get_actor()
%URI{host: host} = URI.new!(url)