aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/admin_api
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2021-01-21 18:51:21 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2021-01-27 07:45:02 +0300
commit6806c03e8543c57ef85393eafdc6117d9776049f (patch)
treec6028508d82e59f70645df687bae411446e2fca8 /lib/pleroma/web/admin_api
parentd7af0294e6a3a690524e0a08a35c9c6dafbb9f79 (diff)
downloadpleroma-6806c03e8543c57ef85393eafdc6117d9776049f.tar.gz
added total
to the user statuses adminAPI endpoint
Diffstat (limited to 'lib/pleroma/web/admin_api')
-rw-r--r--lib/pleroma/web/admin_api/controllers/admin_api_controller.ex7
-rw-r--r--lib/pleroma/web/admin_api/views/status_view.ex4
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex b/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex
index 709c863ec..500556710 100644
--- a/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex
+++ b/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex
@@ -105,18 +105,19 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
with %User{} = user <- User.get_cached_by_nickname_or_id(nickname, for: admin) do
{page, page_size} = page_params(params)
- activities =
+ result =
ActivityPub.fetch_user_activities(user, nil, %{
limit: page_size,
offset: (page - 1) * page_size,
godmode: godmode,
exclude_reblogs: not with_reblogs,
- pagination_type: :offset
+ pagination_type: :offset,
+ total: true
})
conn
|> put_view(AdminAPI.StatusView)
- |> render("index.json", %{activities: activities, as: :activity})
+ |> render("index.json", %{total: result[:total], activities: result[:items], as: :activity})
else
_ -> {:error, :not_found}
end
diff --git a/lib/pleroma/web/admin_api/views/status_view.ex b/lib/pleroma/web/admin_api/views/status_view.ex
index 361fa5b0d..48d639b41 100644
--- a/lib/pleroma/web/admin_api/views/status_view.ex
+++ b/lib/pleroma/web/admin_api/views/status_view.ex
@@ -13,6 +13,10 @@ defmodule Pleroma.Web.AdminAPI.StatusView do
defdelegate merge_account_views(user), to: AdminAPI.AccountView
+ def render("index.json", %{total: total} = opts) do
+ %{total: total, activities: safe_render_many(opts.activities, __MODULE__, "show.json", opts)}
+ end
+
def render("index.json", opts) do
safe_render_many(opts.activities, __MODULE__, "show.json", opts)
end