Compare commits

..

26 Commits

Author SHA1 Message Date
JustArchi
ac007a7d12 Translations update 2020-06-26 11:01:12 +02:00
JustArchi
d5c55407b3 Misc 2020-06-26 10:57:11 +02:00
Vitaliy
42ad54e3df Add new item types (#1871) 2020-06-26 10:52:21 +02:00
Vitaliy
d13da54dab Fix getting privacy settings (#1866)
* Fix getting privacy settings

* Cleanup

* Misc
2020-06-26 10:52:06 +02:00
dependabot-preview[bot]
21efa0371a Bump Swashbuckle.AspNetCore.Newtonsoft from 5.5.0 to 5.5.1
Bumps [Swashbuckle.AspNetCore.Newtonsoft](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) from 5.5.0 to 5.5.1.
- [Release notes](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/releases)
- [Commits](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/compare/v5.5.0...v5.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-25 22:24:55 +00:00
dependabot-preview[bot]
ebf91cf98c Bump Swashbuckle.AspNetCore.Annotations from 5.5.0 to 5.5.1
Bumps [Swashbuckle.AspNetCore.Annotations](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) from 5.5.0 to 5.5.1.
- [Release notes](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/releases)
- [Commits](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/compare/v5.5.0...v5.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-25 22:01:25 +00:00
dependabot-preview[bot]
4f4cf083ad Bump Swashbuckle.AspNetCore from 5.5.0 to 5.5.1
Bumps [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) from 5.5.0 to 5.5.1.
- [Release notes](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/releases)
- [Commits](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/compare/v5.5.0...v5.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-25 21:40:11 +00:00
dependabot-preview[bot]
a6a1781ab9 Bump ASF-ui from 1ea7589 to 53684df
Bumps [ASF-ui](https://github.com/JustArchiNET/ASF-ui) from `1ea7589` to `53684df`.
- [Release notes](https://github.com/JustArchiNET/ASF-ui/releases)
- [Commits](1ea7589aef...53684df966)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-25 17:02:51 +00:00
JustArchi
3f3a00e457 Correct ASF-ui deploy type for github actions 2020-06-25 18:44:10 +02:00
JustArchi
0382663191 Misc 2020-06-25 17:53:37 +02:00
JustArchi
f838b3389b Bullet-proofing 2020-06-25 17:42:49 +02:00
JustArchi
73885f117a Simply x-definition 2020-06-25 17:36:05 +02:00
JustArchi
0bde6ed45f Implement EnumSchemaFilter for swagger 2020-06-25 17:07:58 +02:00
JustArchi
f550d65897 Append flags format to flags enum types in swagger 2020-06-25 15:40:04 +02:00
JustArchi
5246b2b82d Always serialize default values in API case, and never in save case 2020-06-25 14:05:39 +02:00
JustArchi
6e99d5beed Start using StringEnumConverter
In preparation for new ASF-ui code
2020-06-24 23:34:57 +02:00
JustArchi
69936d55b6 Add GET /Api/Plugins endpoint,
In regards to https://github.com/JustArchiNET/ASF-ui/issues/1015
2020-06-24 20:54:41 +02:00
JustArchi
d191820317 Expose STDP global config schema in swagger and tag it 2020-06-24 20:49:55 +02:00
JustArchi
c144c1761d Bump 2020-06-24 19:38:11 +02:00
JustArchi
267f7b1e53 Closes #1862 2020-06-24 19:34:39 +02:00
JustArchi
c45364ef99 +x for hooks/build 2020-06-24 18:55:42 +02:00
dependabot-preview[bot]
a2542a8c12 Bump ASF-ui from b74e430 to 1ea7589
Bumps [ASF-ui](https://github.com/JustArchiNET/ASF-ui) from `b74e430` to `1ea7589`.
- [Release notes](https://github.com/JustArchiNET/ASF-ui/releases)
- [Commits](b74e43068e...1ea7589aef)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-24 01:29:00 +00:00
dependabot-preview[bot]
2e2fb1828d Bump ASF-WebConfigGenerator from 5efdaf9 to c62b75a
Bumps [ASF-WebConfigGenerator](https://github.com/JustArchiNET/ASF-WebConfigGenerator) from `5efdaf9` to `c62b75a`.
- [Release notes](https://github.com/JustArchiNET/ASF-WebConfigGenerator/releases)
- [Commits](5efdaf96ac...c62b75a7a8)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-24 01:22:25 +00:00
JustArchi
f007f30c0d Bump 2020-06-23 00:09:57 +02:00
JustArchi
74881094ab Never allow clearing of OwnedPackageIDs, especially on invalid Valve callbacks 2020-06-23 00:09:27 +02:00
JustArchi
ee98282475 Bump 2020-06-22 17:28:58 +02:00
28 changed files with 348 additions and 123 deletions

View File

@@ -50,7 +50,7 @@ jobs:
run: npm ci --no-progress --prefix ASF-ui
- name: Build ASF-ui
run: npm run-script build:ci --no-progress --prefix ASF-ui
run: npm run-script deploy --no-progress --prefix ASF-ui
- name: Build ArchiSteamFarm
run: dotnet build ArchiSteamFarm -c "${{ env.CONFIGURATION }}" -p:UseAppHost=false --nologo

2
ASF-ui

Submodule ASF-ui updated: b74e43068e...e3da5e5f7a

View File

@@ -26,6 +26,7 @@ using System.Linq;
using System.Threading.Tasks;
using ArchiSteamFarm.Json;
using ArchiSteamFarm.Plugins;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SteamKit2;
@@ -38,6 +39,10 @@ namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin {
// This will keep your code compact, efficient and less dependent. You can always add additional interfaces when you'll need them, this example project will inherit quite a bit of them to show you potential usage
// ReSharper disable once UnusedType.Global - this is example plugin class that isn't used in our main code
internal sealed class ExamplePlugin : IASF, IBot, IBotCommand, IBotConnection, IBotFriendRequest, IBotMessage, IBotModules, IBotTradeOffer {
// Plugins can expose custom properties for our GET /Api/Plugins API call, simply annotate them with [JsonProperty] (or keep public)
[JsonProperty]
public readonly bool CustomIsEnabledField = true;
// This is used for identification purposes, typically you want to use a friendly name of your plugin here, such as the name of your main class
// Please note that this property can have direct dependencies only on structures that were initialized by the constructor, as it's possible to be called before OnLoaded() takes place
public string Name => nameof(ExamplePlugin);

View File

@@ -0,0 +1,32 @@
// _ _ _ ____ _ _____
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
// |
// Copyright 2015-2020 Łukasz "JustArchi" Domeradzki
// Contact: JustArchi@JustArchi.net
// |
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// |
// http://www.apache.org/licenses/LICENSE-2.0
// |
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using Newtonsoft.Json;
namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
public sealed class GlobalConfigExtension {
[JsonProperty]
public readonly bool SteamTokenDumperPluginEnabled;
[JsonConstructor]
internal GlobalConfigExtension() { }
}
}

View File

@@ -23,7 +23,6 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
internal static class SharedInfo {
internal const byte ApiVersion = 1;
internal const byte AppInfosPerSingleRequest = byte.MaxValue;
internal const string ConfigurationPropertyEnabled = nameof(SteamTokenDumperPlugin) + "Enabled";
internal const byte MaximumHoursBetweenRefresh = 8; // Per single bot account, makes sense to be 2 or 3 times less than MinimumHoursBetweenUploads
internal const byte MaximumMinutesBeforeFirstUpload = 60; // Must be greater or equal to MinimumMinutesBeforeFirstUpload
internal const byte MinimumHoursBetweenUploads = 24;

View File

@@ -0,0 +1,35 @@
// _ _ _ ____ _ _____
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
// |
// Copyright 2015-2020 Łukasz "JustArchi" Domeradzki
// Contact: JustArchi@JustArchi.net
// |
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// |
// http://www.apache.org/licenses/LICENSE-2.0
// |
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System.Net;
using ArchiSteamFarm.IPC.Controllers.Api;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
[Route("Api/SteamTokenDumperPlugin")]
public sealed class SteamTokenDumperController : ArchiController {
[HttpGet(nameof(GlobalConfigExtension))]
[ProducesResponseType(typeof(GlobalConfigExtension), (int) HttpStatusCode.OK)]
[SwaggerOperation(Tags = new[] { nameof(GlobalConfigExtension) })]
public ActionResult<GlobalConfigExtension> Get() => Ok(new GlobalConfigExtension());
}
}

View File

@@ -30,6 +30,7 @@ using System.Threading.Tasks;
using ArchiSteamFarm.Localization;
using ArchiSteamFarm.Plugins;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SteamKit2;
@@ -43,10 +44,14 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
private static readonly Timer SubmissionTimer = new Timer(async e => await SubmitData().ConfigureAwait(false));
private static GlobalCache GlobalCache;
[JsonProperty]
private static bool IsEnabled;
[JsonProperty]
public override string Name => nameof(SteamTokenDumperPlugin);
[JsonProperty]
public override Version Version => typeof(SteamTokenDumperPlugin).Assembly.GetName().Version ?? throw new ArgumentNullException(nameof(Version));
public Task<uint> GetPreferredChangeNumberToStartFrom() => Task.FromResult(IsEnabled ? GlobalCache?.LastChangeNumber ?? 0 : 0);
@@ -63,7 +68,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
if (additionalConfigProperties != null) {
foreach ((string configProperty, JToken configValue) in additionalConfigProperties) {
try {
if (configProperty == SharedInfo.ConfigurationPropertyEnabled) {
if (configProperty == nameof(GlobalConfigExtension.SteamTokenDumperPluginEnabled)) {
enabled = configValue.Value<bool>();
}
} catch (Exception e) {
@@ -356,7 +361,15 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
if (depotTasks.Count > 0) {
bot.ArchiLogger.LogGenericInfo($"Retrieving {depotTasks.Count} depot keys...");
SteamApps.DepotKeyCallback[] results = await Task.WhenAll(depotTasks).ConfigureAwait(false);
SteamApps.DepotKeyCallback[] results;
try {
results = await Task.WhenAll(depotTasks).ConfigureAwait(false);
} catch (Exception e) {
bot.ArchiLogger.LogGenericWarningException(e);
return;
}
bot.ArchiLogger.LogGenericInfo($"Finished retrieving {depotTasks.Count} depot keys.");

View File

@@ -27,9 +27,9 @@
<PackageReference Include="NLog" Version="4.7.2" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.2" />
<PackageReference Include="SteamKit2" Version="2.3.0-beta.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.5.1" />
<PackageReference Include="System.Composition" Version="1.4.1" />
<PackageReference Include="System.Linq.Async" Version="4.1.1" />
</ItemGroup>

View File

@@ -2626,7 +2626,7 @@ namespace ArchiSteamFarm {
return (false, false);
}
IElement htmlNode = htmlDocument.SelectSingleNode("//div[@data-component='ProfilePrivacySettings']/@data-privacysettings");
IElement htmlNode = htmlDocument.SelectSingleNode("//div[@id='profile_edit_config']");
if (htmlNode == null) {
Bot.ArchiLogger.LogNullError(nameof(htmlNode));
@@ -2634,7 +2634,7 @@ namespace ArchiSteamFarm {
return (false, false);
}
string json = htmlNode.GetAttributeValue("data-privacysettings");
string json = htmlNode.GetAttributeValue("data-profile-edit");
if (string.IsNullOrEmpty(json)) {
Bot.ArchiLogger.LogNullError(nameof(json));
@@ -2645,40 +2645,40 @@ namespace ArchiSteamFarm {
// This json is encoded as html attribute, don't forget to decode it
json = WebUtility.HtmlDecode(json);
Steam.UserPrivacy userPrivacy;
Steam.ProfileEditData profileEditData;
try {
userPrivacy = JsonConvert.DeserializeObject<Steam.UserPrivacy>(json);
profileEditData = JsonConvert.DeserializeObject<Steam.ProfileEditData>(json);
} catch (JsonException e) {
Bot.ArchiLogger.LogGenericException(e);
return (false, false);
}
if (userPrivacy == null) {
Bot.ArchiLogger.LogNullError(nameof(userPrivacy));
if (profileEditData == null) {
Bot.ArchiLogger.LogNullError(nameof(profileEditData));
return (false, false);
}
switch (userPrivacy.Settings.Profile) {
switch (profileEditData.Privacy.Settings.Profile) {
case Steam.UserPrivacy.PrivacySettings.EPrivacySetting.FriendsOnly:
case Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Private:
return (true, false);
case Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Public:
switch (userPrivacy.Settings.Inventory) {
switch (profileEditData.Privacy.Settings.Inventory) {
case Steam.UserPrivacy.PrivacySettings.EPrivacySetting.FriendsOnly:
case Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Private:
return (true, false);
case Steam.UserPrivacy.PrivacySettings.EPrivacySetting.Public:
return (true, true);
default:
Bot.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userPrivacy.Settings.Inventory), userPrivacy.Settings.Inventory));
Bot.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(profileEditData.Privacy.Settings.Inventory), profileEditData.Privacy.Settings.Inventory));
return (false, false);
}
default:
Bot.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userPrivacy.Settings.Profile), userPrivacy.Settings.Profile));
Bot.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(profileEditData.Privacy.Settings.Profile), profileEditData.Privacy.Settings.Profile));
return (false, false);
}

View File

@@ -23,6 +23,7 @@ using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
@@ -122,8 +123,6 @@ namespace ArchiSteamFarm {
internal readonly ArchiHandler ArchiHandler;
internal readonly BotDatabase BotDatabase;
internal readonly ConcurrentDictionary<uint, (EPaymentMethod PaymentMethod, DateTime TimeCreated)> OwnedPackageIDs = new ConcurrentDictionary<uint, (EPaymentMethod PaymentMethod, DateTime TimeCreated)>();
internal bool CanReceiveSteamCards => !IsAccountLimited && !IsAccountLocked;
internal bool IsAccountLimited => AccountFlags.HasFlag(EAccountFlags.LimitedUser) || AccountFlags.HasFlag(EAccountFlags.LimitedUserForce);
internal bool IsAccountLocked => AccountFlags.HasFlag(EAccountFlags.Lockdown);
@@ -195,6 +194,7 @@ namespace ArchiSteamFarm {
[PublicAPI]
public ECurrencyCode WalletCurrency { get; private set; }
internal ImmutableDictionary<uint, (EPaymentMethod PaymentMethod, DateTime TimeCreated)> OwnedPackageIDs { get; private set; } = ImmutableDictionary<uint, (EPaymentMethod PaymentMethod, DateTime TimeCreated)>.Empty;
internal bool PlayingBlocked { get; private set; }
internal bool PlayingWasBlocked { get; private set; }
@@ -2160,7 +2160,6 @@ namespace ArchiSteamFarm {
ArchiLogger.LogGenericInfo(Strings.BotDisconnected);
OwnedPackageIDs.Clear();
PastNotifications.Clear();
Actions.OnDisconnected();
@@ -2384,16 +2383,21 @@ namespace ArchiSteamFarm {
return;
}
bool initialLogin = OwnedPackageIDs.Count == 0;
if (callback.LicenseList.Count == 0) {
ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsEmpty, nameof(callback.LicenseList)));
return;
}
Commands.OnNewLicenseList();
OwnedPackageIDs.Clear();
Dictionary<uint, (EPaymentMethod PaymentMethod, DateTime TimeCreated)> ownedPackageIDs = new Dictionary<uint, (EPaymentMethod PaymentMethod, DateTime TimeCreated)>();
Dictionary<uint, ulong> packageAccessTokens = new Dictionary<uint, ulong>();
Dictionary<uint, uint> packagesToRefresh = new Dictionary<uint, uint>();
foreach (SteamApps.LicenseListCallback.License license in callback.LicenseList.GroupBy(license => license.PackageID, (packageID, licenses) => licenses.OrderByDescending(license => license.TimeCreated).First())) {
OwnedPackageIDs[license.PackageID] = (license.PaymentMethod, license.TimeCreated);
ownedPackageIDs[license.PackageID] = (license.PaymentMethod, license.TimeCreated);
if (!ASF.GlobalDatabase.PackageAccessTokensReadOnly.TryGetValue(license.PackageID, out ulong packageAccessToken) || (packageAccessToken != license.AccessToken)) {
packageAccessTokens[license.PackageID] = license.AccessToken;
@@ -2405,6 +2409,8 @@ namespace ArchiSteamFarm {
}
}
OwnedPackageIDs = ownedPackageIDs.ToImmutableDictionary();
if (packageAccessTokens.Count > 0) {
ASF.GlobalDatabase.RefreshPackageAccessTokens(packageAccessTokens);
}
@@ -2415,11 +2421,6 @@ namespace ArchiSteamFarm {
ArchiLogger.LogGenericTrace(Strings.Done);
}
if (initialLogin && CardsFarmer.Paused) {
// Emit initial game playing status in this case
await ResetGamesPlayed().ConfigureAwait(false);
}
await CardsFarmer.OnNewGameAdded().ConfigureAwait(false);
}
@@ -2623,6 +2624,11 @@ namespace ArchiSteamFarm {
);
}
if (CardsFarmer.Paused) {
// Emit initial game playing status in this case
Utilities.InBackground(ResetGamesPlayed);
}
SteamPICSChanges.OnBotLoggedOn();
await PluginsCore.OnBotLoggedOn(this).ConfigureAwait(false);

View File

@@ -190,8 +190,9 @@ namespace ArchiSteamFarm {
internal bool IsSteamLoginSet { get; private set; }
internal bool IsSteamParentalCodeSet { get; private set; }
internal bool IsSteamPasswordSet { get; private set; }
internal bool ShouldSerializeEverything { private get; set; } = true;
internal bool ShouldSerializeDefaultValues { private get; set; } = true;
internal bool ShouldSerializeHelperProperties { private get; set; } = true;
internal bool ShouldSerializeSensitiveDetails { private get; set; }
[JsonProperty]
internal string SteamLogin {
@@ -226,7 +227,6 @@ namespace ArchiSteamFarm {
private string BackingSteamLogin = DefaultSteamLogin;
private string BackingSteamParentalCode = DefaultSteamParentalCode;
private string BackingSteamPassword = DefaultSteamPassword;
private bool ShouldSerializeSensitiveDetails = true;
[JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamMasterClanID), Required = Required.DisallowNull)]
[JetBrains.Annotations.NotNull]
@@ -345,9 +345,6 @@ namespace ArchiSteamFarm {
return null;
}
botConfig.ShouldSerializeEverything = false;
botConfig.ShouldSerializeSensitiveDetails = false;
return botConfig;
}
@@ -442,36 +439,36 @@ namespace ArchiSteamFarm {
}
// ReSharper disable UnusedMember.Global
public bool ShouldSerializeAcceptGifts() => ShouldSerializeEverything || (AcceptGifts != DefaultAcceptGifts);
public bool ShouldSerializeAutoSteamSaleEvent() => ShouldSerializeEverything || (AutoSteamSaleEvent != DefaultAutoSteamSaleEvent);
public bool ShouldSerializeBotBehaviour() => ShouldSerializeEverything || (BotBehaviour != DefaultBotBehaviour);
public bool ShouldSerializeCustomGamePlayedWhileFarming() => ShouldSerializeEverything || (CustomGamePlayedWhileFarming != DefaultCustomGamePlayedWhileFarming);
public bool ShouldSerializeCustomGamePlayedWhileIdle() => ShouldSerializeEverything || (CustomGamePlayedWhileIdle != DefaultCustomGamePlayedWhileIdle);
public bool ShouldSerializeEnabled() => ShouldSerializeEverything || (Enabled != DefaultEnabled);
public bool ShouldSerializeFarmingOrders() => ShouldSerializeEverything || ((FarmingOrders != DefaultFarmingOrders) && !FarmingOrders.SequenceEqual(DefaultFarmingOrders));
public bool ShouldSerializeGamesPlayedWhileIdle() => ShouldSerializeEverything || ((GamesPlayedWhileIdle != DefaultGamesPlayedWhileIdle) && !GamesPlayedWhileIdle.SetEquals(DefaultGamesPlayedWhileIdle));
public bool ShouldSerializeHoursUntilCardDrops() => ShouldSerializeEverything || (HoursUntilCardDrops != DefaultHoursUntilCardDrops);
public bool ShouldSerializeIdlePriorityQueueOnly() => ShouldSerializeEverything || (IdlePriorityQueueOnly != DefaultIdlePriorityQueueOnly);
public bool ShouldSerializeIdleRefundableGames() => ShouldSerializeEverything || (IdleRefundableGames != DefaultIdleRefundableGames);
public bool ShouldSerializeLootableTypes() => ShouldSerializeEverything || ((LootableTypes != DefaultLootableTypes) && !LootableTypes.SetEquals(DefaultLootableTypes));
public bool ShouldSerializeMatchableTypes() => ShouldSerializeEverything || ((MatchableTypes != DefaultMatchableTypes) && !MatchableTypes.SetEquals(DefaultMatchableTypes));
public bool ShouldSerializeOnlineStatus() => ShouldSerializeEverything || (OnlineStatus != DefaultOnlineStatus);
public bool ShouldSerializePasswordFormat() => ShouldSerializeEverything || (PasswordFormat != DefaultPasswordFormat);
public bool ShouldSerializePaused() => ShouldSerializeEverything || (Paused != DefaultPaused);
public bool ShouldSerializeRedeemingPreferences() => ShouldSerializeEverything || (RedeemingPreferences != DefaultRedeemingPreferences);
public bool ShouldSerializeSendOnFarmingFinished() => ShouldSerializeEverything || (SendOnFarmingFinished != DefaultSendOnFarmingFinished);
public bool ShouldSerializeSendTradePeriod() => ShouldSerializeEverything || (SendTradePeriod != DefaultSendTradePeriod);
public bool ShouldSerializeShutdownOnFarmingFinished() => ShouldSerializeEverything || (ShutdownOnFarmingFinished != DefaultShutdownOnFarmingFinished);
public bool ShouldSerializeSSteamMasterClanID() => ShouldSerializeEverything || (ShouldSerializeHelperProperties && (SteamMasterClanID != DefaultSteamMasterClanID));
public bool ShouldSerializeSteamLogin() => ShouldSerializeSensitiveDetails && (ShouldSerializeEverything || (SteamLogin != DefaultSteamLogin));
public bool ShouldSerializeSteamMasterClanID() => ShouldSerializeEverything || (SteamMasterClanID != DefaultSteamMasterClanID);
public bool ShouldSerializeSteamParentalCode() => ShouldSerializeSensitiveDetails && (ShouldSerializeEverything || (SteamParentalCode != DefaultSteamParentalCode));
public bool ShouldSerializeSteamPassword() => ShouldSerializeSensitiveDetails && (ShouldSerializeEverything || (SteamPassword != DefaultSteamPassword));
public bool ShouldSerializeSteamTradeToken() => ShouldSerializeEverything || (SteamTradeToken != DefaultSteamTradeToken);
public bool ShouldSerializeSteamUserPermissions() => ShouldSerializeEverything || ((SteamUserPermissions != DefaultSteamUserPermissions) && ((SteamUserPermissions.Count != DefaultSteamUserPermissions.Count) || SteamUserPermissions.Except(DefaultSteamUserPermissions).Any()));
public bool ShouldSerializeTradingPreferences() => ShouldSerializeEverything || (TradingPreferences != DefaultTradingPreferences);
public bool ShouldSerializeTransferableTypes() => ShouldSerializeEverything || ((TransferableTypes != DefaultTransferableTypes) && !TransferableTypes.SetEquals(DefaultTransferableTypes));
public bool ShouldSerializeUseLoginKeys() => ShouldSerializeEverything || (UseLoginKeys != DefaultUseLoginKeys);
public bool ShouldSerializeAcceptGifts() => ShouldSerializeDefaultValues || (AcceptGifts != DefaultAcceptGifts);
public bool ShouldSerializeAutoSteamSaleEvent() => ShouldSerializeDefaultValues || (AutoSteamSaleEvent != DefaultAutoSteamSaleEvent);
public bool ShouldSerializeBotBehaviour() => ShouldSerializeDefaultValues || (BotBehaviour != DefaultBotBehaviour);
public bool ShouldSerializeCustomGamePlayedWhileFarming() => ShouldSerializeDefaultValues || (CustomGamePlayedWhileFarming != DefaultCustomGamePlayedWhileFarming);
public bool ShouldSerializeCustomGamePlayedWhileIdle() => ShouldSerializeDefaultValues || (CustomGamePlayedWhileIdle != DefaultCustomGamePlayedWhileIdle);
public bool ShouldSerializeEnabled() => ShouldSerializeDefaultValues || (Enabled != DefaultEnabled);
public bool ShouldSerializeFarmingOrders() => ShouldSerializeDefaultValues || ((FarmingOrders != DefaultFarmingOrders) && !FarmingOrders.SequenceEqual(DefaultFarmingOrders));
public bool ShouldSerializeGamesPlayedWhileIdle() => ShouldSerializeDefaultValues || ((GamesPlayedWhileIdle != DefaultGamesPlayedWhileIdle) && !GamesPlayedWhileIdle.SetEquals(DefaultGamesPlayedWhileIdle));
public bool ShouldSerializeHoursUntilCardDrops() => ShouldSerializeDefaultValues || (HoursUntilCardDrops != DefaultHoursUntilCardDrops);
public bool ShouldSerializeIdlePriorityQueueOnly() => ShouldSerializeDefaultValues || (IdlePriorityQueueOnly != DefaultIdlePriorityQueueOnly);
public bool ShouldSerializeIdleRefundableGames() => ShouldSerializeDefaultValues || (IdleRefundableGames != DefaultIdleRefundableGames);
public bool ShouldSerializeLootableTypes() => ShouldSerializeDefaultValues || ((LootableTypes != DefaultLootableTypes) && !LootableTypes.SetEquals(DefaultLootableTypes));
public bool ShouldSerializeMatchableTypes() => ShouldSerializeDefaultValues || ((MatchableTypes != DefaultMatchableTypes) && !MatchableTypes.SetEquals(DefaultMatchableTypes));
public bool ShouldSerializeOnlineStatus() => ShouldSerializeDefaultValues || (OnlineStatus != DefaultOnlineStatus);
public bool ShouldSerializePasswordFormat() => ShouldSerializeDefaultValues || (PasswordFormat != DefaultPasswordFormat);
public bool ShouldSerializePaused() => ShouldSerializeDefaultValues || (Paused != DefaultPaused);
public bool ShouldSerializeRedeemingPreferences() => ShouldSerializeDefaultValues || (RedeemingPreferences != DefaultRedeemingPreferences);
public bool ShouldSerializeSendOnFarmingFinished() => ShouldSerializeDefaultValues || (SendOnFarmingFinished != DefaultSendOnFarmingFinished);
public bool ShouldSerializeSendTradePeriod() => ShouldSerializeDefaultValues || (SendTradePeriod != DefaultSendTradePeriod);
public bool ShouldSerializeShutdownOnFarmingFinished() => ShouldSerializeDefaultValues || (ShutdownOnFarmingFinished != DefaultShutdownOnFarmingFinished);
public bool ShouldSerializeSSteamMasterClanID() => ShouldSerializeDefaultValues || (ShouldSerializeHelperProperties && (SteamMasterClanID != DefaultSteamMasterClanID));
public bool ShouldSerializeSteamLogin() => ShouldSerializeSensitiveDetails && (ShouldSerializeDefaultValues || (SteamLogin != DefaultSteamLogin));
public bool ShouldSerializeSteamMasterClanID() => ShouldSerializeDefaultValues || (SteamMasterClanID != DefaultSteamMasterClanID);
public bool ShouldSerializeSteamParentalCode() => ShouldSerializeSensitiveDetails && (ShouldSerializeDefaultValues || (SteamParentalCode != DefaultSteamParentalCode));
public bool ShouldSerializeSteamPassword() => ShouldSerializeSensitiveDetails && (ShouldSerializeDefaultValues || (SteamPassword != DefaultSteamPassword));
public bool ShouldSerializeSteamTradeToken() => ShouldSerializeDefaultValues || (SteamTradeToken != DefaultSteamTradeToken);
public bool ShouldSerializeSteamUserPermissions() => ShouldSerializeDefaultValues || ((SteamUserPermissions != DefaultSteamUserPermissions) && ((SteamUserPermissions.Count != DefaultSteamUserPermissions.Count) || SteamUserPermissions.Except(DefaultSteamUserPermissions).Any()));
public bool ShouldSerializeTradingPreferences() => ShouldSerializeDefaultValues || (TradingPreferences != DefaultTradingPreferences);
public bool ShouldSerializeTransferableTypes() => ShouldSerializeDefaultValues || ((TransferableTypes != DefaultTransferableTypes) && !TransferableTypes.SetEquals(DefaultTransferableTypes));
public bool ShouldSerializeUseLoginKeys() => ShouldSerializeDefaultValues || (UseLoginKeys != DefaultUseLoginKeys);
// ReSharper restore UnusedMember.Global
}

View File

@@ -204,8 +204,9 @@ namespace ArchiSteamFarm {
}
internal bool IsWebProxyPasswordSet { get; private set; }
internal bool ShouldSerializeEverything { private get; set; } = true;
internal bool ShouldSerializeDefaultValues { private get; set; } = true;
internal bool ShouldSerializeHelperProperties { private get; set; } = true;
internal bool ShouldSerializeSensitiveDetails { private get; set; }
[JsonProperty]
internal string WebProxyPassword {
@@ -219,7 +220,6 @@ namespace ArchiSteamFarm {
private WebProxy BackingWebProxy;
private string BackingWebProxyPassword = DefaultWebProxyPassword;
private bool ShouldSerializeSensitiveDetails = true;
[JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamOwnerID), Required = Required.DisallowNull)]
[JetBrains.Annotations.NotNull]
@@ -238,7 +238,7 @@ namespace ArchiSteamFarm {
}
[JsonConstructor]
private GlobalConfig() { }
internal GlobalConfig() { }
internal (bool Valid, string ErrorMessage) CheckValidation() {
if (ConnectionTimeout == 0) {
@@ -272,13 +272,6 @@ namespace ArchiSteamFarm {
return Enum.IsDefined(typeof(EUpdateChannel), UpdateChannel) ? (true, null) : (false, string.Format(Strings.ErrorConfigPropertyInvalid, nameof(UpdateChannel), UpdateChannel));
}
[JetBrains.Annotations.NotNull]
internal static GlobalConfig Create() =>
new GlobalConfig {
ShouldSerializeEverything = false,
ShouldSerializeSensitiveDetails = false
};
[ItemCanBeNull]
internal static async Task<GlobalConfig> Load(string filePath) {
if (string.IsNullOrEmpty(filePath)) {
@@ -323,9 +316,6 @@ namespace ArchiSteamFarm {
return null;
}
globalConfig.ShouldSerializeEverything = false;
globalConfig.ShouldSerializeSensitiveDetails = false;
return globalConfig;
}
@@ -374,35 +364,35 @@ namespace ArchiSteamFarm {
}
// ReSharper disable UnusedMember.Global
public bool ShouldSerializeAutoRestart() => ShouldSerializeEverything || (AutoRestart != DefaultAutoRestart);
public bool ShouldSerializeBlacklist() => ShouldSerializeEverything || ((Blacklist != DefaultBlacklist) && !Blacklist.SetEquals(DefaultBlacklist));
public bool ShouldSerializeCommandPrefix() => ShouldSerializeEverything || (CommandPrefix != DefaultCommandPrefix);
public bool ShouldSerializeConfirmationsLimiterDelay() => ShouldSerializeEverything || (ConfirmationsLimiterDelay != DefaultConfirmationsLimiterDelay);
public bool ShouldSerializeConnectionTimeout() => ShouldSerializeEverything || (ConnectionTimeout != DefaultConnectionTimeout);
public bool ShouldSerializeCurrentCulture() => ShouldSerializeEverything || (CurrentCulture != DefaultCurrentCulture);
public bool ShouldSerializeDebug() => ShouldSerializeEverything || (Debug != DefaultDebug);
public bool ShouldSerializeFarmingDelay() => ShouldSerializeEverything || (FarmingDelay != DefaultFarmingDelay);
public bool ShouldSerializeGiftsLimiterDelay() => ShouldSerializeEverything || (GiftsLimiterDelay != DefaultGiftsLimiterDelay);
public bool ShouldSerializeHeadless() => ShouldSerializeEverything || (Headless != DefaultHeadless);
public bool ShouldSerializeIdleFarmingPeriod() => ShouldSerializeEverything || (IdleFarmingPeriod != DefaultIdleFarmingPeriod);
public bool ShouldSerializeInventoryLimiterDelay() => ShouldSerializeEverything || (InventoryLimiterDelay != DefaultInventoryLimiterDelay);
public bool ShouldSerializeIPC() => ShouldSerializeEverything || (IPC != DefaultIPC);
public bool ShouldSerializeIPCPassword() => ShouldSerializeEverything || (IPCPassword != DefaultIPCPassword);
public bool ShouldSerializeLoginLimiterDelay() => ShouldSerializeEverything || (LoginLimiterDelay != DefaultLoginLimiterDelay);
public bool ShouldSerializeMaxFarmingTime() => ShouldSerializeEverything || (MaxFarmingTime != DefaultMaxFarmingTime);
public bool ShouldSerializeMaxTradeHoldDuration() => ShouldSerializeEverything || (MaxTradeHoldDuration != DefaultMaxTradeHoldDuration);
public bool ShouldSerializeOptimizationMode() => ShouldSerializeEverything || (OptimizationMode != DefaultOptimizationMode);
public bool ShouldSerializeSSteamOwnerID() => ShouldSerializeEverything || (ShouldSerializeHelperProperties && (SteamOwnerID != DefaultSteamOwnerID));
public bool ShouldSerializeStatistics() => ShouldSerializeEverything || (Statistics != DefaultStatistics);
public bool ShouldSerializeSteamMessagePrefix() => ShouldSerializeEverything || (SteamMessagePrefix != DefaultSteamMessagePrefix);
public bool ShouldSerializeSteamOwnerID() => ShouldSerializeEverything || (SteamOwnerID != DefaultSteamOwnerID);
public bool ShouldSerializeSteamProtocols() => ShouldSerializeEverything || (SteamProtocols != DefaultSteamProtocols);
public bool ShouldSerializeUpdateChannel() => ShouldSerializeEverything || (UpdateChannel != DefaultUpdateChannel);
public bool ShouldSerializeUpdatePeriod() => ShouldSerializeEverything || (UpdatePeriod != DefaultUpdatePeriod);
public bool ShouldSerializeWebLimiterDelay() => ShouldSerializeEverything || (WebLimiterDelay != DefaultWebLimiterDelay);
public bool ShouldSerializeWebProxyPassword() => ShouldSerializeSensitiveDetails && (ShouldSerializeEverything || (WebProxyPassword != DefaultWebProxyPassword));
public bool ShouldSerializeWebProxyText() => ShouldSerializeEverything || (WebProxyText != DefaultWebProxyText);
public bool ShouldSerializeWebProxyUsername() => ShouldSerializeEverything || (WebProxyUsername != DefaultWebProxyUsername);
public bool ShouldSerializeAutoRestart() => ShouldSerializeDefaultValues || (AutoRestart != DefaultAutoRestart);
public bool ShouldSerializeBlacklist() => ShouldSerializeDefaultValues || ((Blacklist != DefaultBlacklist) && !Blacklist.SetEquals(DefaultBlacklist));
public bool ShouldSerializeCommandPrefix() => ShouldSerializeDefaultValues || (CommandPrefix != DefaultCommandPrefix);
public bool ShouldSerializeConfirmationsLimiterDelay() => ShouldSerializeDefaultValues || (ConfirmationsLimiterDelay != DefaultConfirmationsLimiterDelay);
public bool ShouldSerializeConnectionTimeout() => ShouldSerializeDefaultValues || (ConnectionTimeout != DefaultConnectionTimeout);
public bool ShouldSerializeCurrentCulture() => ShouldSerializeDefaultValues || (CurrentCulture != DefaultCurrentCulture);
public bool ShouldSerializeDebug() => ShouldSerializeDefaultValues || (Debug != DefaultDebug);
public bool ShouldSerializeFarmingDelay() => ShouldSerializeDefaultValues || (FarmingDelay != DefaultFarmingDelay);
public bool ShouldSerializeGiftsLimiterDelay() => ShouldSerializeDefaultValues || (GiftsLimiterDelay != DefaultGiftsLimiterDelay);
public bool ShouldSerializeHeadless() => ShouldSerializeDefaultValues || (Headless != DefaultHeadless);
public bool ShouldSerializeIdleFarmingPeriod() => ShouldSerializeDefaultValues || (IdleFarmingPeriod != DefaultIdleFarmingPeriod);
public bool ShouldSerializeInventoryLimiterDelay() => ShouldSerializeDefaultValues || (InventoryLimiterDelay != DefaultInventoryLimiterDelay);
public bool ShouldSerializeIPC() => ShouldSerializeDefaultValues || (IPC != DefaultIPC);
public bool ShouldSerializeIPCPassword() => ShouldSerializeDefaultValues || (IPCPassword != DefaultIPCPassword);
public bool ShouldSerializeLoginLimiterDelay() => ShouldSerializeDefaultValues || (LoginLimiterDelay != DefaultLoginLimiterDelay);
public bool ShouldSerializeMaxFarmingTime() => ShouldSerializeDefaultValues || (MaxFarmingTime != DefaultMaxFarmingTime);
public bool ShouldSerializeMaxTradeHoldDuration() => ShouldSerializeDefaultValues || (MaxTradeHoldDuration != DefaultMaxTradeHoldDuration);
public bool ShouldSerializeOptimizationMode() => ShouldSerializeDefaultValues || (OptimizationMode != DefaultOptimizationMode);
public bool ShouldSerializeSSteamOwnerID() => ShouldSerializeDefaultValues || (ShouldSerializeHelperProperties && (SteamOwnerID != DefaultSteamOwnerID));
public bool ShouldSerializeStatistics() => ShouldSerializeDefaultValues || (Statistics != DefaultStatistics);
public bool ShouldSerializeSteamMessagePrefix() => ShouldSerializeDefaultValues || (SteamMessagePrefix != DefaultSteamMessagePrefix);
public bool ShouldSerializeSteamOwnerID() => ShouldSerializeDefaultValues || (SteamOwnerID != DefaultSteamOwnerID);
public bool ShouldSerializeSteamProtocols() => ShouldSerializeDefaultValues || (SteamProtocols != DefaultSteamProtocols);
public bool ShouldSerializeUpdateChannel() => ShouldSerializeDefaultValues || (UpdateChannel != DefaultUpdateChannel);
public bool ShouldSerializeUpdatePeriod() => ShouldSerializeDefaultValues || (UpdatePeriod != DefaultUpdatePeriod);
public bool ShouldSerializeWebLimiterDelay() => ShouldSerializeDefaultValues || (WebLimiterDelay != DefaultWebLimiterDelay);
public bool ShouldSerializeWebProxyPassword() => ShouldSerializeSensitiveDetails && (ShouldSerializeDefaultValues || (WebProxyPassword != DefaultWebProxyPassword));
public bool ShouldSerializeWebProxyText() => ShouldSerializeDefaultValues || (WebProxyText != DefaultWebProxyText);
public bool ShouldSerializeWebProxyUsername() => ShouldSerializeDefaultValues || (WebProxyUsername != DefaultWebProxyUsername);
// ReSharper restore UnusedMember.Global
}

View File

@@ -136,8 +136,8 @@ namespace ArchiSteamFarm {
return globalDatabase;
}
internal HashSet<uint> GetPackageIDs(uint appID, ICollection<uint> packageIDs) {
if ((appID == 0) || (packageIDs == null) || (packageIDs.Count == 0)) {
internal HashSet<uint> GetPackageIDs(uint appID, IEnumerable<uint> packageIDs) {
if ((appID == 0) || (packageIDs == null)) {
ASF.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(packageIDs));
return null;

View File

@@ -66,8 +66,9 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
return BadRequest(new GenericResponse(false, errorMessage));
}
request.GlobalConfig.ShouldSerializeEverything = false;
request.GlobalConfig.ShouldSerializeDefaultValues = false;
request.GlobalConfig.ShouldSerializeHelperProperties = false;
request.GlobalConfig.ShouldSerializeSensitiveDetails = true;
if (!request.GlobalConfig.IsWebProxyPasswordSet && ASF.GlobalConfig.IsWebProxyPasswordSet) {
request.GlobalConfig.WebProxyPassword = ASF.GlobalConfig.WebProxyPassword;

View File

@@ -100,8 +100,9 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
return BadRequest(new GenericResponse(false, errorMessage));
}
request.BotConfig.ShouldSerializeEverything = false;
request.BotConfig.ShouldSerializeDefaultValues = false;
request.BotConfig.ShouldSerializeHelperProperties = false;
request.BotConfig.ShouldSerializeSensitiveDetails = true;
HashSet<string> bots = botNames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Where(botName => botName != SharedInfo.ASF).ToHashSet(Bot.BotsComparer);

View File

@@ -0,0 +1,39 @@
// _ _ _ ____ _ _____
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
// |
// Copyright 2015-2020 Łukasz "JustArchi" Domeradzki
// Contact: JustArchi@JustArchi.net
// |
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// |
// http://www.apache.org/licenses/LICENSE-2.0
// |
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System.Collections.Generic;
using System.Net;
using ArchiSteamFarm.IPC.Responses;
using ArchiSteamFarm.Plugins;
using Microsoft.AspNetCore.Mvc;
namespace ArchiSteamFarm.IPC.Controllers.Api {
[Route("Api/Plugins")]
public sealed class PluginsController : ArchiController {
[HttpGet]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyCollection<IPlugin>>), (int) HttpStatusCode.OK)]
public ActionResult<GenericResponse<IReadOnlyCollection<IPlugin>>> PluginsGet() {
IReadOnlyCollection<IPlugin> activePlugins = PluginsCore.ActivePlugins ?? (IReadOnlyCollection<IPlugin>) new IPlugin[0];
return Ok(new GenericResponse<IReadOnlyCollection<IPlugin>>(activePlugins));
}
}
}

View File

@@ -0,0 +1,89 @@
// _ _ _ ____ _ _____
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
// |
// Copyright 2015-2020 Łukasz "JustArchi" Domeradzki
// Contact: JustArchi@JustArchi.net
// |
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// |
// http://www.apache.org/licenses/LICENSE-2.0
// |
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using JetBrains.Annotations;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace ArchiSteamFarm.IPC.Integration {
[UsedImplicitly]
internal sealed class EnumSchemaFilter : ISchemaFilter {
public void Apply([NotNull] OpenApiSchema schema, [NotNull] SchemaFilterContext context) {
if ((schema == null) || (context == null)) {
throw new ArgumentNullException(nameof(schema) + " || " + nameof(context));
}
if (!context.Type.IsEnum) {
return;
}
if (context.Type.IsDefined(typeof(FlagsAttribute), false)) {
schema.Format = "flags";
}
OpenApiObject definition = new OpenApiObject();
foreach (object enumValue in context.Type.GetEnumValues()) {
string enumName = Enum.GetName(context.Type, enumValue);
if (string.IsNullOrEmpty(enumName)) {
enumName = enumValue.ToString();
if (string.IsNullOrEmpty(enumName)) {
continue;
}
}
IOpenApiAny enumObject;
if (TryCast(enumValue, out int intValue)) {
enumObject = new OpenApiInteger(intValue);
} else if (TryCast(enumValue, out long longValue)) {
enumObject = new OpenApiLong(longValue);
} else if (TryCast(enumValue, out ulong ulongValue)) {
// OpenApi spec doesn't support ulongs as of now
enumObject = new OpenApiString(ulongValue.ToString());
} else {
throw new ArgumentOutOfRangeException(nameof(enumValue));
}
definition.Add(enumName, enumObject);
}
schema.AddExtension("x-definition", definition);
}
private static bool TryCast<T>(object value, out T typedValue) {
try {
typedValue = (T) Convert.ChangeType(value, typeof(T));
return true;
} catch (InvalidCastException) {
typedValue = default;
return false;
}
}
}
}

View File

@@ -167,6 +167,7 @@ namespace ArchiSteamFarm.IPC {
);
options.EnableAnnotations(true);
options.SchemaFilter<EnumSchemaFilter>();
options.SwaggerDoc(
SharedInfo.ASF, new OpenApiInfo {
@@ -234,9 +235,6 @@ namespace ArchiSteamFarm.IPC {
// Fix default contract resolver to use original names and not a camel case
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
// TODO: Enable this again once ASF-ui adds support in https://github.com/JustArchiNET/ASF-ui/issues/871
//options.SerializerSettings.Converters.Add(new StringEnumConverter());
if (Debugging.IsUserDebugging) {
options.SerializerSettings.Formatting = Formatting.Indented;
}

View File

@@ -283,7 +283,9 @@ namespace ArchiSteamFarm.Json {
ProfileModifier,
Sticker,
ChatEffect,
MiniProfileBackground
MiniProfileBackground,
AvatarProfileFrame,
AnimatedAvatar
}
}
@@ -603,6 +605,10 @@ namespace ArchiSteamFarm.Json {
return Asset.EType.ChatEffect;
case "item_class_13":
return Asset.EType.MiniProfileBackground;
case "item_class_14":
return Asset.EType.AvatarProfileFrame;
case "item_class_15":
return Asset.EType.AnimatedAvatar;
default:
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(tag.Value), tag.Value));
@@ -702,6 +708,15 @@ namespace ArchiSteamFarm.Json {
private NewDiscoveryQueueResponse() { }
}
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class ProfileEditData {
[JsonProperty(PropertyName = "Privacy", Required = Required.Always)]
internal readonly UserPrivacy Privacy;
[JsonConstructor]
private ProfileEditData() { }
}
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class RedeemWalletResponse : EResultResponse {
[JsonProperty(PropertyName = "wallet", Required = Required.DisallowNull)]

View File

@@ -21,6 +21,7 @@
using System;
using JetBrains.Annotations;
using Newtonsoft.Json;
namespace ArchiSteamFarm.Plugins {
[PublicAPI]
@@ -29,6 +30,7 @@ namespace ArchiSteamFarm.Plugins {
/// ASF will use this property as general plugin identifier for the user.
/// </summary>
/// <returns>String that will be used as the name of this plugin.</returns>
[JsonProperty]
[NotNull]
string Name { get; }
@@ -37,6 +39,7 @@ namespace ArchiSteamFarm.Plugins {
/// You have a freedom in deciding what versioning you want to use, this is for identification purposes only.
/// </summary>
/// <returns>Version that will be shown to the user when plugin is loaded.</returns>
[JsonProperty]
[NotNull]
Version Version { get; }

View File

@@ -39,10 +39,10 @@ namespace ArchiSteamFarm.Plugins {
internal static class PluginsCore {
internal static bool HasCustomPluginsLoaded => HasActivePluginsLoaded && ActivePlugins.Any(plugin => !(plugin is OfficialPlugin officialPlugin) || !officialPlugin.HasSameVersion());
private static bool HasActivePluginsLoaded => ActivePlugins?.Count > 0;
[ImportMany]
private static ImmutableHashSet<IPlugin> ActivePlugins { get; set; }
internal static ImmutableHashSet<IPlugin> ActivePlugins { get; private set; }
private static bool HasActivePluginsLoaded => ActivePlugins?.Count > 0;
[ItemNotNull]
internal static async Task<StringComparer> GetBotsComparer() {

View File

@@ -214,7 +214,7 @@ namespace ArchiSteamFarm {
return;
}
} else {
globalConfig = GlobalConfig.Create();
globalConfig = new GlobalConfig();
}
ASF.InitGlobalConfig(globalConfig);

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>4.2.3.1</Version>
<Version>4.2.3.4</Version>
</PropertyGroup>
<PropertyGroup>

View File

@@ -1,3 +1,5 @@
ARG DOTNET_ARCH=
FROM node:lts AS build-node
WORKDIR /app
COPY ASF-ui .
@@ -31,7 +33,6 @@ RUN dotnet --info && \
if [ -d "ArchiSteamFarm/overlay/generic" ]; then cp "ArchiSteamFarm/overlay/generic/"* "out/result"; fi && \
if [ -f "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}/${STEAM_TOKEN_DUMPER_NAME}.dll" ]; then mkdir -p "out/result/plugins/${STEAM_TOKEN_DUMPER_NAME}"; cp "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}/${STEAM_TOKEN_DUMPER_NAME}.dll" "out/result/plugins/${STEAM_TOKEN_DUMPER_NAME}"; fi
ARG DOTNET_ARCH=
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim${DOTNET_ARCH} AS runtime
ENV ASPNETCORE_URLS=
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1

View File

@@ -1,3 +1,5 @@
ARG DOTNET_ARCH=
FROM node:lts AS build-node
WORKDIR /app
COPY ASF-ui .
@@ -31,7 +33,6 @@ RUN dotnet --info && \
if [ -d "ArchiSteamFarm/overlay/linux-${ASF_ARCH}" ]; then cp "ArchiSteamFarm/overlay/linux-${ASF_ARCH}/"* "out/result"; fi && \
if [ -f "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}/${STEAM_TOKEN_DUMPER_NAME}.dll" ]; then mkdir -p "out/result/plugins/${STEAM_TOKEN_DUMPER_NAME}"; cp "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}/${STEAM_TOKEN_DUMPER_NAME}.dll" "out/result/plugins/${STEAM_TOKEN_DUMPER_NAME}"; fi
ARG DOTNET_ARCH=
FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-buster-slim${DOTNET_ARCH} AS runtime
ENV ASPNETCORE_URLS=
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1

0
hooks/build Normal file → Executable file
View File

2
wiki

Submodule wiki updated: 31e95fe1d8...6bc6f038c7