Return a proper error directly when a group name conflicts

And translate the error

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
chapril
Thomas Citharel 9 months ago
parent 93425108c5
commit cd3c316881
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
  1. 11
      lib/graphql/api/groups.ex

@ -5,9 +5,10 @@ defmodule Mobilizon.GraphQL.API.Groups do
alias Mobilizon.Actors
alias Mobilizon.Actors.Actor
alias Mobilizon.GraphQL.Error
alias Mobilizon.Federation.ActivityPub.{Actions, Activity}
alias Mobilizon.Service.Formatter.HTML
import Mobilizon.Web.Gettext
@doc """
Create a group
@ -26,7 +27,13 @@ defmodule Mobilizon.GraphQL.API.Groups do
Actions.Create.create(:actor, args, true, %{"actor" => args.creator_actor.url})
%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

Loading…
Cancel
Save