mirror of
https://github.com/yawaflua/PL_JusticeBot.git
synced 2025-12-08 19:39:27 +02:00
also hotfix
This commit is contained in:
@@ -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);
|
||||
if (data.RedirectType == Types.RedirectType.None)
|
||||
{
|
||||
data.RedirectType = Types.RedirectType.Redirected;
|
||||
Startup.appDbContext.Redirects.Update(data);
|
||||
Startup.appDbContext.SaveChanges();
|
||||
return Redirect(data.url);
|
||||
}
|
||||
|
||||
[HttpPost("/addOnMap")]
|
||||
public ActionResult Create(string bodyContent)
|
||||
else
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
}
|
||||
[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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
14
Types/RedirectType.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace DiscordApp.Types
|
||||
{
|
||||
public enum RedirectType
|
||||
{
|
||||
/// <summary>
|
||||
/// Если еще не использовался
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Если один раз уже редиректил
|
||||
/// </summary>
|
||||
Redirected = 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user