Skip to content

Commit

Permalink
Allow duplicate level uploads if the user is the original author
Browse files Browse the repository at this point in the history
Closes #620
  • Loading branch information
jvyden committed Aug 10, 2024
1 parent 406ae41 commit a8e6486
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Refresh.GameServer/Endpoints/Game/Levels/PublishEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class PublishEndpoints : EndpointGroup
/// </summary>
/// <param name="body">The level to verify</param>
/// <param name="dataContext">The data context associated with the request</param>
/// <returns>Whether or not validation succeeded</returns>
/// <returns>Whether validation succeeded</returns>
private static bool VerifyLevel(GameLevelRequest body, DataContext dataContext)
{
if (body.Title.Length > UgcConstantLimits.TitleLimit)
Expand All @@ -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!);

Expand Down

0 comments on commit a8e6486

Please sign in to comment.