Mix format

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2018-12-03 12:08:18 +01:00
parent fca5d0b8e6
commit dd87ad4f7e
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
4 changed files with 15 additions and 10 deletions

View File

@ -174,10 +174,12 @@ defmodule Mobilizon.Actors.Actor do
|> put_change(:local, true)
end
@spec build_urls(Ecto.Changeset.t, atom()) :: Ecto.Changeset.t
@spec build_urls(Ecto.Changeset.t(), atom()) :: Ecto.Changeset.t()
defp build_urls(changeset, type \\ :Person)
defp build_urls(%Ecto.Changeset{changes: %{preferred_username: username}} = changeset, type) do
symbol = if type == :Group, do: "~", else: "@"
changeset
|> put_change(
:outbox_url,

View File

@ -21,7 +21,7 @@ defmodule MobilizonWeb.Resolvers.Group do
Lists all groups
"""
def list_groups(_parent, _args, _resolution) do
{:ok, Actors.list_groups}
{:ok, Actors.list_groups()}
end
@doc """
@ -34,15 +34,15 @@ defmodule MobilizonWeb.Resolvers.Group do
context: %{current_user: user}
}
) do
with %Actor{id: actor_id} <- Actors.get_local_actor_by_name(actor_username),
{:user_actor, true} <-
{:user_actor, actor_id in Enum.map(Actors.get_actors_for_user(user), & &1.id)},
{:ok, %Actor{} = group} <- Actors.create_group(%{preferred_username: preferred_username}) do
{:ok, group}
{:ok, %Actor{} = group} <- Actors.create_group(%{preferred_username: preferred_username}) do
{:ok, group}
else
{:error, %Ecto.Changeset{errors: [url: {"has already been taken", []}]}} ->
{:error, :group_name_not_available}
err ->
Logger.error(inspect(err))
err

View File

@ -548,6 +548,7 @@ defmodule MobilizonWeb.Schema do
arg(:creator_username, :string,
description: "The actor's username which will be the admin (otherwise user's default one)"
)
resolve(&Resolvers.Group.create_group/3)
end

View File

@ -35,11 +35,12 @@ defmodule MobilizonWeb.Resolvers.GroupResolverTest do
|> auth_conn(user)
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
assert json_response(res, 200)["data"]["createGroup"]["preferred_username"] ==
@new_group_params.groupname
assert json_response(res, 200)["data"]["createGroup"]["type"] == "GROUP"
assert json_response(res, 200)["data"]["createGroup"]["preferred_username"] ==
@new_group_params.groupname
mutation = """
assert json_response(res, 200)["data"]["createGroup"]["type"] == "GROUP"
mutation = """
mutation {
createGroup(
preferred_username: "#{@new_group_params.groupname}",
@ -56,11 +57,12 @@ defmodule MobilizonWeb.Resolvers.GroupResolverTest do
|> auth_conn(user)
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
assert hd(json_response(res, 200)["errors"])["message"] == "group_name_not_available"
assert hd(json_response(res, 200)["errors"])["message"] == "group_name_not_available"
end
test "list_groups/3 returns all groups", context do
group = insert(:group)
query = """
{
groups {