Merge branch 'feature/admin-api-user-statuses' into 'develop'
Admin API: Endpoint for fetching latest user's statuses See merge request pleroma/pleroma!1413
This commit is contained in:
commit
9c6357324e
7 changed files with 110 additions and 6 deletions
|
|
@ -631,17 +631,28 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
|> Map.put("pinned_activity_ids", user.info.pinned_activities)
|
||||
|
||||
recipients =
|
||||
if reading_user do
|
||||
["https://www.w3.org/ns/activitystreams#Public"] ++
|
||||
[reading_user.ap_id | reading_user.following]
|
||||
else
|
||||
["https://www.w3.org/ns/activitystreams#Public"]
|
||||
end
|
||||
user_activities_recipients(%{
|
||||
"godmode" => params["godmode"],
|
||||
"reading_user" => reading_user
|
||||
})
|
||||
|
||||
fetch_activities(recipients, params)
|
||||
|> Enum.reverse()
|
||||
end
|
||||
|
||||
defp user_activities_recipients(%{"godmode" => true}) do
|
||||
[]
|
||||
end
|
||||
|
||||
defp user_activities_recipients(%{"reading_user" => reading_user}) do
|
||||
if reading_user do
|
||||
["https://www.w3.org/ns/activitystreams#Public"] ++
|
||||
[reading_user.ap_id | reading_user.following]
|
||||
else
|
||||
["https://www.w3.org/ns/activitystreams#Public"]
|
||||
end
|
||||
end
|
||||
|
||||
defp restrict_since(query, %{"since_id" => ""}), do: query
|
||||
|
||||
defp restrict_since(query, %{"since_id" => since_id}) do
|
||||
|
|
|
|||
|
|
@ -82,6 +82,25 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
end
|
||||
end
|
||||
|
||||
def list_user_statuses(conn, %{"nickname" => nickname} = params) do
|
||||
godmode = params["godmode"] == "true" || params["godmode"] == true
|
||||
|
||||
with %User{} = user <- User.get_cached_by_nickname_or_id(nickname) do
|
||||
{_, page_size} = page_params(params)
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_user_activities(user, nil, %{
|
||||
"limit" => page_size,
|
||||
"godmode" => godmode
|
||||
})
|
||||
|
||||
conn
|
||||
|> json(StatusView.render("index.json", %{activities: activities, as: :activity}))
|
||||
else
|
||||
_ -> {:error, :not_found}
|
||||
end
|
||||
end
|
||||
|
||||
def user_toggle_activation(conn, %{"nickname" => nickname}) do
|
||||
user = User.get_cached_by_nickname(nickname)
|
||||
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ defmodule Pleroma.Web.Router do
|
|||
|
||||
get("/users", AdminAPIController, :list_users)
|
||||
get("/users/:nickname", AdminAPIController, :user_show)
|
||||
get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
|
||||
|
||||
get("/reports", AdminAPIController, :list_reports)
|
||||
get("/reports/:id", AdminAPIController, :report_show)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue