From 2bffbf18a302dab8c25b1405e17c01b1de13be90 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 27 Dec 2025 20:49:33 +0800 Subject: [PATCH] :bug: Fix Sphere Rewind --- DysonNetwork.Pass/Startup/BroadcastEventHandler.cs | 4 ++-- DysonNetwork.Pass/Wallet/SubscriptionService.cs | 4 ++-- DysonNetwork.Shared/Proto/GrpcTypeHelper.cs | 6 +++--- DysonNetwork.Sphere/Rewind/SphereRewindServiceGrpc.cs | 2 +- DysonNetwork.Sphere/WebReader/EmbeddableBase.cs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DysonNetwork.Pass/Startup/BroadcastEventHandler.cs b/DysonNetwork.Pass/Startup/BroadcastEventHandler.cs index 6ce9047..ef48aef 100644 --- a/DysonNetwork.Pass/Startup/BroadcastEventHandler.cs +++ b/DysonNetwork.Pass/Startup/BroadcastEventHandler.cs @@ -175,7 +175,7 @@ public class BroadcastEventHandler( AccountId = evt.AccountId, Status = status, UpdatedAt = SystemClock.Instance.GetCurrentInstant() - }, GrpcTypeHelper.SerializerOptionsWithIgnore)).ToByteArray() + }, GrpcTypeHelper.SerializerOptionsWithoutIgnore)).ToByteArray() ); logger.LogInformation("Broadcasted status update for user {AccountId}", evt.AccountId); @@ -214,7 +214,7 @@ public class BroadcastEventHandler( AccountId = evt.AccountId, Status = status, UpdatedAt = SystemClock.Instance.GetCurrentInstant() - }, GrpcTypeHelper.SerializerOptionsWithIgnore)).ToByteArray() + }, GrpcTypeHelper.SerializerOptionsWithoutIgnore)).ToByteArray() ); logger.LogInformation("Broadcasted status update for user {AccountId}", evt.AccountId); diff --git a/DysonNetwork.Pass/Wallet/SubscriptionService.cs b/DysonNetwork.Pass/Wallet/SubscriptionService.cs index 721dd33..2f9186e 100644 --- a/DysonNetwork.Pass/Wallet/SubscriptionService.cs +++ b/DysonNetwork.Pass/Wallet/SubscriptionService.cs @@ -727,13 +727,13 @@ public class SubscriptionService( } // Update gift status and link - gift.Status = DysonNetwork.Shared.Models.GiftStatus.Redeemed; + gift.Status = Shared.Models.GiftStatus.Redeemed; gift.RedeemedAt = now; gift.RedeemerId = redeemer.Id; gift.SubscriptionId = sameTypeSubscription.Id; gift.UpdatedAt = now; - using var transaction = await db.Database.BeginTransactionAsync(); + await using var transaction = await db.Database.BeginTransactionAsync(); try { db.WalletSubscriptions.Update(sameTypeSubscription); diff --git a/DysonNetwork.Shared/Proto/GrpcTypeHelper.cs b/DysonNetwork.Shared/Proto/GrpcTypeHelper.cs index 984019f..10de9c1 100644 --- a/DysonNetwork.Shared/Proto/GrpcTypeHelper.cs +++ b/DysonNetwork.Shared/Proto/GrpcTypeHelper.cs @@ -14,7 +14,7 @@ namespace DysonNetwork.Shared.Proto; public abstract class GrpcTypeHelper { - public static readonly JsonSerializerOptions? SerializerOptionsWithIgnore = new JsonSerializerOptions() + public static readonly JsonSerializerOptions? SerializerOptionsWithoutIgnore = new JsonSerializerOptions() { NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals, PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, @@ -161,10 +161,10 @@ public abstract class GrpcTypeHelper }; } - public static ByteString ConvertObjectToByteString(object? obj) + public static ByteString ConvertObjectToByteString(object? obj, bool withoutIgnore = true) { return ByteString.CopyFromUtf8( - JsonSerializer.Serialize(obj, SerializerOptions) + JsonSerializer.Serialize(obj, withoutIgnore ? SerializerOptionsWithoutIgnore : SerializerOptions) ); } diff --git a/DysonNetwork.Sphere/Rewind/SphereRewindServiceGrpc.cs b/DysonNetwork.Sphere/Rewind/SphereRewindServiceGrpc.cs index bda08da..5250994 100644 --- a/DysonNetwork.Sphere/Rewind/SphereRewindServiceGrpc.cs +++ b/DysonNetwork.Sphere/Rewind/SphereRewindServiceGrpc.cs @@ -268,7 +268,7 @@ public class SphereRewindServiceGrpc( { ServiceId = "sphere", AccountId = request.AccountId, - Data = GrpcTypeHelper.ConvertObjectToByteString(data), + Data = GrpcTypeHelper.ConvertObjectToByteString(data, withoutIgnore: true), }; } } \ No newline at end of file diff --git a/DysonNetwork.Sphere/WebReader/EmbeddableBase.cs b/DysonNetwork.Sphere/WebReader/EmbeddableBase.cs index 51924fa..e0839bf 100644 --- a/DysonNetwork.Sphere/WebReader/EmbeddableBase.cs +++ b/DysonNetwork.Sphere/WebReader/EmbeddableBase.cs @@ -31,11 +31,11 @@ public abstract class EmbeddableBase { var jsonRaw = JsonSerializer.Serialize( input, - GrpcTypeHelper.SerializerOptionsWithIgnore + GrpcTypeHelper.SerializerOptionsWithoutIgnore ); return JsonSerializer.Deserialize>( jsonRaw, - GrpcTypeHelper.SerializerOptionsWithIgnore + GrpcTypeHelper.SerializerOptionsWithoutIgnore ); } } \ No newline at end of file