namespace Backend.Endpoints;

public static partial class AdminModerationEndpoints
{
    public static RouteGroupBuilder MapAdminModerationEndpoints(this RouteGroupBuilder group)
    {
        group.MapDelete("/clips/{clipId:int}", DeleteClip)
            .AddEndpointFilter((context, next) => AdminEndpointConventions.RequireWritePermission(context, next, Backend.Security.AdminPermissionCatalog.Clips))
            .WithName("DeleteAdminClip")
            .WithOpenApi();
        group.MapPost("/clips/{clipId:int}/status", UpdateClipStatus)
            .AddEndpointFilter((context, next) => AdminEndpointConventions.RequireWritePermission(context, next, Backend.Security.AdminPermissionCatalog.Clips))
            .WithName("UpdateAdminClipStatus")
            .WithOpenApi();
        group.MapPost("/nominations/{nominationId:int}/approve", ApproveNomination)
            .AddEndpointFilter((context, next) => AdminEndpointConventions.RequireWritePermission(context, next, Backend.Security.AdminPermissionCatalog.Nominations))
            .WithName("ApproveAdminNomination")
            .WithOpenApi();
        group.MapPost("/nominations/{nominationId:int}/reject", RejectNomination)
            .AddEndpointFilter((context, next) => AdminEndpointConventions.RequireWritePermission(context, next, Backend.Security.AdminPermissionCatalog.Nominations))
            .WithName("RejectAdminNomination")
            .WithOpenApi();
        group.MapGet("/risk-flags", GetRiskFlags)
            .AddEndpointFilter((context, next) => AdminEndpointConventions.RequirePermission(context, next, Backend.Security.AdminPermissionCatalog.Risk))
            .WithName("GetAdminRiskFlags")
            .WithOpenApi();
        group.MapPost("/risk-flags/{riskFlagId:int}/resolve", ResolveRiskFlag)
            .AddEndpointFilter((context, next) => AdminEndpointConventions.RequireWritePermission(context, next, Backend.Security.AdminPermissionCatalog.Risk))
            .WithName("ResolveRiskFlag")
            .WithOpenApi();
        group.MapPost("/risk-flags/bulk-resolve", BulkResolveRiskFlags)
            .AddEndpointFilter((context, next) => AdminEndpointConventions.RequireWritePermission(context, next, Backend.Security.AdminPermissionCatalog.Risk))
            .WithName("BulkResolveRiskFlags")
            .WithOpenApi();
        group.MapGet("/risk-rules", GetRiskRules)
            .AddEndpointFilter((context, next) => AdminEndpointConventions.RequirePermission(context, next, Backend.Security.AdminPermissionCatalog.Risk))
            .WithName("GetAdminRiskRules")
            .WithOpenApi();
        group.MapPut("/risk-rules", UpdateRiskRules)
            .AddEndpointFilter((context, next) => AdminEndpointConventions.RequireWritePermission(context, next, Backend.Security.AdminPermissionCatalog.Risk))
            .WithName("UpdateAdminRiskRules")
            .WithOpenApi();
        return group;
    }
}
