From a56d7f521c4346ea266d2d2270ffd182e9bbfd6b Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Tue, 16 Apr 2024 02:05:11 +0200 Subject: [PATCH] [backend/masto-client] Fix renotes appearing more than once in note responses (ISH-261) --- .../Mastodon/Renderers/NoteRenderer.cs | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs index 806286c0..99aee605 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs @@ -281,26 +281,27 @@ public class NoteRenderer( List? accounts = null ) { - var noteList = notes.SelectMany(p => [p, p.Renote]) - .Where(p => p != null) - .Cast() - .DistinctBy(p => p.Id) - .ToList(); - + var noteList = notes.ToList(); if (noteList.Count == 0) return []; + var allNotes = noteList.SelectMany(p => [p, p.Renote]) + .Where(p => p != null) + .Cast() + .DistinctBy(p => p.Id) + .ToList(); + var data = new NoteRendererDto { - Accounts = accounts ?? await GetAccounts(noteList.Select(p => p.User).ToList()), - Mentions = await GetMentions(noteList), - Attachments = await GetAttachments(noteList), - Polls = await GetPolls(noteList, user), - LikedNotes = await GetLikedNotes(noteList, user), - BookmarkedNotes = await GetBookmarkedNotes(noteList, user), - PinnedNotes = await GetPinnedNotes(noteList, user), - Renotes = await GetRenotes(noteList, user), - Emoji = await GetEmoji(noteList), - Reactions = await GetReactions(noteList, user), + Accounts = accounts ?? await GetAccounts(allNotes.Select(p => p.User).ToList()), + Mentions = await GetMentions(allNotes), + Attachments = await GetAttachments(allNotes), + Polls = await GetPolls(allNotes, user), + LikedNotes = await GetLikedNotes(allNotes, user), + BookmarkedNotes = await GetBookmarkedNotes(allNotes, user), + PinnedNotes = await GetPinnedNotes(allNotes, user), + Renotes = await GetRenotes(allNotes, user), + Emoji = await GetEmoji(allNotes), + Reactions = await GetReactions(allNotes, user), Filters = await GetFilters(user, filterContext) };