2019-01-14 17:13:17 +01:00
|
|
|
defmodule MobilizonWeb.Schema.Actors.PersonType do
|
2019-01-14 17:48:08 +01:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Person
|
|
|
|
"""
|
2019-01-14 17:13:17 +01:00
|
|
|
use Absinthe.Schema.Notation
|
|
|
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
2019-01-21 15:08:22 +01:00
|
|
|
alias Mobilizon.Events
|
2019-01-25 15:41:10 +01:00
|
|
|
alias MobilizonWeb.Resolvers
|
2019-01-29 11:02:32 +01:00
|
|
|
import MobilizonWeb.Schema.Utils
|
2019-01-14 17:13:17 +01:00
|
|
|
|
2019-03-08 18:52:27 +01:00
|
|
|
import_types(MobilizonWeb.Schema.Events.FeedTokenType)
|
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
@desc """
|
|
|
|
Represents a person identity
|
|
|
|
"""
|
|
|
|
object :person do
|
|
|
|
interfaces([:actor])
|
2019-02-01 15:38:35 +01:00
|
|
|
field(:id, :integer, description: "Internal ID for this person")
|
2019-01-14 17:13:17 +01:00
|
|
|
field(:user, :user, description: "The user this actor is associated to")
|
|
|
|
|
|
|
|
field(:member_of, list_of(:member), description: "The list of groups this person is member of")
|
|
|
|
|
|
|
|
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(:keys, :string, description: "The actors RSA Keys")
|
|
|
|
|
|
|
|
field(:manually_approves_followers, :boolean,
|
|
|
|
description: "Whether the actors manually approves followers"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:suspended, :boolean, description: "If the actor is suspended")
|
|
|
|
field(:avatar_url, :string, description: "The actor's avatar url")
|
|
|
|
field(:banner_url, :string, description: "The actor's banner url")
|
|
|
|
|
|
|
|
# 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")
|
|
|
|
|
2019-03-08 18:52:27 +01:00
|
|
|
field(:feed_tokens, list_of(:feed_token),
|
|
|
|
resolve: dataloader(Events),
|
|
|
|
description: "A list of the feed tokens for this person"
|
|
|
|
)
|
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
# 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"
|
|
|
|
)
|
|
|
|
end
|
2019-01-25 15:41:10 +01:00
|
|
|
|
|
|
|
object :person_queries do
|
|
|
|
@desc "Get the current actor for the logged-in user"
|
|
|
|
field :logged_person, :person do
|
|
|
|
resolve(&Resolvers.Person.get_current_person/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Get a person by it's preferred username"
|
|
|
|
field :person, :person do
|
|
|
|
arg(:preferred_username, non_null(:string))
|
|
|
|
resolve(&Resolvers.Person.find_person/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Get the persons for an user"
|
|
|
|
field :identities, list_of(:person) do
|
|
|
|
resolve(&Resolvers.Person.identities/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
object :person_mutations do
|
|
|
|
@desc "Create a new person for user"
|
|
|
|
field :create_person, :person do
|
|
|
|
arg(:preferred_username, non_null(:string))
|
|
|
|
|
2019-01-29 11:02:32 +01:00
|
|
|
arg(:name, :string, description: "The displayed name for the new profile", default_value: "")
|
2019-01-25 15:41:10 +01:00
|
|
|
|
2019-01-29 11:02:32 +01:00
|
|
|
arg(:summary, :string, description: "The summary for the new profile", default_value: "")
|
|
|
|
|
|
|
|
resolve(handle_errors(&Resolvers.Person.create_person/3))
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Register a first profile on registration"
|
|
|
|
field :register_person, :person do
|
|
|
|
arg(:preferred_username, non_null(:string))
|
|
|
|
|
|
|
|
arg(:name, :string, description: "The displayed name for the new profile", default_value: "")
|
|
|
|
|
|
|
|
arg(:summary, :string, description: "The summary for the new profile", default_value: "")
|
|
|
|
arg(:email, non_null(:string), description: "The email from the user previously created")
|
|
|
|
|
|
|
|
resolve(handle_errors(&Resolvers.Person.register_person/3))
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|