Mix format
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
fca5d0b8e6
commit
dd87ad4f7e
|
@ -174,10 +174,12 @@ defmodule Mobilizon.Actors.Actor do
|
||||||
|> put_change(:local, true)
|
|> put_change(:local, true)
|
||||||
end
|
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(changeset, type \\ :Person)
|
||||||
|
|
||||||
defp build_urls(%Ecto.Changeset{changes: %{preferred_username: username}} = changeset, type) do
|
defp build_urls(%Ecto.Changeset{changes: %{preferred_username: username}} = changeset, type) do
|
||||||
symbol = if type == :Group, do: "~", else: "@"
|
symbol = if type == :Group, do: "~", else: "@"
|
||||||
|
|
||||||
changeset
|
changeset
|
||||||
|> put_change(
|
|> put_change(
|
||||||
:outbox_url,
|
:outbox_url,
|
||||||
|
|
|
@ -21,7 +21,7 @@ defmodule MobilizonWeb.Resolvers.Group do
|
||||||
Lists all groups
|
Lists all groups
|
||||||
"""
|
"""
|
||||||
def list_groups(_parent, _args, _resolution) do
|
def list_groups(_parent, _args, _resolution) do
|
||||||
{:ok, Actors.list_groups}
|
{:ok, Actors.list_groups()}
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -34,7 +34,6 @@ defmodule MobilizonWeb.Resolvers.Group do
|
||||||
context: %{current_user: user}
|
context: %{current_user: user}
|
||||||
}
|
}
|
||||||
) do
|
) do
|
||||||
|
|
||||||
with %Actor{id: actor_id} <- Actors.get_local_actor_by_name(actor_username),
|
with %Actor{id: actor_id} <- Actors.get_local_actor_by_name(actor_username),
|
||||||
{:user_actor, true} <-
|
{:user_actor, true} <-
|
||||||
{:user_actor, actor_id in Enum.map(Actors.get_actors_for_user(user), & &1.id)},
|
{:user_actor, actor_id in Enum.map(Actors.get_actors_for_user(user), & &1.id)},
|
||||||
|
@ -43,6 +42,7 @@ defmodule MobilizonWeb.Resolvers.Group do
|
||||||
else
|
else
|
||||||
{:error, %Ecto.Changeset{errors: [url: {"has already been taken", []}]}} ->
|
{:error, %Ecto.Changeset{errors: [url: {"has already been taken", []}]}} ->
|
||||||
{:error, :group_name_not_available}
|
{:error, :group_name_not_available}
|
||||||
|
|
||||||
err ->
|
err ->
|
||||||
Logger.error(inspect(err))
|
Logger.error(inspect(err))
|
||||||
err
|
err
|
||||||
|
|
|
@ -548,6 +548,7 @@ defmodule MobilizonWeb.Schema do
|
||||||
arg(:creator_username, :string,
|
arg(:creator_username, :string,
|
||||||
description: "The actor's username which will be the admin (otherwise user's default one)"
|
description: "The actor's username which will be the admin (otherwise user's default one)"
|
||||||
)
|
)
|
||||||
|
|
||||||
resolve(&Resolvers.Group.create_group/3)
|
resolve(&Resolvers.Group.create_group/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ defmodule MobilizonWeb.Resolvers.GroupResolverTest do
|
||||||
|
|
||||||
assert json_response(res, 200)["data"]["createGroup"]["preferred_username"] ==
|
assert json_response(res, 200)["data"]["createGroup"]["preferred_username"] ==
|
||||||
@new_group_params.groupname
|
@new_group_params.groupname
|
||||||
|
|
||||||
assert json_response(res, 200)["data"]["createGroup"]["type"] == "GROUP"
|
assert json_response(res, 200)["data"]["createGroup"]["type"] == "GROUP"
|
||||||
|
|
||||||
mutation = """
|
mutation = """
|
||||||
|
@ -61,6 +62,7 @@ defmodule MobilizonWeb.Resolvers.GroupResolverTest do
|
||||||
|
|
||||||
test "list_groups/3 returns all groups", context do
|
test "list_groups/3 returns all groups", context do
|
||||||
group = insert(:group)
|
group = insert(:group)
|
||||||
|
|
||||||
query = """
|
query = """
|
||||||
{
|
{
|
||||||
groups {
|
groups {
|
||||||
|
|
Loading…
Reference in a new issue