diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs index deb10b46..3661b5f7 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs @@ -174,6 +174,15 @@ public class NoteRenderer( var visibility = IsPleroma && note.LocalOnly ? "local" : StatusEntity.EncodeVisibility(note.Visibility); + var pleromaExtensions = IsPleroma + ? new PleromaStatusExtensions + { + LocalOnly = note.LocalOnly, + Reactions = reactions, + ConversationId = note.ThreadId + } + : null; + var res = new StatusEntity { Id = note.Id, @@ -209,12 +218,7 @@ public class NoteRenderer( Reactions = reactions, Tags = tags, Filtered = filterResult, - Pleroma = new PleromaStatusExtensions - { - LocalOnly = note.LocalOnly, - Reactions = reactions, - ConversationId = note.ThreadId - } + Pleroma = pleromaExtensions }; return res; diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs index 8f63152a..d2634706 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs @@ -62,7 +62,7 @@ public class NotificationRenderer( CreatedAt = notification.CreatedAt.ToStringIso8601Like(), Emoji = notification.Reaction, EmojiUrl = emojiUrl, - Pleroma = new PleromaNotificationExtensions { IsSeen = notification.IsRead } + Pleroma = noteRenderer.IsPleroma ? new PleromaNotificationExtensions { IsSeen = notification.IsRead } : null }; return res; diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/NotificationEntity.cs b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/NotificationEntity.cs index 1439f27d..b513b78d 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/NotificationEntity.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/NotificationEntity.cs @@ -1,21 +1,25 @@ +using System.Text.Json.Serialization; using Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities; using Iceshrimp.Backend.Core.Middleware; using Iceshrimp.Shared.Helpers; using J = System.Text.Json.Serialization.JsonPropertyNameAttribute; +using JI = System.Text.Json.Serialization.JsonIgnoreAttribute; using static Iceshrimp.Backend.Core.Database.Tables.Notification; namespace Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities; public class NotificationEntity : IIdentifiable { - [J("created_at")] public required string CreatedAt { get; set; } - [J("type")] public required string Type { get; set; } - [J("account")] public required AccountEntity Notifier { get; set; } - [J("status")] public required StatusEntity? Note { get; set; } - [J("id")] public required string Id { get; set; } - [J("pleroma")] public required PleromaNotificationExtensions Pleroma { get; set; } - [J("emoji")] public string? Emoji { get; set; } - [J("emoji_url")] public string? EmojiUrl { get; set; } + [J("created_at")] public required string CreatedAt { get; set; } + [J("type")] public required string Type { get; set; } + [J("account")] public required AccountEntity Notifier { get; set; } + [J("status")] public required StatusEntity? Note { get; set; } + [J("id")] public required string Id { get; set; } + [J("emoji")] public string? Emoji { get; set; } + [J("emoji_url")] public string? EmojiUrl { get; set; } + + [J("pleroma")] [JI(Condition = JsonIgnoreCondition.WhenWritingNull)] + public required PleromaNotificationExtensions? Pleroma { get; set; } public static string EncodeType(NotificationType type, bool isPleroma) { diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/StatusEntity.cs b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/StatusEntity.cs index 305f74ab..4df638f0 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/StatusEntity.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/StatusEntity.cs @@ -56,7 +56,8 @@ public class StatusEntity : IIdentifiable, ICloneable public object Clone() => MemberwiseClone(); [J("id")] public required string Id { get; set; } - [J("pleroma")] public required PleromaStatusExtensions Pleroma { get; set; } + [J("pleroma")] [JI(Condition = JsonIgnoreCondition.WhenWritingNull)] + public required PleromaStatusExtensions? Pleroma { get; set; } public static string EncodeVisibility(Note.NoteVisibility visibility) {