diff --git a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs index 42fc53ae..9d849c8b 100644 --- a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs +++ b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs @@ -1139,6 +1139,20 @@ public class DatabaseContext(DbContextOptions options) }); } + public async Task ReloadEntityAsync(object entity) + { + await Entry(entity).ReloadAsync(); + } + + public async Task ReloadEntityRecursiveAsync(object entity) + { + await ReloadEntityAsync(entity); + await Entry(entity) + .References.Where(p => p is { IsLoaded: true, TargetEntry: not null }) + .Select(p => p.TargetEntry!.ReloadAsync()) + .AwaitAllAsync(); + } + public IQueryable NoteAncestors(string noteId, int depth) => FromExpression(() => NoteAncestors(noteId, depth)); diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/UserResolver.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/UserResolver.cs index 84ba55dd..61d4ea8a 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/UserResolver.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/UserResolver.cs @@ -236,6 +236,9 @@ public class UserResolver( logger.LogError("UpdateUserAsync for user {user} failed with {error}", user.Uri, e.Message); } - return success ? await db.Users.IncludeCommonProperties().FirstAsync(p => p.Id == user.Id) : user; + if (success) + await db.ReloadEntityRecursiveAsync(user); + + return user; } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Services/UserService.cs b/Iceshrimp.Backend/Core/Services/UserService.cs index fc03a8dd..2b672f30 100644 --- a/Iceshrimp.Backend/Core/Services/UserService.cs +++ b/Iceshrimp.Backend/Core/Services/UserService.cs @@ -781,6 +781,9 @@ public class UserService( await task.SafeWaitAsync(TimeSpan.FromMilliseconds(500)); - return success ? await db.Users.IncludeCommonProperties().FirstAsync(p => p.Id == user.Id) : user; + if (success) + await db.ReloadEntityRecursiveAsync(user); + + return user; } } \ No newline at end of file