[backend/core] Fix erroneous attempts to compute instance stats for local instance when creating follow relationship between local users
This commit is contained in:
parent
f2bf80100d
commit
4448e00333
2 changed files with 35 additions and 20 deletions
|
@ -726,11 +726,14 @@ public class UserService(
|
|||
// Followee has auto accept enabled & is already following the follower user
|
||||
if (autoAccept)
|
||||
{
|
||||
if (requestId == null)
|
||||
throw new Exception("requestId must not be null at this stage");
|
||||
if (follower.IsRemoteUser)
|
||||
{
|
||||
if (requestId == null)
|
||||
throw new Exception("requestId must not be null at this stage");
|
||||
|
||||
var activity = activityRenderer.RenderAccept(followee, follower, requestId);
|
||||
await deliverSvc.DeliverToAsync(activity, followee, follower);
|
||||
var activity = activityRenderer.RenderAccept(followee, follower, requestId);
|
||||
await deliverSvc.DeliverToAsync(activity, followee, follower);
|
||||
}
|
||||
|
||||
var following = new Following
|
||||
{
|
||||
|
@ -757,15 +760,18 @@ public class UserService(
|
|||
.ExecuteUpdateAsync(p => p.SetProperty(i => i.FollowersCount,
|
||||
i => i.FollowersCount + 1));
|
||||
|
||||
_ = followupTaskSvc.ExecuteTask("IncrementInstanceIncomingFollowsCounter", async provider =>
|
||||
if (follower.IsRemoteUser)
|
||||
{
|
||||
var bgDb = provider.GetRequiredService<DatabaseContext>();
|
||||
var bgInstanceSvc = provider.GetRequiredService<InstanceService>();
|
||||
var dbInstance = await bgInstanceSvc.GetUpdatedInstanceMetadataAsync(follower);
|
||||
await bgDb.Instances.Where(p => p.Id == dbInstance.Id)
|
||||
.ExecuteUpdateAsync(p => p.SetProperty(i => i.IncomingFollows,
|
||||
i => i.IncomingFollows + 1));
|
||||
});
|
||||
_ = followupTaskSvc.ExecuteTask("IncrementInstanceIncomingFollowsCounter", async provider =>
|
||||
{
|
||||
var bgDb = provider.GetRequiredService<DatabaseContext>();
|
||||
var bgInstanceSvc = provider.GetRequiredService<InstanceService>();
|
||||
var dbInstance = await bgInstanceSvc.GetUpdatedInstanceMetadataAsync(follower);
|
||||
await bgDb.Instances.Where(p => p.Id == dbInstance.Id)
|
||||
.ExecuteUpdateAsync(p => p.SetProperty(i => i.IncomingFollows,
|
||||
i => i.IncomingFollows + 1));
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -821,15 +827,18 @@ public class UserService(
|
|||
await db.Users.Where(p => p.Id == followee.Id)
|
||||
.ExecuteUpdateAsync(p => p.SetProperty(i => i.FollowersCount, i => i.FollowersCount + 1));
|
||||
|
||||
_ = followupTaskSvc.ExecuteTask("IncrementInstanceIncomingFollowsCounter", async provider =>
|
||||
if (follower.IsRemoteUser)
|
||||
{
|
||||
var bgDb = provider.GetRequiredService<DatabaseContext>();
|
||||
var bgInstanceSvc = provider.GetRequiredService<InstanceService>();
|
||||
var dbInstance = await bgInstanceSvc.GetUpdatedInstanceMetadataAsync(follower);
|
||||
await bgDb.Instances.Where(p => p.Id == dbInstance.Id)
|
||||
.ExecuteUpdateAsync(p => p.SetProperty(i => i.IncomingFollows,
|
||||
i => i.IncomingFollows + 1));
|
||||
});
|
||||
_ = followupTaskSvc.ExecuteTask("IncrementInstanceIncomingFollowsCounter", async provider =>
|
||||
{
|
||||
var bgDb = provider.GetRequiredService<DatabaseContext>();
|
||||
var bgInstanceSvc = provider.GetRequiredService<InstanceService>();
|
||||
var dbInstance = await bgInstanceSvc.GetUpdatedInstanceMetadataAsync(follower);
|
||||
await bgDb.Instances.Where(p => p.Id == dbInstance.Id)
|
||||
.ExecuteUpdateAsync(p => p.SetProperty(i => i.IncomingFollows,
|
||||
i => i.IncomingFollows + 1));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// If follower is remote, send an accept activity
|
||||
|
|
6
Iceshrimp.Shared/Schemas/Web/MigrationSchemas.cs
Normal file
6
Iceshrimp.Shared/Schemas/Web/MigrationSchemas.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace Iceshrimp.Shared.Schemas.Web;
|
||||
|
||||
public class MigrationSchemas
|
||||
{
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue