2024-05-21 17:45:35 +02:00
|
|
|
using Foxchat.Core;
|
2024-05-20 17:00:21 +02:00
|
|
|
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")]
|
2024-05-21 17:45:35 +02:00
|
|
|
public class NodeController(IdentityContext db, ChatInstanceResolverService chatInstanceResolverService)
|
|
|
|
: ControllerBase
|
2024-05-11 15:26:47 +02:00
|
|
|
{
|
2024-05-21 17:45:35 +02:00
|
|
|
private const string SoftwareName = "Foxchat.NET.Identity";
|
2024-05-11 15:26:47 +02:00
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
public async Task<IActionResult> GetNode()
|
|
|
|
{
|
2024-05-20 17:00:21 +02:00
|
|
|
var instance = await db.GetInstanceAsync();
|
2024-05-21 17:45:35 +02:00
|
|
|
return Ok(new Hello.NodeInfo(new Hello.NodeSoftware(SoftwareName, BuildInfo.Version), 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);
|
|
|
|
}
|
2024-05-21 17:45:35 +02:00
|
|
|
}
|