a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend/masto-client] Use a cursed polyglot Mastodon/Pleroma-style quote representation

Kopper 6e48fd71 6cb5dd43

+18 -43
+8 -20
Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs
··· 48 48 ? await RenderAsync(note.Renote, user, null, data, --recurse) 49 49 : null; 50 50 51 - IMastodonQuotable? quote = null; 52 - var text = note.Text; 53 - string? quoteUri = null; 51 + StatusEntity? quote = null; 52 + var text = note.Text; 53 + string? quoteUri = null; 54 54 55 55 if (note is { Renote: not null, IsQuote: true } ) 56 56 { 57 - if (flags.IsPleroma.Value) 58 - { 59 - if (recurse > 0) quote = await RenderAsync(note.Renote, user, null, data, 0); 60 - } 61 - else 57 + if (recurse > 0) quote = await RenderAsync(note.Renote, user, null, data, 0); 58 + 59 + if (!flags.IsPleroma.Value && quote != null) 62 60 { 63 - if (recurse > 0) 64 - { 65 - quote = new Quote 66 - { 67 - State = QuoteState.Accepted, 68 - QuotedStatus = await RenderAsync(note.Renote, user, null, data, 0) 69 - }; 70 - } 71 - else 72 - { 73 - quote = new ShallowQuote { State = QuoteState.Accepted, QuotedStatusId = note.RenoteId }; 74 - } 61 + quote.QuotedStatus = (StatusEntity)quote.Clone(); // cloning to prevent recursion 62 + quote.State = QuoteState.Accepted; 75 63 } 76 64 77 65 var qUri = note.Renote?.Url ?? note.Renote?.Uri ?? note.Renote?.GetPublicUriOrNull(config.Value);
+10 -23
Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/StatusEntity.cs
··· 8 8 9 9 namespace Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities; 10 10 11 - public class StatusEntity : IIdentifiable, ICloneable, IMastodonQuotable 11 + public class StatusEntity : IIdentifiable, ICloneable 12 12 { 13 13 [JI] public string? MastoReplyUserId; 14 14 [J("text")] public required string? Text { get; set; } ··· 19 19 [J("in_reply_to_id")] public required string? ReplyId { get; set; } 20 20 [J("in_reply_to_account_id")] public required string? ReplyUserId { get; set; } 21 21 [J("reblog")] public required StatusEntity? Renote { get; set; } 22 - [J("quote")] public required IMastodonQuotable? Quote { get; set; } 22 + [J("quote")] public required StatusEntity? Quote { get; set; } 23 23 [J("quote_approval")] public required QuoteApproval? QuoteApproval { get; set; } 24 24 [J("content_type")] public required string ContentType { get; set; } 25 25 [J("created_at")] public required string CreatedAt { get; set; } ··· 58 58 59 59 [J("pleroma")] [JI(Condition = JsonIgnoreCondition.WhenWritingNull)] 60 60 public required PleromaStatusExtensions? Pleroma { get; set; } 61 + 62 + // HACK: make Status also a valid Quote entity for client compatibility 63 + // https://issues.iceshrimp.dev/issue/ISH-871#comment-019c24ed-c841-7de2-9c69-85e2951135ca 64 + [J("state")] [JI(Condition = JsonIgnoreCondition.WhenWritingNull)] 65 + public QuoteState? State { get; set; } 66 + 67 + [J("quoted_status")] [JI(Condition = JsonIgnoreCondition.WhenWritingNull)] 68 + public StatusEntity? QuotedStatus { get; set; } 61 69 62 70 public static string EncodeVisibility(Note.NoteVisibility visibility) 63 71 { ··· 113 121 { 114 122 [J("name")] public required string Name { get; set; } 115 123 [J("url")] public required string Url { get; set; } 116 - } 117 - 118 - /// <summary> 119 - /// The Mastodon API and Pleroma API disagree on the value of the quote parameter, and in Mastodon API there are two 120 - /// separate object types ("shallow" and regular) that can be used. 121 - /// </summary> 122 - [JsonDerivedType(typeof(Quote))] 123 - [JsonDerivedType(typeof(ShallowQuote))] 124 - [JsonDerivedType(typeof(StatusEntity))] 125 - public interface IMastodonQuotable { } 126 - 127 - public class Quote : IMastodonQuotable 128 - { 129 - [J("state")] public required QuoteState State { get; set; } 130 - [J("quoted_status")] public required StatusEntity? QuotedStatus { get; set; } 131 - } 132 - 133 - public class ShallowQuote : IMastodonQuotable 134 - { 135 - [J("state")] public required QuoteState State { get; set; } 136 - [J("quoted_status_id")] public required string? QuotedStatusId { get; set; } 137 124 } 138 125 139 126 public enum QuoteState