2019-07-17 11:45:36 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-02-12 14:16:19 +00:00
|
|
|
|
2019-07-17 11:45:36 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
2019-12-28 14:52:59 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
2020-02-12 14:16:19 +00:00
|
|
|
using PluralKit.Core;
|
|
|
|
|
|
|
|
namespace PluralKit.API
|
2019-07-17 11:45:36 +00:00
|
|
|
{
|
|
|
|
[ApiController]
|
2020-05-07 02:39:49 +00:00
|
|
|
[ApiVersion("1.0")]
|
2019-07-17 11:45:36 +00:00
|
|
|
[Route("a")]
|
2020-05-07 02:39:49 +00:00
|
|
|
[Route( "v{version:apiVersion}/a" )]
|
2019-07-17 11:45:36 +00:00
|
|
|
public class AccountController: ControllerBase
|
|
|
|
{
|
2019-10-26 17:45:30 +00:00
|
|
|
private IDataStore _data;
|
2020-01-11 15:49:20 +00:00
|
|
|
private TokenAuthService _auth;
|
2019-07-17 11:45:36 +00:00
|
|
|
|
2020-01-11 15:49:20 +00:00
|
|
|
public AccountController(IDataStore data, TokenAuthService auth)
|
2019-07-17 11:45:36 +00:00
|
|
|
{
|
2019-10-26 17:45:30 +00:00
|
|
|
_data = data;
|
2020-01-11 15:49:20 +00:00
|
|
|
_auth = auth;
|
2019-07-17 11:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[HttpGet("{aid}")]
|
2019-12-28 14:52:59 +00:00
|
|
|
public async Task<ActionResult<JObject>> GetSystemByAccount(ulong aid)
|
2019-07-17 11:45:36 +00:00
|
|
|
{
|
2019-10-26 17:45:30 +00:00
|
|
|
var system = await _data.GetSystemByAccount(aid);
|
2019-07-17 11:45:36 +00:00
|
|
|
if (system == null) return NotFound("Account not found.");
|
|
|
|
|
2020-01-11 15:49:20 +00:00
|
|
|
return Ok(system.ToJson(_auth.ContextFor(system)));
|
2019-07-17 11:45:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|