2020-01-26 20:34:25 +01:00
|
|
|
defmodule Mobilizon.GraphQL.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
|
|
|
|
2021-05-17 11:36:28 +02:00
|
|
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1, dataloader: 2]
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2020-07-09 17:24:28 +02:00
|
|
|
alias Mobilizon.{Actors, Addresses, Discussions}
|
2023-10-17 16:41:31 +02:00
|
|
|
alias Mobilizon.GraphQL.Resolvers.{Conversation, Event, Media, Tag}
|
2020-01-26 20:34:25 +01:00
|
|
|
alias Mobilizon.GraphQL.Schema
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2020-01-26 20:34:25 +01:00
|
|
|
import_types(Schema.AddressType)
|
|
|
|
import_types(Schema.Events.ParticipantType)
|
|
|
|
import_types(Schema.TagType)
|
2019-01-14 17:13:17 +01:00
|
|
|
|
2023-03-24 12:13:42 +01:00
|
|
|
@env Application.compile_env(:mobilizon, :env)
|
|
|
|
@event_rate_limiting 60
|
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
@desc "An event"
|
|
|
|
object :event do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :all)
|
|
|
|
meta(:scope_field?, true)
|
2022-08-26 16:08:58 +02:00
|
|
|
interfaces([:action_log_object, :interactable, :activity_object, :event_search_result])
|
2019-09-09 09:31:08 +02:00
|
|
|
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")
|
2021-10-19 15:56:18 +02:00
|
|
|
field(:external_participation_url, :string, description: "External URL for participation")
|
2019-05-22 14:12:11 +02:00
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
field(:picture, :media,
|
2019-05-22 14:12:11 +02:00
|
|
|
description: "The event's picture",
|
2020-11-26 11:41:13 +01:00
|
|
|
resolve: &Media.media/3
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:media, list_of(:media),
|
|
|
|
description: "The event's media",
|
|
|
|
resolve: &Media.medias/3
|
2019-05-22 14:12:11 +02:00
|
|
|
)
|
|
|
|
|
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),
|
2020-11-19 17:06:28 +01:00
|
|
|
description: "The event's physical address"
|
2019-03-22 15:51:23 +01:00
|
|
|
)
|
|
|
|
|
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
|
|
|
|
2020-12-01 17:30:41 +01:00
|
|
|
field(:attributed_to, :actor,
|
|
|
|
resolve: dataloader(Actors),
|
|
|
|
description: "Who the event is attributed to (often a group)"
|
|
|
|
)
|
2019-02-14 14:19:55 +01:00
|
|
|
|
2021-01-25 12:00:06 +01:00
|
|
|
field(:organizer_actor, :actor,
|
|
|
|
resolve: &Event.organizer_for_event/3,
|
|
|
|
description: "The event's organizer (as a person)"
|
|
|
|
)
|
|
|
|
|
2023-03-17 18:10:59 +01:00
|
|
|
field(:tags, list_of(:tag), description: "The event's tags") do
|
|
|
|
resolve(&Tag.list_tags_for_event/3)
|
|
|
|
end
|
2019-02-14 14:19:55 +01:00
|
|
|
|
2022-03-28 17:42:59 +02:00
|
|
|
field(:category, :event_category, 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")
|
|
|
|
|
2020-06-15 19:41:11 +02:00
|
|
|
field(:participant_stats, :participant_stats,
|
|
|
|
description: "Statistics on the event",
|
|
|
|
resolve: &Event.stats_participants/3
|
|
|
|
)
|
2019-09-11 16:37:30 +02:00
|
|
|
|
2023-03-17 18:10:59 +01:00
|
|
|
field(:participants, :paginated_participant_list,
|
|
|
|
description: "The event's participants",
|
|
|
|
meta: [private: true, rule: :"read:event:participants"]
|
|
|
|
) do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:page, :integer,
|
|
|
|
default_value: 1,
|
|
|
|
description: "The page in the paginated participants list"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:limit, :integer, default_value: 10, description: "The limit of participants per page")
|
|
|
|
arg(:roles, :string, default_value: "", description: "Filter by roles")
|
2019-09-20 18:22:03 +02:00
|
|
|
resolve(&Event.list_participants_for_event/3)
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
field(:contacts, list_of(:actor), description: "The events contacts")
|
|
|
|
|
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-11-15 18:36:47 +01:00
|
|
|
field(:comments, list_of(:comment), description: "The comments in reply to the event") do
|
2021-05-17 11:36:28 +02:00
|
|
|
resolve(dataloader(Discussions, args: %{top_level: true}))
|
2019-11-15 18:36:47 +01:00
|
|
|
end
|
|
|
|
|
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")
|
2021-02-12 18:19:49 +01:00
|
|
|
field(:inserted_at, :datetime, description: "When the event was created")
|
2019-08-28 11:28:27 +02:00
|
|
|
field(:options, :event_options, description: "The event options")
|
2021-08-09 14:26:11 +02:00
|
|
|
field(:metadata, list_of(:event_metadata), description: "A key-value list of metadata")
|
2021-11-23 09:36:19 +01:00
|
|
|
field(:language, :string, description: "The event language")
|
2023-10-17 16:41:31 +02:00
|
|
|
|
|
|
|
field(:conversations, :paginated_conversation_list,
|
|
|
|
description: "The list of conversations started on this event"
|
|
|
|
) do
|
|
|
|
arg(:page, :integer,
|
|
|
|
default_value: 1,
|
|
|
|
description: "The page in the paginated conversation list"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:limit, :integer, default_value: 10, description: "The limit of conversations per page")
|
|
|
|
resolve(&Conversation.find_conversations_for_event/3)
|
|
|
|
end
|
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")
|
2021-10-19 15:56:18 +02:00
|
|
|
value(:external, description: "External registration")
|
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
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc "A paginated list of events"
|
2020-02-18 08:57:00 +01:00
|
|
|
object :paginated_event_list do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :all)
|
2020-02-18 08:57:00 +01:00
|
|
|
field(:elements, list_of(:event), description: "A list of events")
|
|
|
|
field(:total, :integer, description: "The total number of events in the list")
|
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc "Participation statistics"
|
2019-09-11 16:37:30 +02:00
|
|
|
object :participant_stats do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :all)
|
2020-06-15 19:41:11 +02:00
|
|
|
field(:going, :integer, description: "The number of approved participants")
|
2019-10-25 17:43:37 +02:00
|
|
|
field(:not_approved, :integer, description: "The number of not approved participants")
|
2019-12-20 13:04:34 +01:00
|
|
|
field(:not_confirmed, :integer, description: "The number of not confirmed participants")
|
2019-09-30 13:48:47 +02:00
|
|
|
field(:rejected, :integer, description: "The number of rejected participants")
|
2019-10-11 15:06:58 +02:00
|
|
|
|
2019-10-25 17:43:37 +02:00
|
|
|
field(:participant, :integer,
|
2019-10-11 15:06:58 +02:00
|
|
|
description: "The number of simple participants (excluding creators)"
|
|
|
|
)
|
2019-10-25 17:43:37 +02:00
|
|
|
|
|
|
|
field(:moderator, :integer, description: "The number of moderators")
|
|
|
|
field(:administrator, :integer, description: "The number of administrators")
|
|
|
|
field(:creator, :integer, description: "The number of creators")
|
2019-09-11 16:37:30 +02:00
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
An event offer
|
|
|
|
"""
|
2019-08-28 11:28:27 +02:00
|
|
|
object :event_offer do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :all)
|
2019-08-28 11:28:27 +02:00
|
|
|
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
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
An event participation condition
|
|
|
|
"""
|
2019-08-28 11:28:27 +02:00
|
|
|
object :event_participation_condition do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :all)
|
2019-08-28 11:28:27 +02:00
|
|
|
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
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
An event offer
|
|
|
|
"""
|
2019-08-28 11:28:27 +02:00
|
|
|
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
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
An event participation condition
|
|
|
|
"""
|
2019-08-28 11:28:27 +02:00
|
|
|
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
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
Event options
|
|
|
|
"""
|
2019-08-28 11:28:27 +02:00
|
|
|
object :event_options do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :all)
|
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
field(:anonymous_participation, :boolean,
|
|
|
|
description: "Whether or not to allow anonymous participation (if the server allows it)"
|
|
|
|
)
|
|
|
|
|
2023-08-17 13:18:01 +02:00
|
|
|
field(:offers, list_of(:event_offer),
|
|
|
|
description: "The list of offers to show for this event"
|
|
|
|
)
|
2019-08-28 11:28:27 +02:00
|
|
|
|
|
|
|
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"
|
|
|
|
)
|
2019-10-14 19:29:18 +02:00
|
|
|
|
2024-04-10 14:36:21 +02:00
|
|
|
field(:hide_number_of_participants, :boolean,
|
|
|
|
description: "Whether or not the number of participants is hidden"
|
|
|
|
)
|
|
|
|
|
2019-10-14 19:29:18 +02:00
|
|
|
field(:show_start_time, :boolean, description: "Show event start time")
|
|
|
|
field(:show_end_time, :boolean, description: "Show event end time")
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2023-06-05 09:12:02 +02:00
|
|
|
field(:timezone, :timezone, description: "The event's timezone")
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
field(:hide_organizer_when_group_event, :boolean,
|
|
|
|
description:
|
|
|
|
"Whether to show or hide the person organizer when event is organized by a group"
|
|
|
|
)
|
2021-10-15 15:59:49 +02:00
|
|
|
|
|
|
|
field(:is_online, :boolean, description: "Whether the event is fully online")
|
2019-08-28 11:28:27 +02:00
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
Event options
|
|
|
|
"""
|
2019-08-28 11:28:27 +02:00
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
field(:anonymous_participation, :boolean,
|
|
|
|
default_value: false,
|
|
|
|
description: "Whether or not to allow anonymous participation (if the server allows it)"
|
|
|
|
)
|
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
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"
|
|
|
|
)
|
2024-04-10 14:36:21 +02:00
|
|
|
|
|
|
|
field(:hide_number_of_participants, :boolean,
|
|
|
|
description: "Whether or not the number of participants is hidden"
|
|
|
|
)
|
2019-10-14 19:29:18 +02:00
|
|
|
|
|
|
|
field(:show_start_time, :boolean, description: "Show event start time")
|
|
|
|
field(:show_end_time, :boolean, description: "Show event end time")
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2023-06-05 09:12:02 +02:00
|
|
|
field(:timezone, :timezone, description: "The event's timezone")
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
field(:hide_organizer_when_group_event, :boolean,
|
|
|
|
description:
|
|
|
|
"Whether to show or hide the person organizer when event is organized by a group"
|
|
|
|
)
|
2021-10-15 15:59:49 +02:00
|
|
|
|
|
|
|
field(:is_online, :boolean, description: "Whether the event is fully online")
|
2019-08-28 11:28:27 +02:00
|
|
|
end
|
|
|
|
|
2021-08-09 14:26:11 +02:00
|
|
|
enum :event_metadata_type do
|
|
|
|
value(:string, description: "A string")
|
|
|
|
value(:integer, description: "An integer")
|
|
|
|
value(:boolean, description: "A boolean")
|
|
|
|
end
|
|
|
|
|
|
|
|
object :event_metadata do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :all)
|
2021-08-09 14:26:11 +02:00
|
|
|
field(:key, :string, description: "The key for the metadata")
|
|
|
|
field(:title, :string, description: "The title for the metadata")
|
|
|
|
field(:value, :string, description: "The value for the metadata")
|
|
|
|
field(:type, :event_metadata_type, description: "The metadata type")
|
|
|
|
end
|
|
|
|
|
|
|
|
input_object :event_metadata_input do
|
|
|
|
field(:key, non_null(:string), description: "The key for the metadata")
|
|
|
|
field(:title, :string, description: "The title for the metadata")
|
|
|
|
field(:value, non_null(:string), description: "The value for the metadata")
|
|
|
|
field(:type, :event_metadata_type, description: "The metadata type")
|
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
A event contact
|
|
|
|
"""
|
2020-09-29 09:53:48 +02:00
|
|
|
input_object :contact do
|
|
|
|
field(:id, :string, description: "The Contact Actor ID")
|
|
|
|
end
|
|
|
|
|
2021-03-16 19:08:00 +01:00
|
|
|
@desc "Available event sort fields"
|
|
|
|
enum :event_order_by do
|
|
|
|
value(:begins_on, description: "Sort by the date the event starts")
|
|
|
|
value(:inserted_at, description: "Sort by the date the event was created")
|
|
|
|
value(:updated_at, description: "Sort by the date the event was updated")
|
|
|
|
end
|
|
|
|
|
2019-01-25 15:41:10 +01:00
|
|
|
object :event_queries do
|
|
|
|
@desc "Get all events"
|
2020-12-09 17:55:38 +01:00
|
|
|
field :events, :paginated_event_list do
|
2024-07-08 23:44:22 +02:00
|
|
|
arg(:location, :string, default_value: nil, description: "A geohash for coordinates")
|
|
|
|
|
|
|
|
arg(:radius, :float,
|
|
|
|
default_value: nil,
|
|
|
|
description: "Radius around the location to search in"
|
|
|
|
)
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:page, :integer, default_value: 1, description: "The page in the paginated event list")
|
|
|
|
arg(:limit, :integer, default_value: 10, description: "The limit of events per page")
|
2021-03-16 19:08:00 +01:00
|
|
|
|
|
|
|
arg(:order_by, :event_order_by,
|
|
|
|
default_value: :begins_on,
|
|
|
|
description: "Order the list of events by field"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:direction, :sort_direction,
|
|
|
|
default_value: :asc,
|
|
|
|
description: "Direction for the sort"
|
|
|
|
)
|
|
|
|
|
2024-07-08 23:44:22 +02:00
|
|
|
arg(:longevents, :boolean,
|
|
|
|
default_value: nil,
|
|
|
|
description: "if mention filter in or out long events"
|
|
|
|
)
|
|
|
|
|
2023-03-17 18:10:59 +01:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :all)
|
|
|
|
|
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
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:uuid, non_null(:uuid), description: "The event's UUID")
|
2023-03-17 18:10:59 +01:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :all)
|
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
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:title, non_null(:string), description: "The event's title")
|
|
|
|
arg(:description, non_null(:string), description: "The event's description")
|
|
|
|
arg(:begins_on, non_null(:datetime), description: "Datetime for when the event begins")
|
|
|
|
arg(:ends_on, :datetime, description: "Datetime for when the event ends")
|
|
|
|
arg(:status, :event_status, description: "Status of the event")
|
|
|
|
|
|
|
|
arg(:visibility, :event_visibility,
|
|
|
|
default_value: :public,
|
|
|
|
description: "The event's visibility"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:join_options, :event_join_options,
|
|
|
|
default_value: :free,
|
|
|
|
description: "The event's options to join"
|
|
|
|
)
|
2019-05-22 14:12:11 +02:00
|
|
|
|
2021-10-19 15:56:18 +02:00
|
|
|
arg(:external_participation_url, :string, description: "External URL for participation")
|
|
|
|
|
2019-07-26 11:30:28 +02:00
|
|
|
arg(:tags, list_of(:string),
|
|
|
|
default_value: [],
|
|
|
|
description: "The list of tags associated to the event"
|
|
|
|
)
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
arg(:picture, :media_input,
|
2019-05-22 14:12:11 +02:00
|
|
|
description:
|
2020-11-26 11:41:13 +01:00
|
|
|
"The picture for the event, either as an object or directly the ID of an existing media"
|
2019-05-22 14:12:11 +02:00
|
|
|
)
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:publish_at, :datetime, description: "Datetime when the event was published")
|
|
|
|
arg(:online_address, :string, description: "Online address of the event")
|
|
|
|
arg(:phone_address, :string, description: "Phone address for the event")
|
|
|
|
|
|
|
|
arg(:organizer_actor_id, non_null(:id),
|
|
|
|
description: "The event's organizer ID (as a person)"
|
|
|
|
)
|
|
|
|
|
2023-08-17 13:18:01 +02:00
|
|
|
arg(:attributed_to_id, :id,
|
|
|
|
description: "Who the event is attributed to ID (often a group)"
|
|
|
|
)
|
2020-11-19 17:06:28 +01:00
|
|
|
|
2022-03-28 17:42:59 +02:00
|
|
|
arg(:category, :event_category,
|
|
|
|
default_value: "MEETING",
|
|
|
|
description: "The event's category"
|
|
|
|
)
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:physical_address, :address_input, description: "The event's physical address")
|
2021-10-10 16:25:50 +02:00
|
|
|
arg(:options, :event_options_input, default_value: %{}, description: "The event options")
|
2021-08-09 14:26:11 +02:00
|
|
|
arg(:metadata, list_of(:event_metadata_input), description: "The event metadata")
|
2020-11-19 17:06:28 +01:00
|
|
|
|
|
|
|
arg(:draft, :boolean,
|
|
|
|
default_value: false,
|
|
|
|
description: "Whether or not the event is a draft"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:contacts, list_of(:contact), default_value: [], description: "The events contacts")
|
2021-08-19 20:43:35 +02:00
|
|
|
arg(:language, :string, description: "The event language", default_value: "und")
|
2019-01-25 15:41:10 +01:00
|
|
|
|
2023-03-17 18:10:59 +01:00
|
|
|
middleware(Rajska.QueryAuthorization,
|
|
|
|
permit: :user,
|
|
|
|
scope: Mobilizon.Events.Event,
|
|
|
|
rule: :"write:event:create",
|
|
|
|
args: %{organizer_actor_id: :organizer_actor_id}
|
|
|
|
)
|
|
|
|
|
2023-03-24 12:13:42 +01:00
|
|
|
middleware(Rajska.RateLimiter, limit: event_rate_limiting(@env))
|
|
|
|
|
2020-10-01 15:07:15 +02:00
|
|
|
resolve(&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
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:event_id, non_null(:id), description: "The event's ID")
|
2019-09-02 17:23:00 +02:00
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:title, :string, description: "The event's title")
|
|
|
|
arg(:description, :string, description: "The event's description")
|
|
|
|
arg(:begins_on, :datetime, description: "Datetime for when the event begins")
|
|
|
|
arg(:ends_on, :datetime, description: "Datetime for when the event ends")
|
|
|
|
arg(:status, :event_status, description: "Status of the event")
|
|
|
|
|
|
|
|
arg(:visibility, :event_visibility,
|
|
|
|
default_value: :public,
|
|
|
|
description: "The event's visibility"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:join_options, :event_join_options,
|
|
|
|
default_value: :free,
|
|
|
|
description: "The event's options to join"
|
|
|
|
)
|
2019-09-02 17:23:00 +02:00
|
|
|
|
2021-10-19 15:56:18 +02:00
|
|
|
arg(:external_participation_url, :string, description: "External URL for participation")
|
|
|
|
|
2019-09-02 17:23:00 +02:00
|
|
|
arg(:tags, list_of(:string), description: "The list of tags associated to the event")
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
arg(:picture, :media_input,
|
2019-09-02 17:23:00 +02:00
|
|
|
description:
|
2020-11-26 11:41:13 +01:00
|
|
|
"The picture for the event, either as an object or directly the ID of an existing media"
|
2019-09-02 17:23:00 +02:00
|
|
|
)
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:online_address, :string, description: "Online address of the event")
|
|
|
|
arg(:phone_address, :string, description: "Phone address for the event")
|
|
|
|
arg(:organizer_actor_id, :id, description: "The event's organizer ID (as a person)")
|
|
|
|
|
2023-08-17 13:18:01 +02:00
|
|
|
arg(:attributed_to_id, :id,
|
|
|
|
description: "Who the event is attributed to ID (often a group)"
|
|
|
|
)
|
2020-11-19 17:06:28 +01:00
|
|
|
|
2022-03-28 17:42:59 +02:00
|
|
|
arg(:category, :event_category, description: "The event's category")
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:physical_address, :address_input, description: "The event's physical address")
|
|
|
|
arg(:options, :event_options_input, description: "The event options")
|
2021-08-09 14:26:11 +02:00
|
|
|
arg(:metadata, list_of(:event_metadata_input), description: "The event metadata")
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:draft, :boolean, description: "Whether or not the event is a draft")
|
|
|
|
arg(:contacts, list_of(:contact), default_value: [], description: "The events contacts")
|
2021-08-19 20:43:35 +02:00
|
|
|
arg(:language, :string, description: "The event language", default_value: "und")
|
2019-09-02 17:23:00 +02:00
|
|
|
|
2023-03-17 18:10:59 +01:00
|
|
|
middleware(Rajska.QueryAuthorization,
|
|
|
|
permit: :user,
|
|
|
|
scope: Mobilizon.Events.Event,
|
|
|
|
args: %{id: :event_id},
|
|
|
|
rule: :"write:event:update"
|
|
|
|
)
|
|
|
|
|
2020-10-01 15:07:15 +02:00
|
|
|
resolve(&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
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:event_id, non_null(:id), description: "The event ID to delete")
|
2019-01-25 15:41:10 +01:00
|
|
|
|
2023-03-17 18:10:59 +01:00
|
|
|
middleware(Rajska.QueryAuthorization,
|
|
|
|
permit: [:user, :moderator, :administrator],
|
|
|
|
scope: Mobilizon.Events.Event,
|
|
|
|
rule: :"write:event:delete",
|
|
|
|
args: %{id: :event_id}
|
|
|
|
)
|
|
|
|
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve(&Event.delete_event/3)
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
|
|
|
end
|
2023-03-24 12:13:42 +01:00
|
|
|
|
|
|
|
defp event_rate_limiting(:test), do: @event_rate_limiting * 1000
|
|
|
|
defp event_rate_limiting(_), do: @event_rate_limiting
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|