feat(api): add news to /api/meta response
This commit is contained in:
parent
31b6ac2cac
commit
5c57b75335
6 changed files with 147 additions and 5 deletions
|
|
@ -15,7 +15,10 @@
|
|||
|
||||
using Catalogger.Backend.Api.Middleware;
|
||||
using Catalogger.Backend.Cache.InMemoryCache;
|
||||
using Catalogger.Backend.Extensions;
|
||||
using Catalogger.Backend.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Remora.Discord.API.Abstractions.Objects;
|
||||
|
||||
namespace Catalogger.Backend.Api;
|
||||
|
||||
|
|
@ -23,20 +26,24 @@ namespace Catalogger.Backend.Api;
|
|||
public class MetaController(
|
||||
Config config,
|
||||
GuildCache guildCache,
|
||||
NewsService newsService,
|
||||
DiscordRequestService discordRequestService
|
||||
) : ApiControllerBase
|
||||
{
|
||||
[HttpGet("meta")]
|
||||
public IActionResult GetMeta()
|
||||
public async Task<IActionResult> GetMetaAsync()
|
||||
{
|
||||
var inviteUrl =
|
||||
$"https://discord.com/oauth2/authorize?client_id={config.Discord.ApplicationId}"
|
||||
+ "&permissions=537250993&scope=bot+applications.commands";
|
||||
|
||||
var news = await newsService.GetNewsAsync();
|
||||
|
||||
return Ok(
|
||||
new MetaResponse(
|
||||
Guilds: (int)CataloggerMetrics.GuildsCached.Value,
|
||||
InviteUrl: inviteUrl
|
||||
InviteUrl: inviteUrl,
|
||||
News: news
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -60,7 +67,11 @@ public class MetaController(
|
|||
);
|
||||
}
|
||||
|
||||
private record MetaResponse(int Guilds, string InviteUrl);
|
||||
private record MetaResponse(
|
||||
int Guilds,
|
||||
string InviteUrl,
|
||||
IEnumerable<NewsService.NewsMessage> News
|
||||
);
|
||||
|
||||
private record CurrentUserResponse(ApiUser User, IEnumerable<ApiGuild> Guilds);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue