Radicade Public Code

This commit is contained in:
JogmansonReal
2026-10-16 23:33:13 -07:00
commit 55175acdf6
832 changed files with 363261 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
using Microsoft.AspNetCore.Mvc;
using RadicadeServer.RecNet.Moderation;
using RadicadeServer.RecNet.Responses;
using RadicadeServer.Utils;
using System.Linq;
namespace RadicadeServer.API
{
[Route("api/sanitize")]
public class SanitizeAPI : Controller
{
[HttpPost("v1/isPure")]
public IsPureResponse GetIsPure([FromBody] IsPureRequest req)
{
if (req.Value == null) return new IsPureResponse { IsPure = false };
return new IsPureResponse { IsPure = req.Value.IsPure() };
}
[HttpPost("v1")]
public string GetSanitized([FromBody] SanitizeStringRequest req)
{
if (req.Value == null) return "";
return $"\"{req.Value.Sanitize()}\"";
}
[HttpPost("v2/isAllowed/bulk")]
public Success IsAllowedBulk()
{
var values = ReadBulkValues();
var arePure = values.Select(value => value.IsPure()).ToList();
return new Success(true, null, new { ArePure = arePure });
}
private List<string> ReadBulkValues()
{
if (Request.HasFormContentType)
{
var form = Request.Form["Values"];
if (form.Count > 0) return form.Where(value => value != null).Select(value => value!).ToList();
}
var query = Request.Query["Values"];
if (query.Count > 0) return query.Where(value => value != null).Select(value => value!).ToList();
return new List<string>();
}
}
}