diff --git a/src/BirdsiteLive.Pipeline/BirdsiteLive.Pipeline.csproj b/src/BirdsiteLive.Pipeline/BirdsiteLive.Pipeline.csproj
index 8601b19..a190af6 100644
--- a/src/BirdsiteLive.Pipeline/BirdsiteLive.Pipeline.csproj
+++ b/src/BirdsiteLive.Pipeline/BirdsiteLive.Pipeline.csproj
@@ -19,6 +19,7 @@
+
diff --git a/src/BirdsiteLive.Pipeline/Contracts/IRefreshTwitterUserStatusProcessor.cs b/src/BirdsiteLive.Pipeline/Contracts/Federation/IRefreshTwitterUserStatusProcessor.cs
similarity index 84%
rename from src/BirdsiteLive.Pipeline/Contracts/IRefreshTwitterUserStatusProcessor.cs
rename to src/BirdsiteLive.Pipeline/Contracts/Federation/IRefreshTwitterUserStatusProcessor.cs
index 9f20e59..bf74efd 100644
--- a/src/BirdsiteLive.Pipeline/Contracts/IRefreshTwitterUserStatusProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Contracts/Federation/IRefreshTwitterUserStatusProcessor.cs
@@ -3,7 +3,7 @@ using System.Threading.Tasks;
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Pipeline.Models;
-namespace BirdsiteLive.Pipeline.Contracts
+namespace BirdsiteLive.Pipeline.Contracts.Federation
{
public interface IRefreshTwitterUserStatusProcessor
{
diff --git a/src/BirdsiteLive.Pipeline/Contracts/IRetrieveFollowersProcessor.cs b/src/BirdsiteLive.Pipeline/Contracts/Federation/IRetrieveFollowersProcessor.cs
similarity index 89%
rename from src/BirdsiteLive.Pipeline/Contracts/IRetrieveFollowersProcessor.cs
rename to src/BirdsiteLive.Pipeline/Contracts/Federation/IRetrieveFollowersProcessor.cs
index a9ef35c..567d41b 100644
--- a/src/BirdsiteLive.Pipeline/Contracts/IRetrieveFollowersProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Contracts/Federation/IRetrieveFollowersProcessor.cs
@@ -3,7 +3,7 @@ using System.Threading;
using System.Threading.Tasks;
using BirdsiteLive.Pipeline.Models;
-namespace BirdsiteLive.Pipeline.Contracts
+namespace BirdsiteLive.Pipeline.Contracts.Federation
{
public interface IRetrieveFollowersProcessor
{
diff --git a/src/BirdsiteLive.Pipeline/Contracts/IRetrieveTweetsProcessor.cs b/src/BirdsiteLive.Pipeline/Contracts/Federation/IRetrieveTweetsProcessor.cs
similarity index 84%
rename from src/BirdsiteLive.Pipeline/Contracts/IRetrieveTweetsProcessor.cs
rename to src/BirdsiteLive.Pipeline/Contracts/Federation/IRetrieveTweetsProcessor.cs
index 49712c2..0cbf2cb 100644
--- a/src/BirdsiteLive.Pipeline/Contracts/IRetrieveTweetsProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Contracts/Federation/IRetrieveTweetsProcessor.cs
@@ -3,7 +3,7 @@ using System.Threading.Tasks;
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Pipeline.Models;
-namespace BirdsiteLive.Pipeline.Contracts
+namespace BirdsiteLive.Pipeline.Contracts.Federation
{
public interface IRetrieveTweetsProcessor
{
diff --git a/src/BirdsiteLive.Pipeline/Contracts/IRetrieveTwitterUsersProcessor.cs b/src/BirdsiteLive.Pipeline/Contracts/Federation/IRetrieveTwitterUsersProcessor.cs
similarity index 85%
rename from src/BirdsiteLive.Pipeline/Contracts/IRetrieveTwitterUsersProcessor.cs
rename to src/BirdsiteLive.Pipeline/Contracts/Federation/IRetrieveTwitterUsersProcessor.cs
index b71ae93..c6d08d0 100644
--- a/src/BirdsiteLive.Pipeline/Contracts/IRetrieveTwitterUsersProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Contracts/Federation/IRetrieveTwitterUsersProcessor.cs
@@ -3,7 +3,7 @@ using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using BirdsiteLive.DAL.Models;
-namespace BirdsiteLive.Pipeline.Contracts
+namespace BirdsiteLive.Pipeline.Contracts.Federation
{
public interface IRetrieveTwitterUsersProcessor
{
diff --git a/src/BirdsiteLive.Pipeline/Contracts/ISaveProgressionProcessor.cs b/src/BirdsiteLive.Pipeline/Contracts/Federation/ISaveProgressionProcessor.cs
similarity index 81%
rename from src/BirdsiteLive.Pipeline/Contracts/ISaveProgressionProcessor.cs
rename to src/BirdsiteLive.Pipeline/Contracts/Federation/ISaveProgressionProcessor.cs
index 6b1c9ba..f0320cb 100644
--- a/src/BirdsiteLive.Pipeline/Contracts/ISaveProgressionProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Contracts/Federation/ISaveProgressionProcessor.cs
@@ -2,7 +2,7 @@
using System.Threading.Tasks;
using BirdsiteLive.Pipeline.Models;
-namespace BirdsiteLive.Pipeline.Contracts
+namespace BirdsiteLive.Pipeline.Contracts.Federation
{
public interface ISaveProgressionProcessor
{
diff --git a/src/BirdsiteLive.Pipeline/Contracts/ISendTweetsToFollowersProcessor.cs b/src/BirdsiteLive.Pipeline/Contracts/Federation/ISendTweetsToFollowersProcessor.cs
similarity index 83%
rename from src/BirdsiteLive.Pipeline/Contracts/ISendTweetsToFollowersProcessor.cs
rename to src/BirdsiteLive.Pipeline/Contracts/Federation/ISendTweetsToFollowersProcessor.cs
index 33db423..49d47f0 100644
--- a/src/BirdsiteLive.Pipeline/Contracts/ISendTweetsToFollowersProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Contracts/Federation/ISendTweetsToFollowersProcessor.cs
@@ -2,7 +2,7 @@
using System.Threading.Tasks;
using BirdsiteLive.Pipeline.Models;
-namespace BirdsiteLive.Pipeline.Contracts
+namespace BirdsiteLive.Pipeline.Contracts.Federation
{
public interface ISendTweetsToFollowersProcessor
{
diff --git a/src/BirdsiteLive.Pipeline/Processors/RefreshTwitterUserStatusProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/Federation/RefreshTwitterUserStatusProcessor.cs
similarity index 97%
rename from src/BirdsiteLive.Pipeline/Processors/RefreshTwitterUserStatusProcessor.cs
rename to src/BirdsiteLive.Pipeline/Processors/Federation/RefreshTwitterUserStatusProcessor.cs
index 739d50b..a3e7ab2 100644
--- a/src/BirdsiteLive.Pipeline/Processors/RefreshTwitterUserStatusProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Processors/Federation/RefreshTwitterUserStatusProcessor.cs
@@ -6,12 +6,12 @@ using BirdsiteLive.Common.Settings;
using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Moderation.Actions;
-using BirdsiteLive.Pipeline.Contracts;
+using BirdsiteLive.Pipeline.Contracts.Federation;
using BirdsiteLive.Pipeline.Models;
using BirdsiteLive.Twitter;
using BirdsiteLive.Twitter.Models;
-namespace BirdsiteLive.Pipeline.Processors
+namespace BirdsiteLive.Pipeline.Processors.Federation
{
public class RefreshTwitterUserStatusProcessor : IRefreshTwitterUserStatusProcessor
{
diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/Federation/RetrieveFollowersProcessor.cs
similarity index 89%
rename from src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs
rename to src/BirdsiteLive.Pipeline/Processors/Federation/RetrieveFollowersProcessor.cs
index 57e3e49..7f696f7 100644
--- a/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Processors/Federation/RetrieveFollowersProcessor.cs
@@ -2,10 +2,10 @@
using System.Threading;
using System.Threading.Tasks;
using BirdsiteLive.DAL.Contracts;
-using BirdsiteLive.Pipeline.Contracts;
+using BirdsiteLive.Pipeline.Contracts.Federation;
using BirdsiteLive.Pipeline.Models;
-namespace BirdsiteLive.Pipeline.Processors
+namespace BirdsiteLive.Pipeline.Processors.Federation
{
public class RetrieveFollowersProcessor : IRetrieveFollowersProcessor
{
diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/Federation/RetrieveTweetsProcessor.cs
similarity index 96%
rename from src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs
rename to src/BirdsiteLive.Pipeline/Processors/Federation/RetrieveTweetsProcessor.cs
index 321fbf0..d38feb2 100644
--- a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Processors/Federation/RetrieveTweetsProcessor.cs
@@ -5,14 +5,14 @@ using System.Threading;
using System.Threading.Tasks;
using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
-using BirdsiteLive.Pipeline.Contracts;
+using BirdsiteLive.Pipeline.Contracts.Federation;
using BirdsiteLive.Pipeline.Models;
using BirdsiteLive.Twitter;
using BirdsiteLive.Twitter.Models;
using Microsoft.Extensions.Logging;
using Tweetinvi.Models;
-namespace BirdsiteLive.Pipeline.Processors
+namespace BirdsiteLive.Pipeline.Processors.Federation
{
public class RetrieveTweetsProcessor : IRetrieveTweetsProcessor
{
@@ -64,7 +64,7 @@ namespace BirdsiteLive.Pipeline.Processors
private ExtractedTweet[] RetrieveNewTweets(SyncTwitterUser user)
{
var tweets = new ExtractedTweet[0];
-
+
try
{
if (user.LastTweetPostedId == -1)
diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/Federation/RetrieveTwitterUsersProcessor.cs
similarity index 93%
rename from src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs
rename to src/BirdsiteLive.Pipeline/Processors/Federation/RetrieveTwitterUsersProcessor.cs
index d9d0ffb..7d16ac5 100644
--- a/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Processors/Federation/RetrieveTwitterUsersProcessor.cs
@@ -7,18 +7,18 @@ using BirdsiteLive.Common.Extensions;
using BirdsiteLive.Common.Settings;
using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
-using BirdsiteLive.Pipeline.Contracts;
+using BirdsiteLive.Pipeline.Contracts.Federation;
using BirdsiteLive.Pipeline.Tools;
using Microsoft.Extensions.Logging;
-namespace BirdsiteLive.Pipeline.Processors
+namespace BirdsiteLive.Pipeline.Processors.Federation
{
public class RetrieveTwitterUsersProcessor : IRetrieveTwitterUsersProcessor
{
private readonly ITwitterUserDal _twitterUserDal;
private readonly IMaxUsersNumberProvider _maxUsersNumberProvider;
private readonly ILogger _logger;
-
+
public int WaitFactor = 1000 * 60; //1 min
#region Ctor
@@ -42,7 +42,7 @@ namespace BirdsiteLive.Pipeline.Processors
var users = await _twitterUserDal.GetAllTwitterUsersAsync(maxUsersNumber, false);
var userCount = users.Any() ? users.Length : 1;
- var splitNumber = (int) Math.Ceiling(userCount / 15d);
+ var splitNumber = (int)Math.Ceiling(userCount / 15d);
var splitUsers = users.Split(splitNumber).ToList();
foreach (var u in splitUsers)
diff --git a/src/BirdsiteLive.Pipeline/Processors/SaveProgressionProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/Federation/SaveProgressionProcessor.cs
similarity index 94%
rename from src/BirdsiteLive.Pipeline/Processors/SaveProgressionProcessor.cs
rename to src/BirdsiteLive.Pipeline/Processors/Federation/SaveProgressionProcessor.cs
index 1f94871..0b29769 100644
--- a/src/BirdsiteLive.Pipeline/Processors/SaveProgressionProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Processors/Federation/SaveProgressionProcessor.cs
@@ -5,11 +5,11 @@ using System.Threading.Tasks;
using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Moderation.Actions;
-using BirdsiteLive.Pipeline.Contracts;
+using BirdsiteLive.Pipeline.Contracts.Federation;
using BirdsiteLive.Pipeline.Models;
using Microsoft.Extensions.Logging;
-namespace BirdsiteLive.Pipeline.Processors
+namespace BirdsiteLive.Pipeline.Processors.Federation
{
public class SaveProgressionProcessor : ISaveProgressionProcessor
{
@@ -36,13 +36,13 @@ namespace BirdsiteLive.Pipeline.Processors
await UpdateUserSyncDateAsync(userWithTweetsToSync.User);
return;
}
- if(userWithTweetsToSync.Followers.Length == 0)
+ if (userWithTweetsToSync.Followers.Length == 0)
{
_logger.LogInformation("No Followers found for {User}", userWithTweetsToSync.User.Acct);
await _removeTwitterAccountAction.ProcessAsync(userWithTweetsToSync.User);
return;
}
-
+
var userId = userWithTweetsToSync.User.Id;
var followingSyncStatuses = userWithTweetsToSync.Followers.Select(x => x.FollowingsSyncStatus[userId]).ToList();
var lastPostedTweet = userWithTweetsToSync.Tweets.Select(x => x.Id).Max();
diff --git a/src/BirdsiteLive.Pipeline/Processors/SendTweetsToFollowersProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/Federation/SendTweetsToFollowersProcessor.cs
similarity index 97%
rename from src/BirdsiteLive.Pipeline/Processors/SendTweetsToFollowersProcessor.cs
rename to src/BirdsiteLive.Pipeline/Processors/Federation/SendTweetsToFollowersProcessor.cs
index e210f39..3a52544 100644
--- a/src/BirdsiteLive.Pipeline/Processors/SendTweetsToFollowersProcessor.cs
+++ b/src/BirdsiteLive.Pipeline/Processors/Federation/SendTweetsToFollowersProcessor.cs
@@ -10,7 +10,7 @@ using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Domain;
using BirdsiteLive.Moderation.Actions;
-using BirdsiteLive.Pipeline.Contracts;
+using BirdsiteLive.Pipeline.Contracts.Federation;
using BirdsiteLive.Pipeline.Models;
using BirdsiteLive.Pipeline.Processors.SubTasks;
using BirdsiteLive.Twitter;
@@ -18,7 +18,7 @@ using BirdsiteLive.Twitter.Models;
using Microsoft.Extensions.Logging;
using Tweetinvi.Models;
-namespace BirdsiteLive.Pipeline.Processors
+namespace BirdsiteLive.Pipeline.Processors.Federation
{
public class SendTweetsToFollowersProcessor : ISendTweetsToFollowersProcessor
{
@@ -83,7 +83,7 @@ namespace BirdsiteLive.Pipeline.Processors
}
}
}
-
+
private async Task ProcessFollowersWithInboxAsync(ExtractedTweet[] tweets, List followerWtInbox, SyncTwitterUser user)
{
foreach (var follower in followerWtInbox)
@@ -114,7 +114,7 @@ namespace BirdsiteLive.Pipeline.Processors
{
follower.PostingErrorCount++;
- if (follower.PostingErrorCount > _instanceSettings.FailingFollowerCleanUpThreshold
+ if (follower.PostingErrorCount > _instanceSettings.FailingFollowerCleanUpThreshold
&& _instanceSettings.FailingFollowerCleanUpThreshold > 0
|| follower.PostingErrorCount > 2147483600)
{
diff --git a/src/BirdsiteLive.Pipeline/Processors/SubTasks/SendTweetsTaskBase.cs b/src/BirdsiteLive.Pipeline/Processors/Federation/SubTasks/SendTweetsTaskBase.cs
similarity index 100%
rename from src/BirdsiteLive.Pipeline/Processors/SubTasks/SendTweetsTaskBase.cs
rename to src/BirdsiteLive.Pipeline/Processors/Federation/SubTasks/SendTweetsTaskBase.cs
diff --git a/src/BirdsiteLive.Pipeline/Processors/SubTasks/SendTweetsToInboxTask.cs b/src/BirdsiteLive.Pipeline/Processors/Federation/SubTasks/SendTweetsToInboxTask.cs
similarity index 100%
rename from src/BirdsiteLive.Pipeline/Processors/SubTasks/SendTweetsToInboxTask.cs
rename to src/BirdsiteLive.Pipeline/Processors/Federation/SubTasks/SendTweetsToInboxTask.cs
diff --git a/src/BirdsiteLive.Pipeline/Processors/SubTasks/SendTweetsToSharedInboxTask.cs b/src/BirdsiteLive.Pipeline/Processors/Federation/SubTasks/SendTweetsToSharedInboxTask.cs
similarity index 100%
rename from src/BirdsiteLive.Pipeline/Processors/SubTasks/SendTweetsToSharedInboxTask.cs
rename to src/BirdsiteLive.Pipeline/Processors/Federation/SubTasks/SendTweetsToSharedInboxTask.cs
diff --git a/src/BirdsiteLive.Pipeline/Processors/TweetsCleanUp/DeleteTweetsProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/TweetsCleanUp/DeleteTweetsProcessor.cs
new file mode 100644
index 0000000..9dbb765
--- /dev/null
+++ b/src/BirdsiteLive.Pipeline/Processors/TweetsCleanUp/DeleteTweetsProcessor.cs
@@ -0,0 +1,7 @@
+namespace BirdsiteLive.Pipeline.Processors.TweetsCleanUp
+{
+ public class DeleteTweetsProcessor
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/BirdsiteLive.Pipeline/Processors/TweetsCleanUp/RetrieveTweetsToDeleteProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/TweetsCleanUp/RetrieveTweetsToDeleteProcessor.cs
new file mode 100644
index 0000000..dd2c565
--- /dev/null
+++ b/src/BirdsiteLive.Pipeline/Processors/TweetsCleanUp/RetrieveTweetsToDeleteProcessor.cs
@@ -0,0 +1,7 @@
+namespace BirdsiteLive.Pipeline.Processors.TweetsCleanUp
+{
+ public class RetrieveTweetsToDeleteProcessor
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/BirdsiteLive.Pipeline/Processors/TweetsCleanUp/SaveDeletedTweetStatusProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/TweetsCleanUp/SaveDeletedTweetStatusProcessor.cs
new file mode 100644
index 0000000..ccf2181
--- /dev/null
+++ b/src/BirdsiteLive.Pipeline/Processors/TweetsCleanUp/SaveDeletedTweetStatusProcessor.cs
@@ -0,0 +1,7 @@
+namespace BirdsiteLive.Pipeline.Processors.TweetsCleanUp
+{
+ public class SaveDeletedTweetStatusProcessor
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs b/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs
index c6917e7..f0a81e6 100644
--- a/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs
+++ b/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs
@@ -4,7 +4,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using BirdsiteLive.DAL.Models;
-using BirdsiteLive.Pipeline.Contracts;
+using BirdsiteLive.Pipeline.Contracts.Federation;
using BirdsiteLive.Pipeline.Models;
using Microsoft.Extensions.Logging;
diff --git a/src/BirdsiteLive.Pipeline/TweetCleanUpPipeline.cs b/src/BirdsiteLive.Pipeline/TweetCleanUpPipeline.cs
new file mode 100644
index 0000000..9dfc451
--- /dev/null
+++ b/src/BirdsiteLive.Pipeline/TweetCleanUpPipeline.cs
@@ -0,0 +1,18 @@
+using System.Threading.Tasks;
+using System.Threading;
+
+namespace BirdsiteLive.Pipeline
+{
+ public interface ITweetCleanUpPipeline
+ {
+ Task ExecuteAsync(CancellationToken ct);
+ }
+
+ public class TweetCleanUpPipeline : ITweetCleanUpPipeline
+ {
+ public async Task ExecuteAsync(CancellationToken ct)
+ {
+ throw new System.NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/BirdsiteLive/Program.cs b/src/BirdsiteLive/Program.cs
index d238b02..7f29e76 100644
--- a/src/BirdsiteLive/Program.cs
+++ b/src/BirdsiteLive/Program.cs
@@ -29,6 +29,7 @@ namespace BirdsiteLive
.ConfigureServices(services =>
{
services.AddHostedService();
+ services.AddHostedService();
});
}
}
diff --git a/src/BirdsiteLive/Services/FederationService.cs b/src/BirdsiteLive/Services/FederationService.cs
index 0b0faed..32e8b5e 100644
--- a/src/BirdsiteLive/Services/FederationService.cs
+++ b/src/BirdsiteLive/Services/FederationService.cs
@@ -6,6 +6,7 @@ using BirdsiteLive.DAL;
using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.Moderation;
using BirdsiteLive.Pipeline;
+using BirdsiteLive.Tools;
using Microsoft.Extensions.Hosting;
namespace BirdsiteLive.Services
@@ -32,6 +33,7 @@ namespace BirdsiteLive.Services
try
{
await _databaseInitializer.InitAndMigrateDbAsync();
+ InitStateSynchronization.IsDbInitialized = true;
await _moderationPipeline.ApplyModerationSettingsAsync();
await _statusPublicationPipeline.ExecuteAsync(stoppingToken);
}
diff --git a/src/BirdsiteLive/Services/TweetCleanUpService.cs b/src/BirdsiteLive/Services/TweetCleanUpService.cs
new file mode 100644
index 0000000..c2d81bd
--- /dev/null
+++ b/src/BirdsiteLive/Services/TweetCleanUpService.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using BirdsiteLive.Pipeline;
+using BirdsiteLive.Tools;
+using Microsoft.Extensions.Hosting;
+
+namespace BirdsiteLive.Services
+{
+ public class TweetCleanUpService : BackgroundService
+ {
+ private readonly ITweetCleanUpPipeline _cleanUpPipeline;
+ private readonly IHostApplicationLifetime _applicationLifetime;
+
+ #region Ctor
+ public TweetCleanUpService(IHostApplicationLifetime applicationLifetime, ITweetCleanUpPipeline cleanUpPipeline)
+ {
+ _applicationLifetime = applicationLifetime;
+ _cleanUpPipeline = cleanUpPipeline;
+ }
+ #endregion
+
+ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
+ {
+ try
+ {
+ // Wait for initialization
+ while (!InitStateSynchronization.IsDbInitialized)
+ {
+ if (stoppingToken.IsCancellationRequested) return;
+ await Task.Delay(250, stoppingToken);
+ }
+
+ await _cleanUpPipeline.ExecuteAsync(stoppingToken);
+ }
+ catch (Exception)
+ {
+ await Task.Delay(1000 * 30);
+ _applicationLifetime.StopApplication();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/BirdsiteLive/Tools/InitStateSynchronization.cs b/src/BirdsiteLive/Tools/InitStateSynchronization.cs
new file mode 100644
index 0000000..c2a2e42
--- /dev/null
+++ b/src/BirdsiteLive/Tools/InitStateSynchronization.cs
@@ -0,0 +1,7 @@
+namespace BirdsiteLive.Tools
+{
+ public static class InitStateSynchronization
+ {
+ public static bool IsDbInitialized { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs
index f95ad82..1f69775 100644
--- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs
+++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Pipeline.Models;
-using BirdsiteLive.Pipeline.Processors;
+using BirdsiteLive.Pipeline.Processors.Federation;
using BirdsiteLive.Twitter;
using BirdsiteLive.Twitter.Models;
using Microsoft.Extensions.Logging;
diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTwitterUsersProcessorTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTwitterUsersProcessorTests.cs
index daf0bfa..8a5a5ba 100644
--- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTwitterUsersProcessorTests.cs
+++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTwitterUsersProcessorTests.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks.Dataflow;
using BirdsiteLive.Common.Settings;
using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
-using BirdsiteLive.Pipeline.Processors;
+using BirdsiteLive.Pipeline.Processors.Federation;
using BirdsiteLive.Pipeline.Tools;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SaveProgressionProcessorTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SaveProgressionProcessorTests.cs
index d245713..f38d806 100644
--- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SaveProgressionProcessorTests.cs
+++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SaveProgressionProcessorTests.cs
@@ -2,7 +2,7 @@
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Moderation.Actions;
using BirdsiteLive.Pipeline.Models;
-using BirdsiteLive.Pipeline.Processors;
+using BirdsiteLive.Pipeline.Processors.Federation;
using BirdsiteLive.Twitter.Models;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SendTweetsToFollowersProcessorTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SendTweetsToFollowersProcessorTests.cs
index 8a78038..bd03747 100644
--- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SendTweetsToFollowersProcessorTests.cs
+++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SendTweetsToFollowersProcessorTests.cs
@@ -7,7 +7,7 @@ using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Moderation.Actions;
using BirdsiteLive.Pipeline.Models;
-using BirdsiteLive.Pipeline.Processors;
+using BirdsiteLive.Pipeline.Processors.Federation;
using BirdsiteLive.Pipeline.Processors.SubTasks;
using BirdsiteLive.Twitter.Models;
using Microsoft.Extensions.Logging;
diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs
index 81eeb59..d21d296 100644
--- a/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs
+++ b/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs
@@ -2,7 +2,7 @@
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using BirdsiteLive.DAL.Models;
-using BirdsiteLive.Pipeline.Contracts;
+using BirdsiteLive.Pipeline.Contracts.Federation;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;