From: Maxim Filippov Date: Thu, 18 Jul 2019 20:38:38 +0000 (+0300) Subject: Merge branch 'develop' into feature/admin-api-user-statuses X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=9570a5be405c4cf4f07907eab4ced21e07fa20c9;p=akkoma Merge branch 'develop' into feature/admin-api-user-statuses --- 9570a5be405c4cf4f07907eab4ced21e07fa20c9 diff --cc CHANGELOG.md index 149944a02,6f268d110..3a0f2cdc9 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@@ -33,9 -40,11 +40,12 @@@ The format is based on [Keep a Changelo - Admin API: Added support for `tuples`. - Added synchronization of following/followers counters for external users - Configuration: `enabled` option for `Pleroma.Emails.Mailer`, defaulting to `false`. - - Mastodon API: Add support for categories for custom emojis by reusing the group feature. - Configuration: Pleroma.Plugs.RateLimiter `bucket_name`, `params` options. + - Addressable lists + - Twitter API: added rate limit for `/api/account/password_reset` endpoint. + - ActivityPub: Add an internal service actor for fetching ActivityPub objects. + - ActivityPub: Optional signing of ActivityPub object fetches. +- Admin API: Endpoint for fetching latest user's statuses ### Changed - Configuration: Filter.AnonymizeFilename added ability to retain file extension with custom text diff --cc test/web/admin_api/admin_api_controller_test.exs index 9d4b3d74b,ee48b752c..25e062878 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@@ -1862,40 -1862,46 +1862,79 @@@ defmodule Pleroma.Web.AdminAPI.AdminAPI ] } end + + test "queues key as atom", %{conn: conn} do + conn = + post(conn, "/api/pleroma/admin/config", %{ + configs: [ + %{ + "group" => "pleroma_job_queue", + "key" => ":queues", + "value" => [ + %{"tuple" => [":federator_incoming", 50]}, + %{"tuple" => [":federator_outgoing", 50]}, + %{"tuple" => [":web_push", 50]}, + %{"tuple" => [":mailer", 10]}, + %{"tuple" => [":transmogrifier", 20]}, + %{"tuple" => [":scheduled_activities", 10]}, + %{"tuple" => [":background", 5]} + ] + } + ] + }) + + assert json_response(conn, 200) == %{ + "configs" => [ + %{ + "group" => "pleroma_job_queue", + "key" => ":queues", + "value" => [ + %{"tuple" => [":federator_incoming", 50]}, + %{"tuple" => [":federator_outgoing", 50]}, + %{"tuple" => [":web_push", 50]}, + %{"tuple" => [":mailer", 10]}, + %{"tuple" => [":transmogrifier", 20]}, + %{"tuple" => [":scheduled_activities", 10]}, + %{"tuple" => [":background", 5]} + ] + } + ] + } + end end + + describe "GET /api/pleroma/admin/users/:nickname/statuses" do + setup do + admin = insert(:user, info: %{is_admin: true}) + user = insert(:user) + + date1 = (DateTime.to_unix(DateTime.utc_now()) + 2000) |> DateTime.from_unix!() + date2 = (DateTime.to_unix(DateTime.utc_now()) + 1000) |> DateTime.from_unix!() + date3 = (DateTime.to_unix(DateTime.utc_now()) + 3000) |> DateTime.from_unix!() + + insert(:note_activity, user: user, published: date1) + insert(:note_activity, user: user, published: date2) + insert(:note_activity, user: user, published: date3) + + conn = + build_conn() + |> assign(:user, admin) + + {:ok, conn: conn, user: user} + end + + test "renders user's statuses", %{conn: conn, user: user} do + conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses") + + 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") + + assert json_response(conn, 200) |> length() == 2 + end + end end # Needed for testing