also hotfix

This commit is contained in:
Дмитрий Шиманский
2023-11-16 20:04:25 +03:00
parent b675e8b77b
commit 1c48750d87
4 changed files with 32 additions and 10 deletions

View File

@@ -11,16 +11,23 @@ namespace DiscordApp.Controllers
{
[HttpGet("/redirects/{uri}")]
public IActionResult Get(string uri)
public IActionResult Get(string uri, [FromBody] string? bodyContent)
{
var data = Startup.appDbContext.Redirects.First(k => k.Id == uri);
Startup.appDbContext.Redirects.Remove(data);
Startup.appDbContext.SaveChanges();
return Redirect(data.url);
if (data.RedirectType == Types.RedirectType.None)
{
data.RedirectType = Types.RedirectType.Redirected;
Startup.appDbContext.Redirects.Update(data);
Startup.appDbContext.SaveChanges();
return Redirect(data.url);
}
else
{
return BadRequest();
}
}
[HttpPost("/addOnMap")]
public ActionResult Create(string bodyContent)
[HttpPost("/redirects/{uri}")]
public IActionResult Post(string uri, [FromBody] string bodyContent)
{
JsonNode jsonBodyContent = JsonNode.Parse(bodyContent);
string[] paymentData = jsonBodyContent["data"].ToString().Split(";");
@@ -35,7 +42,7 @@ namespace DiscordApp.Controllers
.Build();
}).RunSynchronously();
return Ok();
return Redirect(message.GetJumpUrl());
}
}

View File

@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using DiscordApp.Types;
namespace DiscordApp.Database.Tables
{
@@ -9,6 +10,6 @@ namespace DiscordApp.Database.Tables
[Key]
public string Id { get; set; }
public string url { get; set; }
public RedirectType RedirectType { get; set; } = RedirectType.None;
}
}

View File

@@ -24,7 +24,7 @@ namespace DiscordApp.Justice.Interactions
var redirectTable = new Redirects() { Id = redirectUri , url = uri};
Startup.appDbContext.Redirects.Add(redirectTable);
Startup.appDbContext.SaveChanges();
await FollowupAsync("Нажмите на кнопку ниже для оплаты", components: new ComponentBuilder().WithButton("Оплатить", url: $"https://discord.yawaflua.ru/redirects/{redirectUri}", style: ButtonStyle.Link).Build());//, ephemeral: true);
await FollowupAsync("Нажмите на кнопку ниже для оплаты", components: new ComponentBuilder().WithButton("Оплатить", url: $"https://discord.yawaflua.ru/redirects/{redirectUri}", style: ButtonStyle.Link).Build(), ephemeral: true);
}

14
Types/RedirectType.cs Normal file
View File

@@ -0,0 +1,14 @@
namespace DiscordApp.Types
{
public enum RedirectType
{
/// <summary>
/// Если еще не использовался
/// </summary>
None = 0,
/// <summary>
/// Если один раз уже редиректил
/// </summary>
Redirected = 1
}
}