forked from AkkomaGang/akkoma
Admin API: Exclude boosts from GET /api/pleroma/admin/users/:nickname/statuses
and GET /api/pleroma/admin/instance/:instance/statuses
This commit is contained in:
parent
fda6f35a46
commit
4ab07cf0d5
4 changed files with 46 additions and 3 deletions
|
@ -104,6 +104,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Configuration: `feed` option for user atom feed.
|
||||
- Pleroma API: Add Emoji reactions
|
||||
- Admin API: Add `/api/pleroma/admin/instances/:instance/statuses` - lists all statuses from a given instance
|
||||
- Admin API: Add `/api/pleroma/admin/users/:nickname/statuses` - lists all statuses from a given user
|
||||
- Admin API: `PATCH /api/pleroma/users/confirm_email` to confirm email for multiple users, `PATCH /api/pleroma/users/resend_confirmation_email` to resend confirmation email for multiple users
|
||||
- ActivityPub: Configurable `type` field of the actors.
|
||||
- Mastodon API: `/api/v1/accounts/:id` has `source/pleroma/actor_type` field.
|
||||
|
|
|
@ -260,10 +260,24 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
|||
- `nickname` or `id`
|
||||
- *optional* `page_size`: number of statuses to return (default is `20`)
|
||||
- *optional* `godmode`: `true`/`false` – allows to see private statuses
|
||||
- *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false)
|
||||
- Response:
|
||||
- On failure: `Not found`
|
||||
- On success: JSON array of user's latest statuses
|
||||
|
||||
## `GET /api/pleroma/admin/instances/:instance/statuses`
|
||||
|
||||
### Retrive instance's latest statuses
|
||||
|
||||
- Params:
|
||||
- `instance`: instance name
|
||||
- *optional* `page_size`: number of statuses to return (default is `20`)
|
||||
- *optional* `godmode`: `true`/`false` – allows to see private statuses
|
||||
- *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false)
|
||||
- Response:
|
||||
- On failure: `Not found`
|
||||
- On success: JSON array of instance's latest statuses
|
||||
|
||||
## `POST /api/pleroma/admin/relay`
|
||||
|
||||
### Follow a Relay
|
||||
|
|
|
@ -244,13 +244,15 @@ def user_show(conn, %{"nickname" => nickname}) do
|
|||
end
|
||||
|
||||
def list_instance_statuses(conn, %{"instance" => instance} = params) do
|
||||
with_reblogs = params["with_reblogs"] == "true" || params["with_reblogs"] == true
|
||||
{page, page_size} = page_params(params)
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_instance_activities(%{
|
||||
"instance" => instance,
|
||||
"limit" => page_size,
|
||||
"offset" => (page - 1) * page_size
|
||||
"offset" => (page - 1) * page_size,
|
||||
"exclude_reblogs" => !with_reblogs && "true"
|
||||
})
|
||||
|
||||
conn
|
||||
|
@ -259,6 +261,7 @@ def list_instance_statuses(conn, %{"instance" => instance} = params) do
|
|||
end
|
||||
|
||||
def list_user_statuses(conn, %{"nickname" => nickname} = params) do
|
||||
with_reblogs = params["with_reblogs"] == "true" || params["with_reblogs"] == true
|
||||
godmode = params["godmode"] == "true" || params["godmode"] == true
|
||||
|
||||
with %User{} = user <- User.get_cached_by_nickname_or_id(nickname) do
|
||||
|
@ -267,7 +270,8 @@ def list_user_statuses(conn, %{"nickname" => nickname} = params) do
|
|||
activities =
|
||||
ActivityPub.fetch_user_activities(user, nil, %{
|
||||
"limit" => page_size,
|
||||
"godmode" => godmode
|
||||
"godmode" => godmode,
|
||||
"exclude_reblogs" => !with_reblogs && "true"
|
||||
})
|
||||
|
||||
conn
|
||||
|
|
|
@ -3115,6 +3115,20 @@ test "returns private statuses with godmode on", %{conn: conn, user: user} do
|
|||
|
||||
assert json_response(conn, 200) |> length() == 5
|
||||
end
|
||||
|
||||
test "excludes reblogs by default", %{conn: conn, user: user} do
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "."})
|
||||
{:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
conn_res = get(conn, "/api/pleroma/admin/users/#{other_user.nickname}/statuses")
|
||||
assert json_response(conn_res, 200) |> length() == 0
|
||||
|
||||
conn_res =
|
||||
get(conn, "/api/pleroma/admin/users/#{other_user.nickname}/statuses?with_reblogs=true")
|
||||
|
||||
assert json_response(conn_res, 200) |> length() == 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/moderation_log" do
|
||||
|
@ -3397,7 +3411,7 @@ test "GET /instances/:instance/statuses", %{conn: conn} do
|
|||
user = insert(:user, local: false, nickname: "archaeme@archae.me")
|
||||
user2 = insert(:user, local: false, nickname: "test@test.com")
|
||||
insert_pair(:note_activity, user: user)
|
||||
insert(:note_activity, user: user2)
|
||||
activity = insert(:note_activity, user: user2)
|
||||
|
||||
ret_conn = get(conn, "/api/pleroma/admin/instances/archae.me/statuses")
|
||||
|
||||
|
@ -3416,6 +3430,16 @@ test "GET /instances/:instance/statuses", %{conn: conn} do
|
|||
response = json_response(ret_conn, 200)
|
||||
|
||||
assert Enum.empty?(response)
|
||||
|
||||
CommonAPI.repeat(activity.id, user)
|
||||
|
||||
ret_conn = get(conn, "/api/pleroma/admin/instances/archae.me/statuses")
|
||||
response = json_response(ret_conn, 200)
|
||||
assert length(response) == 2
|
||||
|
||||
ret_conn = get(conn, "/api/pleroma/admin/instances/archae.me/statuses?with_reblogs=true")
|
||||
response = json_response(ret_conn, 200)
|
||||
assert length(response) == 3
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue