[backend] Backfill users on incoming follow
This commit is contained in:
parent
6b1d84801e
commit
d965653972
1 changed files with 11 additions and 9 deletions
|
@ -786,6 +786,8 @@ public class UserService(
|
||||||
|
|
||||||
if (follower.IsRemoteUser)
|
if (follower.IsRemoteUser)
|
||||||
{
|
{
|
||||||
|
await EnqueueBackfillTaskAsync(follower);
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
_ = followupTaskSvc.ExecuteTaskAsync("IncrementInstanceIncomingFollowsCounter", async provider =>
|
_ = followupTaskSvc.ExecuteTaskAsync("IncrementInstanceIncomingFollowsCounter", async provider =>
|
||||||
{
|
{
|
||||||
|
@ -820,6 +822,8 @@ public class UserService(
|
||||||
await db.AddAsync(request);
|
await db.AddAsync(request);
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
await notificationSvc.GenerateFollowRequestReceivedNotificationAsync(request);
|
await notificationSvc.GenerateFollowRequestReceivedNotificationAsync(request);
|
||||||
|
|
||||||
|
if (follower.IsRemoteUser) await EnqueueBackfillTaskAsync(follower);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -854,6 +858,8 @@ public class UserService(
|
||||||
|
|
||||||
if (follower.IsRemoteUser)
|
if (follower.IsRemoteUser)
|
||||||
{
|
{
|
||||||
|
await EnqueueBackfillTaskAsync(follower);
|
||||||
|
|
||||||
_ = followupTaskSvc.ExecuteTaskAsync("IncrementInstanceIncomingFollowsCounter", async provider =>
|
_ = followupTaskSvc.ExecuteTaskAsync("IncrementInstanceIncomingFollowsCounter", async provider =>
|
||||||
{
|
{
|
||||||
var bgDb = provider.GetRequiredService<DatabaseContext>();
|
var bgDb = provider.GetRequiredService<DatabaseContext>();
|
||||||
|
@ -886,17 +892,13 @@ public class UserService(
|
||||||
if (!cfg.Enabled) return;
|
if (!cfg.Enabled) return;
|
||||||
|
|
||||||
// don't try to schedule a backfill for local users
|
// don't try to schedule a backfill for local users
|
||||||
if (user.Host == null) return;
|
if (user.IsLocalUser) return;
|
||||||
|
|
||||||
// we don't need to backfill anyone we have followers for since we'll get their posts delivered to us
|
// we don't need to backfill anyone we have followers for since we'll get their posts delivered to us
|
||||||
var needBackfill = await db.Users
|
var needBackfill = await db.Users.AnyAsync(u => u.Id == user.Id
|
||||||
.AnyAsync(u => u.Id == user.Id
|
&& !u.Followers.Any()
|
||||||
&& !u.Followers.Any()
|
&& u.Outbox != null
|
||||||
&& u.Outbox != null
|
&& (u.OutboxFetchedAt == null || u.OutboxFetchedAt <= DateTime.UtcNow - cfg.RefreshAfterTimeSpan));
|
||||||
&& (u.OutboxFetchedAt == null || u.OutboxFetchedAt <= DateTime.UtcNow - cfg.RefreshAfterTimeSpan));
|
|
||||||
|
|
||||||
// only queue if the user's backfill timestamp got updated. if it didn't, it means this user doesn't need backfilling
|
|
||||||
// (or the thread doesn't exist, which shouldn't be possible)
|
|
||||||
if (!needBackfill) return;
|
if (!needBackfill) return;
|
||||||
|
|
||||||
var jobData = new BackfillUserJobData
|
var jobData = new BackfillUserJobData
|
||||||
|
|
Loading…
Add table
Reference in a new issue