🐛 Fix the message pack serializer
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using MessagePack;
|
||||
using MessagePack.NodaTime;
|
||||
using MessagePack.Resolvers;
|
||||
|
||||
namespace DysonNetwork.Shared.Cache;
|
||||
@@ -6,7 +7,13 @@ namespace DysonNetwork.Shared.Cache;
|
||||
public class MessagePackCacheSerializer(MessagePackSerializerOptions? options = null) : ICacheSerializer
|
||||
{
|
||||
private readonly MessagePackSerializerOptions _options = options ?? MessagePackSerializerOptions.Standard
|
||||
.WithResolver(ContractlessStandardResolver.Instance)
|
||||
.WithResolver(CompositeResolver.Create(
|
||||
BuiltinResolver.Instance,
|
||||
AttributeFormatterResolver.Instance,
|
||||
NodatimeResolver.Instance,
|
||||
DynamicEnumAsStringResolver.Instance,
|
||||
ContractlessStandardResolver.Instance
|
||||
))
|
||||
.WithCompression(MessagePackCompression.Lz4BlockArray)
|
||||
.WithSecurity(MessagePackSecurity.UntrustedData)
|
||||
.WithOmitAssemblyVersion(true);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NodaTime;
|
||||
using NodaTime.Serialization.Protobuf;
|
||||
@@ -26,13 +27,13 @@ public class SnAccount : ModelBase
|
||||
public ICollection<SnAccountContact> Contacts { get; set; } = [];
|
||||
public ICollection<SnAccountBadge> Badges { get; set; } = [];
|
||||
|
||||
[JsonIgnore] public ICollection<SnAccountAuthFactor> AuthFactors { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnAccountConnection> Connections { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnAuthSession> Sessions { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnAuthChallenge> Challenges { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAccountAuthFactor> AuthFactors { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAccountConnection> Connections { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAuthSession> Sessions { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAuthChallenge> Challenges { get; set; } = [];
|
||||
|
||||
[JsonIgnore] public ICollection<SnAccountRelationship> OutgoingRelationships { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnAccountRelationship> IncomingRelationships { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAccountRelationship> OutgoingRelationships { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnAccountRelationship> IncomingRelationships { get; set; } = [];
|
||||
|
||||
[NotMapped] public SnSubscriptionReferenceObject? PerkSubscription { get; set; }
|
||||
|
||||
@@ -217,7 +218,7 @@ public class SnAccountProfile : ModelBase, IIdentifiedResource
|
||||
[Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; }
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
[JsonIgnore] public SnAccount Account { get; set; } = null!;
|
||||
[IgnoreMember] [JsonIgnore] public SnAccount Account { get; set; } = null!;
|
||||
|
||||
public Proto.AccountProfile ToProtoValue()
|
||||
{
|
||||
@@ -331,7 +332,7 @@ public class SnAccountContact : ModelBase
|
||||
[MaxLength(1024)] public string Content { get; set; } = string.Empty;
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
[JsonIgnore] public SnAccount Account { get; set; } = null!;
|
||||
[IgnoreMember] [JsonIgnore] public SnAccount Account { get; set; } = null!;
|
||||
|
||||
public Proto.AccountContact ToProtoValue()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using MessagePack;
|
||||
using NodaTime;
|
||||
using NodaTime.Serialization.Protobuf;
|
||||
|
||||
@@ -18,7 +19,7 @@ public class SnAccountBadge : ModelBase
|
||||
public Instant? ExpiredAt { get; set; }
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
[JsonIgnore] public SnAccount Account { get; set; } = null!;
|
||||
[IgnoreMember] [JsonIgnore] public SnAccount Account { get; set; } = null!;
|
||||
|
||||
public SnAccountBadgeRef ToReference()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Shared.Models;
|
||||
@@ -30,6 +31,7 @@ public class SnChatRoom : ModelBase, IIdentifiedResource
|
||||
[Column(TypeName = "jsonb")]
|
||||
public SnCloudFileReferenceObject? Background { get; set; }
|
||||
|
||||
[IgnoreMember]
|
||||
[JsonIgnore]
|
||||
public ICollection<SnChatMember> Members { get; set; } = new List<SnChatMember>();
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MessagePack;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NodaTime;
|
||||
using NodaTime.Extensions;
|
||||
@@ -29,11 +31,11 @@ public class SnPublisher : ModelBase, IIdentifiedResource
|
||||
|
||||
[Column(TypeName = "jsonb")] public SnVerificationMark? Verification { get; set; }
|
||||
|
||||
[JsonIgnore] public ICollection<SnPost> Posts { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnPoll> Polls { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnPostCollection> Collections { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnPublisherMember> Members { get; set; } = [];
|
||||
[JsonIgnore] public ICollection<SnPublisherFeature> Features { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPost> Posts { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPoll> Polls { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPostCollection> Collections { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPublisherMember> Members { get; set; } = [];
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnPublisherFeature> Features { get; set; } = [];
|
||||
|
||||
[JsonIgnore]
|
||||
public ICollection<SnPublisherSubscription> Subscriptions { get; set; } = [];
|
||||
@@ -45,7 +47,7 @@ public class SnPublisher : ModelBase, IIdentifiedResource
|
||||
|
||||
public string ResourceIdentifier => $"publisher:{Id}";
|
||||
|
||||
public static SnPublisher FromProtoValue(Proto.Publisher proto)
|
||||
public static SnPublisher FromProtoValue(Publisher proto)
|
||||
{
|
||||
var publisher = new SnPublisher
|
||||
{
|
||||
@@ -87,25 +89,25 @@ public class SnPublisher : ModelBase, IIdentifiedResource
|
||||
return publisher;
|
||||
}
|
||||
|
||||
public Proto.Publisher ToProtoValue()
|
||||
public Publisher ToProtoValue()
|
||||
{
|
||||
var p = new Proto.Publisher()
|
||||
var p = new Publisher
|
||||
{
|
||||
Id = Id.ToString(),
|
||||
Type = Type == PublisherType.Individual
|
||||
? Shared.Proto.PublisherType.PubIndividual
|
||||
: Shared.Proto.PublisherType.PubOrganizational,
|
||||
? Proto.PublisherType.PubIndividual
|
||||
: Proto.PublisherType.PubOrganizational,
|
||||
Name = Name,
|
||||
Nick = Nick,
|
||||
Bio = Bio,
|
||||
AccountId = AccountId?.ToString() ?? string.Empty,
|
||||
RealmId = RealmId?.ToString() ?? string.Empty,
|
||||
CreatedAt = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(CreatedAt.ToDateTimeOffset()),
|
||||
UpdatedAt = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(UpdatedAt.ToDateTimeOffset())
|
||||
CreatedAt = Timestamp.FromDateTimeOffset(CreatedAt.ToDateTimeOffset()),
|
||||
UpdatedAt = Timestamp.FromDateTimeOffset(UpdatedAt.ToDateTimeOffset())
|
||||
};
|
||||
if (Picture is not null)
|
||||
{
|
||||
p.Picture = new Proto.CloudFile
|
||||
p.Picture = new CloudFile
|
||||
{
|
||||
Id = Picture.Id,
|
||||
Name = Picture.Name,
|
||||
@@ -117,7 +119,7 @@ public class SnPublisher : ModelBase, IIdentifiedResource
|
||||
|
||||
if (Background is not null)
|
||||
{
|
||||
p.Background = new Proto.CloudFile
|
||||
p.Background = new CloudFile
|
||||
{
|
||||
Id = Background.Id,
|
||||
Name = Background.Name,
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using MessagePack;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NodaTime;
|
||||
using NodaTime.Serialization.Protobuf;
|
||||
@@ -23,7 +24,7 @@ public class SnRealm : ModelBase, IIdentifiedResource
|
||||
|
||||
[Column(TypeName = "jsonb")] public SnVerificationMark? Verification { get; set; }
|
||||
|
||||
[JsonIgnore] public ICollection<SnRealmMember> Members { get; set; } = new List<SnRealmMember>();
|
||||
[IgnoreMember] [JsonIgnore] public ICollection<SnRealmMember> Members { get; set; } = new List<SnRealmMember>();
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using NodaTime;
|
||||
using NodaTime.Serialization.Protobuf;
|
||||
|
||||
@@ -46,7 +47,7 @@ public class SnWalletPocket : ModelBase
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
public Guid WalletId { get; set; }
|
||||
[JsonIgnore] public SnWallet Wallet { get; set; } = null!;
|
||||
[IgnoreMember] [JsonIgnore] public SnWallet Wallet { get; set; } = null!;
|
||||
|
||||
public Proto.WalletPocket ToProtoValue() => new()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user