feat(backend): add pride flag models
This commit is contained in:
parent
39b0917585
commit
a70078995b
9 changed files with 346 additions and 0 deletions
28
Foxnouns.Backend/Controllers/FlagsController.cs
Normal file
28
Foxnouns.Backend/Controllers/FlagsController.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using Foxnouns.Backend.Database;
|
||||
using Foxnouns.Backend.Middleware;
|
||||
using Foxnouns.Backend.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Foxnouns.Backend.Controllers;
|
||||
|
||||
[Route("/api/v2/users/@me/flags")]
|
||||
public class FlagsController(DatabaseContext db, UserRendererService userRenderer) : ApiControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize("identify")]
|
||||
[ProducesResponseType<IEnumerable<PrideFlagResponse>>(statusCode: StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetFlagsAsync(CancellationToken ct = default)
|
||||
{
|
||||
var flags = await db.PrideFlags.Where(f => f.UserId == CurrentUser!.Id).ToListAsync(ct);
|
||||
|
||||
return Ok(flags.Select(f => new PrideFlagResponse(
|
||||
f.Id, userRenderer.ImageUrlFor(f), f.Name, f.Description)));
|
||||
}
|
||||
|
||||
private record PrideFlagResponse(
|
||||
Snowflake Id,
|
||||
string ImageUrl,
|
||||
string Name,
|
||||
string? Description);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue