Fix following groups + Add interface to manage followers

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-01-20 18:16:44 +01:00
parent 58fe7b74a5
commit 4fbdc94e7c
25 changed files with 929 additions and 83 deletions

View File

@@ -32,8 +32,6 @@ defmodule Mobilizon.GraphQL.Schema.ActorInterface do
field(:banner, :media, description: "The actor's banner media")
# 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")

View File

@@ -31,8 +31,6 @@ defmodule Mobilizon.GraphQL.Schema.Actors.ApplicationType do
field(:banner, :media, description: "The actor's banner media")
# 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")

View File

@@ -3,11 +3,13 @@ defmodule Mobilizon.GraphQL.Schema.Actors.FollowerType do
Schema representation for Follower
"""
use Absinthe.Schema.Notation
alias Mobilizon.GraphQL.Resolvers.Followers
@desc """
Represents an actor's follower
"""
object :follower do
field(:id, :id, description: "The follow ID")
field(:target_actor, :actor, description: "What or who the profile follows")
field(:actor, :actor, description: "Which profile follows")
@@ -26,4 +28,17 @@ defmodule Mobilizon.GraphQL.Schema.Actors.FollowerType do
field(:elements, list_of(:follower), description: "A list of followers")
field(:total, :integer, description: "The total number of elements in the list")
end
object :follower_mutations do
@desc "Update follower"
field :update_follower, :follower do
arg(:id, non_null(:id), description: "The follower ID")
arg(:approved, non_null(:boolean),
description: "Whether the follower has been approved by the target actor or not"
)
resolve(&Followers.update_follower/3)
end
end
end

View File

@@ -8,7 +8,18 @@ defmodule Mobilizon.GraphQL.Schema.Actors.GroupType do
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
alias Mobilizon.Addresses
alias Mobilizon.GraphQL.Resolvers.{Discussion, Group, Media, Member, Post, Resource, Todos}
alias Mobilizon.GraphQL.Resolvers.{
Discussion,
Followers,
Group,
Media,
Member,
Post,
Resource,
Todos
}
alias Mobilizon.GraphQL.Schema
import_types(Schema.Actors.MemberType)
@@ -47,8 +58,6 @@ defmodule Mobilizon.GraphQL.Schema.Actors.GroupType do
)
# 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")
@@ -116,6 +125,23 @@ defmodule Mobilizon.GraphQL.Schema.Actors.GroupType do
resolve(&Todos.find_todo_lists_for_group/3)
description("A paginated list of the todo lists this group has")
end
field :followers, :paginated_follower_list do
arg(:page, :integer,
default_value: 1,
description: "The page in the paginated followers list"
)
arg(:limit, :integer, default_value: 10, description: "The limit of followers per page")
arg(:approved, :boolean,
default_value: nil,
description: "Used to filter the followers list by approved status"
)
resolve(&Followers.find_followers_for_group/3)
description("A paginated list of the followers this group has")
end
end
@desc """
@@ -232,6 +258,10 @@ defmodule Mobilizon.GraphQL.Schema.Actors.GroupType do
description: "Whether the group can be join freely, with approval or is invite-only."
)
arg(:manually_approves_followers, :boolean,
description: "Whether this group approves new followers manually"
)
arg(:avatar, :media_input,
description:
"The avatar for the group, either as an object or directly the ID of an existing media"

View File

@@ -44,8 +44,6 @@ defmodule Mobilizon.GraphQL.Schema.Actors.PersonType do
field(:banner, :media, description: "The actor's banner media")
# 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")