29 lines
No EOL
894 B
C#
29 lines
No EOL
894 B
C#
using Foxchat.Core;
|
|
using Foxchat.Core.Models.Http;
|
|
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
|
|
{
|
|
private const string SoftwareName = "Foxchat.NET.Identity";
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetNode()
|
|
{
|
|
var instance = await db.GetInstanceAsync();
|
|
return Ok(new Hello.NodeInfo(new Hello.NodeSoftware(SoftwareName, BuildInfo.Version), instance.PublicKey));
|
|
}
|
|
|
|
[HttpGet("{domain}")]
|
|
public async Task<IActionResult> GetChatNode(string domain)
|
|
{
|
|
var instance = await chatInstanceResolverService.ResolveChatInstanceAsync(domain);
|
|
return Ok(instance);
|
|
}
|
|
} |