[backend/core] Fix order of operations on user create

This commit is contained in:
Laura Hausmann 2024-03-01 02:18:33 +01:00
parent 5082f15e75
commit a905c271fb
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -179,10 +179,8 @@ public class UserService(
try
{
await db.AddRangeAsync(user, profile, publicKey);
// We need to do this after calling db.Add(Range) to ensure data consistency
var processPendingDeletes = await ResolveAvatarAndBanner(user, actor);
await db.SaveChangesAsync();
var processPendingDeletes = await ResolveAvatarAndBanner(user, actor);
await processPendingDeletes();
user = await UpdateProfileMentions(user, actor);
UpdateUserPinnedNotesInBackground(actor, user);
@ -405,6 +403,8 @@ public class UserService(
user.AvatarUrl = avatar?.Url;
user.BannerUrl = banner?.Url;
await db.SaveChangesAsync();
return async () =>
{
if (prevAvatarId != null && avatar?.Id != prevAvatarId)