@page "/admin/relays"
@using Iceshrimp.Backend.Components.Admin
@using Iceshrimp.Backend.Core.Configuration
@using Iceshrimp.Backend.Core.Database.Tables
@using Iceshrimp.Backend.Core.Middleware
@using Iceshrimp.Backend.Core.Services
@using Microsoft.AspNetCore.Mvc
@using Microsoft.EntityFrameworkCore
@using Microsoft.Extensions.Options
@using Microsoft.AspNetCore.Components.Forms
@inherits AdminComponentBase
@if (!Options.Value.AcceptLdSignatures)
{
Warning: The configuration option AcceptLdSignatures
is not enabled. Activities received from relays will be rejected.
}
URI |
Status |
Actions |
@foreach (var relay in _relays)
{
@relay.Inbox |
@(relay.Status.ToString())
|
Unsubscribe
|
}
@if (_relays is [])
{
No relays configured.
}
Subscribe to new relay
@code {
[Inject] public required IOptionsSnapshot Options { get; set; }
[Inject] public required RelayService RelayService { get; set; }
[Parameter, FromQuery] public int? Offset { get; set; }
[SupplyParameterFromForm] private RelayModel Model { get; set; } = null!;
private Relay[] _relays = [];
private class RelayModel
{
public string? InboxUri { get; set; }
}
protected override void OnParametersSet()
{
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
Model ??= new RelayModel();
}
protected override async Task OnGet()
{
_relays = await Database.Relays.OrderBy(p => p.Id).ToArrayAsync();
}
private async Task OnSubmit()
{
if (Model.InboxUri == null)
throw GracefulException.BadRequest("Missing host field");
await RelayService.SubscribeToRelayAsync(Model.InboxUri);
ReloadPage();
}
}