refactoring + init workerservice to delete tweets
This commit is contained in:
parent
5b32a9021f
commit
b223bb0216
|
@ -19,6 +19,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Folder Include="Processors\TweetsCleanUp\" />
|
||||||
<Folder Include="Tools\" />
|
<Folder Include="Tools\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Contracts
|
namespace BirdsiteLive.Pipeline.Contracts.Federation
|
||||||
{
|
{
|
||||||
public interface IRefreshTwitterUserStatusProcessor
|
public interface IRefreshTwitterUserStatusProcessor
|
||||||
{
|
{
|
|
@ -3,7 +3,7 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Contracts
|
namespace BirdsiteLive.Pipeline.Contracts.Federation
|
||||||
{
|
{
|
||||||
public interface IRetrieveFollowersProcessor
|
public interface IRetrieveFollowersProcessor
|
||||||
{
|
{
|
|
@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Contracts
|
namespace BirdsiteLive.Pipeline.Contracts.Federation
|
||||||
{
|
{
|
||||||
public interface IRetrieveTweetsProcessor
|
public interface IRetrieveTweetsProcessor
|
||||||
{
|
{
|
|
@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks.Dataflow;
|
using System.Threading.Tasks.Dataflow;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Contracts
|
namespace BirdsiteLive.Pipeline.Contracts.Federation
|
||||||
{
|
{
|
||||||
public interface IRetrieveTwitterUsersProcessor
|
public interface IRetrieveTwitterUsersProcessor
|
||||||
{
|
{
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Contracts
|
namespace BirdsiteLive.Pipeline.Contracts.Federation
|
||||||
{
|
{
|
||||||
public interface ISaveProgressionProcessor
|
public interface ISaveProgressionProcessor
|
||||||
{
|
{
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Contracts
|
namespace BirdsiteLive.Pipeline.Contracts.Federation
|
||||||
{
|
{
|
||||||
public interface ISendTweetsToFollowersProcessor
|
public interface ISendTweetsToFollowersProcessor
|
||||||
{
|
{
|
|
@ -6,12 +6,12 @@ using BirdsiteLive.Common.Settings;
|
||||||
using BirdsiteLive.DAL.Contracts;
|
using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Moderation.Actions;
|
using BirdsiteLive.Moderation.Actions;
|
||||||
using BirdsiteLive.Pipeline.Contracts;
|
using BirdsiteLive.Pipeline.Contracts.Federation;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
using BirdsiteLive.Twitter;
|
using BirdsiteLive.Twitter;
|
||||||
using BirdsiteLive.Twitter.Models;
|
using BirdsiteLive.Twitter.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Processors
|
namespace BirdsiteLive.Pipeline.Processors.Federation
|
||||||
{
|
{
|
||||||
public class RefreshTwitterUserStatusProcessor : IRefreshTwitterUserStatusProcessor
|
public class RefreshTwitterUserStatusProcessor : IRefreshTwitterUserStatusProcessor
|
||||||
{
|
{
|
|
@ -2,10 +2,10 @@
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BirdsiteLive.DAL.Contracts;
|
using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.Pipeline.Contracts;
|
using BirdsiteLive.Pipeline.Contracts.Federation;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Processors
|
namespace BirdsiteLive.Pipeline.Processors.Federation
|
||||||
{
|
{
|
||||||
public class RetrieveFollowersProcessor : IRetrieveFollowersProcessor
|
public class RetrieveFollowersProcessor : IRetrieveFollowersProcessor
|
||||||
{
|
{
|
|
@ -5,14 +5,14 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BirdsiteLive.DAL.Contracts;
|
using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Pipeline.Contracts;
|
using BirdsiteLive.Pipeline.Contracts.Federation;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
using BirdsiteLive.Twitter;
|
using BirdsiteLive.Twitter;
|
||||||
using BirdsiteLive.Twitter.Models;
|
using BirdsiteLive.Twitter.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Tweetinvi.Models;
|
using Tweetinvi.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Processors
|
namespace BirdsiteLive.Pipeline.Processors.Federation
|
||||||
{
|
{
|
||||||
public class RetrieveTweetsProcessor : IRetrieveTweetsProcessor
|
public class RetrieveTweetsProcessor : IRetrieveTweetsProcessor
|
||||||
{
|
{
|
|
@ -7,11 +7,11 @@ using BirdsiteLive.Common.Extensions;
|
||||||
using BirdsiteLive.Common.Settings;
|
using BirdsiteLive.Common.Settings;
|
||||||
using BirdsiteLive.DAL.Contracts;
|
using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Pipeline.Contracts;
|
using BirdsiteLive.Pipeline.Contracts.Federation;
|
||||||
using BirdsiteLive.Pipeline.Tools;
|
using BirdsiteLive.Pipeline.Tools;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Processors
|
namespace BirdsiteLive.Pipeline.Processors.Federation
|
||||||
{
|
{
|
||||||
public class RetrieveTwitterUsersProcessor : IRetrieveTwitterUsersProcessor
|
public class RetrieveTwitterUsersProcessor : IRetrieveTwitterUsersProcessor
|
||||||
{
|
{
|
|
@ -5,11 +5,11 @@ using System.Threading.Tasks;
|
||||||
using BirdsiteLive.DAL.Contracts;
|
using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Moderation.Actions;
|
using BirdsiteLive.Moderation.Actions;
|
||||||
using BirdsiteLive.Pipeline.Contracts;
|
using BirdsiteLive.Pipeline.Contracts.Federation;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Processors
|
namespace BirdsiteLive.Pipeline.Processors.Federation
|
||||||
{
|
{
|
||||||
public class SaveProgressionProcessor : ISaveProgressionProcessor
|
public class SaveProgressionProcessor : ISaveProgressionProcessor
|
||||||
{
|
{
|
|
@ -10,7 +10,7 @@ using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Domain;
|
using BirdsiteLive.Domain;
|
||||||
using BirdsiteLive.Moderation.Actions;
|
using BirdsiteLive.Moderation.Actions;
|
||||||
using BirdsiteLive.Pipeline.Contracts;
|
using BirdsiteLive.Pipeline.Contracts.Federation;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
using BirdsiteLive.Pipeline.Processors.SubTasks;
|
using BirdsiteLive.Pipeline.Processors.SubTasks;
|
||||||
using BirdsiteLive.Twitter;
|
using BirdsiteLive.Twitter;
|
||||||
|
@ -18,7 +18,7 @@ using BirdsiteLive.Twitter.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Tweetinvi.Models;
|
using Tweetinvi.Models;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Processors
|
namespace BirdsiteLive.Pipeline.Processors.Federation
|
||||||
{
|
{
|
||||||
public class SendTweetsToFollowersProcessor : ISendTweetsToFollowersProcessor
|
public class SendTweetsToFollowersProcessor : ISendTweetsToFollowersProcessor
|
||||||
{
|
{
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace BirdsiteLive.Pipeline.Processors.TweetsCleanUp
|
||||||
|
{
|
||||||
|
public class DeleteTweetsProcessor
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace BirdsiteLive.Pipeline.Processors.TweetsCleanUp
|
||||||
|
{
|
||||||
|
public class RetrieveTweetsToDeleteProcessor
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace BirdsiteLive.Pipeline.Processors.TweetsCleanUp
|
||||||
|
{
|
||||||
|
public class SaveDeletedTweetStatusProcessor
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks.Dataflow;
|
using System.Threading.Tasks.Dataflow;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Pipeline.Contracts;
|
using BirdsiteLive.Pipeline.Contracts.Federation;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ namespace BirdsiteLive
|
||||||
.ConfigureServices(services =>
|
.ConfigureServices(services =>
|
||||||
{
|
{
|
||||||
services.AddHostedService<FederationService>();
|
services.AddHostedService<FederationService>();
|
||||||
|
services.AddHostedService<TweetCleanUpService>();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ using BirdsiteLive.DAL;
|
||||||
using BirdsiteLive.DAL.Contracts;
|
using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.Moderation;
|
using BirdsiteLive.Moderation;
|
||||||
using BirdsiteLive.Pipeline;
|
using BirdsiteLive.Pipeline;
|
||||||
|
using BirdsiteLive.Tools;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace BirdsiteLive.Services
|
namespace BirdsiteLive.Services
|
||||||
|
@ -32,6 +33,7 @@ namespace BirdsiteLive.Services
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _databaseInitializer.InitAndMigrateDbAsync();
|
await _databaseInitializer.InitAndMigrateDbAsync();
|
||||||
|
InitStateSynchronization.IsDbInitialized = true;
|
||||||
await _moderationPipeline.ApplyModerationSettingsAsync();
|
await _moderationPipeline.ApplyModerationSettingsAsync();
|
||||||
await _statusPublicationPipeline.ExecuteAsync(stoppingToken);
|
await _statusPublicationPipeline.ExecuteAsync(stoppingToken);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace BirdsiteLive.Tools
|
||||||
|
{
|
||||||
|
public static class InitStateSynchronization
|
||||||
|
{
|
||||||
|
public static bool IsDbInitialized { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ using System.Threading.Tasks;
|
||||||
using BirdsiteLive.DAL.Contracts;
|
using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
using BirdsiteLive.Pipeline.Processors;
|
using BirdsiteLive.Pipeline.Processors.Federation;
|
||||||
using BirdsiteLive.Twitter;
|
using BirdsiteLive.Twitter;
|
||||||
using BirdsiteLive.Twitter.Models;
|
using BirdsiteLive.Twitter.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks.Dataflow;
|
||||||
using BirdsiteLive.Common.Settings;
|
using BirdsiteLive.Common.Settings;
|
||||||
using BirdsiteLive.DAL.Contracts;
|
using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Pipeline.Processors;
|
using BirdsiteLive.Pipeline.Processors.Federation;
|
||||||
using BirdsiteLive.Pipeline.Tools;
|
using BirdsiteLive.Pipeline.Tools;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Moderation.Actions;
|
using BirdsiteLive.Moderation.Actions;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
using BirdsiteLive.Pipeline.Processors;
|
using BirdsiteLive.Pipeline.Processors.Federation;
|
||||||
using BirdsiteLive.Twitter.Models;
|
using BirdsiteLive.Twitter.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
|
@ -7,7 +7,7 @@ using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Moderation.Actions;
|
using BirdsiteLive.Moderation.Actions;
|
||||||
using BirdsiteLive.Pipeline.Models;
|
using BirdsiteLive.Pipeline.Models;
|
||||||
using BirdsiteLive.Pipeline.Processors;
|
using BirdsiteLive.Pipeline.Processors.Federation;
|
||||||
using BirdsiteLive.Pipeline.Processors.SubTasks;
|
using BirdsiteLive.Pipeline.Processors.SubTasks;
|
||||||
using BirdsiteLive.Twitter.Models;
|
using BirdsiteLive.Twitter.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks.Dataflow;
|
using System.Threading.Tasks.Dataflow;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Pipeline.Contracts;
|
using BirdsiteLive.Pipeline.Contracts.Federation;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
Loading…
Reference in New Issue