[backend/federation] Transfer blocks on migration (ISH-563)
This commit is contained in:
parent
b79d2213be
commit
ac2527aa75
1 changed files with 41 additions and 0 deletions
|
@ -1458,6 +1458,28 @@ public class UserService(
|
|||
}
|
||||
}
|
||||
|
||||
var blocks = db.Blockings
|
||||
.Where(p => p.Blockee == source)
|
||||
.Select(p => p.Blocker)
|
||||
.AsChunkedAsyncEnumerable(50, p => p.Id, p => p.PrecomputeRelationshipData(source));
|
||||
|
||||
await foreach (var blocker in blocks)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (blocker.Id == target.Id) continue;
|
||||
|
||||
// We need to transfer the precomputed properties to the target user for each blocker so that the block method works correctly
|
||||
target.PrecomputedIsBlockedBy = blocker.PrecomputedIsBlocking;
|
||||
await BlockUserAsync(blocker, target);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogWarning("Failed to process move ({sourceUri} -> {targetUri}) for blocker {id}: {error}",
|
||||
sourceUri, targetUri, blocker.Id, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (source.IsRemoteUser || target.IsRemoteUser) return;
|
||||
|
||||
var following = db.Followings
|
||||
|
@ -1478,6 +1500,25 @@ public class UserService(
|
|||
sourceUri, targetUri, followee.Id, e);
|
||||
}
|
||||
}
|
||||
|
||||
blocks = db.Blockings
|
||||
.Where(p => p.Blocker == source)
|
||||
.Select(p => p.Blockee)
|
||||
.AsChunkedAsyncEnumerable(50, p => p.Id, p => p.PrecomputeRelationshipData(source));
|
||||
|
||||
await foreach (var blockee in blocks)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (blockee.Id == target.Id) continue;
|
||||
await BlockUserAsync(blockee, target);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogWarning("Failed to process move ({sourceUri} -> {targetUri}) for blockee {id}: {error}",
|
||||
sourceUri, targetUri, blockee.Id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SuspendUserAsync(User user)
|
||||
|
|
Loading…
Add table
Reference in a new issue