From a8e6486bf832b16951ae2fdd1c4a24e002af328f Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 10 Aug 2024 19:17:22 -0400 Subject: [PATCH] Allow duplicate level uploads if the user is the original author Closes #620 --- .../Endpoints/Game/Levels/PublishEndpoints.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Refresh.GameServer/Endpoints/Game/Levels/PublishEndpoints.cs b/Refresh.GameServer/Endpoints/Game/Levels/PublishEndpoints.cs index 4eb09cef..cf960e61 100644 --- a/Refresh.GameServer/Endpoints/Game/Levels/PublishEndpoints.cs +++ b/Refresh.GameServer/Endpoints/Game/Levels/PublishEndpoints.cs @@ -26,7 +26,7 @@ public class PublishEndpoints : EndpointGroup /// /// The level to verify /// The data context associated with the request - /// Whether or not validation succeeded + /// Whether validation succeeded private static bool VerifyLevel(GameLevelRequest body, DataContext dataContext) { if (body.Title.Length > UgcConstantLimits.TitleLimit) @@ -46,8 +46,12 @@ private static bool VerifyLevel(GameLevelRequest body, DataContext dataContext) return false; GameLevel? existingLevel = dataContext.Database.GetLevelByRootResource(body.RootResource); - // If there is an existing level with this root hash, and this isn't an update request, block the upload - if (existingLevel != null && body.LevelId != existingLevel.LevelId) + // If all are true: + // - there is an existing level with this root hash + // - this isn't an update request + // - we're not the author of the other level + // then block the upload + if (existingLevel != null && body.LevelId != existingLevel.LevelId && existingLevel.Publisher?.UserId != dataContext.User!.UserId) { dataContext.Database.AddPublishFailNotification("The level you tried to publish has already been uploaded by another user.", body.ToGameLevel(dataContext.User!), dataContext.User!);