mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 22:20:52 +00:00
Closes #2116
This commit is contained in:
@@ -443,12 +443,40 @@ namespace ArchiSteamFarm {
|
||||
foreach (Steam.TradeOfferSendRequest trade in trades) {
|
||||
data["json_tradeoffer"] = JsonConvert.SerializeObject(trade);
|
||||
|
||||
WebBrowser.ObjectResponse<Steam.TradeOfferSendResponse>? response = await UrlPostToJsonObjectWithSession<Steam.TradeOfferSendResponse>(SteamCommunityURL, request, data: data, referer: referer).ConfigureAwait(false);
|
||||
WebBrowser.ObjectResponse<Steam.TradeOfferSendResponse>? response = null;
|
||||
|
||||
for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) {
|
||||
response = await UrlPostToJsonObjectWithSession<Steam.TradeOfferSendResponse>(SteamCommunityURL, request, data: data, referer: referer, requestOptions: WebBrowser.ERequestOptions.ReturnServerErrors).ConfigureAwait(false);
|
||||
|
||||
if (response == null) {
|
||||
return (false, mobileTradeOfferIDs);
|
||||
}
|
||||
|
||||
if (response.StatusCode.IsServerErrorCode()) {
|
||||
if (string.IsNullOrEmpty(response.Content?.ErrorText)) {
|
||||
// This is a generic server error without a reason, try again
|
||||
response = null;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// This is actually client error with a reason, so it doesn't make sense to retry
|
||||
Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.Content!.ErrorText));
|
||||
|
||||
return (false, mobileTradeOfferIDs);
|
||||
}
|
||||
}
|
||||
|
||||
if (response?.Content == null) {
|
||||
return (false, mobileTradeOfferIDs);
|
||||
}
|
||||
|
||||
if (response.Content.TradeOfferID == 0) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(response.Content.TradeOfferID));
|
||||
|
||||
return (false, mobileTradeOfferIDs);
|
||||
}
|
||||
|
||||
if (response.Content.RequiresMobileConfirmation) {
|
||||
mobileTradeOfferIDs.Add(response.Content.TradeOfferID);
|
||||
}
|
||||
|
||||
@@ -626,12 +626,15 @@ namespace ArchiSteamFarm.Json {
|
||||
|
||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||
internal sealed class TradeOfferSendResponse {
|
||||
[JsonProperty(PropertyName = "strError", Required = Required.DisallowNull)]
|
||||
internal readonly string ErrorText = "";
|
||||
|
||||
[JsonProperty(PropertyName = "needs_mobile_confirmation", Required = Required.DisallowNull)]
|
||||
internal readonly bool RequiresMobileConfirmation;
|
||||
|
||||
internal ulong TradeOfferID { get; private set; }
|
||||
|
||||
[JsonProperty(PropertyName = "tradeofferid", Required = Required.Always)]
|
||||
[JsonProperty(PropertyName = "tradeofferid", Required = Required.DisallowNull)]
|
||||
private string TradeOfferIDText {
|
||||
set {
|
||||
if (string.IsNullOrEmpty(value)) {
|
||||
|
||||
Reference in New Issue
Block a user