[bakend/akko-api] Don't send note/notification entity pleroma extensions unless isPleroma is enabled for the auth token
This commit is contained in:
parent
11faef2152
commit
eb65294219
4 changed files with 25 additions and 16 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue