From 7c801bfa89d8d7dcf313b302834dde94a8e5a78f Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 26 Feb 2024 21:31:33 +0100 Subject: [PATCH] [backend/core] Fix UpdateProfileMentions early return codepath --- Iceshrimp.Backend/Core/Services/UserService.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Iceshrimp.Backend/Core/Services/UserService.cs b/Iceshrimp.Backend/Core/Services/UserService.cs index 666571a0..ce030854 100644 --- a/Iceshrimp.Backend/Core/Services/UserService.cs +++ b/Iceshrimp.Backend/Core/Services/UserService.cs @@ -182,7 +182,7 @@ public class UserService( var processPendingDeletes = await ResolveAvatarAndBanner(user, actor); await db.SaveChangesAsync(); await processPendingDeletes(); - await UpdateProfileMentions(user, actor); + user = await UpdateProfileMentions(user, actor); return user; } catch (UniqueConstraintException) @@ -289,7 +289,7 @@ public class UserService( db.Update(user); await db.SaveChangesAsync(); await processPendingDeletes(); - await UpdateProfileMentions(user, actor, force: true); + user = await UpdateProfileMentions(user, actor, force: true); return user; } @@ -624,10 +624,10 @@ public class UserService( [SuppressMessage("ReSharper", "EntityFramework.NPlusOne.IncompleteDataQuery", Justification = "Projectables")] [SuppressMessage("ReSharper", "EntityFramework.NPlusOne.IncompleteDataUsage", Justification = "Same as above")] [SuppressMessage("ReSharper", "SuggestBaseTypeForParameter", Justification = "Method only makes sense for users")] - private async Task UpdateProfileMentions(User user, ASActor? actor, bool force = false) + private async Task UpdateProfileMentions(User user, ASActor? actor, bool force = false) { - if (followupTaskSvc.IsBackgroundWorker && !force) return; - if (KeyedLocker.IsInUse($"profileMentions:{user.Id}")) return; + if (followupTaskSvc.IsBackgroundWorker && !force) return user; + if (KeyedLocker.IsInUse($"profileMentions:{user.Id}")) return user; var task = followupTaskSvc.ExecuteTask("UpdateProfileMentionsInBackground", async provider => { @@ -674,5 +674,6 @@ public class UserService( }); await task.SafeWaitAsync(TimeSpan.FromMilliseconds(500)); + return user; } } \ No newline at end of file