Return a proper error directly when a group name conflicts
And translate the error Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
29062ff883
commit
c2f0ee7928
@ -5,9 +5,10 @@ defmodule Mobilizon.GraphQL.API.Groups do
|
|||||||
|
|
||||||
alias Mobilizon.Actors
|
alias Mobilizon.Actors
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
|
alias Mobilizon.GraphQL.Error
|
||||||
alias Mobilizon.Federation.ActivityPub.{Actions, Activity}
|
alias Mobilizon.Federation.ActivityPub.{Actions, Activity}
|
||||||
alias Mobilizon.Service.Formatter.HTML
|
alias Mobilizon.Service.Formatter.HTML
|
||||||
|
import Mobilizon.Web.Gettext
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Create a group
|
Create a group
|
||||||
@ -26,7 +27,13 @@ defmodule Mobilizon.GraphQL.API.Groups do
|
|||||||
Actions.Create.create(:actor, args, true, %{"actor" => args.creator_actor.url})
|
Actions.Create.create(:actor, args, true, %{"actor" => args.creator_actor.url})
|
||||||
|
|
||||||
%Actor{} ->
|
%Actor{} ->
|
||||||
{:error, "A profile or group with that name already exists"}
|
{:error,
|
||||||
|
%Error{
|
||||||
|
code: :validation,
|
||||||
|
message: dgettext("errors", "A profile or group with that name already exists"),
|
||||||
|
status_code: 409,
|
||||||
|
field: "preferred_username"
|
||||||
|
}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user