Skip to content

Commit

Permalink
Implement reupload marking for all levels of a user
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Aug 3, 2024
1 parent b01ce09 commit 0a40301
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Refresh.GameServer/CommandLineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ private class Options

[Option("fully-delete-user", HelpText = "Fully deletes a user, entirely removing the row and allowing people to register with that username once again. Not recommended.")]
public bool FullyDeleteUser { get; set; }

[Option("mark-all-reuploads", HelpText = "Marks all levels uploaded by a user as re-uploaded. Username or Email options are required if this is set.")]
public bool MarkAllReuploads { get; set; }
}

internal void StartWithArgs(string[] args)
Expand Down Expand Up @@ -195,5 +198,10 @@ private void StartWithOptions(Options options)
GameUser user = this.GetUserOrFail(options);
this._server.FullyDeleteUser(user);
}
else if (options.MarkAllReuploads)
{
GameUser user = this.GetUserOrFail(options);
this._server.MarkAllReuploads(user);
}
}
}
16 changes: 16 additions & 0 deletions Refresh.GameServer/Database/GameDatabaseContext.Users.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,20 @@ public void SetPrivacySettings(GameUser user, SerializedPrivacySettings settings
user.ProfileVisibility = settings.ProfileVisibility.Value;
});
}

public void MarkAllReuploads(GameUser user)
{
IQueryable<GameLevel> levels = this.GameLevels.Where(l => l.Publisher == user);

this.Write(() =>
{
foreach (GameLevel level in levels)
{
level.IsReUpload = true;
// normally, we'd also set the original publisher when marking a reupload.
// but since were doing this blindly, we shouldn't because the level might already be a reupload.
// we'd be setting it to null here, which could be loss of information.
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public static GameLevelResponse FromHash(string hash, DataContext dataContext)
{
string publisher;
if (!old.IsReUpload)
publisher = "!DeletedUser";
publisher = FakeUserConstants.DeletedUserName;
else
publisher = string.IsNullOrEmpty(old.OriginalPublisher)
? FakeUserConstants.UnknownUserName
Expand Down
6 changes: 6 additions & 0 deletions Refresh.GameServer/RefreshGameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ public void FullyDeleteUser(GameUser user)
using GameDatabaseContext context = this.GetContext();
context.FullyDeleteUser(user);
}

public void MarkAllReuploads(GameUser user)
{
using GameDatabaseContext context = this.GetContext();
context.MarkAllReuploads(user);
}

public override void Dispose()
{
Expand Down

0 comments on commit 0a40301

Please sign in to comment.