@@ -29,12 +29,12 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
end
|
||||
|
||||
def find_event(_parent, %{uuid: uuid}, _resolution) do
|
||||
case Mobilizon.Events.get_public_event_by_uuid_with_preload(uuid) do
|
||||
nil ->
|
||||
{:error, "Event with UUID #{uuid} not found"}
|
||||
|
||||
event ->
|
||||
case {:has_event, Mobilizon.Events.get_public_event_by_uuid_with_preload(uuid)} do
|
||||
{:has_event, %Event{} = event} ->
|
||||
{:ok, Map.put(event, :organizer_actor, Person.proxify_pictures(event.organizer_actor))}
|
||||
|
||||
{:has_event, _} ->
|
||||
{:error, "Event with UUID #{uuid} not found"}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
Handles the user-related GraphQL calls
|
||||
"""
|
||||
|
||||
alias Mobilizon.{Actors, Config, Users}
|
||||
alias Mobilizon.{Actors, Config, Users, Events}
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Service.Users.{ResetPassword, Activation}
|
||||
alias Mobilizon.Users.User
|
||||
@@ -220,4 +220,22 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
{:error, :unable_to_change_default_actor}
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns the list of events for all of this user's identities are going to
|
||||
"""
|
||||
def user_participations(_parent, args, %{
|
||||
context: %{current_user: %User{id: user_id}}
|
||||
}) do
|
||||
with participations <-
|
||||
Events.list_participations_for_user(
|
||||
user_id,
|
||||
Map.get(args, :after_datetime),
|
||||
Map.get(args, :before_datetime),
|
||||
Map.get(args, :page),
|
||||
Map.get(args, :limit)
|
||||
) do
|
||||
{:ok, participations}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user