[backend/core] Update user record with updated lastFetchedAt property in UserResolver.GetUpdatedUser

This commit is contained in:
Laura Hausmann 2024-07-11 02:46:53 +02:00
parent 5c5370bd1a
commit d5ce61d901
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -5,6 +5,7 @@ using Iceshrimp.Backend.Core.Database.Tables;
using Iceshrimp.Backend.Core.Federation.WebFinger;
using Iceshrimp.Backend.Core.Middleware;
using Iceshrimp.Backend.Core.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
namespace Iceshrimp.Backend.Core.Federation.ActivityPub;
@ -288,7 +289,11 @@ public class UserResolver(
public async Task<User> GetUpdatedUser(User user)
{
if (!user.NeedsUpdate) return user;
user.LastFetchedAt = DateTime.UtcNow; // Prevent multiple background tasks from being started
// Prevent multiple background tasks from being started
user.LastFetchedAt = DateTime.UtcNow;
await db.Users.Where(p => p == user)
.ExecuteUpdateAsync(p => p.SetProperty(i => i.LastFetchedAt, _ => user.LastFetchedAt));
var success = false;