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] Render note bookmarked

authored by

pancakes and committed by
Laura Hausmann
151f1140 8ec2ee17

+23 -8
+21 -7
Iceshrimp.Backend/Controllers/Web/Renderers/NoteRenderer.cs
··· 79 79 var reactions = (data?.Reactions ?? await GetReactionsAsync([note], user)).Where(p => p.NoteId == note.Id); 80 80 var liked = data?.LikedNotes?.Contains(note.Id) 81 81 ?? await db.NoteLikes.AnyAsync(p => p.Note == note && p.User == user); 82 + var bookmarked = data?.BookmarkedNotes?.Contains(note.Id) 83 + ?? await db.NoteBookmarks.AnyAsync(p => p.Note == note && p.User == user); 82 84 var emoji = data?.Emoji?.Where(p => note.Emojis.Contains(p.Id)).ToList() ?? await GetEmojiAsync([note]); 83 85 var poll = (data?.Polls ?? await GetPollsAsync([note], user)).FirstOrDefault(p => p.NoteId == note.Id); 84 86 ··· 98 100 Likes = note.LikeCount, 99 101 Renotes = note.RenoteCount, 100 102 Replies = note.RepliesCount, 103 + Bookmarked = bookmarked, 101 104 Liked = liked, 102 105 Emoji = emoji, 103 106 Poll = poll ··· 164 167 return res; 165 168 } 166 169 170 + private async Task<List<string>> GetBookmarkedNotesAsync(List<Note> notes, User? user) 171 + { 172 + if (user == null) return []; 173 + if (notes.Count == 0) return []; 174 + return await db.NoteBookmarks.Where(p => p.User == user && notes.Contains(p.Note)) 175 + .Select(p => p.NoteId) 176 + .ToListAsync(); 177 + } 178 + 167 179 private async Task<List<string>> GetLikedNotesAsync(List<Note> notes, User? user) 168 180 { 169 181 if (user == null) return []; ··· 249 261 var allNotes = GetAllNotes(notesList); 250 262 var data = new NoteRendererDto 251 263 { 252 - Users = await GetUsersAsync(allNotes), 253 - Attachments = await GetAttachmentsAsync(allNotes), 254 - Reactions = await GetReactionsAsync(allNotes, user), 255 - Filters = await GetFiltersAsync(user, filterContext), 256 - LikedNotes = await GetLikedNotesAsync(allNotes, user), 257 - Emoji = await GetEmojiAsync(allNotes), 258 - Polls = await GetPollsAsync(allNotes, user) 264 + Users = await GetUsersAsync(allNotes), 265 + Attachments = await GetAttachmentsAsync(allNotes), 266 + Reactions = await GetReactionsAsync(allNotes, user), 267 + Filters = await GetFiltersAsync(user, filterContext), 268 + BookmarkedNotes = await GetBookmarkedNotesAsync(allNotes, user), 269 + LikedNotes = await GetLikedNotesAsync(allNotes, user), 270 + Emoji = await GetEmojiAsync(allNotes), 271 + Polls = await GetPollsAsync(allNotes, user) 259 272 }; 260 273 261 274 return await notesList.Select(p => RenderOne(p, user, filterContext, data)).AwaitAllAsync(); ··· 266 279 public List<NoteAttachment>? Attachments; 267 280 public List<EmojiResponse>? Emoji; 268 281 public List<Filter>? Filters; 282 + public List<string>? BookmarkedNotes; 269 283 public List<string>? LikedNotes; 270 284 public List<NoteReactionSchema>? Reactions; 271 285 public List<UserResponse>? Users;
+2 -1
Iceshrimp.Shared/Schemas/Web/NoteResponse.cs
··· 39 39 public required List<EmojiResponse> Emoji { get; set; } 40 40 public required NoteVisibility Visibility { get; set; } 41 41 public required bool LocalOnly { get; set; } 42 + public required bool Bookmarked { get; set; } 42 43 public required bool Liked { get; set; } 43 44 public required int Likes { get; set; } 44 45 public required int Renotes { get; set; } ··· 101 102 Home = 1, 102 103 Followers = 2, 103 104 Specified = 3 104 - } 105 + }