[backend/masto-client] Implement /api/v1/accounts (Get multiple accounts)
This commit is contained in:
parent
905b7d173a
commit
f6957ba4de
1 changed files with 17 additions and 0 deletions
|
@ -167,6 +167,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)]
|
||||
|
|
Loading…
Add table
Reference in a new issue