From 69e88537bd80d11e15a1c0a3749e5d948acce405 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 21 Feb 2024 17:31:30 +0100 Subject: [PATCH] [backend/masto-client] Add account search endpoint --- .../Controllers/Mastodon/SearchController.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs b/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs index 9c2fddbe..028ceb4a 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs @@ -50,6 +50,23 @@ public class SearchController( return Ok(result); } + [HttpGet("/api/v1/accounts/search")] + [Authorize("read:accounts")] + [LinkPagination(20, 40)] + [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List))] + [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] + public async Task SearchAccounts( + SearchSchemas.SearchRequest search, MastodonPaginationQuery pagination + ) + { + if (search.Query == null) + throw GracefulException.BadRequest("Query is missing or invalid"); + + var result = await SearchUsersAsync(search, pagination); + + return Ok(result); + } + [SuppressMessage("ReSharper", "EntityFramework.UnsupportedServerSideFunctionCall", Justification = "Inspection doesn't know about the Projectable attribute")] private async Task> SearchUsersAsync(