added total
to the user statuses adminAPI endpoint
This commit is contained in:
parent
d7af0294e6
commit
6806c03e85
6 changed files with 80 additions and 39 deletions
|
|
@ -591,7 +591,21 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
|> Enum.reverse()
|
||||
end
|
||||
|
||||
def fetch_user_activities(user, reading_user, params \\ %{}) do
|
||||
def fetch_user_activities(user, reading_user, params \\ %{})
|
||||
|
||||
def fetch_user_activities(user, reading_user, %{total: true} = params) do
|
||||
result = fetch_activities_for_user(user, reading_user, params)
|
||||
|
||||
Keyword.put(result, :items, Enum.reverse(result[:items]))
|
||||
end
|
||||
|
||||
def fetch_user_activities(user, reading_user, params) do
|
||||
user
|
||||
|> fetch_activities_for_user(reading_user, params)
|
||||
|> Enum.reverse()
|
||||
end
|
||||
|
||||
defp fetch_activities_for_user(user, reading_user, params) do
|
||||
params =
|
||||
params
|
||||
|> Map.put(:type, ["Create", "Announce"])
|
||||
|
|
@ -616,7 +630,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
}
|
||||
|> user_activities_recipients()
|
||||
|> fetch_activities(params, pagination_type)
|
||||
|> Enum.reverse()
|
||||
end
|
||||
|
||||
def fetch_statuses(reading_user, params) do
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue