forked from potsda.mn/mobilizon
Make sure instance list is refreshed before notifying admin from new
instance follow Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
83d518579b
commit
530539c631
|
@ -1,6 +1,6 @@
|
|||
defmodule Mobilizon.Federation.ActivityPub.Types.Actors do
|
||||
@moduledoc false
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.{Actors, Instances}
|
||||
alias Mobilizon.Actors.{Actor, Follower, Member}
|
||||
alias Mobilizon.Federation.ActivityPub.{Actions, Audience, Permission, Relay}
|
||||
alias Mobilizon.Federation.ActivityPub.Types.Entity
|
||||
|
@ -204,7 +204,12 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Actors do
|
|||
def follow(%Actor{} = follower_actor, %Actor{type: type} = followed, _local, additional)
|
||||
when type != :Person do
|
||||
case Mobilizon.Actors.follow(followed, follower_actor, additional["activity_id"], false) do
|
||||
{:ok, %Follower{} = follower} ->
|
||||
{:ok, %Follower{actor: %Actor{type: actor_type}} = follower} ->
|
||||
# We refresh the instance materialized view to make sure the instance page will be available
|
||||
# when the admin clicks on the email link and access it
|
||||
if actor_type == :Application do
|
||||
Instances.refresh()
|
||||
end
|
||||
FollowMailer.send_notification_to_admins(follower)
|
||||
follower_as_data = Convertible.model_to_as(follower)
|
||||
approve_if_manually_approves_followers(follower, follower_as_data)
|
||||
|
|
|
@ -464,6 +464,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
|
|||
{:error, :unauthenticated}
|
||||
end
|
||||
|
||||
@spec get_instance(any, map(), Absinthe.Resolution.t()) ::
|
||||
{:error, :unauthenticated | :unauthorized | :not_found} | {:ok, Mobilizon.Instances.Instance.t()}
|
||||
def get_instance(_parent, %{domain: domain}, %{
|
||||
context: %{current_user: %User{role: role}}
|
||||
})
|
||||
|
@ -482,7 +484,10 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
|
|||
followed_status: follow_status(local_relay, remote_relay)
|
||||
}
|
||||
|
||||
{:ok, Map.merge(Instances.instance(domain), result)}
|
||||
case Instances.instance(domain) do
|
||||
nil -> {:error, :not_found}
|
||||
instance -> {:ok, Map.merge(instance, result)}
|
||||
end
|
||||
end
|
||||
|
||||
def get_instance(_parent, _args, %{context: %{current_user: %User{}}}) do
|
||||
|
|
|
@ -67,7 +67,7 @@ defmodule Mobilizon.Instances do
|
|||
}
|
||||
end
|
||||
|
||||
@spec instance(String.t()) :: Instance.t()
|
||||
@spec instance(String.t()) :: Instance.t() | nil
|
||||
def instance(domain) do
|
||||
Instance
|
||||
|> where(domain: ^domain)
|
||||
|
|
Loading…
Reference in a new issue