fix(follow-instances): Show correct error message when trying to follow already following actor
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
8543204bd9
commit
d969c6648f
|
@ -527,6 +527,12 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
|
|||
Instances.refresh()
|
||||
get_instance(parent, args, resolution)
|
||||
|
||||
{:error, :follow_pending} ->
|
||||
{:error, dgettext("errors", "This instance is pending follow approval")}
|
||||
|
||||
{:error, :already_following} ->
|
||||
{:error, dgettext("errors", "You are already following this instance")}
|
||||
|
||||
{:error, :http_error} ->
|
||||
{:error, dgettext("errors", "Unable to find an instance to follow at this address")}
|
||||
|
||||
|
|
|
@ -1226,12 +1226,16 @@ defmodule Mobilizon.Actors do
|
|||
approved :: boolean | nil
|
||||
) ::
|
||||
{:ok, Follower.t()}
|
||||
| {:error, :already_following | :followed_suspended | Ecto.Changeset.t()}
|
||||
| {:error,
|
||||
:already_following | :follow_pending | :followed_suspended | Ecto.Changeset.t()}
|
||||
def follow(%Actor{} = followed, %Actor{} = follower, url \\ nil, approved \\ true) do
|
||||
if followed.suspended do
|
||||
{:error, :followed_suspended}
|
||||
else
|
||||
case check_follow(follower, followed) do
|
||||
%Follower{approved: false} ->
|
||||
{:error, :follow_pending}
|
||||
|
||||
%Follower{} ->
|
||||
{:error, :already_following}
|
||||
|
||||
|
|
Loading…
Reference in a new issue