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 Mastodon-style quotes in StatusEntity if not Pleroma

Kopper 6cb5dd43 e20dc94b

+110 -32
+31 -7
Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs
··· 47 47 var renote = note is { Renote: not null, IsQuote: false } && recurse > 1 48 48 ? await RenderAsync(note.Renote, user, null, data, --recurse) 49 49 : null; 50 - var quote = note is { Renote: not null, IsQuote: true } && recurse > 0 51 - ? await RenderAsync(note.Renote, user, null, data, 0) 52 - : null; 53 - var text = note.Text; 54 - string? quoteUri = null; 55 50 56 - if (note is { Renote: not null, IsQuote: true }) 51 + IMastodonQuotable? quote = null; 52 + var text = note.Text; 53 + string? quoteUri = null; 54 + 55 + if (note is { Renote: not null, IsQuote: true } ) 57 56 { 57 + if (flags.IsPleroma.Value) 58 + { 59 + if (recurse > 0) quote = await RenderAsync(note.Renote, user, null, data, 0); 60 + } 61 + else 62 + { 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 + } 75 + } 76 + 58 77 var qUri = note.Renote?.Url ?? note.Renote?.Uri ?? note.Renote?.GetPublicUriOrNull(config.Value); 59 78 var alt = note.Renote?.Uri; 60 79 var t = text ?? ""; ··· 197 216 ReplyUserId = note.MastoReplyUserId ?? note.ReplyUserId, 198 217 MastoReplyUserId = note.MastoReplyUserId, 199 218 Renote = renote, 219 + QuoteApproval = new QuoteApproval 220 + { 221 + Automatic = [QuoteAuthorization.Public], 222 + Manual = [], 223 + CurrentUser = CurrentUserQuoteAuthorization.Automatic 224 + }, 200 225 Quote = quote, 201 - QuoteId = note.IsQuote ? note.RenoteId : null, 202 226 ContentType = "text/x.misskeymarkdown", 203 227 CreatedAt = note.CreatedAt.ToStringIso8601Like(), 204 228 EditedAt = note.UpdatedAt?.ToStringIso8601Like(),
+79 -25
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 11 + public class StatusEntity : IIdentifiable, ICloneable, IMastodonQuotable 12 12 { 13 - [JI] public string? MastoReplyUserId; 14 - [J("text")] public required string? Text { get; set; } 15 - [J("content")] public required string? Content { get; set; } 16 - [J("uri")] public required string Uri { get; set; } 17 - [J("url")] public required string? Url { get; set; } 18 - [J("account")] public required AccountEntity Account { get; set; } 19 - [J("in_reply_to_id")] public required string? ReplyId { get; set; } 20 - [J("in_reply_to_account_id")] public required string? ReplyUserId { get; set; } 21 - [J("reblog")] public required StatusEntity? Renote { get; set; } 22 - [J("quote")] public required StatusEntity? Quote { get; set; } 23 - [J("quote_id")] public required string? QuoteId { get; set; } 24 - [J("content_type")] public required string ContentType { get; set; } 25 - [J("created_at")] public required string CreatedAt { get; set; } 26 - [J("edited_at")] public required string? EditedAt { get; set; } 27 - [J("replies_count")] public required long RepliesCount { get; set; } 28 - [J("reblogs_count")] public required long RenoteCount { get; set; } 29 - [J("favourites_count")] public required long FavoriteCount { get; set; } 30 - [J("reblogged")] public required bool? IsRenoted { get; set; } 31 - [J("favourited")] public required bool? IsFavorited { get; set; } 32 - [J("bookmarked")] public required bool? IsBookmarked { get; set; } 33 - [J("muted")] public required bool? IsMuted { get; set; } 34 - [J("sensitive")] public required bool IsSensitive { get; set; } 35 - [J("spoiler_text")] public required string ContentWarning { get; set; } 36 - [J("visibility")] public required string Visibility { get; set; } 13 + [JI] public string? MastoReplyUserId; 14 + [J("text")] public required string? Text { get; set; } 15 + [J("content")] public required string? Content { get; set; } 16 + [J("uri")] public required string Uri { get; set; } 17 + [J("url")] public required string? Url { get; set; } 18 + [J("account")] public required AccountEntity Account { get; set; } 19 + [J("in_reply_to_id")] public required string? ReplyId { get; set; } 20 + [J("in_reply_to_account_id")] public required string? ReplyUserId { get; set; } 21 + [J("reblog")] public required StatusEntity? Renote { get; set; } 22 + [J("quote")] public required IMastodonQuotable? Quote { get; set; } 23 + [J("quote_approval")] public required QuoteApproval? QuoteApproval { get; set; } 24 + [J("content_type")] public required string ContentType { get; set; } 25 + [J("created_at")] public required string CreatedAt { get; set; } 26 + [J("edited_at")] public required string? EditedAt { get; set; } 27 + [J("replies_count")] public required long RepliesCount { get; set; } 28 + [J("reblogs_count")] public required long RenoteCount { get; set; } 29 + [J("favourites_count")] public required long FavoriteCount { get; set; } 30 + [J("reblogged")] public required bool? IsRenoted { get; set; } 31 + [J("favourited")] public required bool? IsFavorited { get; set; } 32 + [J("bookmarked")] public required bool? IsBookmarked { get; set; } 33 + [J("muted")] public required bool? IsMuted { get; set; } 34 + [J("sensitive")] public required bool IsSensitive { get; set; } 35 + [J("spoiler_text")] public required string ContentWarning { get; set; } 36 + [J("visibility")] public required string Visibility { get; set; } 37 37 38 38 [J("pinned")] 39 39 [JI(Condition = JsonIgnoreCondition.WhenWritingNull)] ··· 114 114 [J("name")] public required string Name { get; set; } 115 115 [J("url")] public required string Url { get; set; } 116 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 + } 138 + 139 + public enum QuoteState 140 + { 141 + Pending, 142 + Accepted, 143 + Rejected, 144 + Revoked, 145 + Deleted, 146 + Unauthorized, 147 + } 148 + 149 + public class QuoteApproval 150 + { 151 + [J("automatic")] public required QuoteAuthorization[] Automatic { get; set; } 152 + [J("manual")] public required QuoteAuthorization[] Manual { get; set; } 153 + [J("current_user")] public required CurrentUserQuoteAuthorization CurrentUser { get; set; } 154 + } 155 + 156 + public enum QuoteAuthorization 157 + { 158 + UnsupportedPolicy, 159 + Public, 160 + Followers, 161 + Following 162 + } 163 + 164 + public enum CurrentUserQuoteAuthorization 165 + { 166 + Unknown, 167 + Automatic, 168 + Manual, 169 + Denied 170 + }