From 7595f257f8f5e4cbe7498d3f50748de5570ca599 Mon Sep 17 00:00:00 2001 From: Kopper Date: Tue, 4 Feb 2025 10:05:47 +0300 Subject: [PATCH] [backend/masto-client] Use List<> instead of HashSet<> for batch endpoints CustomCollectionModelBinder's `as IList` cast does not work for HashSet, breaking the code around trailing []s in query arguments. The values are still being treated as a set in the query so adding the same value multiple times shouldn't do anything except hit the max limit quicker. The intention was to aid clients which may not be doing their own deduplication but I haven't really observed that behavior in the wild and I doubt it's anything too much to expect from clients. That said, testing on mastodon.social shows Mastodon itself may be doing deduplication here before checking the limit, though I'm not entirely sure if this will ever be noticed in the wild. --- Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs | 2 +- Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs b/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs index d67a85f5..a3557178 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs @@ -174,7 +174,7 @@ public class AccountController( [ProducesErrors(HttpStatusCode.Forbidden)] public async Task> GetManyUsers( [FromQuery(Name = "id")] [MaxLength(40)] - HashSet ids + List ids ) { var localUser = HttpContext.GetUser(); diff --git a/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs b/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs index 4d63dc34..6c1c49a6 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs @@ -76,7 +76,7 @@ public class StatusController( [Authenticate("read:statuses")] [ProducesResults(HttpStatusCode.OK)] [ProducesErrors(HttpStatusCode.Forbidden)] - public async Task> GetManyNotes([FromQuery(Name = "id")] [MaxLength(20)] HashSet ids) + public async Task> GetManyNotes([FromQuery(Name = "id")] [MaxLength(20)] List ids) { var user = HttpContext.GetUser(); if (security.Value.PublicPreview == Enums.PublicPreview.Lockdown && user == null)