Add API to join and leave an event

This commit is contained in:
Chocobozzz
2019-02-01 15:38:35 +01:00
committed by Thomas Citharel
parent 421fbda9fa
commit 250f0b3bd1
12 changed files with 430 additions and 74 deletions

View File

@@ -12,7 +12,7 @@ defmodule MobilizonWeb.Schema.ActorInterface do
@desc "An ActivityPub actor"
interface :actor do
field(:id, :id, description: "Internal ID for this actor")
field(:id, :integer, description: "Internal ID for this actor")
field(:url, :string, description: "The ActivityPub actor's URL")
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
field(:name, :string, description: "The actor's displayed name")

View File

@@ -13,7 +13,7 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
object :group do
interfaces([:actor])
field(:id, :id, description: "Internal ID for this group")
field(:id, :integer, description: "Internal ID for this group")
field(:url, :string, description: "The ActivityPub actor's URL")
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
field(:name, :string, description: "The actor's displayed name")

View File

@@ -13,7 +13,7 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
"""
object :person do
interfaces([:actor])
field(:id, :id, description: "Internal ID for this person")
field(:id, :integer, description: "Internal ID for this person")
field(:user, :user, description: "The user this actor is associated to")
field(:member_of, list_of(:member), description: "The list of groups this person is member of")

View File

@@ -12,7 +12,7 @@ defmodule MobilizonWeb.Schema.EventType do
@desc "An event"
object :event do
field(:id, :id, description: "Internal ID for this event")
field(:id, :integer, description: "Internal ID for this event")
field(:uuid, :uuid, description: "The Event UUID")
field(:url, :string, description: "The ActivityPub Event URL")
field(:local, :boolean, description: "Whether the event is local or not")

View File

@@ -5,18 +5,34 @@ defmodule MobilizonWeb.Schema.Events.ParticipantType do
use Absinthe.Schema.Notation
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
alias MobilizonWeb.Resolvers
alias Mobilizon.Events
alias Mobilizon.Actors
@desc "Represents a participant to an event"
object :participant do
field(:event, :event,
field(
:event,
:event,
resolve: dataloader(Events),
description: "The event which the actor participates in"
)
field(:actor, :actor, description: "The actor that participates to the event")
field(
:actor,
:actor,
resolve: dataloader(Actors),
description: "The actor that participates to the event"
)
field(:role, :integer, description: "The role of this actor at this event")
end
@desc "Represents a deleted participant"
object :deleted_participant do
field(:event, :deleted_object)
field(:actor, :deleted_object)
end
object :participant_queries do
@desc "Get all participants for an event uuid"
field :participants, list_of(:participant) do
@@ -26,4 +42,22 @@ defmodule MobilizonWeb.Schema.Events.ParticipantType do
resolve(&Resolvers.Event.list_participants_for_event/3)
end
end
object :participant_mutations do
@desc "Join an event"
field :join_event, :participant do
arg(:event_id, non_null(:integer))
arg(:actor_id, non_null(:integer))
resolve(&Resolvers.Event.actor_join_event/3)
end
@desc "Leave an event"
field :leave_event, :deleted_participant do
arg(:event_id, non_null(:integer))
arg(:actor_id, non_null(:integer))
resolve(&Resolvers.Event.actor_leave_event/3)
end
end
end