Skip empty nickname in self persona state callback

This commit is contained in:
Archi 2023-01-24 01:29:55 +01:00
parent 8bb48d829e
commit e0f9fe3555
No known key found for this signature in database
GPG key ID: 6B138B4C64555AEA
2 changed files with 4 additions and 3 deletions

View file

@ -320,7 +320,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
SignedInWithSteam = true;
}
Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Localization.Strings.ListingAnnouncing, Bot.SteamID, nickname, assetsForListing.Count));
Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Localization.Strings.ListingAnnouncing, Bot.SteamID, nickname ?? Bot.SteamID.ToString(CultureInfo.InvariantCulture), assetsForListing.Count));
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
BasicResponse? response = await Backend.AnnounceForListing(Bot.SteamID, WebBrowser, assetsForListing, acceptedMatchableTypes, (uint) inventory.Count, matchEverything, tradeToken!, nickname, avatarHash).ConfigureAwait(false);

View file

@ -3000,11 +3000,12 @@ public sealed class Bot : IAsyncDisposable, IDisposable {
return;
}
Nickname = callback.Name;
// Empty name should be converted to null, this is actually lack of value, but it's transmitted as empty in protobufs
Nickname = !string.IsNullOrEmpty(callback.Name) ? callback.Name : null;
string? avatarHash = null;
if ((callback.AvatarHash?.Length > 0) && callback.AvatarHash.Any(static singleByte => singleByte != 0)) {
if ((callback.AvatarHash?.Length > 0) && callback.AvatarHash.Any(static singleByte => singleByte > 0)) {
#pragma warning disable CA1308 // False positive, we're intentionally converting this part to lowercase and it's not used for any security decisions based on the result of the normalization
avatarHash = Convert.ToHexString(callback.AvatarHash).ToLowerInvariant();
#pragma warning restore CA1308 // False positive, we're intentionally converting this part to lowercase and it's not used for any security decisions based on the result of the normalization