From 3e3d6b74aa622c42452388b7a0b780ac466ee6cf Mon Sep 17 00:00:00 2001 From: jvyden Date: Mon, 21 Feb 2022 19:22:26 -0500 Subject: [PATCH] Check if there are no free slots *after* handling republished levels Closes #179 --- .../GameApi/Slots/PublishController.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ProjectLighthouse/Controllers/GameApi/Slots/PublishController.cs b/ProjectLighthouse/Controllers/GameApi/Slots/PublishController.cs index 564a0607..bcfdd34a 100644 --- a/ProjectLighthouse/Controllers/GameApi/Slots/PublishController.cs +++ b/ProjectLighthouse/Controllers/GameApi/Slots/PublishController.cs @@ -41,11 +41,6 @@ public class PublishController : ControllerBase User user = userAndToken.Value.Item1; GameToken gameToken = userAndToken.Value.Item2; - if (user.GetUsedSlotsForGame(gameToken.GameVersion, database) > 50) - { - return this.StatusCode(403, ""); - } - Slot? slot = await this.getSlotFromBody(); if (slot == null) return this.BadRequest(); // if the level cant be parsed then it obviously cant be uploaded @@ -60,6 +55,10 @@ public class PublishController : ControllerBase if (oldSlot == null) return this.NotFound(); if (oldSlot.CreatorId != user.UserId) return this.BadRequest(); } + else if (user.GetUsedSlotsForGame(gameToken.GameVersion, database) > ServerSettings.Instance.EntitledSlots) + { + return this.StatusCode(403, ""); + } slot.ResourceCollection += "," + slot.IconHash; // tells LBP to upload icon after we process resources here @@ -84,9 +83,6 @@ public class PublishController : ControllerBase // ReSharper disable once PossibleInvalidOperationException User user = userAndToken.Value.Item1; GameToken gameToken = userAndToken.Value.Item2; - - if (user.UsedSlots >= ServerSettings.Instance.EntitledSlots) return this.BadRequest(); - Slot? slot = await this.getSlotFromBody(); if (slot?.Location == null) return this.BadRequest(); @@ -141,6 +137,11 @@ public class PublishController : ControllerBase return this.Ok(oldSlot.Serialize(gameToken.GameVersion)); } + if (user.GetUsedSlotsForGame(gameToken.GameVersion, database) > ServerSettings.Instance.EntitledSlots) + { + return this.StatusCode(403, ""); + } + //TODO: parse location in body Location l = new() {