forked from AkkomaGang/akkoma
Merge branch 'develop' into issue/733
This commit is contained in:
commit
0447c42715
6 changed files with 16 additions and 6 deletions
|
@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
– Pagination: (optional) return `total` alongside with `items` when paginating
|
– Pagination: (optional) return `total` alongside with `items` when paginating
|
||||||
- Replaced [pleroma_job_queue](https://git.pleroma.social/pleroma/pleroma_job_queue) and `Pleroma.Web.Federator.RetryQueue` with [Oban](https://github.com/sorentwo/oban) (see [`docs/config.md`](docs/config.md) on migrating customized worker / retry settings)
|
- Replaced [pleroma_job_queue](https://git.pleroma.social/pleroma/pleroma_job_queue) and `Pleroma.Web.Federator.RetryQueue` with [Oban](https://github.com/sorentwo/oban) (see [`docs/config.md`](docs/config.md) on migrating customized worker / retry settings)
|
||||||
- Introduced [quantum](https://github.com/quantum-elixir/quantum-core) job scheduler
|
- Introduced [quantum](https://github.com/quantum-elixir/quantum-core) job scheduler
|
||||||
|
- Admin API: Return `total` when querying for reports
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Following from Osada
|
- Following from Osada
|
||||||
|
|
|
@ -317,6 +317,7 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
"total" : 1,
|
||||||
"reports": [
|
"reports": [
|
||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
|
|
|
@ -442,11 +442,9 @@ def list_reports(conn, params) do
|
||||||
params
|
params
|
||||||
|> Map.put("type", "Flag")
|
|> Map.put("type", "Flag")
|
||||||
|> Map.put("skip_preload", true)
|
|> Map.put("skip_preload", true)
|
||||||
|
|> Map.put("total", true)
|
||||||
|
|
||||||
reports =
|
reports = ActivityPub.fetch_activities([], params)
|
||||||
[]
|
|
||||||
|> ActivityPub.fetch_activities(params)
|
|
||||||
|> Enum.reverse()
|
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_view(ReportView)
|
|> put_view(ReportView)
|
||||||
|
|
|
@ -12,7 +12,9 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
|
||||||
|
|
||||||
def render("index.json", %{reports: reports}) do
|
def render("index.json", %{reports: reports}) do
|
||||||
%{
|
%{
|
||||||
reports: render_many(reports, __MODULE__, "show.json", as: :report)
|
reports:
|
||||||
|
render_many(reports[:items], __MODULE__, "show.json", as: :report) |> Enum.reverse(),
|
||||||
|
total: reports[:total]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
2
mix.exs
2
mix.exs
|
@ -99,7 +99,7 @@ defp deps do
|
||||||
{:plug_cowboy, "~> 2.0"},
|
{:plug_cowboy, "~> 2.0"},
|
||||||
{:phoenix_pubsub, "~> 1.1"},
|
{:phoenix_pubsub, "~> 1.1"},
|
||||||
{:phoenix_ecto, "~> 4.0"},
|
{:phoenix_ecto, "~> 4.0"},
|
||||||
{:ecto_sql, "~> 3.1"},
|
{:ecto_sql, "~> 3.2"},
|
||||||
{:postgrex, ">= 0.13.5"},
|
{:postgrex, ">= 0.13.5"},
|
||||||
{:oban, "~> 0.8.1"},
|
{:oban, "~> 0.8.1"},
|
||||||
{:quantum, "~> 2.3"},
|
{:quantum, "~> 2.3"},
|
||||||
|
|
|
@ -1309,6 +1309,7 @@ test "returns empty response when no reports created", %{conn: conn} do
|
||||||
|> json_response(:ok)
|
|> json_response(:ok)
|
||||||
|
|
||||||
assert Enum.empty?(response["reports"])
|
assert Enum.empty?(response["reports"])
|
||||||
|
assert response["total"] == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns reports", %{conn: conn} do
|
test "returns reports", %{conn: conn} do
|
||||||
|
@ -1331,6 +1332,8 @@ test "returns reports", %{conn: conn} do
|
||||||
|
|
||||||
assert length(response["reports"]) == 1
|
assert length(response["reports"]) == 1
|
||||||
assert report["id"] == report_id
|
assert report["id"] == report_id
|
||||||
|
|
||||||
|
assert response["total"] == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns reports with specified state", %{conn: conn} do
|
test "returns reports with specified state", %{conn: conn} do
|
||||||
|
@ -1364,6 +1367,8 @@ test "returns reports with specified state", %{conn: conn} do
|
||||||
assert length(response["reports"]) == 1
|
assert length(response["reports"]) == 1
|
||||||
assert open_report["id"] == first_report_id
|
assert open_report["id"] == first_report_id
|
||||||
|
|
||||||
|
assert response["total"] == 1
|
||||||
|
|
||||||
response =
|
response =
|
||||||
conn
|
conn
|
||||||
|> get("/api/pleroma/admin/reports", %{
|
|> get("/api/pleroma/admin/reports", %{
|
||||||
|
@ -1376,6 +1381,8 @@ test "returns reports with specified state", %{conn: conn} do
|
||||||
assert length(response["reports"]) == 1
|
assert length(response["reports"]) == 1
|
||||||
assert closed_report["id"] == second_report_id
|
assert closed_report["id"] == second_report_id
|
||||||
|
|
||||||
|
assert response["total"] == 1
|
||||||
|
|
||||||
response =
|
response =
|
||||||
conn
|
conn
|
||||||
|> get("/api/pleroma/admin/reports", %{
|
|> get("/api/pleroma/admin/reports", %{
|
||||||
|
@ -1384,6 +1391,7 @@ test "returns reports with specified state", %{conn: conn} do
|
||||||
|> json_response(:ok)
|
|> json_response(:ok)
|
||||||
|
|
||||||
assert Enum.empty?(response["reports"])
|
assert Enum.empty?(response["reports"])
|
||||||
|
assert response["total"] == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns 403 when requested by a non-admin" do
|
test "returns 403 when requested by a non-admin" do
|
||||||
|
|
Loading…
Reference in a new issue