Add pagination to moderation logs

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-04-27 17:53:11 +02:00
parent 6646391558
commit 495fbda330
11 changed files with 231 additions and 110 deletions

View File

@@ -31,17 +31,20 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
query = """
{
actionLogs {
action,
actor {
preferredUsername
},
object {
... on Report {
id,
status
total
elements {
action,
actor {
preferredUsername
},
... on ReportNote {
content
object {
... on Report {
id,
status
},
... on ReportNote {
content
}
}
}
}
@@ -62,9 +65,10 @@ defmodule Mobilizon.GraphQL.Resolvers.AdminTest do
assert json_response(res, 200)["errors"] == nil
assert json_response(res, 200)["data"]["actionLogs"] |> length == 3
assert json_response(res, 200)["data"]["actionLogs"]["total"] == 3
assert json_response(res, 200)["data"]["actionLogs"]["elements"] |> length == 3
assert json_response(res, 200)["data"]["actionLogs"] == [
assert json_response(res, 200)["data"]["actionLogs"]["elements"] == [
%{
"action" => "NOTE_DELETION",
"actor" => %{"preferredUsername" => moderator_2.preferred_username},

View File

@@ -228,25 +228,28 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do
query = """
{
actionLogs {
action,
actor {
preferredUsername
},
object {
... on Report {
id,
status
total
elements {
action,
actor {
preferredUsername
},
... on ReportNote {
content
}
... on Event {
id,
title
},
... on Comment {
id,
text
object {
... on Report {
id,
status
},
... on ReportNote {
content
}
... on Event {
id,
title
},
... on Comment {
id,
text
}
}
}
}
@@ -260,7 +263,7 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do
refute json_response(res, 200)["errors"]
assert hd(json_response(res, 200)["data"]["actionLogs"]) == %{
assert hd(json_response(res, 200)["data"]["actionLogs"]["elements"]) == %{
"action" => "COMMENT_DELETION",
"actor" => %{"preferredUsername" => actor_moderator.preferred_username},
"object" => %{"text" => comment.text, "id" => to_string(comment.id)}

View File

@@ -1368,21 +1368,24 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
query = """
{
actionLogs {
action,
actor {
preferredUsername
},
object {
... on Report {
id,
status
total
elements {
action,
actor {
preferredUsername
},
... on ReportNote {
content
}
... on Event {
id,
title
object {
... on Report {
id,
status
},
... on ReportNote {
content
}
... on Event {
id,
title
}
}
}
}
@@ -1394,7 +1397,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|> auth_conn(user_moderator)
|> get("/api", AbsintheHelpers.query_skeleton(query, "actionLogs"))
assert hd(json_response(res, 200)["data"]["actionLogs"]) == %{
assert hd(json_response(res, 200)["data"]["actionLogs"]["elements"]) == %{
"action" => "EVENT_DELETION",
"actor" => %{"preferredUsername" => actor_moderator.preferred_username},
"object" => %{"title" => event.title, "id" => to_string(event.id)}

View File

@@ -685,15 +685,18 @@ defmodule Mobilizon.GraphQL.Resolvers.PersonTest do
@moderation_logs_query """
{
actionLogs {
action,
actor {
id,
preferredUsername
},
object {
...on Person {
total
elements {
action,
actor {
id,
preferredUsername
},
object {
...on Person {
id,
preferredUsername
}
}
}
}
@@ -733,7 +736,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PersonTest do
|> auth_conn(modo)
|> AbsintheHelpers.graphql_query(query: @moderation_logs_query)
actionlog = hd(res["data"]["actionLogs"])
actionlog = hd(res["data"]["actionLogs"]["elements"])
refute is_nil(actionlog)
assert actionlog["action"] == "ACTOR_SUSPENSION"
assert actionlog["actor"]["id"] == to_string(modo_actor_id)