[bakend/akko-api] Don't send note/notification entity pleroma extensions unless isPleroma is enabled for the auth token

This commit is contained in:
Laura Hausmann 2025-03-18 09:25:37 +01:00
parent 11faef2152
commit eb65294219
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
4 changed files with 25 additions and 16 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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)
{

View file

@ -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)
{