From 6804f5b5f79f273f47c8629d4b578eec7abfed8c Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 13 Jun 2020 21:45:37 +0200 Subject: [PATCH] Fix for multiple licenses for the same package --- .../SteamTokenDumperPlugin.cs | 2 +- ArchiSteamFarm/Bot.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs index b36205aea..c9125d52f 100644 --- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs @@ -197,7 +197,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { throw new ArgumentNullException(nameof(GlobalCache)); } - Dictionary packageTokens = callback.LicenseList.ToDictionary(license => license.PackageID, license => license.AccessToken); + Dictionary packageTokens = callback.LicenseList.GroupBy(license => license.PackageID).ToDictionary(group => group.Key, group => group.OrderByDescending(license => license.TimeCreated).First().AccessToken); await GlobalCache.UpdatePackageTokens(packageTokens).ConfigureAwait(false); await Refresh(bot, packageTokens.Keys).ConfigureAwait(false); diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 6d886c811..1e857c669 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -2376,7 +2376,7 @@ namespace ArchiSteamFarm { Dictionary packageAccessTokens = new Dictionary(); Dictionary packagesToRefresh = new Dictionary(); - foreach (SteamApps.LicenseListCallback.License license in callback.LicenseList) { + foreach (SteamApps.LicenseListCallback.License license in callback.LicenseList.GroupBy(license => license.PackageID).Select(group => group.OrderByDescending(license => license.TimeCreated).First())) { OwnedPackageIDs[license.PackageID] = (license.PaymentMethod, license.TimeCreated); if (!ASF.GlobalDatabase.PackageAccessTokensReadOnly.TryGetValue(license.PackageID, out ulong packageAccessToken) || (packageAccessToken != license.AccessToken)) {