feat: add sort parameter for users/search api endpoint (#8594)

Introduces a new sort parameter to the `/users/search` API endpoint, similar to the one that already exists for the `/admin/users` endpoint.

Resolves #8499

Co-authored-by: DebuggerAndrzej <redpandaworkstation@gmail.com>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8594
Reviewed-by: Lucas <sclu1034@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: DebuggerAndrzej <debuggerandrzej@noreply.codeberg.org>
Co-committed-by: DebuggerAndrzej <debuggerandrzej@noreply.codeberg.org>
This commit is contained in:
DebuggerAndrzej 2025-07-24 22:40:27 +02:00 committed by Gusted
commit f4894b0edd
5 changed files with 114 additions and 21 deletions

View file

@ -33,6 +33,11 @@ func Search(ctx *context.APIContext) {
// description: ID of the user to search for
// type: integer
// format: int64
// - name: sort
// in: query
// description: sort order of results
// type: string
// enum: [oldest, newest, alphabetically, reversealphabetically, recentupdate, leastupdate]
// - name: page
// in: query
// description: page number of results to return (1-based)
@ -81,6 +86,7 @@ func Search(ctx *context.APIContext) {
SearchByEmail: true,
Visible: visible,
ListOptions: listOptions,
OrderBy: utils.GetDbSearchOrder(ctx),
})
if err != nil {
ctx.JSON(http.StatusInternalServerError, map[string]any{