[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 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
|
var res = new StatusEntity
|
||||||
{
|
{
|
||||||
Id = note.Id,
|
Id = note.Id,
|
||||||
|
@ -209,12 +218,7 @@ public class NoteRenderer(
|
||||||
Reactions = reactions,
|
Reactions = reactions,
|
||||||
Tags = tags,
|
Tags = tags,
|
||||||
Filtered = filterResult,
|
Filtered = filterResult,
|
||||||
Pleroma = new PleromaStatusExtensions
|
Pleroma = pleromaExtensions
|
||||||
{
|
|
||||||
LocalOnly = note.LocalOnly,
|
|
||||||
Reactions = reactions,
|
|
||||||
ConversationId = note.ThreadId
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class NotificationRenderer(
|
||||||
CreatedAt = notification.CreatedAt.ToStringIso8601Like(),
|
CreatedAt = notification.CreatedAt.ToStringIso8601Like(),
|
||||||
Emoji = notification.Reaction,
|
Emoji = notification.Reaction,
|
||||||
EmojiUrl = emojiUrl,
|
EmojiUrl = emojiUrl,
|
||||||
Pleroma = new PleromaNotificationExtensions { IsSeen = notification.IsRead }
|
Pleroma = noteRenderer.IsPleroma ? new PleromaNotificationExtensions { IsSeen = notification.IsRead } : null
|
||||||
};
|
};
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities;
|
using Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities;
|
||||||
using Iceshrimp.Backend.Core.Middleware;
|
using Iceshrimp.Backend.Core.Middleware;
|
||||||
using Iceshrimp.Shared.Helpers;
|
using Iceshrimp.Shared.Helpers;
|
||||||
using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
|
using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
|
||||||
|
using JI = System.Text.Json.Serialization.JsonIgnoreAttribute;
|
||||||
using static Iceshrimp.Backend.Core.Database.Tables.Notification;
|
using static Iceshrimp.Backend.Core.Database.Tables.Notification;
|
||||||
|
|
||||||
namespace Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities;
|
namespace Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities;
|
||||||
|
@ -13,10 +15,12 @@ public class NotificationEntity : IIdentifiable
|
||||||
[J("account")] public required AccountEntity Notifier { get; set; }
|
[J("account")] public required AccountEntity Notifier { get; set; }
|
||||||
[J("status")] public required StatusEntity? Note { get; set; }
|
[J("status")] public required StatusEntity? Note { get; set; }
|
||||||
[J("id")] public required string Id { 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")] public string? Emoji { get; set; }
|
||||||
[J("emoji_url")] public string? EmojiUrl { 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)
|
public static string EncodeType(NotificationType type, bool isPleroma)
|
||||||
{
|
{
|
||||||
return type switch
|
return type switch
|
||||||
|
|
|
@ -56,7 +56,8 @@ public class StatusEntity : IIdentifiable, ICloneable
|
||||||
public object Clone() => MemberwiseClone();
|
public object Clone() => MemberwiseClone();
|
||||||
[J("id")] public required string Id { get; set; }
|
[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)
|
public static string EncodeVisibility(Note.NoteVisibility visibility)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue