Skip to content

feat: add endpoint to list disabled users with cursor-based pagination#327

Open
francismars wants to merge 1 commit intopubky:mainfrom
francismars:feat/admin-banned-users-api
Open

feat: add endpoint to list disabled users with cursor-based pagination#327
francismars wants to merge 1 commit intopubky:mainfrom
francismars:feat/admin-banned-users-api

Conversation

@francismars
Copy link

Summary

This PR adds an admin endpoint in pubky-homeserver to list disabled users with cursor pagination.

  • Added GET /users/disabled to the admin protected router.
  • Added handler/query/response support for disabled users listing.
  • Added repository-level disabled-users pagination with deterministic ordering.

API contract

Endpoint

GET /users/disabled

Auth

Uses existing admin middleware (X-Admin-Password header).

Query params

  • limit?: u16
  • cursor?: string (z32 pubkey, non-inclusive)

Response

{
  "items": [{ "pubkey": "..." }],
  "next_cursor": "..." | null
}

Error behavior

  • Invalid cursor => 400 Bad Request (Invalid cursor)

Implementation details

  • Route wiring:
    • pubky-homeserver/src/admin_server/app.rs
  • Admin handler + response/query types:
    • pubky-homeserver/src/admin_server/routes/disable_users.rs
  • Persistence query + pagination:
    • pubky-homeserver/src/persistence/sql/entities/user.rs

Pagination behavior:

  • Filter on disabled = true
  • Deterministic order by public_key ascending
  • Cursor is non-inclusive (public_key > cursor)
  • Uses limit + 1 fetch to determine next_cursor

Test plan

  • cargo fmt
  • cargo check -p pubky-homeserver
  • Manual Umbrel validation:
    • Seeded users in Postgres (2 disabled, 1 enabled)
    • GET /users/disabled?limit=1 returned one disabled user + non-null next_cursor
    • Request with returned cursor returned remaining disabled user(s) + next_cursor: null
    • Invalid cursor returned 400
    • Enabled user was not returned

* Implemented `GET /users/disabled` route to retrieve disabled users.
* Added pagination support using cursor for efficient data retrieval.
* Updated `UserRepository` to include a method for fetching disabled users.
* Added tests for the new endpoint and pagination functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant