PluralKit/PluralKit.API/Controllers/AccountController.cs

31 lines
808 B
C#
Raw Normal View History

using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace PluralKit.API.Controllers
{
[ApiController]
[Route("a")]
[Route("v1/a")]
public class AccountController: ControllerBase
{
private IDataStore _data;
2020-01-11 15:49:20 +00:00
private TokenAuthService _auth;
2020-01-11 15:49:20 +00:00
public AccountController(IDataStore data, TokenAuthService auth)
{
_data = data;
2020-01-11 15:49:20 +00:00
_auth = auth;
}
[HttpGet("{aid}")]
public async Task<ActionResult<JObject>> GetSystemByAccount(ulong aid)
{
var system = await _data.GetSystemByAccount(aid);
if (system == null) return NotFound("Account not found.");
2020-01-11 15:49:20 +00:00
return Ok(system.ToJson(_auth.ContextFor(system)));
}
}
}