add mastoapi route for blocked instances
Some checks are pending
/ test-build-and-push (push) Waiting to run
Some checks are pending
/ test-build-and-push (push) Waiting to run
This commit is contained in:
parent
b79de70345
commit
8bb1ead80e
1 changed files with 16 additions and 0 deletions
|
@ -7,7 +7,9 @@ using Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities;
|
|||
using Iceshrimp.Backend.Controllers.Shared.Attributes;
|
||||
using Iceshrimp.Backend.Core.Configuration;
|
||||
using Iceshrimp.Backend.Core.Database;
|
||||
using Iceshrimp.Backend.Core.Database.Tables;
|
||||
using Iceshrimp.Backend.Core.Extensions;
|
||||
using Iceshrimp.Backend.Core.Middleware;
|
||||
using Iceshrimp.Backend.Core.Services;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -23,6 +25,8 @@ namespace Iceshrimp.Backend.Controllers.Mastodon;
|
|||
[Produces(MediaTypeNames.Application.Json)]
|
||||
public class InstanceController(
|
||||
IOptions<Config.InstanceSection> instance,
|
||||
// ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local
|
||||
IOptionsSnapshot<Config.SecuritySection> security,
|
||||
DatabaseContext db,
|
||||
MetaService meta
|
||||
) : ControllerBase
|
||||
|
@ -99,6 +103,18 @@ public class InstanceController(
|
|||
.Select(p => new RuleEntity { Id = p.Id, Text = p.Text, Hint = p.Description })
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
[HttpGet("/api/v1/domain_blocks")]
|
||||
[ProducesResults(HttpStatusCode.OK)]
|
||||
public async Task<List<BlockedInstance>> GetBlockedInstances()
|
||||
{
|
||||
if (security.Value.FederationMode == Enums.FederationMode.AllowList)
|
||||
throw GracefulException.BadRequest("Federation mode is set to allowlist.");
|
||||
|
||||
var q = db.BlockedInstances.OrderBy(p => p.Host).AsQueryable();
|
||||
|
||||
return await q.ToListAsync();
|
||||
}
|
||||
|
||||
[HttpGet("/api/v1/instance/translation_languages")]
|
||||
[ProducesResults(HttpStatusCode.OK)]
|
||||
|
|
Loading…
Add table
Reference in a new issue