From 36c6092fd20cdb97b5a76683aa1e46b24dfeb0c5 Mon Sep 17 00:00:00 2001 From: pancakes Date: Tue, 4 Feb 2025 22:46:59 +1000 Subject: [PATCH] Revert "[backend/api] Add missing inclusions of user avatar and banner" This reverts commit b4084b8e2222d0935fb536feac78d5ed31dc6fa5. --- .../Controllers/Web/InstanceController.cs | 4 ---- .../Controllers/Web/NoteController.cs | 3 --- .../Controllers/Web/Renderers/UserRenderer.cs | 9 --------- .../Core/Extensions/QueryableExtensions.cs | 20 +++---------------- 4 files changed, 3 insertions(+), 33 deletions(-) diff --git a/Iceshrimp.Backend/Controllers/Web/InstanceController.cs b/Iceshrimp.Backend/Controllers/Web/InstanceController.cs index 309d1eb4..5ae22e64 100644 --- a/Iceshrimp.Backend/Controllers/Web/InstanceController.cs +++ b/Iceshrimp.Backend/Controllers/Web/InstanceController.cs @@ -119,16 +119,12 @@ public class InstanceController( { var admins = db.Users .Where(p => p.IsAdmin == true) - .Include(p => p.Avatar) - .Include(p => p.Banner) .OrderBy(p => p.UsernameLower); var adminList = await userRenderer.RenderManyAsync(admins) .ToListAsync(); var moderators = db.Users .Where(p => p.IsAdmin == false && p.IsModerator == true) - .Include(p => p.Avatar) - .Include(p => p.Banner) .OrderBy(p => p.UsernameLower); var moderatorList = await userRenderer.RenderManyAsync(moderators) .ToListAsync(); diff --git a/Iceshrimp.Backend/Controllers/Web/NoteController.cs b/Iceshrimp.Backend/Controllers/Web/NoteController.cs index caebdf4a..23f9ac1b 100644 --- a/Iceshrimp.Backend/Controllers/Web/NoteController.cs +++ b/Iceshrimp.Backend/Controllers/Web/NoteController.cs @@ -159,7 +159,6 @@ public class NoteController( var users = await db.NoteReactions .Where(p => p.Note == note && p.Reaction == $":{name.Trim(':')}:") - .Include(p => p.User.Avatar) .Include(p => p.User.UserProfile) .Select(p => p.User) .ToListAsync(); @@ -245,7 +244,6 @@ public class NoteController( var users = await db.NoteLikes .Where(p => p.Note == note) - .Include(p => p.User.Avatar) .Include(p => p.User.UserProfile) .Paginate(pq, ControllerContext) .Wrap(p => p.User) @@ -311,7 +309,6 @@ public class NoteController( var users = await db.Notes .Where(p => p.Renote == note && p.IsPureRenote) .EnsureVisibleFor(user) - .Include(p => p.User.Avatar) .Include(p => p.User.UserProfile) .FilterHidden(user, db) .Paginate(pq, ControllerContext) diff --git a/Iceshrimp.Backend/Controllers/Web/Renderers/UserRenderer.cs b/Iceshrimp.Backend/Controllers/Web/Renderers/UserRenderer.cs index 38daf0f9..5f114e50 100644 --- a/Iceshrimp.Backend/Controllers/Web/Renderers/UserRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Web/Renderers/UserRenderer.cs @@ -46,15 +46,6 @@ public class UserRenderer(IOptions config, DatabaseConte var emojis = await GetEmojisAsync([user]); var data = new UserRendererDto { Emojis = emojis, InstanceData = instanceData }; - user.Avatar ??= await db.Users.Where(p => p.Id == user.Id) - .Include(p => p.Avatar) - .Select(p => p.Avatar) - .FirstOrDefaultAsync(); - user.Banner ??= await db.Users.Where(p => p.Id == user.Id) - .Include(p => p.Banner) - .Select(p => p.Banner) - .FirstOrDefaultAsync(); - return Render(user, data); } diff --git a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs index 1191183d..99c07443 100644 --- a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs @@ -601,13 +601,9 @@ public static class QueryableExtensions public static IQueryable IncludeCommonProperties(this IQueryable query) { - return query.Include(p => p.User.Avatar) - .Include(p => p.User.UserProfile) - .Include(p => p.Renote.User.Avatar) + return query.Include(p => p.User.UserProfile) .Include(p => p.Renote.User.UserProfile) - .Include(p => p.Renote.Renote.User.Avatar) .Include(p => p.Renote.Renote.User.UserProfile) - .Include(p => p.Reply.User.Avatar) .Include(p => p.Reply.User.UserProfile); } @@ -625,9 +621,7 @@ public static class QueryableExtensions public static IQueryable IncludeCommonProperties(this IQueryable query) { - return query.Include(p => p.Follower.Avatar) - .Include(p => p.Follower.UserProfile) - .Include(p => p.Followee.Avatar) + return query.Include(p => p.Follower.UserProfile) .Include(p => p.Followee.UserProfile); } @@ -649,21 +643,13 @@ public static class QueryableExtensions public static IQueryable IncludeCommonProperties(this IQueryable query) { - return query.Include(p => p.Notifiee.Avatar) - .Include(p => p.Notifiee.UserProfile) - .Include(p => p.Notifier.Avatar) + return query.Include(p => p.Notifiee.UserProfile) .Include(p => p.Notifier.UserProfile) - .Include(p => p.Note.User.Avatar) .Include(p => p.Note.User.UserProfile) - .Include(p => p.Note.Renote.User.Avatar) .Include(p => p.Note.Renote.User.UserProfile) - .Include(p => p.Note.Renote.Renote.User.Avatar) .Include(p => p.Note.Renote.Renote.User.UserProfile) - .Include(p => p.Note.Reply.User.Avatar) .Include(p => p.Note.Reply.User.UserProfile) - .Include(p => p.FollowRequest.Follower.Avatar) .Include(p => p.FollowRequest.Follower.UserProfile) - .Include(p => p.FollowRequest.Followee.Avatar) .Include(p => p.FollowRequest.Followee.UserProfile) .Include(p => p.Bite); }