2020-01-26 20:34:25 +01:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.AdminType do
|
2019-07-23 13:49:22 +02:00
|
|
|
@moduledoc """
|
2019-09-22 16:26:23 +02:00
|
|
|
Schema representation for ActionLog.
|
2019-07-23 13:49:22 +02:00
|
|
|
"""
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2019-07-23 13:49:22 +02:00
|
|
|
use Absinthe.Schema.Notation
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2020-06-11 19:13:21 +02:00
|
|
|
alias Mobilizon.Actors.Actor
|
2020-07-09 17:24:28 +02:00
|
|
|
alias Mobilizon.Discussions.Comment
|
2020-02-18 08:57:00 +01:00
|
|
|
alias Mobilizon.Events.Event
|
2019-09-22 16:26:23 +02:00
|
|
|
alias Mobilizon.Reports.{Note, Report}
|
2020-06-15 19:41:11 +02:00
|
|
|
alias Mobilizon.Users.User
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2020-01-26 20:34:25 +01:00
|
|
|
alias Mobilizon.GraphQL.Resolvers.Admin
|
2019-07-23 13:49:22 +02:00
|
|
|
|
|
|
|
@desc "An action log"
|
|
|
|
object :action_log do
|
|
|
|
field(:id, :id, description: "Internal ID for this comment")
|
|
|
|
field(:actor, :actor, description: "The actor that acted")
|
|
|
|
field(:object, :action_log_object, description: "The object that was acted upon")
|
2019-09-09 09:31:08 +02:00
|
|
|
field(:action, :action_log_action, description: "The action that was done")
|
|
|
|
field(:inserted_at, :datetime, description: "The time when the action was performed")
|
|
|
|
end
|
|
|
|
|
|
|
|
enum :action_log_action do
|
|
|
|
value(:report_update_closed)
|
|
|
|
value(:report_update_opened)
|
|
|
|
value(:report_update_resolved)
|
|
|
|
value(:note_creation)
|
|
|
|
value(:note_deletion)
|
|
|
|
value(:event_deletion)
|
2019-11-15 18:36:47 +01:00
|
|
|
value(:comment_deletion)
|
2019-09-09 09:31:08 +02:00
|
|
|
value(:event_update)
|
2020-06-11 19:13:21 +02:00
|
|
|
value(:actor_suspension)
|
|
|
|
value(:actor_unsuspension)
|
2020-06-15 19:41:11 +02:00
|
|
|
value(:user_deletion)
|
2019-07-23 13:49:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "The objects that can be in an action log"
|
|
|
|
interface :action_log_object do
|
|
|
|
field(:id, :id, description: "Internal ID for this object")
|
|
|
|
|
|
|
|
resolve_type(fn
|
|
|
|
%Report{}, _ ->
|
|
|
|
:report
|
|
|
|
|
|
|
|
%Note{}, _ ->
|
|
|
|
:report_note
|
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
%Event{}, _ ->
|
|
|
|
:event
|
|
|
|
|
2019-11-15 18:36:47 +01:00
|
|
|
%Comment{}, _ ->
|
|
|
|
:comment
|
|
|
|
|
2020-06-11 19:13:21 +02:00
|
|
|
%Actor{type: "Person"}, _ ->
|
|
|
|
:person
|
|
|
|
|
2020-06-15 19:41:11 +02:00
|
|
|
%User{}, _ ->
|
|
|
|
:user
|
|
|
|
|
2019-07-23 13:49:22 +02:00
|
|
|
_, _ ->
|
|
|
|
nil
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2020-10-07 15:37:23 +02:00
|
|
|
object :language do
|
|
|
|
field(:code, :string, description: "The iso-639-3 language code")
|
|
|
|
field(:name, :string, description: "The language name")
|
|
|
|
end
|
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
object :dashboard do
|
2020-10-15 11:04:05 +02:00
|
|
|
field(:last_public_event_published, :event, description: "Last public event published")
|
|
|
|
field(:last_group_created, :group, description: "Last public group created")
|
2019-09-09 09:31:08 +02:00
|
|
|
field(:number_of_users, :integer, description: "The number of local users")
|
|
|
|
field(:number_of_events, :integer, description: "The number of local events")
|
|
|
|
field(:number_of_comments, :integer, description: "The number of local comments")
|
2020-10-15 11:04:05 +02:00
|
|
|
field(:number_of_groups, :integer, description: "The number of local groups")
|
2019-09-09 09:31:08 +02:00
|
|
|
field(:number_of_reports, :integer, description: "The number of current opened reports")
|
2020-10-15 11:04:05 +02:00
|
|
|
field(:number_of_followers, :integer, description: "The number of instance followers")
|
|
|
|
field(:number_of_followings, :integer, description: "The number of instance followings")
|
|
|
|
|
|
|
|
field(:number_of_confirmed_participations_to_local_events, :integer,
|
|
|
|
description: "The number of total confirmed participations to local events"
|
|
|
|
)
|
2019-09-09 09:31:08 +02:00
|
|
|
end
|
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
object :admin_settings do
|
|
|
|
field(:instance_name, :string)
|
|
|
|
field(:instance_description, :string)
|
2020-06-19 19:27:10 +02:00
|
|
|
field(:instance_long_description, :string)
|
2020-10-21 17:49:18 +02:00
|
|
|
field(:instance_slogan, :string)
|
2020-06-19 19:27:10 +02:00
|
|
|
field(:contact, :string)
|
2019-12-20 13:04:34 +01:00
|
|
|
field(:instance_terms, :string)
|
|
|
|
field(:instance_terms_type, :instance_terms_type)
|
|
|
|
field(:instance_terms_url, :string)
|
2020-06-19 19:27:10 +02:00
|
|
|
field(:instance_privacy_policy, :string)
|
|
|
|
field(:instance_privacy_policy_type, :instance_privacy_type)
|
|
|
|
field(:instance_privacy_policy_url, :string)
|
2020-06-15 11:01:49 +02:00
|
|
|
field(:instance_rules, :string)
|
2019-12-20 13:04:34 +01:00
|
|
|
field(:registrations_open, :boolean)
|
2020-10-07 15:37:23 +02:00
|
|
|
field(:instance_languages, list_of(:string))
|
2019-12-20 13:04:34 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
enum :instance_terms_type do
|
|
|
|
value(:url, as: "URL")
|
|
|
|
value(:default, as: "DEFAULT")
|
|
|
|
value(:custom, as: "CUSTOM")
|
|
|
|
end
|
|
|
|
|
2020-06-19 19:27:10 +02:00
|
|
|
enum :instance_privacy_type do
|
|
|
|
value(:url, as: "URL")
|
|
|
|
value(:default, as: "DEFAULT")
|
|
|
|
value(:custom, as: "CUSTOM")
|
|
|
|
end
|
|
|
|
|
2019-07-23 13:49:22 +02:00
|
|
|
object :admin_queries do
|
|
|
|
@desc "Get the list of action logs"
|
|
|
|
field :action_logs, type: list_of(:action_log) do
|
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
|
|
|
resolve(&Admin.list_action_logs/3)
|
|
|
|
end
|
2019-09-09 09:31:08 +02:00
|
|
|
|
2020-10-07 15:37:23 +02:00
|
|
|
field :languages, type: list_of(:language) do
|
2020-11-02 11:22:54 +01:00
|
|
|
arg(:codes, list_of(:string))
|
2020-10-07 15:37:23 +02:00
|
|
|
resolve(&Admin.get_list_of_languages/3)
|
|
|
|
end
|
|
|
|
|
2019-09-09 09:31:08 +02:00
|
|
|
field :dashboard, type: :dashboard do
|
|
|
|
resolve(&Admin.get_dashboard/3)
|
|
|
|
end
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
field :admin_settings, type: :admin_settings do
|
|
|
|
resolve(&Admin.get_settings/3)
|
|
|
|
end
|
|
|
|
|
2019-12-03 11:29:51 +01:00
|
|
|
field :relay_followers, type: :paginated_follower_list do
|
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
|
|
|
resolve(&Admin.list_relay_followers/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
field :relay_followings, type: :paginated_follower_list do
|
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
|
|
|
arg(:order_by, :string, default_value: :updated_at)
|
|
|
|
arg(:direction, :string, default_value: :desc)
|
|
|
|
resolve(&Admin.list_relay_followings/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
object :admin_mutations do
|
|
|
|
@desc "Add a relay subscription"
|
|
|
|
field :add_relay, type: :follower do
|
|
|
|
arg(:address, non_null(:string))
|
|
|
|
|
|
|
|
resolve(&Admin.create_relay/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Delete a relay subscription"
|
|
|
|
field :remove_relay, type: :follower do
|
|
|
|
arg(:address, non_null(:string))
|
|
|
|
|
|
|
|
resolve(&Admin.remove_relay/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Accept a relay subscription"
|
|
|
|
field :accept_relay, type: :follower do
|
|
|
|
arg(:address, non_null(:string))
|
|
|
|
|
|
|
|
resolve(&Admin.accept_subscription/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Reject a relay subscription"
|
|
|
|
field :reject_relay, type: :follower do
|
|
|
|
arg(:address, non_null(:string))
|
|
|
|
|
|
|
|
resolve(&Admin.reject_subscription/3)
|
|
|
|
end
|
2019-12-20 13:04:34 +01:00
|
|
|
|
|
|
|
field :save_admin_settings, type: :admin_settings do
|
|
|
|
arg(:instance_name, :string)
|
|
|
|
arg(:instance_description, :string)
|
2020-06-19 19:27:10 +02:00
|
|
|
arg(:instance_long_description, :string)
|
2020-10-21 17:49:18 +02:00
|
|
|
arg(:instance_slogan, :string)
|
2020-06-19 19:27:10 +02:00
|
|
|
arg(:contact, :string)
|
2019-12-20 13:04:34 +01:00
|
|
|
arg(:instance_terms, :string)
|
|
|
|
arg(:instance_terms_type, :instance_terms_type)
|
|
|
|
arg(:instance_terms_url, :string)
|
2020-06-19 19:27:10 +02:00
|
|
|
arg(:instance_privacy_policy, :string)
|
|
|
|
arg(:instance_privacy_policy_type, :instance_privacy_type)
|
|
|
|
arg(:instance_privacy_policy_url, :string)
|
2020-06-15 11:01:49 +02:00
|
|
|
arg(:instance_rules, :string)
|
2019-12-20 13:04:34 +01:00
|
|
|
arg(:registrations_open, :boolean)
|
2020-10-07 15:37:23 +02:00
|
|
|
arg(:instance_languages, list_of(:string))
|
2019-12-20 13:04:34 +01:00
|
|
|
|
|
|
|
resolve(&Admin.save_settings/3)
|
|
|
|
end
|
2019-07-23 13:49:22 +02:00
|
|
|
end
|
|
|
|
end
|