2019-01-14 17:13:17 +01:00
|
|
|
defmodule MobilizonWeb.Schema.EventType do
|
2019-01-14 17:48:08 +01:00
|
|
|
@moduledoc """
|
2019-09-22 16:26:23 +02:00
|
|
|
Schema representation for Event.
|
2019-01-14 17:48:08 +01:00
|
|
|
"""
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
use Absinthe.Schema.Notation
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
2019-10-02 17:59:07 +02:00
|
|
|
import MobilizonWeb.Schema.Utils
|
2019-09-22 16:26:23 +02:00
|
|
|
|
|
|
|
alias Mobilizon.{Actors, Addresses}
|
|
|
|
|
|
|
|
alias MobilizonWeb.Resolvers.{Event, Picture, Tag}
|
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
import_types(MobilizonWeb.Schema.AddressType)
|
|
|
|
import_types(MobilizonWeb.Schema.Events.ParticipantType)
|
2019-02-14 14:19:55 +01:00
|
|
|
import_types(MobilizonWeb.Schema.TagType)
|
2019-01-14 17:13:17 +01:00
|
|
|
|
|
|
|
@desc "An event"
|
|
|
|
object :event do
|
2019-09-09 09:31:08 +02:00
|
|
|
interfaces([:action_log_object])
|
|
|
|
field(:id, :id, description: "Internal ID for this event")
|
2019-01-14 17:13:17 +01:00
|
|
|
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")
|
|
|
|
field(:title, :string, description: "The event's title")
|
2019-04-11 14:45:31 +02:00
|
|
|
field(:slug, :string, description: "The event's description's slug")
|
2019-01-14 17:13:17 +01:00
|
|
|
field(:description, :string, description: "The event's description")
|
|
|
|
field(:begins_on, :datetime, description: "Datetime for when the event begins")
|
|
|
|
field(:ends_on, :datetime, description: "Datetime for when the event ends")
|
2019-01-14 17:48:08 +01:00
|
|
|
field(:status, :event_status, description: "Status of the event")
|
2019-09-20 18:22:03 +02:00
|
|
|
field(:visibility, :event_visibility, description: "The event's visibility")
|
|
|
|
field(:join_options, :event_join_options, description: "The event's visibility")
|
2019-05-22 14:12:11 +02:00
|
|
|
|
|
|
|
field(:picture, :picture,
|
|
|
|
description: "The event's picture",
|
|
|
|
resolve: &Picture.picture/3
|
|
|
|
)
|
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
field(:publish_at, :datetime, description: "When the event was published")
|
2019-03-22 15:51:23 +01:00
|
|
|
|
|
|
|
field(:physical_address, :address,
|
|
|
|
resolve: dataloader(Addresses),
|
|
|
|
description: "The type of the event's address"
|
|
|
|
)
|
|
|
|
|
2019-09-09 11:21:42 +02:00
|
|
|
field(:online_address, :string, description: "Online address of the event")
|
|
|
|
field(:phone_address, :string, description: "Phone address for the event")
|
2019-01-14 17:13:17 +01:00
|
|
|
|
2019-01-21 15:08:22 +01:00
|
|
|
field(:organizer_actor, :actor,
|
2019-01-14 17:13:17 +01:00
|
|
|
resolve: dataloader(Actors),
|
|
|
|
description: "The event's organizer (as a person)"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:attributed_to, :actor, description: "Who the event is attributed to (often a group)")
|
2019-02-14 14:19:55 +01:00
|
|
|
|
|
|
|
field(:tags, list_of(:tag),
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve: &Tag.list_tags_for_event/3,
|
2019-02-14 14:19:55 +01:00
|
|
|
description: "The event's tags"
|
|
|
|
)
|
|
|
|
|
2019-02-22 16:54:01 +01:00
|
|
|
field(:category, :string, description: "The event's category")
|
2019-01-14 17:13:17 +01:00
|
|
|
|
2019-10-02 17:59:07 +02:00
|
|
|
field(:draft, :boolean, description: "Whether or not the event is a draft")
|
|
|
|
|
2019-09-11 16:37:30 +02:00
|
|
|
field(:participant_stats, :participant_stats, resolve: &Event.stats_participants_for_event/3)
|
|
|
|
|
2019-09-20 18:22:03 +02:00
|
|
|
field(:participants, list_of(:participant), description: "The event's participants") do
|
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
|
|
|
arg(:roles, :string, default_value: "")
|
2019-09-26 16:38:58 +02:00
|
|
|
arg(:actor_id, :id)
|
2019-09-20 18:22:03 +02:00
|
|
|
resolve(&Event.list_participants_for_event/3)
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
|
2019-04-11 18:25:32 +02:00
|
|
|
field(:related_events, list_of(:event),
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve: &Event.list_related_events/3,
|
2019-04-11 18:25:32 +02:00
|
|
|
description: "Events related to this one"
|
|
|
|
)
|
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
# field(:tracks, list_of(:track))
|
|
|
|
# field(:sessions, list_of(:session))
|
|
|
|
|
|
|
|
field(:updated_at, :datetime, description: "When the event was last updated")
|
|
|
|
field(:created_at, :datetime, description: "When the event was created")
|
2019-08-28 11:28:27 +02:00
|
|
|
field(:options, :event_options, description: "The event options")
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|
2019-01-14 17:48:08 +01:00
|
|
|
|
|
|
|
@desc "The list of visibility options for an event"
|
|
|
|
enum :event_visibility do
|
2019-09-02 10:50:00 +02:00
|
|
|
value(:public, description: "Publicly listed and federated. Can be shared.")
|
2019-01-14 17:48:08 +01:00
|
|
|
value(:unlisted, description: "Visible only to people with the link - or invited")
|
2019-09-20 18:22:03 +02:00
|
|
|
value(:restricted, description: "Visible only after a moderator accepted")
|
2019-01-14 17:48:08 +01:00
|
|
|
|
|
|
|
value(:private,
|
|
|
|
description: "Visible only to people members of the group or followers of the person"
|
|
|
|
)
|
2019-09-20 18:22:03 +02:00
|
|
|
end
|
2019-01-14 17:48:08 +01:00
|
|
|
|
2019-09-20 18:22:03 +02:00
|
|
|
@desc "The list of join options for an event"
|
|
|
|
enum :event_join_options do
|
|
|
|
value(:free, description: "Anyone can join and is automatically accepted")
|
|
|
|
value(:restricted, description: "Manual acceptation")
|
|
|
|
value(:invite, description: "Participants must be invited")
|
2019-01-14 17:48:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "The list of possible options for the event's status"
|
|
|
|
enum :event_status do
|
|
|
|
value(:tentative, description: "The event is tentative")
|
|
|
|
value(:confirmed, description: "The event is confirmed")
|
|
|
|
value(:cancelled, description: "The event is cancelled")
|
|
|
|
end
|
2019-01-25 15:41:10 +01:00
|
|
|
|
2019-09-11 16:37:30 +02:00
|
|
|
object :participant_stats do
|
|
|
|
field(:approved, :integer, description: "The number of approved participants")
|
|
|
|
field(:unapproved, :integer, description: "The number of unapproved participants")
|
2019-09-30 13:48:47 +02:00
|
|
|
field(:rejected, :integer, description: "The number of rejected participants")
|
2019-10-11 11:54:57 +02:00
|
|
|
field(:participants, :integer, description: "The number of simple participants (excluding creators)")
|
2019-09-11 16:37:30 +02:00
|
|
|
end
|
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
object :event_offer do
|
|
|
|
field(:price, :float, description: "The price amount for this offer")
|
|
|
|
field(:price_currency, :string, description: "The currency for this price offer")
|
|
|
|
field(:url, :string, description: "The URL to access to this offer")
|
|
|
|
end
|
|
|
|
|
|
|
|
object :event_participation_condition do
|
|
|
|
field(:title, :string, description: "The title for this condition")
|
|
|
|
field(:content, :string, description: "The content for this condition")
|
|
|
|
field(:url, :string, description: "The URL to access this condition")
|
|
|
|
end
|
|
|
|
|
|
|
|
input_object :event_offer_input do
|
|
|
|
field(:price, :float, description: "The price amount for this offer")
|
|
|
|
field(:price_currency, :string, description: "The currency for this price offer")
|
|
|
|
field(:url, :string, description: "The URL to access to this offer")
|
|
|
|
end
|
|
|
|
|
|
|
|
input_object :event_participation_condition_input do
|
|
|
|
field(:title, :string, description: "The title for this condition")
|
|
|
|
field(:content, :string, description: "The content for this condition")
|
|
|
|
field(:url, :string, description: "The URL to access this condition")
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "The list of possible options for the event's status"
|
|
|
|
enum :event_comment_moderation do
|
|
|
|
value(:allow_all, description: "Anyone can comment under the event")
|
|
|
|
value(:moderated, description: "Every comment has to be moderated by the admin")
|
|
|
|
value(:closed, description: "No one can comment except for the admin")
|
|
|
|
end
|
|
|
|
|
|
|
|
object :event_options do
|
|
|
|
field(:maximum_attendee_capacity, :integer,
|
|
|
|
description: "The maximum attendee capacity for this event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:remaining_attendee_capacity, :integer,
|
|
|
|
description: "The number of remaining seats for this event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:show_remaining_attendee_capacity, :boolean,
|
|
|
|
description: "Whether or not to show the number of remaining seats for this event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:offers, list_of(:event_offer), description: "The list of offers to show for this event")
|
|
|
|
|
|
|
|
field(:participation_conditions, list_of(:event_participation_condition),
|
|
|
|
description: "The list of participation conditions to accept to join this event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:attendees, list_of(:string), description: "The list of special attendees")
|
|
|
|
field(:program, :string, description: "The list of the event")
|
|
|
|
|
|
|
|
field(:comment_moderation, :event_comment_moderation,
|
|
|
|
description: "The policy on public comment moderation under the event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:show_participation_price, :boolean,
|
|
|
|
description: "Whether or not to show the participation price"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
input_object :event_options_input do
|
|
|
|
field(:maximum_attendee_capacity, :integer,
|
|
|
|
description: "The maximum attendee capacity for this event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:remaining_attendee_capacity, :integer,
|
|
|
|
description: "The number of remaining seats for this event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:show_remaining_attendee_capacity, :boolean,
|
|
|
|
description: "Whether or not to show the number of remaining seats for this event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:offers, list_of(:event_offer_input),
|
|
|
|
description: "The list of offers to show for this event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:participation_conditions, list_of(:event_participation_condition_input),
|
|
|
|
description: "The list of participation conditions to accept to join this event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:attendees, list_of(:string), description: "The list of special attendees")
|
|
|
|
field(:program, :string, description: "The list of the event")
|
|
|
|
|
|
|
|
field(:comment_moderation, :event_comment_moderation,
|
|
|
|
description: "The policy on public comment moderation under the event"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:show_participation_price, :boolean,
|
|
|
|
description: "Whether or not to show the participation price"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2019-01-25 15:41:10 +01:00
|
|
|
object :event_queries do
|
|
|
|
@desc "Get all events"
|
|
|
|
field :events, list_of(:event) do
|
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve(&Event.list_events/3)
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Get an event by uuid"
|
|
|
|
field :event, :event do
|
|
|
|
arg(:uuid, non_null(:uuid))
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve(&Event.find_event/3)
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
object :event_mutations do
|
|
|
|
@desc "Create an event"
|
|
|
|
field :create_event, type: :event do
|
|
|
|
arg(:title, non_null(:string))
|
|
|
|
arg(:description, non_null(:string))
|
|
|
|
arg(:begins_on, non_null(:datetime))
|
|
|
|
arg(:ends_on, :datetime)
|
2019-09-09 11:21:42 +02:00
|
|
|
arg(:status, :event_status)
|
2019-09-22 11:22:16 +02:00
|
|
|
arg(:visibility, :event_visibility, default_value: :public)
|
2019-09-20 18:22:03 +02:00
|
|
|
arg(:join_options, :event_join_options, default_value: :free)
|
2019-05-22 14:12:11 +02:00
|
|
|
|
2019-07-26 11:30:28 +02:00
|
|
|
arg(:tags, list_of(:string),
|
|
|
|
default_value: [],
|
|
|
|
description: "The list of tags associated to the event"
|
|
|
|
)
|
|
|
|
|
2019-05-22 14:12:11 +02:00
|
|
|
arg(:picture, :picture_input,
|
|
|
|
description:
|
|
|
|
"The picture for the event, either as an object or directly the ID of an existing Picture"
|
|
|
|
)
|
|
|
|
|
2019-01-25 15:41:10 +01:00
|
|
|
arg(:publish_at, :datetime)
|
|
|
|
arg(:online_address, :string)
|
|
|
|
arg(:phone_address, :string)
|
|
|
|
arg(:organizer_actor_id, non_null(:id))
|
2019-08-28 11:28:27 +02:00
|
|
|
arg(:category, :string, default_value: "meeting")
|
2019-07-30 10:35:29 +02:00
|
|
|
arg(:physical_address, :address_input)
|
2019-09-04 18:24:31 +02:00
|
|
|
arg(:options, :event_options_input)
|
2019-10-02 17:59:07 +02:00
|
|
|
arg(:draft, :boolean, default_value: false)
|
2019-01-25 15:41:10 +01:00
|
|
|
|
2019-10-02 17:59:07 +02:00
|
|
|
resolve(handle_errors(&Event.create_event/3))
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
|
|
|
|
2019-09-02 17:23:00 +02:00
|
|
|
@desc "Update an event"
|
|
|
|
field :update_event, type: :event do
|
2019-09-04 18:24:31 +02:00
|
|
|
arg(:event_id, non_null(:id))
|
2019-09-02 17:23:00 +02:00
|
|
|
|
|
|
|
arg(:title, :string)
|
|
|
|
arg(:description, :string)
|
|
|
|
arg(:begins_on, :datetime)
|
|
|
|
arg(:ends_on, :datetime)
|
2019-09-09 11:21:42 +02:00
|
|
|
arg(:status, :event_status)
|
2019-09-22 11:22:16 +02:00
|
|
|
arg(:visibility, :event_visibility, default_value: :public)
|
|
|
|
arg(:join_options, :event_join_options, default_value: :free)
|
2019-09-02 17:23:00 +02:00
|
|
|
|
|
|
|
arg(:tags, list_of(:string), description: "The list of tags associated to the event")
|
|
|
|
|
|
|
|
arg(:picture, :picture_input,
|
|
|
|
description:
|
|
|
|
"The picture for the event, either as an object or directly the ID of an existing Picture"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:online_address, :string)
|
|
|
|
arg(:phone_address, :string)
|
|
|
|
arg(:category, :string)
|
|
|
|
arg(:physical_address, :address_input)
|
2019-09-04 18:24:31 +02:00
|
|
|
arg(:options, :event_options_input)
|
2019-10-02 17:59:07 +02:00
|
|
|
arg(:draft, :boolean)
|
2019-09-02 17:23:00 +02:00
|
|
|
|
2019-10-02 17:59:07 +02:00
|
|
|
resolve(handle_errors(&Event.update_event/3))
|
2019-09-02 17:23:00 +02:00
|
|
|
end
|
|
|
|
|
2019-01-25 15:41:10 +01:00
|
|
|
@desc "Delete an event"
|
|
|
|
field :delete_event, :deleted_object do
|
2019-09-09 09:31:08 +02:00
|
|
|
arg(:event_id, non_null(:id))
|
|
|
|
arg(:actor_id, non_null(:id))
|
2019-01-25 15:41:10 +01:00
|
|
|
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve(&Event.delete_event/3)
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|