Add anonymous and remote participations

This commit is contained in:
Thomas Citharel
2019-12-20 13:04:34 +01:00
parent 17e0b3968f
commit 2ed9050a90
135 changed files with 10141 additions and 2271 deletions

View File

@@ -60,6 +60,21 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
field(:number_of_reports, :integer, description: "The number of current opened reports")
end
object :admin_settings do
field(:instance_name, :string)
field(:instance_description, :string)
field(:instance_terms, :string)
field(:instance_terms_type, :instance_terms_type)
field(:instance_terms_url, :string)
field(:registrations_open, :boolean)
end
enum :instance_terms_type do
value(:url, as: "URL")
value(:default, as: "DEFAULT")
value(:custom, as: "CUSTOM")
end
object :admin_queries do
@desc "Get the list of action logs"
field :action_logs, type: list_of(:action_log) do
@@ -72,6 +87,10 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
resolve(&Admin.get_dashboard/3)
end
field :admin_settings, type: :admin_settings do
resolve(&Admin.get_settings/3)
end
field :relay_followers, type: :paginated_follower_list do
arg(:page, :integer, default_value: 1)
arg(:limit, :integer, default_value: 10)
@@ -115,5 +134,16 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
resolve(&Admin.reject_subscription/3)
end
field :save_admin_settings, type: :admin_settings do
arg(:instance_name, :string)
arg(:instance_description, :string)
arg(:instance_terms, :string)
arg(:instance_terms_type, :instance_terms_type)
arg(:instance_terms_url, :string)
arg(:registrations_open, :boolean)
resolve(&Admin.save_settings/3)
end
end
end

View File

@@ -19,6 +19,18 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
field(:location, :lonlat)
field(:geocoding, :geocoding)
field(:maps, :maps)
field(:anonymous, :anonymous)
field(:terms, :terms, description: "The instance's terms") do
arg(:locale, :string, default_value: "en")
resolve(&Config.terms/3)
end
end
object :terms do
field(:url, :string)
field(:type, :instance_terms_type)
field(:body_html, :string)
end
object :lonlat do
@@ -41,6 +53,50 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
field(:attribution, :string)
end
object :anonymous do
field(:participation, :anonymous_participation)
field(:event_creation, :anonymous_event_creation)
field(:actor_id, :id)
end
object :anonymous_participation do
field(:allowed, :boolean)
field(:validation, :anonymous_participation_validation)
end
object :anonymous_participation_validation do
field(:email, :anonymous_participation_validation_email)
field(:captcha, :anonymous_participation_validation_captcha)
end
object :anonymous_participation_validation_email do
field(:enabled, :boolean)
field(:confirmation_required, :boolean)
end
object :anonymous_participation_validation_captcha do
field(:enabled, :boolean)
end
object :anonymous_event_creation do
field(:allowed, :boolean)
field(:validation, :anonymous_event_creation_validation)
end
object :anonymous_event_creation_validation do
field(:email, :anonymous_event_creation_validation_email)
field(:captcha, :anonymous_event_creation_validation_captcha)
end
object :anonymous_event_creation_validation_email do
field(:enabled, :boolean)
field(:confirmation_required, :boolean)
end
object :anonymous_event_creation_validation_captcha do
field(:enabled, :boolean)
end
object :config_queries do
@desc "Get the instance config"
field :config, :config do

View File

@@ -122,6 +122,7 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
)
field(:not_approved, :integer, description: "The number of not approved participants")
field(:not_confirmed, :integer, description: "The number of not confirmed participants")
field(:rejected, :integer, description: "The number of rejected participants")
field(:participant, :integer,
@@ -177,6 +178,10 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
description: "Whether or not to show the number of remaining seats for this event"
)
field(:anonymous_participation, :boolean,
description: "Whether or not to allow anonymous participation (if the server allows it)"
)
field(:offers, list_of(:event_offer), description: "The list of offers to show for this event")
field(:participation_conditions, list_of(:event_participation_condition),
@@ -211,6 +216,11 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
description: "Whether or not to show the number of remaining seats for this event"
)
field(:anonymous_participation, :boolean,
default_value: false,
description: "Whether or not to allow anonymous participation (if the server allows it)"
)
field(:offers, list_of(:event_offer_input),
description: "The list of offers to show for this event"
)

View File

@@ -8,7 +8,7 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
alias Mobilizon.{Actors, Events}
alias Mobilizon.GraphQL.Resolvers.Event
alias Mobilizon.GraphQL.Resolvers.Participant
@desc "Represents a participant to an event"
object :participant do
@@ -29,10 +29,21 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
)
field(:role, :participant_role_enum, description: "The role of this actor at this event")
field(:metadata, :participant_metadata,
description: "The metadata associated to this participant"
)
end
object :participant_metadata do
field(:cancellation_token, :string,
description: "The eventual token to leave an event when user is anonymous"
)
end
enum :participant_role_enum do
value(:not_approved)
value(:not_confirmed)
value(:participant)
value(:moderator)
value(:administrator)
@@ -52,16 +63,18 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
field :join_event, :participant do
arg(:event_id, non_null(:id))
arg(:actor_id, non_null(:id))
arg(:email, :string)
resolve(&Event.actor_join_event/3)
resolve(&Participant.actor_join_event/3)
end
@desc "Leave an event"
field :leave_event, :deleted_participant do
arg(:event_id, non_null(:id))
arg(:actor_id, non_null(:id))
arg(:token, :string)
resolve(&Event.actor_leave_event/3)
resolve(&Participant.actor_leave_event/3)
end
@desc "Accept a participation"
@@ -70,7 +83,13 @@ defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
arg(:role, non_null(:participant_role_enum))
arg(:moderator_actor_id, non_null(:id))
resolve(&Event.update_participation/3)
resolve(&Participant.update_participation/3)
end
@desc "Confirm a participation"
field :confirm_participation, :participant do
arg(:confirmation_token, non_null(:string))
resolve(&Participant.confirm_participation_from_token/3)
end
end
end