From 6b7ca74897763f202c9685237e8039fee4edf908 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 27 Sep 2018 17:28:03 +0200 Subject: [PATCH] Add friendsList to privacy settings --- ArchiSteamFarm/Commands.cs | 22 +++++++++++++++------- ArchiSteamFarm/Json/Steam.cs | 10 +++++++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ArchiSteamFarm/Commands.cs b/ArchiSteamFarm/Commands.cs index e5f854669..1f8c2f9d9 100644 --- a/ArchiSteamFarm/Commands.cs +++ b/ArchiSteamFarm/Commands.cs @@ -1579,13 +1579,14 @@ namespace ArchiSteamFarm { return FormatBotResponse(string.Format(Strings.ErrorIsEmpty, nameof(privacySettingsArgs))); } - // There are only 6 privacy settings - if (privacySettingsArgs.Length > 6) { + // There are only 7 privacy settings + if (privacySettingsArgs.Length > 7) { return FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(privacySettingsArgs))); } Steam.UserPrivacy.PrivacySettings.EPrivacySetting profile = Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Private; Steam.UserPrivacy.PrivacySettings.EPrivacySetting ownedGames = Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Private; + Steam.UserPrivacy.PrivacySettings.EPrivacySetting friendsList = Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Private; Steam.UserPrivacy.PrivacySettings.EPrivacySetting playtime = Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Private; Steam.UserPrivacy.PrivacySettings.EPrivacySetting inventory = Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Private; Steam.UserPrivacy.PrivacySettings.EPrivacySetting inventoryGifts = Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Private; @@ -1609,28 +1610,35 @@ namespace ArchiSteamFarm { ownedGames = privacySetting; break; - case 2: // Playtime, child of OwnedGames + case 2: // FriendsList, child of Profile + if (profile < privacySetting) { + return FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(ownedGames))); + } + + friendsList = privacySetting; + break; + case 3: // Playtime, child of OwnedGames if (ownedGames < privacySetting) { return FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(playtime))); } playtime = privacySetting; break; - case 3: // Inventory, child of Profile + case 4: // Inventory, child of Profile if (profile < privacySetting) { return FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(inventory))); } inventory = privacySetting; break; - case 4: // InventoryGifts, child of Inventory + case 5: // InventoryGifts, child of Inventory if (inventory < privacySetting) { return FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(inventoryGifts))); } inventoryGifts = privacySetting; break; - case 5: // Comments, child of Profile + case 6: // Comments, child of Profile if (profile < privacySetting) { return FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(comments))); } @@ -1658,7 +1666,7 @@ namespace ArchiSteamFarm { } } - Steam.UserPrivacy userPrivacy = new Steam.UserPrivacy(new Steam.UserPrivacy.PrivacySettings(profile, ownedGames, playtime, inventory, inventoryGifts), comments); + Steam.UserPrivacy userPrivacy = new Steam.UserPrivacy(new Steam.UserPrivacy.PrivacySettings(profile, ownedGames, friendsList, playtime, inventory, inventoryGifts), comments); return FormatBotResponse(await Bot.ArchiWebHandler.ChangePrivacySettings(userPrivacy).ConfigureAwait(false) ? Strings.Success : Strings.WarningFailed); } diff --git a/ArchiSteamFarm/Json/Steam.cs b/ArchiSteamFarm/Json/Steam.cs index aa0c837c7..0362111c9 100644 --- a/ArchiSteamFarm/Json/Steam.cs +++ b/ArchiSteamFarm/Json/Steam.cs @@ -615,6 +615,9 @@ namespace ArchiSteamFarm.Json { private UserPrivacy() { } internal sealed class PrivacySettings { + [JsonProperty(PropertyName = "PrivacyFriendsList", Required = Required.Always)] + internal readonly EPrivacySetting FriendsList; + [JsonProperty(PropertyName = "PrivacyInventory", Required = Required.Always)] internal readonly EPrivacySetting Inventory; @@ -631,13 +634,14 @@ namespace ArchiSteamFarm.Json { internal readonly EPrivacySetting Profile; // Constructed from privacy change request - internal PrivacySettings(EPrivacySetting profile, EPrivacySetting ownedGames, EPrivacySetting playtime, EPrivacySetting inventory, EPrivacySetting inventoryGifts) { - if ((profile == EPrivacySetting.Unknown) || (ownedGames == EPrivacySetting.Unknown) || (playtime == EPrivacySetting.Unknown) || (inventory == EPrivacySetting.Unknown) || (inventoryGifts == EPrivacySetting.Unknown)) { - throw new ArgumentNullException(nameof(profile) + " || " + nameof(ownedGames) + " || " + nameof(playtime) + " || " + nameof(inventory) + " || " + nameof(inventoryGifts)); + internal PrivacySettings(EPrivacySetting profile, EPrivacySetting ownedGames, EPrivacySetting friendsList, EPrivacySetting playtime, EPrivacySetting inventory, EPrivacySetting inventoryGifts) { + if ((profile == EPrivacySetting.Unknown) || (ownedGames == EPrivacySetting.Unknown) || (friendsList == EPrivacySetting.Unknown) || (playtime == EPrivacySetting.Unknown) || (inventory == EPrivacySetting.Unknown) || (inventoryGifts == EPrivacySetting.Unknown)) { + throw new ArgumentNullException(nameof(profile) + " || " + nameof(ownedGames) + " || " + nameof(friendsList) + " || " + nameof(playtime) + " || " + nameof(inventory) + " || " + nameof(inventoryGifts)); } Profile = profile; OwnedGames = ownedGames; + FriendsList = friendsList; Playtime = playtime; Inventory = inventory; InventoryGifts = inventoryGifts;