Change schema a bit
Closes #29 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -12,14 +12,40 @@ defmodule MobilizonWeb.Resolvers.Actor do
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Find a person
|
||||
"""
|
||||
def find_person(_parent, %{preferred_username: name}, _resolution) do
|
||||
case ActivityPub.find_or_make_person_from_nickname(name) do
|
||||
{:ok, actor} ->
|
||||
{:ok, actor}
|
||||
|
||||
_ ->
|
||||
{:error, "Person with name #{name} not found"}
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Find a person
|
||||
"""
|
||||
def find_group(_parent, %{preferred_username: name}, _resolution) do
|
||||
case ActivityPub.find_or_make_group_from_nickname(name) do
|
||||
{:ok, actor} ->
|
||||
{:ok, actor}
|
||||
|
||||
_ ->
|
||||
{:error, "Group with name #{name} not found"}
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns the current actor for the currently logged-in user
|
||||
"""
|
||||
def get_current_actor(_parent, _args, %{context: %{current_user: user}}) do
|
||||
def get_current_person(_parent, _args, %{context: %{current_user: user}}) do
|
||||
{:ok, Actors.get_actor_for_user(user)}
|
||||
end
|
||||
|
||||
def get_current_actor(_parent, _args, _resolution) do
|
||||
{:error, "You need to be logged-in to view current actor"}
|
||||
def get_current_person(_parent, _args, _resolution) do
|
||||
{:error, "You need to be logged-in to view current person"}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,7 +60,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
Mobilizon.Actors.Service.Activation.check_confirmation_token(token),
|
||||
%Actor{} = actor <- Actors.get_actor_for_user(user),
|
||||
{:ok, token, _} <- MobilizonWeb.Guardian.encode_and_sign(user) do
|
||||
{:ok, %{token: token, user: user, actor: actor}}
|
||||
{:ok, %{token: token, user: user, person: actor}}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user