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/api] Add liked property to NoteBase

+17 -2
+16 -2
Iceshrimp.Backend/Controllers/Renderers/NoteRenderer.cs
··· 62 62 var noteUser = (data?.Users ?? await GetUsers([note])).First(p => p.Id == note.User.Id); 63 63 var attachments = (data?.Attachments ?? await GetAttachments([note])).Where(p => note.FileIds.Contains(p.Id)); 64 64 var reactions = (data?.Reactions ?? await GetReactions([note], user)).Where(p => p.NoteId == note.Id); 65 + var liked = data?.LikedNotes?.Contains(note.Id) ?? 66 + await db.NoteLikes.AnyAsync(p => p.Note == note && p.User == user); 65 67 66 68 return new NoteResponse 67 69 { ··· 75 77 Reactions = reactions.ToList(), 76 78 Likes = note.LikeCount, 77 79 Renotes = note.RenoteCount, 78 - Replies = note.RepliesCount 80 + Replies = note.RepliesCount, 81 + Liked = liked 79 82 }; 80 83 } 81 84 ··· 141 144 return res; 142 145 } 143 146 147 + private async Task<List<string>> GetLikedNotes(List<Note> notes, User? user) 148 + { 149 + if (user == null) return []; 150 + if (notes.Count == 0) return []; 151 + return await db.NoteLikes.Where(p => p.User == user && notes.Contains(p.Note)) 152 + .Select(p => p.NoteId) 153 + .ToListAsync(); 154 + } 155 + 144 156 private static List<Note> GetAllNotes(IEnumerable<Note> notes) 145 157 { 146 158 return notes.SelectMany<Note, Note?>(p => [p, p.Reply, p.Renote, p.Renote?.Renote]) ··· 167 179 Users = await GetUsers(allNotes), 168 180 Attachments = await GetAttachments(allNotes), 169 181 Reactions = await GetReactions(allNotes, user), 170 - Filters = await GetFilters(user, filterContext) 182 + Filters = await GetFilters(user, filterContext), 183 + LikedNotes = await GetLikedNotes(allNotes, user) 171 184 }; 172 185 173 186 return await notesList.Select(p => RenderOne(p, user, filterContext, data)).AwaitAllAsync(); ··· 179 192 public List<NoteReactionSchema>? Reactions; 180 193 public List<UserResponse>? Users; 181 194 public List<Filter>? Filters; 195 + public List<string>? LikedNotes; 182 196 } 183 197 }
+1
Iceshrimp.Shared/Schemas/NoteResponse.cs
··· 35 35 [J("text")] public required string? Text { get; set; } 36 36 [J("cw")] public required string? Cw { get; set; } 37 37 [J("visibility")] public required string Visibility { get; set; } 38 + [J("liked")] public required bool Liked { get; set; } 38 39 [J("likes")] public required int Likes { get; set; } 39 40 [J("renotes")] public required int Renotes { get; set; } 40 41 [J("replies")] public required int Replies { get; set; }