[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.
This commit is contained in:
Kopper 2025-02-04 10:05:47 +03:00
parent ab0b1e543a
commit 7595f257f8
2 changed files with 2 additions and 2 deletions

View file

@ -174,7 +174,7 @@ public class AccountController(
[ProducesErrors(HttpStatusCode.Forbidden)] [ProducesErrors(HttpStatusCode.Forbidden)]
public async Task<IEnumerable<AccountEntity>> GetManyUsers( public async Task<IEnumerable<AccountEntity>> GetManyUsers(
[FromQuery(Name = "id")] [MaxLength(40)] [FromQuery(Name = "id")] [MaxLength(40)]
HashSet<string> ids List<string> ids
) )
{ {
var localUser = HttpContext.GetUser(); var localUser = HttpContext.GetUser();

View file

@ -76,7 +76,7 @@ public class StatusController(
[Authenticate("read:statuses")] [Authenticate("read:statuses")]
[ProducesResults(HttpStatusCode.OK)] [ProducesResults(HttpStatusCode.OK)]
[ProducesErrors(HttpStatusCode.Forbidden)] [ProducesErrors(HttpStatusCode.Forbidden)]
public async Task<IEnumerable<StatusEntity>> GetManyNotes([FromQuery(Name = "id")] [MaxLength(20)] HashSet<string> ids) public async Task<IEnumerable<StatusEntity>> GetManyNotes([FromQuery(Name = "id")] [MaxLength(20)] List<string> ids)
{ {
var user = HttpContext.GetUser(); var user = HttpContext.GetUser();
if (security.Value.PublicPreview == Enums.PublicPreview.Lockdown && user == null) if (security.Value.PublicPreview == Enums.PublicPreview.Lockdown && user == null)