mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2026-02-04 19:04:12 +02:00
add page redirector for chorten-url service, u can use this feature, using this route: DOMAIN/?uri=SHORTED_URI
fix backend controller and change route to DOMAIN/r/SHORTED_URI
This commit is contained in:
@@ -79,7 +79,7 @@ namespace yaflay.ru.Controllers
|
||||
}
|
||||
string responseBody = await message.Content.ReadAsStringAsync();
|
||||
JsonNode response = JsonNode.Parse(responseBody);
|
||||
if (response["user"] != null || Startup.ownerId.FirstOrDefault(response["user"]?["id"].ToString()) == null)
|
||||
if (response["user"] != null || Startup.ownerId?.FirstOrDefault(response["user"]?["id"].ToString()) == null)
|
||||
{
|
||||
Redirects redirects = new()
|
||||
{
|
||||
@@ -109,7 +109,7 @@ namespace yaflay.ru.Controllers
|
||||
}
|
||||
string responseBody = await message.Content.ReadAsStringAsync();
|
||||
JsonNode response = JsonNode.Parse(responseBody);
|
||||
if (response["user"] != null || Startup.ownerId.FirstOrDefault(response["user"]?["id"].ToString()) == null )
|
||||
if (response["user"] != null || Startup.ownerId?.FirstOrDefault(response["user"]?["id"].ToString()) == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -235,7 +235,7 @@ namespace yaflay.ru.Controllers
|
||||
await ctx.SaveChangesAsync();
|
||||
return Ok(body.melon);
|
||||
}
|
||||
[HttpGet("{uri}")]
|
||||
[HttpGet("r/{uri}")]
|
||||
public async Task<IActionResult> FromGitHub(string uri)
|
||||
{
|
||||
Console.WriteLine(uri);
|
||||
@@ -248,7 +248,7 @@ namespace yaflay.ru.Controllers
|
||||
if (fromCache != null)
|
||||
cache.Set($"redirectsWithUrl-{uri}", (object)fromCache, DateTime.Now.AddMinutes(10));
|
||||
}
|
||||
Console.WriteLine(fromCache.ToString());
|
||||
Console.WriteLine(fromCache?.ToString());
|
||||
return Redirect(fromCache?.redirectTo ?? "/404");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user