@@ -1,6 +1,4 @@
|
||||
defmodule MobilizonWeb.Resolvers.Actor do
|
||||
alias Mobilizon.Actors.Actor, as: ActorSchema
|
||||
alias Mobilizon.Actors.User
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
defmodule MobilizonWeb.Resolvers.Category do
|
||||
require Logger
|
||||
alias Mobilizon.Actors.User
|
||||
|
||||
def list_categories(_parent, _args, _resolution) do
|
||||
categories =
|
||||
@@ -13,7 +14,7 @@ defmodule MobilizonWeb.Resolvers.Category do
|
||||
end
|
||||
|
||||
def create_category(_parent, %{title: title, picture: picture, description: description}, %{
|
||||
context: %{current_user: user}
|
||||
context: %{current_user: %User{} = _user}
|
||||
}) do
|
||||
with {:ok, category} <-
|
||||
Mobilizon.Events.create_category(%{
|
||||
@@ -35,7 +36,7 @@ defmodule MobilizonWeb.Resolvers.Category do
|
||||
end
|
||||
end
|
||||
|
||||
def create_category(_parent, %{title: title, picture: picture, description: description}, %{}) do
|
||||
def create_category(_parent, _args, %{}) do
|
||||
{:error, "You are not allowed to create a category if not connected"}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
defmodule MobilizonWeb.Resolvers.Event do
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Actors
|
||||
|
||||
def list_events(_parent, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_events()}
|
||||
@@ -15,10 +16,20 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
List participant for event (separate request)
|
||||
"""
|
||||
def list_participants_for_event(_parent, %{uuid: uuid}, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_participants_for_event(uuid)}
|
||||
end
|
||||
|
||||
@doc """
|
||||
List participants for event (through an event request)
|
||||
"""
|
||||
def list_participants_for_event(%{uuid: uuid}, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_participants_for_event(uuid)}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Search events by title
|
||||
"""
|
||||
@@ -30,7 +41,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
Search events and actors by title
|
||||
"""
|
||||
def search_events_and_actors(_parent, %{search: search, page: page, limit: limit}, _resolution) do
|
||||
search = String.strip(search)
|
||||
search = String.trim(search)
|
||||
|
||||
found =
|
||||
case String.contains?(search, "@") do
|
||||
@@ -52,14 +63,9 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
{:ok, found}
|
||||
end
|
||||
|
||||
@doc """
|
||||
List participants for event (through an event request)
|
||||
"""
|
||||
def list_participants_for_event(%{uuid: uuid}, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_participants_for_event(uuid)}
|
||||
end
|
||||
|
||||
def create_event(_parent, args, %{context: %{current_user: user}}) do
|
||||
organizer_actor_id = Map.get(args, "organizer_actor_id") || Actors.get_actor_for_user(user).id
|
||||
args = args |> Map.put("organizer_actor_id", organizer_actor_id)
|
||||
Mobilizon.Events.create_event(args)
|
||||
end
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
{:error, "You need to be logged-in to view current user"}
|
||||
end
|
||||
|
||||
@desc """
|
||||
@doc """
|
||||
Login an user. Returns a token and the user
|
||||
"""
|
||||
def login_user(_parent, %{email: email, password: password}, _resolution) do
|
||||
@@ -37,7 +37,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
end
|
||||
end
|
||||
|
||||
@desc """
|
||||
@doc """
|
||||
Register an user :
|
||||
- create the user
|
||||
- create the actor
|
||||
@@ -111,7 +111,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
end
|
||||
end
|
||||
|
||||
@desc "Change an user default actor"
|
||||
@doc "Change an user default actor"
|
||||
def change_default_actor(_parent, %{preferred_username: username}, %{
|
||||
context: %{current_user: user}
|
||||
}) do
|
||||
|
||||
Reference in New Issue
Block a user