From 5eec67fe70bb31f44edcbb12d3bd24fdbb611de1 Mon Sep 17 00:00:00 2001 From: pancakes Date: Fri, 7 Mar 2025 12:30:50 +1000 Subject: [PATCH] [backend/api] Add name and host queries to remote emoji endpoint --- Iceshrimp.Backend/Controllers/Web/EmojiController.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Backend/Controllers/Web/EmojiController.cs b/Iceshrimp.Backend/Controllers/Web/EmojiController.cs index ce898832..efe30d7b 100644 --- a/Iceshrimp.Backend/Controllers/Web/EmojiController.cs +++ b/Iceshrimp.Backend/Controllers/Web/EmojiController.cs @@ -53,10 +53,16 @@ public class EmojiController( [Authorize("role:moderator")] [RestPagination(100, 500)] [ProducesResults(HttpStatusCode.OK)] - public async Task>> GetRemoteEmoji(PaginationQuery pq) + public async Task>> GetRemoteEmoji( + [FromQuery] string? name, [FromQuery] string? host, PaginationQuery pq + ) { var res = await db.Emojis - .Where(p => p.Host != null) + .Where(p => p.Host != null + && (!string.IsNullOrWhiteSpace(host) && p.Host.ToLower().Contains(host.ToLower()) + || string.IsNullOrWhiteSpace(host)) + && (!string.IsNullOrWhiteSpace(name) && p.Name.ToLower().Contains(name.ToLower()) + || string.IsNullOrWhiteSpace(name))) .Select(p => new EmojiResponse { Id = p.Id,