From 70fdc247e707d227e905a0a5485466cf0aef8b92 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 2 Nov 2025 01:52:42 +0800 Subject: [PATCH] :bug: Fix realm lost info when transfering between services --- DysonNetwork.Shared/Models/Realm.cs | 26 +++++++++++++++---- .../Timeline/TimelineService.cs | 4 +-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/DysonNetwork.Shared/Models/Realm.cs b/DysonNetwork.Shared/Models/Realm.cs index 3f341ca..36231ba 100644 --- a/DysonNetwork.Shared/Models/Realm.cs +++ b/DysonNetwork.Shared/Models/Realm.cs @@ -20,7 +20,7 @@ public class SnRealm : ModelBase, IIdentifiedResource [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Picture { get; set; } [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; } - + [Column(TypeName = "jsonb")] public SnVerificationMark? Verification { get; set; } [JsonIgnore] public ICollection Members { get; set; } = new List(); @@ -36,7 +36,12 @@ public class SnRealm : ModelBase, IIdentifiedResource Id = Id.ToString(), Name = Name, Slug = Slug, + Description = Description, + Picture = Picture?.ToProtoValue(), + Background = Background?.ToProtoValue(), + Verification = Verification?.ToProtoValue(), IsCommunity = IsCommunity, + AccountId = AccountId.ToString(), IsPublic = IsPublic }; } @@ -48,9 +53,16 @@ public class SnRealm : ModelBase, IIdentifiedResource Id = Guid.Parse(proto.Id), Name = proto.Name, Slug = proto.Slug, - Description = "", + Description = proto.Description, + Picture = proto.Picture is not null ? SnCloudFileReferenceObject.FromProtoValue(proto.Picture) : null, + Background = proto.Background is not null + ? SnCloudFileReferenceObject.FromProtoValue(proto.Background) + : null, + Verification = + proto.Verification is not null ? SnVerificationMark.FromProtoValue(proto.Verification) : null, IsCommunity = proto.IsCommunity, - IsPublic = proto.IsPublic + IsPublic = proto.IsPublic, + AccountId = Guid.Parse(proto.AccountId), }; } } @@ -89,6 +101,7 @@ public class SnRealmMember : ModelBase { proto.Account = Account.ToProtoValue(); } + return proto; } @@ -101,12 +114,15 @@ public class SnRealmMember : ModelBase Role = proto.Role, JoinedAt = proto.JoinedAt?.ToInstant(), LeaveAt = proto.LeaveAt?.ToInstant(), - Realm = proto.Realm != null ? SnRealm.FromProtoValue(proto.Realm) : new SnRealm() // Provide default or handle null + Realm = proto.Realm != null + ? SnRealm.FromProtoValue(proto.Realm) + : new SnRealm() // Provide default or handle null }; if (proto.Account != null) { member.Account = SnAccount.FromProtoValue(proto.Account); } + return member; } -} +} \ No newline at end of file diff --git a/DysonNetwork.Sphere/Timeline/TimelineService.cs b/DysonNetwork.Sphere/Timeline/TimelineService.cs index 878c8fc..656b7b7 100644 --- a/DysonNetwork.Sphere/Timeline/TimelineService.cs +++ b/DysonNetwork.Sphere/Timeline/TimelineService.cs @@ -367,7 +367,7 @@ public class TimelineService( .Select(p => p.RealmId!.Value) .Distinct() .ToList(); - if (!postRealmIds.Any()) + if (postRealmIds.Count == 0) return; var realms = await rs.GetRealmBatch(postRealmIds.Select(id => id.ToString()).ToList()); @@ -376,9 +376,7 @@ public class TimelineService( foreach (var post in posts.Where(p => p.RealmId != null)) { if (realmDict.TryGetValue(post.RealmId!.Value, out var realm)) - { post.Realm = realm; - } } }