Code review

This commit is contained in:
pleb
2026-04-18 21:40:23 -07:00
parent f1a853691c
commit 2ad7b50f65
6 changed files with 87 additions and 93 deletions
+22 -18
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using IPA;
using IPALogger = IPA.Logging.Logger;
@@ -86,45 +85,50 @@ namespace Setlist
{
}
/// <summary>
/// One-line log for a playlist. Ownership is inferred only from playlist JSON customData
/// (<c>owner</c> vs the game's platform user id). No network verification.
/// </summary>
internal static string FormatPlaylistLogLine(
string title,
bool hasSyncUrl,
string beatLeaderGuid,
string beatLeaderPlaylistGuid,
string ownerId,
string platformUserId,
HashSet<string> ownedGuids)
string platformUserId)
{
var ownerToken = string.IsNullOrEmpty(ownerId) ? "owner=n/a" : $"owner={ownerId}";
string confirmPart;
string ownerMatchesPlatformPart;
if (!hasSyncUrl)
{
confirmPart = "beatLeaderOwnerConfirmed=n/a (no sync URL)";
ownerMatchesPlatformPart = "ownerMatchesPlatform=n/a (no sync URL)";
}
else if (string.IsNullOrEmpty(beatLeaderGuid))
else if (string.IsNullOrEmpty(beatLeaderPlaylistGuid))
{
confirmPart = "beatLeaderOwnerConfirmed=n/a (sync URL is not a BeatLeader playlist)";
ownerMatchesPlatformPart =
"ownerMatchesPlatform=n/a (sync URL is not an api.beatleader.com /playlist/guid/… URL)";
}
else if (!string.IsNullOrEmpty(ownerId)
&& !string.IsNullOrEmpty(platformUserId)
&& string.Equals(ownerId, platformUserId, StringComparison.Ordinal))
else if (string.IsNullOrEmpty(platformUserId))
{
confirmPart = "beatLeaderOwnerConfirmed=true (owner matches platform user id)";
ownerMatchesPlatformPart =
"ownerMatchesPlatform=unknown (platform user id not available yet; cannot compare to owner)";
}
else if (ownedGuids == null)
else if (string.IsNullOrEmpty(ownerId))
{
confirmPart = "beatLeaderOwnerConfirmed=unknown (BeatLeader /user/playlists did not succeed; see prior log line)";
ownerMatchesPlatformPart =
"ownerMatchesPlatform=false (BeatLeader playlist URL but no owner field in playlist JSON)";
}
else if (ownedGuids.Contains(beatLeaderGuid))
else if (string.Equals(ownerId, platformUserId, StringComparison.Ordinal))
{
confirmPart = "beatLeaderOwnerConfirmed=true";
ownerMatchesPlatformPart = "ownerMatchesPlatform=true (playlist owner field equals platform user id)";
}
else
{
confirmPart = "beatLeaderOwnerConfirmed=false";
ownerMatchesPlatformPart =
"ownerMatchesPlatform=false (playlist owner field differs from platform user id)";
}
return $"Playlist \"{title}\": hasSyncUrl={hasSyncUrl}, {ownerToken}, {confirmPart}";
return $"Playlist \"{title}\": hasSyncUrl={hasSyncUrl}, {ownerToken}, {ownerMatchesPlatformPart}";
}
}
}