Check if there are no free slots *after* handling republished levels

Closes #179
This commit is contained in:
jvyden 2022-02-21 19:22:26 -05:00
commit 3e3d6b74aa
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -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()
{