Foxchat.NET/Foxchat.Identity/Controllers/NodeController.cs

28 lines
829 B
C#
Raw Normal View History

using Foxchat.Core.Models.Http;
2024-05-11 15:26:47 +02:00
using Foxchat.Identity.Database;
using Foxchat.Identity.Services;
using Microsoft.AspNetCore.Mvc;
namespace Foxchat.Identity.Controllers;
[ApiController]
[Route("/_fox/ident/node")]
public class NodeController(IdentityContext db, ChatInstanceResolverService chatInstanceResolverService) : ControllerBase
2024-05-11 15:26:47 +02:00
{
public const string SOFTWARE_NAME = "Foxchat.NET.Identity";
[HttpGet]
public async Task<IActionResult> GetNode()
{
var instance = await db.GetInstanceAsync();
return Ok(new Hello.NodeInfo(SOFTWARE_NAME, instance.PublicKey));
2024-05-11 15:26:47 +02:00
}
[HttpGet("{domain}")]
public async Task<IActionResult> GetChatNode(string domain)
{
var instance = await chatInstanceResolverService.ResolveChatInstanceAsync(domain);
return Ok(instance);
}
}