2020-01-26 20:34:25 +01:00
|
|
|
defmodule Mobilizon.GraphQL.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
|
2020-01-26 20:34:25 +01:00
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
2020-01-26 20:34:25 +01:00
|
|
|
|
2019-01-21 15:08:22 +01:00
|
|
|
alias Mobilizon.Events
|
2020-01-26 20:34:25 +01:00
|
|
|
alias Mobilizon.GraphQL.Resolvers.Person
|
|
|
|
alias Mobilizon.GraphQL.Schema
|
2019-01-14 17:13:17 +01:00
|
|
|
|
2020-01-26 20:34:25 +01:00
|
|
|
import_types(Schema.Events.FeedTokenType)
|
2019-03-08 18:52:27 +01:00
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
@desc """
|
|
|
|
Represents a person identity
|
|
|
|
"""
|
|
|
|
object :person do
|
2020-06-11 19:13:21 +02:00
|
|
|
interfaces([:actor, :action_log_object])
|
2019-09-09 09:31:08 +02:00
|
|
|
field(:id, :id, description: "Internal ID for this person")
|
2020-06-11 19:13:21 +02:00
|
|
|
|
|
|
|
field(:user, :user,
|
|
|
|
description: "The user this actor is associated to",
|
|
|
|
resolve: &Person.user_for_person/3
|
|
|
|
)
|
2019-01-14 17:13:17 +01:00
|
|
|
|
|
|
|
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(:manually_approves_followers, :boolean,
|
|
|
|
description: "Whether the actors manually approves followers"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:suspended, :boolean, description: "If the actor is suspended")
|
2019-05-22 14:12:11 +02:00
|
|
|
|
|
|
|
field(:avatar, :picture, description: "The actor's avatar picture")
|
|
|
|
field(:banner, :picture, description: "The actor's banner picture")
|
2019-01-14 17:13:17 +01:00
|
|
|
|
|
|
|
# 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
|
2020-06-11 19:13:21 +02:00
|
|
|
field(:organized_events, :paginated_event_list,
|
2019-01-14 17:13:17 +01:00
|
|
|
description: "A list of the events this actor has organized"
|
2020-06-11 19:13:21 +02:00
|
|
|
) do
|
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
|
|
|
resolve(&Person.organized_events_for_person/3)
|
|
|
|
end
|
2019-03-21 20:23:42 +01:00
|
|
|
|
|
|
|
@desc "The list of events this person goes to"
|
2020-06-11 19:13:21 +02:00
|
|
|
field(:participations, :paginated_participant_list,
|
2019-09-26 16:38:58 +02:00
|
|
|
description: "The list of events this person goes to"
|
|
|
|
) do
|
|
|
|
arg(:event_id, :id)
|
2020-06-11 19:13:21 +02:00
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
2019-09-26 16:38:58 +02:00
|
|
|
resolve(&Person.person_participations/3)
|
2019-03-21 20:23:42 +01:00
|
|
|
end
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
@desc "The list of group this person is member of"
|
|
|
|
field(:memberships, :paginated_member_list,
|
|
|
|
description: "The list of group this person is member of"
|
|
|
|
) do
|
|
|
|
resolve(&Person.person_memberships/3)
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
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
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve(&Person.get_current_person/3)
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
|
|
|
|
2019-10-15 21:18:03 +02:00
|
|
|
@desc "Get a person by its (federated) username"
|
2019-10-04 18:28:25 +02:00
|
|
|
field :fetch_person, :person do
|
2019-01-25 15:41:10 +01:00
|
|
|
arg(:preferred_username, non_null(:string))
|
2019-10-04 18:28:25 +02:00
|
|
|
resolve(&Person.fetch_person/3)
|
|
|
|
end
|
|
|
|
|
2019-10-15 21:18:03 +02:00
|
|
|
@desc "Get a person by its ID"
|
2019-10-04 18:28:25 +02:00
|
|
|
field :person, :person do
|
|
|
|
arg(:id, non_null(:id))
|
|
|
|
resolve(&Person.get_person/3)
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Get the persons for an user"
|
|
|
|
field :identities, list_of(:person) do
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve(&Person.identities/3)
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
2020-06-11 19:13:21 +02:00
|
|
|
|
|
|
|
field :persons, :persons do
|
|
|
|
arg(:preferred_username, :string, default_value: "")
|
|
|
|
arg(:name, :string, default_value: "")
|
|
|
|
arg(:domain, :string, default_value: "")
|
|
|
|
arg(:local, :boolean, default_value: true)
|
|
|
|
arg(:suspended, :boolean, default_value: false)
|
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
|
|
|
resolve(&Person.list_persons/3)
|
|
|
|
end
|
2019-01-25 15:41:10 +01:00
|
|
|
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: "")
|
|
|
|
|
2019-05-22 14:12:11 +02:00
|
|
|
arg(:avatar, :picture_input,
|
|
|
|
description:
|
|
|
|
"The avatar for the profile, either as an object or directly the ID of an existing Picture"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:banner, :picture_input,
|
|
|
|
description:
|
|
|
|
"The banner for the profile, either as an object or directly the ID of an existing Picture"
|
|
|
|
)
|
|
|
|
|
2020-10-01 15:07:15 +02:00
|
|
|
resolve(&Person.create_person/3)
|
2019-01-29 11:02:32 +01:00
|
|
|
end
|
|
|
|
|
2019-06-17 17:15:27 +02:00
|
|
|
@desc "Update an identity"
|
|
|
|
field :update_person, :person do
|
2019-10-04 18:28:25 +02:00
|
|
|
arg(:id, non_null(:id))
|
2019-06-17 17:15:27 +02:00
|
|
|
|
|
|
|
arg(:name, :string, description: "The displayed name for this profile")
|
|
|
|
|
|
|
|
arg(:summary, :string, description: "The summary for this profile")
|
|
|
|
|
|
|
|
arg(:avatar, :picture_input,
|
|
|
|
description:
|
|
|
|
"The avatar for the profile, either as an object or directly the ID of an existing Picture"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:banner, :picture_input,
|
|
|
|
description:
|
|
|
|
"The banner for the profile, either as an object or directly the ID of an existing Picture"
|
|
|
|
)
|
|
|
|
|
2020-10-01 15:07:15 +02:00
|
|
|
resolve(&Person.update_person/3)
|
2019-06-17 17:15:27 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Delete an identity"
|
|
|
|
field :delete_person, :person do
|
2019-10-04 18:28:25 +02:00
|
|
|
arg(:id, non_null(:id))
|
2019-06-17 17:15:27 +02:00
|
|
|
|
2020-10-01 15:07:15 +02:00
|
|
|
resolve(&Person.delete_person/3)
|
2019-06-17 17:15:27 +02:00
|
|
|
end
|
|
|
|
|
2019-01-29 11:02:32 +01:00
|
|
|
@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")
|
|
|
|
|
2019-05-22 14:12:11 +02:00
|
|
|
arg(:avatar, :picture_input,
|
|
|
|
description:
|
|
|
|
"The avatar for the profile, either as an object or directly the ID of an existing Picture"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:banner, :picture_input,
|
|
|
|
description:
|
|
|
|
"The banner for the profile, either as an object or directly the ID of an existing Picture"
|
|
|
|
)
|
|
|
|
|
2020-10-01 15:07:15 +02:00
|
|
|
resolve(&Person.register_person/3)
|
2019-01-25 15:41:10 +01:00
|
|
|
end
|
|
|
|
end
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
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
|
2020-11-06 11:34:32 +01:00
|
|
|
|
|
|
|
field :group_membership_changed, :person do
|
|
|
|
arg(:person_id, non_null(:id))
|
|
|
|
|
|
|
|
config(fn args, _ ->
|
|
|
|
{:ok, topic: args.person_id}
|
|
|
|
end)
|
|
|
|
end
|
2019-12-03 11:29:51 +01:00
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|