moved followers retrieval
This commit is contained in:
parent
62caf7e956
commit
8d6851c639
3 changed files with 18 additions and 13 deletions
|
@ -21,18 +21,18 @@ namespace BirdsiteLive.Pipeline.Processors
|
||||||
|
|
||||||
public async Task<IEnumerable<UserWithDataToSync>> ProcessAsync(UserWithDataToSync[] userWithTweetsToSyncs, CancellationToken ct)
|
public async Task<IEnumerable<UserWithDataToSync>> ProcessAsync(UserWithDataToSync[] userWithTweetsToSyncs, CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<Task> todo = new List<Task>();
|
//List<Task> todo = new List<Task>();
|
||||||
foreach (var user in userWithTweetsToSyncs)
|
//foreach (var user in userWithTweetsToSyncs)
|
||||||
{
|
//{
|
||||||
var t = Task.Run(
|
// var t = Task.Run(
|
||||||
async() => {
|
// async() => {
|
||||||
var followers = await _followersDal.GetFollowersAsync(user.User.Id);
|
// var followers = await _followersDal.GetFollowersAsync(user.User.Id);
|
||||||
user.Followers = followers;
|
// user.Followers = followers;
|
||||||
});
|
// });
|
||||||
todo.Add(t);
|
// todo.Add(t);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
await Task.WhenAll(todo);
|
//await Task.WhenAll(todo);
|
||||||
|
|
||||||
return userWithTweetsToSyncs;
|
return userWithTweetsToSyncs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,10 @@ namespace BirdsiteLive.Pipeline.Processors
|
||||||
|
|
||||||
var t = Task.Run( async () =>
|
var t = Task.Run( async () =>
|
||||||
{
|
{
|
||||||
|
if (userWithTweetsToSync.Followers is null || userWithTweetsToSync.Followers.Length == 0)
|
||||||
|
{
|
||||||
|
userWithTweetsToSync.Followers = await _followersDal.GetFollowersAsync(user.Id);
|
||||||
|
}
|
||||||
// Process Shared Inbox
|
// Process Shared Inbox
|
||||||
var followersWtSharedInbox = userWithTweetsToSync.Followers
|
var followersWtSharedInbox = userWithTweetsToSync.Followers
|
||||||
.Where(x => !string.IsNullOrWhiteSpace(x.SharedInboxRoute))
|
.Where(x => !string.IsNullOrWhiteSpace(x.SharedInboxRoute))
|
||||||
|
@ -60,7 +64,7 @@ namespace BirdsiteLive.Pipeline.Processors
|
||||||
.Where(x => string.IsNullOrWhiteSpace(x.SharedInboxRoute))
|
.Where(x => string.IsNullOrWhiteSpace(x.SharedInboxRoute))
|
||||||
.ToList();
|
.ToList();
|
||||||
await ProcessFollowersWithInboxAsync(userWithTweetsToSync.Tweets, followerWtInbox, user);
|
await ProcessFollowersWithInboxAsync(userWithTweetsToSync.Tweets, followerWtInbox, user);
|
||||||
});
|
}, ct);
|
||||||
_todo.Add(t);
|
_todo.Add(t);
|
||||||
|
|
||||||
if (_todo.Count >= _instanceSettings.ParallelFediversePosts)
|
if (_todo.Count >= _instanceSettings.ParallelFediversePosts)
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace BirdsiteLive.Pipeline.Tests.Processors
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class RetrieveFollowersProcessorTests
|
public class RetrieveFollowersProcessorTests
|
||||||
{
|
{
|
||||||
|
[Ignore]
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task ProcessAsync_Test()
|
public async Task ProcessAsync_Test()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue