Add admin interface to manage instances subscriptions
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -3,13 +3,10 @@ defmodule MobilizonWeb.Schema.ActorInterface do
|
||||
Schema representation for Actor
|
||||
"""
|
||||
use Absinthe.Schema.Notation
|
||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.{Events}
|
||||
|
||||
import_types(MobilizonWeb.Schema.Actors.FollowerType)
|
||||
import_types(MobilizonWeb.Schema.EventType)
|
||||
# import_types(MobilizonWeb.Schema.PictureType)
|
||||
|
||||
@desc "An ActivityPub actor"
|
||||
interface :actor do
|
||||
@@ -21,7 +18,6 @@ defmodule MobilizonWeb.Schema.ActorInterface do
|
||||
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(:keys, :string, description: "The actors RSA Keys")
|
||||
|
||||
field(:manually_approves_followers, :boolean,
|
||||
description: "Whether the actors manually approves followers"
|
||||
@@ -38,17 +34,6 @@ defmodule MobilizonWeb.Schema.ActorInterface do
|
||||
field(:followersCount, :integer, description: "Number of followers for this actor")
|
||||
field(:followingCount, :integer, description: "Number of actors following this actor")
|
||||
|
||||
# This one should have a privacy setting
|
||||
field(:organized_events, list_of(:event),
|
||||
resolve: dataloader(Events),
|
||||
description: "A list of the events this actor has organized"
|
||||
)
|
||||
|
||||
# This one is for the person itself **only**
|
||||
# field(:feed, list_of(:event), description: "List of events the actor sees in his or her feed")
|
||||
|
||||
# field(:memberships, list_of(:member))
|
||||
|
||||
resolve_type(fn
|
||||
%Actor{type: :Person}, _ ->
|
||||
:person
|
||||
@@ -56,6 +41,9 @@ defmodule MobilizonWeb.Schema.ActorInterface do
|
||||
%Actor{type: :Group}, _ ->
|
||||
:group
|
||||
|
||||
%Actor{type: :Application}, _ ->
|
||||
:application
|
||||
|
||||
_, _ ->
|
||||
nil
|
||||
end)
|
||||
|
||||
38
lib/mobilizon_web/schema/actors/application.ex
Normal file
38
lib/mobilizon_web/schema/actors/application.ex
Normal file
@@ -0,0 +1,38 @@
|
||||
defmodule MobilizonWeb.Schema.Actors.ApplicationType do
|
||||
@moduledoc """
|
||||
Schema representation for Group.
|
||||
"""
|
||||
|
||||
use Absinthe.Schema.Notation
|
||||
|
||||
@desc """
|
||||
Represents an application
|
||||
"""
|
||||
object :application do
|
||||
interfaces([:actor])
|
||||
|
||||
field(:id, :id, description: "Internal ID for this application")
|
||||
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")
|
||||
|
||||
field(:avatar, :picture, description: "The actor's avatar picture")
|
||||
field(:banner, :picture, description: "The actor's banner picture")
|
||||
|
||||
# These one should have a privacy setting
|
||||
field(:following, list_of(:follower), description: "List of followings")
|
||||
field(:followers, list_of(:follower), description: "List of followers")
|
||||
field(:followersCount, :integer, description: "Number of followers for this actor")
|
||||
field(:followingCount, :integer, description: "Number of actors following this actor")
|
||||
end
|
||||
end
|
||||
@@ -14,5 +14,13 @@ defmodule MobilizonWeb.Schema.Actors.FollowerType do
|
||||
field(:approved, :boolean,
|
||||
description: "Whether the follow has been approved by the target actor"
|
||||
)
|
||||
|
||||
field(:inserted_at, :datetime, description: "When the follow was created")
|
||||
field(:updated_at, :datetime, description: "When the follow was updated")
|
||||
end
|
||||
|
||||
object :paginated_follower_list do
|
||||
field(:elements, list_of(:follower), description: "A list of followers")
|
||||
field(:total, :integer, description: "The total number of elements in the list")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +27,6 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
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(:keys, :string, description: "The actors RSA Keys")
|
||||
|
||||
field(:manually_approves_followers, :boolean,
|
||||
description: "Whether the actors manually approves followers"
|
||||
|
||||
@@ -27,7 +27,6 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
|
||||
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(:keys, :string, description: "The actors RSA Keys")
|
||||
|
||||
field(:manually_approves_followers, :boolean,
|
||||
description: "Whether the actors manually approves followers"
|
||||
@@ -160,4 +159,14 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
|
||||
resolve(handle_errors(&Person.register_person/3))
|
||||
end
|
||||
end
|
||||
|
||||
object :person_subscriptions do
|
||||
field :event_person_participation_changed, :person do
|
||||
arg(:person_id, non_null(:id))
|
||||
|
||||
config(fn args, _ ->
|
||||
{:ok, topic: args.person_id}
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,5 +71,49 @@ defmodule MobilizonWeb.Schema.AdminType do
|
||||
field :dashboard, type: :dashboard do
|
||||
resolve(&Admin.get_dashboard/3)
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,6 +75,7 @@ defmodule MobilizonWeb.Schema.ReportType do
|
||||
arg(:reported_id, non_null(:id))
|
||||
arg(:event_id, :id, default_value: nil)
|
||||
arg(:comments_ids, list_of(:id), default_value: [])
|
||||
arg(:forward, :boolean, default_value: false)
|
||||
resolve(&Report.create_report/3)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user