Merge remote-tracking branch 'upstream/develop' into neckbeard
This commit is contained in:
commit
e8b0f560b0
|
@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
|
||||
- Search: When using Postgres 11+, Pleroma will use the `websearch_to_tsvector` function to parse search queries.
|
||||
- Emoji: Support the full Unicode 13.1 set of Emoji for reactions, plus regional indicators.
|
||||
- Admin API: Reports now ordered by newest
|
||||
|
||||
### Added
|
||||
|
||||
|
|
|
@ -603,12 +603,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
|> Map.put(:muting_user, reading_user)
|
||||
end
|
||||
|
||||
pagination_type =
|
||||
cond do
|
||||
!Map.has_key?(params, :offset) -> :keyset
|
||||
true -> :offset
|
||||
end
|
||||
|
||||
%{
|
||||
godmode: params[:godmode],
|
||||
reading_user: reading_user
|
||||
}
|
||||
|> user_activities_recipients()
|
||||
|> fetch_activities(params)
|
||||
|> fetch_activities(params, pagination_type)
|
||||
|> Enum.reverse()
|
||||
end
|
||||
|
||||
|
|
|
@ -103,11 +103,12 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
godmode = params["godmode"] == "true" || params["godmode"] == true
|
||||
|
||||
with %User{} = user <- User.get_cached_by_nickname_or_id(nickname, for: admin) do
|
||||
{_, page_size} = page_params(params)
|
||||
{page, page_size} = page_params(params)
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_user_activities(user, nil, %{
|
||||
limit: page_size,
|
||||
offset: (page - 1) * page_size,
|
||||
godmode: godmode,
|
||||
exclude_reblogs: not with_reblogs
|
||||
})
|
||||
|
|
|
@ -19,8 +19,7 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
|
|||
reports:
|
||||
reports[:items]
|
||||
|> Enum.map(&Report.extract_report_info/1)
|
||||
|> Enum.map(&render(__MODULE__, "show.json", &1))
|
||||
|> Enum.reverse(),
|
||||
|> Enum.map(&render(__MODULE__, "show.json", &1)),
|
||||
total: reports[:total]
|
||||
}
|
||||
end
|
||||
|
|
4
mix.exs
4
mix.exs
|
@ -147,8 +147,8 @@ defmodule Pleroma.Mixfile do
|
|||
{:earmark, "1.4.3"},
|
||||
{:bbcode_pleroma, "~> 0.2.0"},
|
||||
{:crypt,
|
||||
git: "https://github.com/msantos/crypt.git",
|
||||
ref: "f63a705f92c26955977ee62a313012e309a4d77a"},
|
||||
git: "https://git.pleroma.social/pleroma/elixir-libraries/crypt.git",
|
||||
ref: "cf2aa3f11632e8b0634810a15b3e612c7526f6a3"},
|
||||
{:cors_plug, "~> 2.0"},
|
||||
{:web_push_encryption, "~> 0.3"},
|
||||
{:swoosh, "~> 1.0"},
|
||||
|
|
2
mix.lock
2
mix.lock
|
@ -22,7 +22,7 @@
|
|||
"cowlib": {:hex, :cowlib, "2.9.1", "61a6c7c50cf07fdd24b2f45b89500bb93b6686579b069a89f88cb211e1125c78", [:rebar3], [], "hexpm", "e4175dc240a70d996156160891e1c62238ede1729e45740bdd38064dad476170"},
|
||||
"credo": {:hex, :credo, "1.4.1", "16392f1edd2cdb1de9fe4004f5ab0ae612c92e230433968eab00aafd976282fc", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "155f8a2989ad77504de5d8291fa0d41320fdcaa6a1030472e9967f285f8c7692"},
|
||||
"crontab": {:hex, :crontab, "1.1.8", "2ce0e74777dfcadb28a1debbea707e58b879e6aa0ffbf9c9bb540887bce43617", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"},
|
||||
"crypt": {:git, "https://github.com/msantos/crypt.git", "f63a705f92c26955977ee62a313012e309a4d77a", [ref: "f63a705f92c26955977ee62a313012e309a4d77a"]},
|
||||
"crypt": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/crypt.git", "cf2aa3f11632e8b0634810a15b3e612c7526f6a3", [ref: "cf2aa3f11632e8b0634810a15b3e612c7526f6a3"]},
|
||||
"custom_base": {:hex, :custom_base, "0.2.1", "4a832a42ea0552299d81652aa0b1f775d462175293e99dfbe4d7dbaab785a706", [:mix], [], "hexpm", "8df019facc5ec9603e94f7270f1ac73ddf339f56ade76a721eaa57c1493ba463"},
|
||||
"db_connection": {:hex, :db_connection, "2.2.2", "3bbca41b199e1598245b716248964926303b5d4609ff065125ce98bcd368939e", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "642af240d8a8affb93b4ba5a6fcd2bbcbdc327e1a524b825d383711536f8070c"},
|
||||
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
|
||||
|
|
|
@ -422,10 +422,20 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
assert json_response(conn, 200) |> length() == 3
|
||||
end
|
||||
|
||||
test "renders user's statuses with a limit", %{conn: conn, user: user} do
|
||||
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses?page_size=2")
|
||||
test "renders user's statuses with pagination", %{conn: conn, user: user} do
|
||||
conn1 = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=1")
|
||||
|
||||
assert json_response(conn, 200) |> length() == 2
|
||||
response1 = json_response(conn1, 200)
|
||||
|
||||
assert response1 |> length() == 1
|
||||
|
||||
conn2 = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=2")
|
||||
|
||||
response2 = json_response(conn2, 200)
|
||||
|
||||
assert response2 |> length() == 1
|
||||
|
||||
refute response1 == response2
|
||||
end
|
||||
|
||||
test "doesn't return private statuses by default", %{conn: conn, user: user} do
|
||||
|
|
|
@ -143,4 +143,29 @@ defmodule Pleroma.Web.AdminAPI.ReportViewTest do
|
|||
|
||||
assert %{} = ReportView.render("show.json", Report.extract_report_info(activity))
|
||||
end
|
||||
|
||||
test "reports are ordered newest first" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, report1} =
|
||||
CommonAPI.report(user, %{
|
||||
account_id: other_user.id,
|
||||
comment: "first report"
|
||||
})
|
||||
|
||||
{:ok, report2} =
|
||||
CommonAPI.report(user, %{
|
||||
account_id: other_user.id,
|
||||
comment: "second report"
|
||||
})
|
||||
|
||||
%{reports: rendered} =
|
||||
ReportView.render("index.json",
|
||||
reports: Pleroma.Web.ActivityPub.Utils.get_reports(%{}, 1, 50)
|
||||
)
|
||||
|
||||
assert report2.id == rendered |> Enum.at(0) |> Map.get(:id)
|
||||
assert report1.id == rendered |> Enum.at(1) |> Map.get(:id)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue