[backend/masto-client] Implement /api/v1/accounts (Get multiple accounts)

This commit is contained in:
Kopper 2025-01-20 15:24:26 +03:00 committed by Laura Hausmann
parent 905b7d173a
commit f6957ba4de
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -168,6 +168,23 @@ public class AccountController(
return await VerifyUserCredentials();
}
[HttpGet]
[ProducesResults(HttpStatusCode.OK)]
[ProducesErrors(HttpStatusCode.Forbidden)]
public async Task<IEnumerable<AccountEntity>> GetManyUsers([FromQuery(Name = "id")] List<string> ids)
{
var localUser = HttpContext.GetUser();
if (config.Value.PublicPreview == Enums.PublicPreview.Lockdown && localUser == null)
throw GracefulException.Forbidden("Public preview is disabled on this instance");
var query = db.Users.IncludeCommonProperties().Where(p => ids.Contains(p.Id));
if (config.Value.PublicPreview <= Enums.PublicPreview.Restricted && localUser == null)
query = query.Where(p => p.IsLocalUser);
return await userRenderer.RenderManyAsync(await query.ToArrayAsync(), localUser);
}
[HttpGet("{id}")]
[ProducesResults(HttpStatusCode.OK)]
[ProducesErrors(HttpStatusCode.NotFound)]