2020-01-26 20:34:25 +01:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.Actors.MemberType do
|
2019-01-14 17:48:08 +01:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Member
|
|
|
|
"""
|
2019-01-14 17:13:17 +01:00
|
|
|
use Absinthe.Schema.Notation
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
alias Mobilizon.GraphQL.Resolvers.{Group, Member}
|
2019-03-01 17:11:28 +01:00
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
@desc """
|
|
|
|
Represents a member of a group
|
|
|
|
"""
|
|
|
|
object :member do
|
2020-02-18 08:57:00 +01:00
|
|
|
field(:id, :id, description: "The member's ID")
|
2019-01-14 17:13:17 +01:00
|
|
|
field(:parent, :group, description: "Of which the profile is member")
|
2019-04-03 17:29:03 +02:00
|
|
|
field(:actor, :person, description: "Which profile is member of")
|
2020-02-18 08:57:00 +01:00
|
|
|
field(:role, :member_role_enum, description: "The role of this membership")
|
|
|
|
field(:invited_by, :person, description: "Who invited this member")
|
2020-07-09 17:24:28 +02:00
|
|
|
field(:inserted_at, :naive_datetime, description: "When was this member created")
|
2020-08-14 11:32:23 +02:00
|
|
|
field(:updated_at, :naive_datetime, description: "When was this member updated")
|
2020-02-18 08:57:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
enum :member_role_enum do
|
|
|
|
value(:not_approved)
|
|
|
|
value(:invited)
|
|
|
|
value(:member)
|
|
|
|
value(:moderator)
|
|
|
|
value(:administrator)
|
|
|
|
value(:creator)
|
|
|
|
value(:rejected)
|
2019-03-01 17:11:28 +01:00
|
|
|
end
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
object :paginated_member_list do
|
|
|
|
field(:elements, list_of(:member), description: "A list of members")
|
|
|
|
field(:total, :integer, description: "The total number of elements in the list")
|
|
|
|
end
|
|
|
|
|
2019-03-01 17:11:28 +01:00
|
|
|
object :member_mutations do
|
|
|
|
@desc "Join a group"
|
|
|
|
field :join_group, :member do
|
2019-09-09 09:31:08 +02:00
|
|
|
arg(:group_id, non_null(:id))
|
|
|
|
arg(:actor_id, non_null(:id))
|
2019-03-01 17:11:28 +01:00
|
|
|
|
2020-01-26 20:34:25 +01:00
|
|
|
resolve(&Group.join_group/3)
|
2019-03-01 17:11:28 +01:00
|
|
|
end
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
@desc "Leave a group"
|
2020-08-14 11:32:23 +02:00
|
|
|
field :leave_group, :deleted_object do
|
2019-09-09 09:31:08 +02:00
|
|
|
arg(:group_id, non_null(:id))
|
2019-03-01 17:11:28 +01:00
|
|
|
|
2020-01-26 20:34:25 +01:00
|
|
|
resolve(&Group.leave_group/3)
|
2019-03-01 17:11:28 +01:00
|
|
|
end
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
@desc "Invite an actor to join the group"
|
|
|
|
field :invite_member, :member do
|
|
|
|
arg(:group_id, non_null(:id))
|
|
|
|
arg(:target_actor_username, non_null(:string))
|
|
|
|
|
|
|
|
resolve(&Member.invite_member/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Accept an invitation to a group"
|
|
|
|
field :accept_invitation, :member do
|
|
|
|
arg(:id, non_null(:id))
|
|
|
|
|
|
|
|
resolve(&Member.accept_invitation/3)
|
|
|
|
end
|
2020-08-14 11:32:23 +02:00
|
|
|
|
|
|
|
@desc "Reject an invitation to a group"
|
|
|
|
field :reject_invitation, :member do
|
|
|
|
arg(:id, non_null(:id))
|
|
|
|
|
|
|
|
resolve(&Member.reject_invitation/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Remove a member from a group"
|
|
|
|
field :remove_member, :member do
|
|
|
|
arg(:group_id, non_null(:id))
|
|
|
|
arg(:member_id, non_null(:id))
|
|
|
|
|
|
|
|
resolve(&Member.remove_member/3)
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|
|
|
|
end
|