internal async Task<HashSet<Confirmation>> GetConfirmations() {
if (!HasCorrectDeviceID) {
Bot.ArchiLogger.LogGenericWarning("Can't execute properly due to invalid DeviceID!");
return null;
}
uint time = await GetSteamTime().ConfigureAwait(false);
if (time == 0) {
Bot.ArchiLogger.LogNullError(nameof(time));
return null;
}
string confirmationHash = GenerateConfirmationKey(time, "conf");
if (string.IsNullOrEmpty(confirmationHash)) {
Bot.ArchiLogger.LogNullError(nameof(confirmationHash));
return null;
}
HtmlDocument htmlDocument = await Bot.ArchiWebHandler.GetConfirmations(DeviceID, confirmationHash, time).ConfigureAwait(false);
HtmlNodeCollection confirmationNodes = htmlDocument?.DocumentNode.SelectNodes("//div[@class='mobileconf_list_entry']");
if (confirmationNodes == null) {
return null;
}
HashSet<Confirmation> result = new HashSet<Confirmation>();
foreach (HtmlNode confirmationNode in confirmationNodes) {
string idString = confirmationNode.GetAttributeValue("data-confid", null);
if (string.IsNullOrEmpty(idString)) {
Bot.ArchiLogger.LogNullError(nameof(idString));
return null;
}
uint id;
if (!uint.TryParse(idString, out id) || (id == 0)) {
Bot.ArchiLogger.LogNullError(nameof(id));
return null;
}
string keyString = confirmationNode.GetAttributeValue("data-key", null);
if (string.IsNullOrEmpty(keyString)) {
Bot.ArchiLogger.LogNullError(nameof(keyString));
return null;
}
ulong key;
if (!ulong.TryParse(keyString, out key) || (key == 0)) {
Bot.ArchiLogger.LogNullError(nameof(key));
return null;
}
HtmlNode descriptionNode = confirmationNode.SelectSingleNode(".//div[@class='mobileconf_list_entry_description']/div");
if (descriptionNode == null) {
Bot.ArchiLogger.LogNullError(nameof(descriptionNode));
return null;
}
Steam.ConfirmationDetails.EType type;
string description = descriptionNode.InnerText;
if (description.StartsWith("Sell - ", StringComparison.Ordinal)) {
type = Steam.ConfirmationDetails.EType.Market;
} else if (description.StartsWith("Trade with ", StringComparison.Ordinal)) {
type = Steam.ConfirmationDetails.EType.Trade;
} else {
Bot.ArchiLogger.LogGenericWarning("Received unknown confirmation type, please report this: " + description);
type = Steam.ConfirmationDetails.EType.Other;
}
result.Add(new Confirmation(id, key, type));
}
return result;
}