mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-15 14:12:27 +00:00
Add logging to StartPublish, fix bug where levels do not publish if rootLevel does not exist
This commit is contained in:
parent
77edfed0be
commit
ab346bc906
2 changed files with 23 additions and 12 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -31,6 +31,8 @@ gitUnpushed.txt
|
||||||
gitRevCount.txt
|
gitRevCount.txt
|
||||||
logs/*
|
logs/*
|
||||||
npTicket*
|
npTicket*
|
||||||
|
r.tar.gz
|
||||||
|
lighthouse.yml.configme
|
||||||
|
|
||||||
# MSBuild stuff
|
# MSBuild stuff
|
||||||
bin/
|
bin/
|
||||||
|
@ -44,4 +46,4 @@ BACKUP*
|
||||||
backup*
|
backup*
|
||||||
|
|
||||||
*.tmp
|
*.tmp
|
||||||
*.bin
|
*.bin
|
|
@ -40,26 +40,35 @@ public class PublishController : ControllerBase
|
||||||
GameToken gameToken = userAndToken.Value.Item2;
|
GameToken gameToken = userAndToken.Value.Item2;
|
||||||
|
|
||||||
Slot? slot = await this.getSlotFromBody();
|
Slot? slot = await this.getSlotFromBody();
|
||||||
if (slot == null) return this.BadRequest(); // if the level cant be parsed then it obviously cant be uploaded
|
if (slot == null) {
|
||||||
|
Logger.Warn("Rejecting level upload, slot is null", LogArea.Publish);
|
||||||
|
return this.BadRequest(); // if the level cant be parsed then it obviously cant be uploaded
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(slot.RootLevel)) return this.BadRequest();
|
if (string.IsNullOrEmpty(slot.RootLevel))
|
||||||
|
{
|
||||||
|
Logger.Warn("Rejecting level upload, slot does not include rootLevel", LogArea.Publish);
|
||||||
|
return this.BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(slot.ResourceCollection)) slot.ResourceCollection = slot.RootLevel;
|
if (string.IsNullOrEmpty(slot.ResourceCollection)) slot.ResourceCollection = slot.RootLevel;
|
||||||
|
|
||||||
LbpFile? rootLevel = LbpFile.FromHash(slot.RootLevel);
|
|
||||||
if (rootLevel == null) return this.BadRequest();
|
|
||||||
|
|
||||||
GameVersion slotVersion = FileHelper.ParseLevelVersion(rootLevel);
|
|
||||||
if (slotVersion == GameVersion.Unknown) slotVersion = gameToken.GameVersion;
|
|
||||||
|
|
||||||
// Republish logic
|
// Republish logic
|
||||||
if (slot.SlotId != 0)
|
if (slot.SlotId != 0)
|
||||||
{
|
{
|
||||||
Slot? oldSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == slot.SlotId);
|
Slot? oldSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == slot.SlotId);
|
||||||
if (oldSlot == null) return this.NotFound();
|
if (oldSlot == null)
|
||||||
if (oldSlot.CreatorId != user.UserId) return this.BadRequest();
|
{
|
||||||
|
Logger.Warn("Rejecting level reupload, could not find old slot", LogArea.Publish);
|
||||||
|
return this.NotFound();
|
||||||
|
}
|
||||||
|
if (oldSlot.CreatorId != user.UserId)
|
||||||
|
{
|
||||||
|
Logger.Warn("Rejecting level reupload, old slot's creator is not publishing user", LogArea.Publish);
|
||||||
|
return this.BadRequest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (user.GetUsedSlotsForGame(slotVersion) > ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots)
|
else if (user.GetUsedSlotsForGame(gameToken.GameVersion) > ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots)
|
||||||
{
|
{
|
||||||
return this.StatusCode(403, "");
|
return this.StatusCode(403, "");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue