mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 15:39:01 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace RadicadeServer.API.Link;
|
||||
|
||||
[Route("link")]
|
||||
public class LinkAPI : Controller
|
||||
{
|
||||
[HttpGet("actionlink/{code}")]
|
||||
public IActionResult ConsumeActionLink(string code)
|
||||
{
|
||||
if (string.Equals(code?.Trim(), "COACH", StringComparison.OrdinalIgnoreCase))
|
||||
return Ok(new { Success = true, Code = "COACH", InfluencerAccountId = 1L });
|
||||
return Ok(new { Success = false, Code = code?.Trim() ?? string.Empty, InfluencerAccountId = 0L });
|
||||
}
|
||||
private static readonly HashSet<string> KnownDeepLinks = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"recroom://testlink",
|
||||
"recroom://solus",
|
||||
"recroom://winterwonderland",
|
||||
"recroom://reccenter",
|
||||
"recroom://testforcat"
|
||||
};
|
||||
|
||||
[HttpPost("actionlink")]
|
||||
public async Task<ActionResult<int>> CheckActionLink()
|
||||
{
|
||||
string? linkId = null;
|
||||
|
||||
using (var reader = new StreamReader(Request.Body))
|
||||
{
|
||||
var body = await reader.ReadToEndAsync();
|
||||
if (!string.IsNullOrWhiteSpace(body))
|
||||
{
|
||||
try
|
||||
{
|
||||
using var doc = JsonDocument.Parse(body);
|
||||
if (doc.RootElement.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
foreach (var prop in doc.RootElement.EnumerateObject())
|
||||
{
|
||||
if (prop.Value.ValueKind == JsonValueKind.String &&
|
||||
(prop.Name.Equals("shortLinkId", StringComparison.OrdinalIgnoreCase) ||
|
||||
prop.Name.Equals("code", StringComparison.OrdinalIgnoreCase) ||
|
||||
prop.Name.Equals("link", StringComparison.OrdinalIgnoreCase) ||
|
||||
prop.Name.Equals("deepLink", StringComparison.OrdinalIgnoreCase) ||
|
||||
prop.Name.Equals("fullLink", StringComparison.OrdinalIgnoreCase) ||
|
||||
prop.Name.Equals("roomId", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
linkId = prop.Value.GetString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (linkId == null && Request.HasFormContentType)
|
||||
linkId = Request.Form["shortLinkId"].ToString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(linkId))
|
||||
{
|
||||
var normalized = linkId.Trim();
|
||||
if (!normalized.StartsWith("recroom://", StringComparison.OrdinalIgnoreCase))
|
||||
normalized = $"recroom://{normalized}";
|
||||
if (KnownDeepLinks.Contains(normalized))
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
return Ok(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user