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
|
|
|
|
|
2021-04-27 17:53:11 +02:00
|
|
|
@desc """
|
|
|
|
A paginated list of action logs
|
|
|
|
"""
|
|
|
|
object :paginated_action_log_list do
|
|
|
|
field(:elements, list_of(:action_log), description: "A list of action logs")
|
|
|
|
field(:total, :integer, description: "The total number of action logs in the list")
|
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
The different types of action log actions
|
|
|
|
"""
|
2019-09-09 09:31:08 +02:00
|
|
|
enum :action_log_action do
|
2020-11-19 17:06:28 +01:00
|
|
|
value(:report_update_closed, description: "The report was closed")
|
|
|
|
value(:report_update_opened, description: "The report was opened")
|
|
|
|
value(:report_update_resolved, description: "The report was resolved")
|
|
|
|
value(:note_creation, description: "A note was created on a report")
|
|
|
|
value(:note_deletion, description: "A note was deleted on a report")
|
|
|
|
value(:event_deletion, description: "An event was deleted")
|
|
|
|
value(:comment_deletion, description: "A comment was deleted")
|
|
|
|
value(:event_update, description: "An event was updated")
|
|
|
|
value(:actor_suspension, description: "An actor was suspended")
|
|
|
|
value(:actor_unsuspension, description: "An actor was unsuspended")
|
|
|
|
value(:user_deletion, description: "An user was deleted")
|
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
|
|
|
|
|
2021-11-04 18:34:43 +01:00
|
|
|
%Actor{type: :Person}, _ ->
|
2020-06-11 19:13:21 +02:00
|
|
|
:person
|
|
|
|
|
2020-06-15 19:41:11 +02:00
|
|
|
%User{}, _ ->
|
|
|
|
:user
|
|
|
|
|
2021-11-04 18:34:43 +01:00
|
|
|
%Actor{type: :Group}, _ ->
|
2021-04-27 16:51:28 +02:00
|
|
|
:group
|
|
|
|
|
2019-07-23 13:49:22 +02:00
|
|
|
_, _ ->
|
|
|
|
nil
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
Language information
|
|
|
|
"""
|
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
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
Dashboard information
|
|
|
|
"""
|
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
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
Admin settings
|
|
|
|
"""
|
2019-12-20 13:04:34 +01:00
|
|
|
object :admin_settings do
|
2020-11-19 17:06:28 +01:00
|
|
|
field(:instance_name, :string, description: "The instance's name")
|
|
|
|
field(:instance_description, :string, description: "The instance's description")
|
|
|
|
field(:instance_long_description, :string, description: "The instance's long description")
|
|
|
|
field(:instance_slogan, :string, description: "The instance's slogan")
|
|
|
|
field(:contact, :string, description: "The instance's contact details")
|
|
|
|
field(:instance_terms, :string, description: "The instance's terms body text")
|
|
|
|
field(:instance_terms_type, :instance_terms_type, description: "The instance's terms type")
|
|
|
|
field(:instance_terms_url, :string, description: "The instance's terms URL")
|
|
|
|
|
|
|
|
field(:instance_privacy_policy, :string,
|
|
|
|
description: "The instance's privacy policy body text"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:instance_privacy_policy_type, :instance_privacy_type,
|
|
|
|
description: "The instance's privacy policy type"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:instance_privacy_policy_url, :string, description: "The instance's privacy policy URL")
|
|
|
|
field(:instance_rules, :string, description: "The instance's rules")
|
|
|
|
field(:registrations_open, :boolean, description: "Whether the registrations are opened")
|
|
|
|
field(:instance_languages, list_of(:string), description: "The instance's languages")
|
2019-12-20 13:04:34 +01:00
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc "The acceptable values for the instance's terms type"
|
2019-12-20 13:04:34 +01:00
|
|
|
enum :instance_terms_type do
|
2020-11-19 17:06:28 +01:00
|
|
|
value(:url, as: "URL", description: "An URL. Users will be redirected to this URL.")
|
|
|
|
value(:default, as: "DEFAULT", description: "Terms will be set to Mobilizon's default terms")
|
|
|
|
value(:custom, as: "CUSTOM", description: "Custom terms text")
|
2019-12-20 13:04:34 +01:00
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
The acceptable values for the instance privacy policy type
|
|
|
|
"""
|
2020-06-19 19:27:10 +02:00
|
|
|
enum :instance_privacy_type do
|
2020-11-19 17:06:28 +01:00
|
|
|
value(:url, as: "URL", description: "An URL. Users will be redirected to this URL.")
|
|
|
|
|
|
|
|
value(:default,
|
|
|
|
as: "DEFAULT",
|
|
|
|
description: "Privacy policy will be set to Mobilizon's default privacy policy"
|
|
|
|
)
|
|
|
|
|
|
|
|
value(:custom, as: "CUSTOM", description: "Custom privacy policy text")
|
2020-06-19 19:27:10 +02:00
|
|
|
end
|
|
|
|
|
2021-12-28 11:42:08 +01:00
|
|
|
enum :instance_follow_status do
|
|
|
|
value(:approved, description: "The instance follow was approved")
|
|
|
|
value(:pending, description: "The instance follow is still pending")
|
|
|
|
value(:none, description: "There's no instance follow etablished")
|
|
|
|
end
|
|
|
|
|
|
|
|
enum :instances_sort_fields do
|
|
|
|
value(:event_count)
|
|
|
|
value(:person_count)
|
|
|
|
value(:group_count)
|
|
|
|
value(:followers_count)
|
|
|
|
value(:followings_count)
|
|
|
|
value(:reports_count)
|
|
|
|
value(:media_size)
|
|
|
|
end
|
|
|
|
|
|
|
|
enum :instance_filter_follow_status do
|
|
|
|
value(:all)
|
|
|
|
value(:following)
|
|
|
|
value(:followed)
|
|
|
|
end
|
|
|
|
|
|
|
|
enum :instance_filter_suspend_status do
|
|
|
|
value(:all)
|
|
|
|
value(:suspended)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
An instance representation
|
|
|
|
"""
|
|
|
|
object :instance do
|
|
|
|
field(:domain, :id, description: "The domain name of the instance")
|
|
|
|
field(:follower_status, :instance_follow_status, description: "Do we follow this instance")
|
|
|
|
field(:followed_status, :instance_follow_status, description: "Does this instance follow us?")
|
|
|
|
|
|
|
|
field(:event_count, :integer, description: "The number of events on this instance we know of")
|
|
|
|
|
|
|
|
field(:person_count, :integer,
|
|
|
|
description: "The number of profiles on this instance we know of"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:group_count, :integer, description: "The number of grouo on this instance we know of")
|
|
|
|
|
|
|
|
field(:followers_count, :integer,
|
|
|
|
description: "The number of their profiles who follow our groups"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:followings_count, :integer,
|
|
|
|
description: "The number of our profiles who follow their groups"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:reports_count, :integer,
|
|
|
|
description: "The number of reports made against profiles from this instance"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:media_size, :integer,
|
|
|
|
description: "The size of all the media files sent by actors from this instance"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:has_relay, :boolean,
|
|
|
|
description:
|
|
|
|
"Whether this instance has a relay, meaning that it's a Mobilizon instance that we can follow"
|
|
|
|
)
|
2022-05-06 17:21:11 +02:00
|
|
|
|
|
|
|
field(:relay_address, :string,
|
|
|
|
description: "If this instance has a relay, it's federated username"
|
|
|
|
)
|
2021-12-28 11:42:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
A paginated list of instances
|
|
|
|
"""
|
|
|
|
object :paginated_instance_list do
|
|
|
|
field(:elements, list_of(:instance), description: "A list of instances")
|
|
|
|
field(:total, :integer, description: "The total number of instances in the list")
|
|
|
|
end
|
|
|
|
|
2019-07-23 13:49:22 +02:00
|
|
|
object :admin_queries do
|
|
|
|
@desc "Get the list of action logs"
|
2021-04-27 17:53:11 +02:00
|
|
|
field :action_logs, type: :paginated_action_log_list do
|
2019-07-23 13:49:22 +02:00
|
|
|
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-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
List the instance's supported languages
|
|
|
|
"""
|
2020-10-07 15:37:23 +02:00
|
|
|
field :languages, type: list_of(:language) do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:codes, list_of(:string),
|
|
|
|
description:
|
|
|
|
"The user's locale. The list of languages will be translated with this locale"
|
|
|
|
)
|
|
|
|
|
2020-10-07 15:37:23 +02:00
|
|
|
resolve(&Admin.get_list_of_languages/3)
|
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
Get dashboard information
|
|
|
|
"""
|
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
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
Get admin settings
|
|
|
|
"""
|
2019-12-20 13:04:34 +01:00
|
|
|
field :admin_settings, type: :admin_settings do
|
|
|
|
resolve(&Admin.get_settings/3)
|
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
List the relay followers
|
|
|
|
"""
|
2019-12-03 11:29:51 +01:00
|
|
|
field :relay_followers, type: :paginated_follower_list do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:page, :integer,
|
|
|
|
default_value: 1,
|
|
|
|
description: "The page in the paginated relay followers list"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:limit, :integer,
|
|
|
|
default_value: 10,
|
|
|
|
description: "The limit of relay followers per page"
|
|
|
|
)
|
|
|
|
|
2019-12-03 11:29:51 +01:00
|
|
|
resolve(&Admin.list_relay_followers/3)
|
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
List the relay followings
|
|
|
|
"""
|
2019-12-03 11:29:51 +01:00
|
|
|
field :relay_followings, type: :paginated_follower_list do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:page, :integer,
|
|
|
|
default_value: 1,
|
|
|
|
description: "The page in the paginated relay followings list"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:limit, :integer,
|
|
|
|
default_value: 10,
|
|
|
|
description: "The limit of relay followings per page"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:order_by, :string,
|
|
|
|
default_value: :updated_at,
|
|
|
|
description: "The field to order by the list"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:direction, :string, default_value: :desc, description: "The sorting direction")
|
2019-12-03 11:29:51 +01:00
|
|
|
resolve(&Admin.list_relay_followings/3)
|
|
|
|
end
|
2021-12-28 11:42:08 +01:00
|
|
|
|
|
|
|
@desc """
|
|
|
|
List instances
|
|
|
|
"""
|
|
|
|
field :instances, :paginated_instance_list do
|
|
|
|
arg(:page, :integer,
|
|
|
|
default_value: 1,
|
|
|
|
description: "The page in the paginated relay followings list"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:limit, :integer,
|
|
|
|
default_value: 10,
|
|
|
|
description: "The limit of relay followings per page"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:order_by, :instances_sort_fields,
|
|
|
|
default_value: :event_count,
|
|
|
|
description: "The field to order by the list"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:filter_domain, :string, default_value: nil, description: "Filter by domain")
|
|
|
|
|
|
|
|
arg(:filter_follow_status, :instance_filter_follow_status,
|
|
|
|
default_value: :all,
|
|
|
|
description: "Whether or not to filter instances by the follow status"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:filter_suspend_status, :instance_filter_suspend_status,
|
|
|
|
default_value: :all,
|
|
|
|
description: "Whether or not to filter instances by the suspended status"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:direction, :string, default_value: :desc, description: "The sorting direction")
|
|
|
|
resolve(&Admin.get_instances/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
Get an instance's details
|
|
|
|
"""
|
|
|
|
field :instance, :instance do
|
|
|
|
arg(:domain, non_null(:id), description: "The instance domain")
|
|
|
|
resolve(&Admin.get_instance/3)
|
|
|
|
end
|
2019-12-03 11:29:51 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
object :admin_mutations do
|
2021-12-28 11:42:08 +01:00
|
|
|
@desc "Add an instance subscription"
|
|
|
|
field :add_instance, type: :instance do
|
|
|
|
arg(:domain, non_null(:string), description: "The instance domain to add")
|
|
|
|
|
|
|
|
resolve(&Admin.create_instance/3)
|
|
|
|
end
|
|
|
|
|
2019-12-03 11:29:51 +01:00
|
|
|
@desc "Delete a relay subscription"
|
|
|
|
field :remove_relay, type: :follower do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:address, non_null(:string), description: "The relay hostname to delete")
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
resolve(&Admin.remove_relay/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Accept a relay subscription"
|
|
|
|
field :accept_relay, type: :follower do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:address, non_null(:string), description: "The accepted relay hostname")
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
resolve(&Admin.accept_subscription/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Reject a relay subscription"
|
|
|
|
field :reject_relay, type: :follower do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:address, non_null(:string), description: "The rejected relay hostname")
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
resolve(&Admin.reject_subscription/3)
|
|
|
|
end
|
2019-12-20 13:04:34 +01:00
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
Save admin settings
|
|
|
|
"""
|
2019-12-20 13:04:34 +01:00
|
|
|
field :save_admin_settings, type: :admin_settings do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:instance_name, :string, description: "The instance's name")
|
|
|
|
arg(:instance_description, :string, description: "The instance's description")
|
|
|
|
arg(:instance_long_description, :string, description: "The instance's long description")
|
|
|
|
arg(:instance_slogan, :string, description: "The instance's slogan")
|
|
|
|
arg(:contact, :string, description: "The instance's contact details")
|
|
|
|
arg(:instance_terms, :string, description: "The instance's terms body text")
|
|
|
|
arg(:instance_terms_type, :instance_terms_type, description: "The instance's terms type")
|
|
|
|
arg(:instance_terms_url, :string, description: "The instance's terms URL")
|
|
|
|
|
|
|
|
arg(:instance_privacy_policy, :string,
|
|
|
|
description: "The instance's privacy policy body text"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:instance_privacy_policy_type, :instance_privacy_type,
|
|
|
|
description: "The instance's privacy policy type"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:instance_privacy_policy_url, :string, description: "The instance's privacy policy URL")
|
|
|
|
arg(:instance_rules, :string, description: "The instance's rules")
|
|
|
|
arg(:registrations_open, :boolean, description: "Whether the registrations are opened")
|
|
|
|
arg(:instance_languages, list_of(:string), description: "The instance's languages")
|
2019-12-20 13:04:34 +01:00
|
|
|
|
|
|
|
resolve(&Admin.save_settings/3)
|
|
|
|
end
|
2022-01-13 15:04:43 +01:00
|
|
|
|
|
|
|
@desc """
|
|
|
|
For an admin to update an user
|
|
|
|
"""
|
|
|
|
field :admin_update_user, type: :user do
|
|
|
|
arg(:id, non_null(:id), description: "The user's ID")
|
|
|
|
arg(:email, :string, description: "The user's new email")
|
2022-01-14 18:10:50 +01:00
|
|
|
arg(:confirmed, :boolean, description: "Manually confirm the user's account")
|
2022-01-13 15:04:43 +01:00
|
|
|
arg(:role, :user_role, description: "Set user's new role")
|
|
|
|
|
|
|
|
arg(:notify, :boolean,
|
|
|
|
default_value: false,
|
|
|
|
description: "Whether or not to notify the user of the change"
|
|
|
|
)
|
|
|
|
|
|
|
|
resolve(&Admin.update_user/3)
|
|
|
|
end
|
2019-07-23 13:49:22 +02:00
|
|
|
end
|
|
|
|
end
|