Foxchat.NET/Foxchat.Identity/Controllers/UsersController.cs

21 lines
No EOL
673 B
C#

using Foxchat.Core;
using Foxchat.Core.Models;
using Foxchat.Identity.Database;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Foxchat.Identity.Controllers;
[ApiController]
[Route("/_fox/ident/users")]
public class UsersController(ILogger logger, InstanceConfig config, IdentityContext db) : ControllerBase
{
[HttpGet("{id}")]
public async Task<IActionResult> GetUser(Ulid id)
{
var user = await db.Accounts.FirstOrDefaultAsync(a => a.Id == id);
if (user == null) throw new ApiError.NotFound("User not found.");
return Ok(new Users.User(user.Id.ToString(), user.Username, config.Domain, null));
}
}