diff --git a/Controllers/WeatherForecastController.cs b/Controllers/WeatherForecastController.cs
index 9093121..325f976 100644
--- a/Controllers/WeatherForecastController.cs
+++ b/Controllers/WeatherForecastController.cs
@@ -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());
}
}
diff --git a/Database/Tables/Redirects.cs b/Database/Tables/Redirects.cs
index 8b4d2cd..1f35bd1 100644
--- a/Database/Tables/Redirects.cs
+++ b/Database/Tables/Redirects.cs
@@ -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;
}
}
diff --git a/Justice/Interactions/CitiesInteractions.cs b/Justice/Interactions/CitiesInteractions.cs
index 90f6594..6b44505 100644
--- a/Justice/Interactions/CitiesInteractions.cs
+++ b/Justice/Interactions/CitiesInteractions.cs
@@ -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);
}
diff --git a/Types/RedirectType.cs b/Types/RedirectType.cs
new file mode 100644
index 0000000..3f035a8
--- /dev/null
+++ b/Types/RedirectType.cs
@@ -0,0 +1,14 @@
+namespace DiscordApp.Types
+{
+ public enum RedirectType
+ {
+ ///
+ /// Если еще не использовался
+ ///
+ None = 0,
+ ///
+ /// Если один раз уже редиректил
+ ///
+ Redirected = 1
+ }
+}