From 811c5d7a46026464d2d66b50d774bcc7ed5ccf5e Mon Sep 17 00:00:00 2001 From: pancakes Date: Fri, 20 Dec 2024 17:13:00 +1000 Subject: [PATCH] [backend/api] Simplify queries for getting avatar and banner when updating profile --- .../Controllers/Web/ProfileController.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Iceshrimp.Backend/Controllers/Web/ProfileController.cs b/Iceshrimp.Backend/Controllers/Web/ProfileController.cs index 0e7c9c41..d3ecdaf8 100644 --- a/Iceshrimp.Backend/Controllers/Web/ProfileController.cs +++ b/Iceshrimp.Backend/Controllers/Web/ProfileController.cs @@ -89,11 +89,8 @@ public class ProfileController( if (newAvatarAlt != null) { - var avatar = await db.Users - .Where(p => p.Id == user.Id) - .Include(p => p.Avatar) - .Select(p => p.Avatar) - .FirstOrDefaultAsync(); + var avatar = await db.DriveFiles + .FirstOrDefaultAsync(p => p.UserId == user.Id && p.UserAvatar != null); if (avatar != null) { @@ -103,11 +100,8 @@ public class ProfileController( } if (newBannerAlt != null) { - var banner = await db.Users - .Where(p => p.Id == user.Id) - .Include(p => p.Banner) - .Select(p => p.Banner) - .FirstOrDefaultAsync(); + var banner = await db.DriveFiles + .FirstOrDefaultAsync(p => p.UserId == user.Id && p.UserBanner != null); if (banner != null) {