2020-01-26 19:34:25 +00:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.ActorInterface do
|
2019-01-14 16:48:08 +00:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Actor
|
|
|
|
"""
|
2019-01-14 16:13:17 +00:00
|
|
|
use Absinthe.Schema.Notation
|
2020-01-26 19:34:25 +00:00
|
|
|
|
2019-01-14 16:13:17 +00:00
|
|
|
alias Mobilizon.Actors.Actor
|
2020-08-27 09:53:24 +00:00
|
|
|
alias Mobilizon.GraphQL.Resolvers.Actor, as: ActorResolver
|
2020-01-26 19:34:25 +00:00
|
|
|
alias Mobilizon.GraphQL.Schema
|
2019-01-14 16:13:17 +00:00
|
|
|
|
2020-01-26 19:34:25 +00:00
|
|
|
import_types(Schema.Actors.FollowerType)
|
|
|
|
import_types(Schema.EventType)
|
2019-01-14 16:13:17 +00:00
|
|
|
|
|
|
|
@desc "An ActivityPub actor"
|
|
|
|
interface :actor do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :all)
|
2019-09-09 07:31:08 +00:00
|
|
|
field(:id, :id, description: "Internal ID for this actor")
|
2019-01-14 16:13:17 +00:00
|
|
|
field(:url, :string, description: "The ActivityPub actor's URL")
|
|
|
|
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
|
|
|
|
field(:name, :string, description: "The actor's displayed name")
|
|
|
|
field(:domain, :string, description: "The actor's domain if (null if it's this instance)")
|
|
|
|
field(:local, :boolean, description: "If the actor is from this instance")
|
|
|
|
field(:summary, :string, description: "The actor's summary")
|
|
|
|
field(:preferred_username, :string, description: "The actor's preferred username")
|
|
|
|
|
|
|
|
field(:manually_approves_followers, :boolean,
|
|
|
|
description: "Whether the actors manually approves followers"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:suspended, :boolean, description: "If the actor is suspended")
|
2019-05-22 12:12:11 +00:00
|
|
|
|
2020-11-26 10:41:13 +00:00
|
|
|
field(:avatar, :media, description: "The actor's avatar media")
|
|
|
|
field(:banner, :media, description: "The actor's banner media")
|
2019-01-14 16:13:17 +00:00
|
|
|
|
|
|
|
# These one should have a privacy setting
|
2022-08-26 14:08:58 +00:00
|
|
|
field(:followers_count, :integer, description: "Number of followers for this actor")
|
|
|
|
field(:following_count, :integer, description: "Number of actors following this actor")
|
2019-01-14 16:13:17 +00:00
|
|
|
|
2020-11-23 11:31:15 +00:00
|
|
|
field(:media_size, :integer, description: "The total size of the media from this actor")
|
|
|
|
|
2019-01-14 16:13:17 +00:00
|
|
|
resolve_type(fn
|
|
|
|
%Actor{type: :Person}, _ ->
|
|
|
|
:person
|
|
|
|
|
|
|
|
%Actor{type: :Group}, _ ->
|
|
|
|
:group
|
2019-01-21 14:08:22 +00:00
|
|
|
|
2019-12-03 10:29:51 +00:00
|
|
|
%Actor{type: :Application}, _ ->
|
|
|
|
:application
|
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
_, _ ->
|
|
|
|
nil
|
2019-01-14 16:13:17 +00:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "The list of types an actor can be"
|
|
|
|
enum :actor_type do
|
|
|
|
value(:Person, description: "An ActivityPub Person")
|
|
|
|
value(:Application, description: "An ActivityPub Application")
|
|
|
|
value(:Group, description: "An ActivityPub Group")
|
|
|
|
value(:Organization, description: "An ActivityPub Organization")
|
|
|
|
value(:Service, description: "An ActivityPub Service")
|
|
|
|
end
|
2020-08-27 09:53:24 +00:00
|
|
|
|
|
|
|
object :actor_mutations do
|
2020-11-19 16:06:28 +00:00
|
|
|
@desc "Suspend an actor"
|
2020-08-27 09:53:24 +00:00
|
|
|
field :suspend_profile, :deleted_object do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:id, non_null(:id), description: "The remote profile ID to suspend")
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :moderator, scope: false)
|
2020-08-27 09:53:24 +00:00
|
|
|
resolve(&ActorResolver.suspend_profile/3)
|
|
|
|
end
|
|
|
|
|
2020-11-19 16:06:28 +00:00
|
|
|
@desc "Unsuspend an actor"
|
2020-08-27 09:53:24 +00:00
|
|
|
field :unsuspend_profile, :actor do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:id, non_null(:id), description: "The remote profile ID to unsuspend")
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :moderator, scope: false)
|
2020-08-27 09:53:24 +00:00
|
|
|
resolve(&ActorResolver.unsuspend_profile/3)
|
|
|
|
end
|
|
|
|
|
2020-11-19 16:06:28 +00:00
|
|
|
@desc "Refresh a profile"
|
2020-08-27 09:53:24 +00:00
|
|
|
field :refresh_profile, :actor do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:id, non_null(:id), description: "The remote profile ID to refresh")
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :moderator, scope: false)
|
2020-08-27 09:53:24 +00:00
|
|
|
resolve(&ActorResolver.refresh_profile/3)
|
|
|
|
end
|
|
|
|
end
|
2019-01-14 16:13:17 +00:00
|
|
|
end
|