From ca70bb54872114c3dbec21131d43b24404b83cb1 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 13 Oct 2025 01:08:48 +0800 Subject: [PATCH] :bug: Fix missing username color in proto profile --- DysonNetwork.Shared/Models/Account.cs | 28 +++++++++++++++++++++++++ DysonNetwork.Shared/Proto/account.proto | 8 +++++++ 2 files changed, 36 insertions(+) diff --git a/DysonNetwork.Shared/Models/Account.cs b/DysonNetwork.Shared/Models/Account.cs index 1ed449f..1348c0d 100644 --- a/DysonNetwork.Shared/Models/Account.cs +++ b/DysonNetwork.Shared/Models/Account.cs @@ -148,6 +148,32 @@ public class UsernameColor public string? Value { get; set; } // e.g. "red" or "#ff6600" public string? Direction { get; set; } // e.g. "to right" public List? Colors { get; set; } // e.g. ["#ff0000", "#00ff00"] + + public Proto.UsernameColor ToProtoValue() + { + var proto = new Proto.UsernameColor + { + Type = Type, + Value = Value, + Direction = Direction, + }; + if (Colors is not null) + { + proto.Colors.AddRange(Colors); + } + return proto; + } + + public static UsernameColor FromProtoValue(Proto.UsernameColor proto) + { + return new UsernameColor + { + Type = proto.Type, + Value = proto.Value, + Direction = proto.Direction, + Colors = proto.Colors?.ToList() + }; + } } public class SnAccountProfile : ModelBase, IIdentifiedResource @@ -218,6 +244,7 @@ public class SnAccountProfile : ModelBase, IIdentifiedResource AccountId = AccountId.ToString(), Verification = Verification?.ToProtoValue(), ActiveBadge = ActiveBadge?.ToProtoValue(), + UsernameColor = UsernameColor?.ToProtoValue(), CreatedAt = CreatedAt.ToTimestamp(), UpdatedAt = UpdatedAt.ToTimestamp() }; @@ -247,6 +274,7 @@ public class SnAccountProfile : ModelBase, IIdentifiedResource Picture = proto.Picture is null ? null : SnCloudFileReferenceObject.FromProtoValue(proto.Picture), Background = proto.Background is null ? null : SnCloudFileReferenceObject.FromProtoValue(proto.Background), AccountId = Guid.Parse(proto.AccountId), + UsernameColor = proto.UsernameColor is not null ? UsernameColor.FromProtoValue(proto.UsernameColor) : null, CreatedAt = proto.CreatedAt.ToInstant(), UpdatedAt = proto.UpdatedAt.ToInstant() }; diff --git a/DysonNetwork.Shared/Proto/account.proto b/DysonNetwork.Shared/Proto/account.proto index 26a3102..ed746d1 100644 --- a/DysonNetwork.Shared/Proto/account.proto +++ b/DysonNetwork.Shared/Proto/account.proto @@ -59,6 +59,13 @@ message AccountStatus { bytes meta = 10; } +message UsernameColor { + string type = 1; + google.protobuf.StringValue value = 2; + google.protobuf.StringValue direction = 3; + repeated string colors = 4; +} + // Profile contains detailed information about a user message AccountProfile { string id = 1; @@ -89,6 +96,7 @@ message AccountProfile { google.protobuf.Timestamp created_at = 22; google.protobuf.Timestamp updated_at = 23; + optional UsernameColor username_color = 24; } // AccountContact represents a contact method for an account