fix: snapshot realms subscription, creating snapshot realms

This commit is contained in:
CyberL1 2024-06-30 09:55:47 +02:00
parent 54953fbd6c
commit c40e29b971
2 changed files with 12 additions and 4 deletions

View File

@ -1,4 +1,5 @@
using Minecraft_Realms_Emulator.Attributes;
using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Attributes;
using Minecraft_Realms_Emulator.Data;
using Minecraft_Realms_Emulator.Entities;
@ -19,10 +20,15 @@ namespace Minecraft_Realms_Emulator.Middlewares
return;
}
Subscription subscription = db.Subscriptions.First(s => s.World.Id == int.Parse(httpContext.Request.RouteValues["wId"].ToString()));
Console.WriteLine(attribute.IsSubscriptionActive(subscription.StartDate));
var wId = int.Parse(httpContext.Request.RouteValues["wId"].ToString());
World world = db.Worlds.Include(w => w.Subscription).Include(w => w.ParentWorld.Subscription).FirstOrDefault(w => w.Id == wId);
if (!attribute.IsSubscriptionActive(subscription.StartDate))
if (world.ParentWorld?.Subscription != null)
{
world = world.ParentWorld;
}
if (!attribute.IsSubscriptionActive(world.Subscription.StartDate))
{
httpContext.Response.StatusCode = 403;
await httpContext.Response.WriteAsync("You don't have an active subscription for this world");

View File

@ -597,6 +597,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
Address = $"{defaultServerAddress.Value}:{port}"
};
new DockerHelper(world).CreateServer(port);
Slot slot = new()
{
World = world,