[backend/federation] Add JsonIgnore attributes to internal properties to prevent them from being written to the job table unnecessarily

This commit is contained in:
Laura Hausmann 2024-06-21 14:14:22 +02:00
parent 19c9b7bf90
commit 0c59081aee
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
4 changed files with 9 additions and 4 deletions

View file

@ -3,6 +3,7 @@ using Iceshrimp.Backend.Core.Configuration;
using Iceshrimp.Backend.Core.Extensions;
using J = Newtonsoft.Json.JsonPropertyAttribute;
using JC = Newtonsoft.Json.JsonConverterAttribute;
using JI = Newtonsoft.Json.JsonIgnoreAttribute;
using VC = Iceshrimp.Backend.Core.Federation.ActivityStreams.Types.ValueObjectConverter;
namespace Iceshrimp.Backend.Core.Federation.ActivityStreams.Types;
@ -125,7 +126,7 @@ public class ASActor : ASObject
[JC(typeof(ASAttachmentConverter))]
public List<ASAttachment>? Attachments { get; set; }
public bool IsBot => Type == $"{Constants.ActivityStreamsNs}#Service";
[JI] public bool IsBot => Type == $"{Constants.ActivityStreamsNs}#Service";
public void Normalize(string uri, string acct)
{

View file

@ -1,6 +1,7 @@
using Iceshrimp.Backend.Core.Configuration;
using J = Newtonsoft.Json.JsonPropertyAttribute;
using JC = Newtonsoft.Json.JsonConverterAttribute;
using JI = Newtonsoft.Json.JsonIgnoreAttribute;
namespace Iceshrimp.Backend.Core.Federation.ActivityStreams.Types;
@ -14,7 +15,7 @@ public class ASLink(string url) : ASObjectBase(url)
[JC(typeof(ValueObjectConverter))]
public string? Name { get; set; }
public string? Link => Id ?? Href?.Id;
[JI] public string? Link => Id ?? Href?.Id;
public override string? ToString() => Link;
}

View file

@ -2,6 +2,7 @@ using Iceshrimp.Backend.Core.Configuration;
using Iceshrimp.Backend.Core.Database.Tables;
using J = Newtonsoft.Json.JsonPropertyAttribute;
using JC = Newtonsoft.Json.JsonConverterAttribute;
using JI = Newtonsoft.Json.JsonIgnoreAttribute;
using VC = Iceshrimp.Backend.Core.Federation.ActivityStreams.Types.ValueObjectConverter;
namespace Iceshrimp.Backend.Core.Federation.ActivityStreams.Types;
@ -10,7 +11,8 @@ public class ASNote : ASObject
{
public ASNote(bool withType = true) => Type = withType ? Types.Note : null;
public bool VerifiedFetch = false;
[JI] public bool VerifiedFetch = false;
private string? _mkContent;
[J("https://misskey-hub.net/ns#_misskey_content")]

View file

@ -4,6 +4,7 @@ using Newtonsoft.Json.Linq;
using J = Newtonsoft.Json.JsonPropertyAttribute;
using JC = Newtonsoft.Json.JsonConverterAttribute;
using JR = Newtonsoft.Json.JsonRequiredAttribute;
using JI = Newtonsoft.Json.JsonIgnoreAttribute;
namespace Iceshrimp.Backend.Core.Federation.ActivityStreams.Types;
@ -21,7 +22,7 @@ public class ASObject : ASObjectBase
[JC(typeof(StringListSingleConverter))]
public string? Type { get; set; }
[JsonIgnore] public bool IsUnresolved => GetType() == typeof(ASObject) && Type == null;
[JI] public bool IsUnresolved => GetType() == typeof(ASObject) && Type == null;
//FIXME: don't recurse creates and co
public static ASObject? Deserialize(JToken token)