mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-25 23:18:56 -07:00
Radicade Public Code
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user