From 4d3eb30feab1f73ab59a6ec51e49e702cf4584c7 Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Mon, 3 Apr 2023 19:08:38 -0400 Subject: [PATCH 1/7] refresh token on timeline fetch failure --- src/BirdsiteLive.Twitter/TwitterTweetsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs index 931acc0..a852d17 100644 --- a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs +++ b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs @@ -118,7 +118,7 @@ namespace BirdsiteLive.Twitter catch (HttpRequestException e) { _logger.LogError(e, "Error retrieving timeline of {Username}; refreshing client", username); - //await _twitterAuthenticationInitializer.RefreshClient(request); + await _twitterAuthenticationInitializer.RefreshClient(request); return null; } catch (Exception e) From 71a2e327b6fd34571e0bfc29a9a0ab7389142004 Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Thu, 6 Apr 2023 17:22:52 -0400 Subject: [PATCH 2/7] documentation change --- README.md | 25 ++++++++++++------------ src/BirdsiteLive/Views/Home/Index.cshtml | 15 ++++++++------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f595160..2c96559 100644 --- a/README.md +++ b/README.md @@ -8,25 +8,26 @@ Bird.makeup is a way to follow Twitter users from any ActivityPub service. The a Compared to BirdsiteLive, bird.makeup is: +More scalable: + - Twitter API calls are not rate-limited + - It is possible to split the Twitter crawling to multiple servers + - There are now integration tests for the non-official api + - The core pipeline has been tweaked to remove bottlenecks. As of writing this, bird.makeup supports without problems more than 20k users. + - Twitter users with no followers on the fediverse will stop being fetched + +More native to the fediverse: + - Retweets are propagated as boosts + - Activities are now "unlisted" which means that they won't polute the public timeline, but they can still be boosted + - WIP support for QT + More modern: - Moved from .net core 3.1 to .net 6 which is still supported - Moved from postgres 9 to 15 - Moved from Newtonsoft.Json to System.Text.Json -More scalable: - - Twitter API calls are not rate-limited - - There are now integration tests for the non-official api - - The core pipeline has been tweaked to remove bottlenecks. As of writing this, bird.makeup supports without problems more than 10k users. - - Twitter users with no followers on the fediverse will stop being fetched - -More native to the fediverse: - - Retweets are propagated as boosts - - Activities are now "unlisted" which means that they won't polute the public timeline - - WIP support for QT - ## Official instance -You can find an official instance here: [bird.makeup](https://bird.makeup). If you are an instance admin that prefers to not have tweets federated to you, please block the entire instance. +You can find the official instance here: [bird.makeup](https://bird.makeup). If you are an instance admin that prefers to not have tweets federated to you, please block the entire instance. Please consider if you really need another instance before spinning up a new one, as having multiple domain makes it harder for moderators to block twitter content. diff --git a/src/BirdsiteLive/Views/Home/Index.cshtml b/src/BirdsiteLive/Views/Home/Index.cshtml index 309e7e8..99a16ed 100644 --- a/src/BirdsiteLive/Views/Home/Index.cshtml +++ b/src/BirdsiteLive/Views/Home/Index.cshtml @@ -12,18 +12,21 @@

- @*
- - - We'll never share your email with anyone else. -
*@
- @**@
+

+
+ bird.makeup is made with ❤️ by Vincent Cloutier in 🇨🇦 +
+
+ Many thanks to our top Patreon supporters:
+ Charlie Fish + +

@*@if (HtmlHelperExtensions.IsDebug()) { From 6bd289b291b3366da3421d52f432e01891af80dd Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Fri, 14 Apr 2023 15:36:53 -0400 Subject: [PATCH 3/7] added follower count --- src/BirdsiteLive/Controllers/UsersController.cs | 16 +++++++++++++++- src/BirdsiteLive/Models/DisplayTwitterUser.cs | 2 ++ src/BirdsiteLive/Views/Users/Index.cshtml | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/BirdsiteLive/Controllers/UsersController.cs b/src/BirdsiteLive/Controllers/UsersController.cs index 32b1fa4..5392068 100644 --- a/src/BirdsiteLive/Controllers/UsersController.cs +++ b/src/BirdsiteLive/Controllers/UsersController.cs @@ -11,6 +11,8 @@ using BirdsiteLive.ActivityPub; using BirdsiteLive.ActivityPub.Models; using BirdsiteLive.Common.Regexes; using BirdsiteLive.Common.Settings; +using BirdsiteLive.DAL.Contracts; +using BirdsiteLive.DAL.Models; using BirdsiteLive.Domain; using BirdsiteLive.Models; using BirdsiteLive.Tools; @@ -30,16 +32,20 @@ namespace BirdsiteLive.Controllers private readonly IUserService _userService; private readonly IStatusService _statusService; private readonly InstanceSettings _instanceSettings; + private readonly IFollowersDal _followersDal; + private readonly ITwitterUserDal _twitterUserDal; private readonly ILogger _logger; #region Ctor - public UsersController(ICachedTwitterUserService twitterUserService, IUserService userService, IStatusService statusService, InstanceSettings instanceSettings, ICachedTwitterTweetsService twitterTweetService, ILogger logger) + public UsersController(ICachedTwitterUserService twitterUserService, IUserService userService, IStatusService statusService, InstanceSettings instanceSettings, ICachedTwitterTweetsService twitterTweetService, IFollowersDal followersDal, ITwitterUserDal twitterUserDal, ILogger logger) { _twitterUserService = twitterUserService; _userService = userService; _statusService = statusService; _instanceSettings = instanceSettings; _twitterTweetService = twitterTweetService; + _followersDal = followersDal; + _twitterUserDal = twitterUserDal; _logger = logger; } #endregion @@ -119,6 +125,12 @@ namespace BirdsiteLive.Controllers if (isSaturated) return View("ApiSaturated"); if (notFound) return View("UserNotFound"); + Follower[] followers = new Follower[] { }; + + var userDal = await _twitterUserDal.GetTwitterUserAsync(user.Acct); + if (userDal != null) + followers = await _followersDal.GetFollowersAsync(userDal.Id); + var displayableUser = new DisplayTwitterUser { Name = user.Name, @@ -127,6 +139,8 @@ namespace BirdsiteLive.Controllers Url = user.Url, ProfileImageUrl = user.ProfileImageUrl, Protected = user.Protected, + FollowerCount = followers.Length, + MostPopularServer = followers.GroupBy(x => x.Host).OrderByDescending(x => x.Count()).Select(x => x.Key).FirstOrDefault("N/A"), InstanceHandle = $"@{user.Acct.ToLowerInvariant()}@{_instanceSettings.Domain}" }; diff --git a/src/BirdsiteLive/Models/DisplayTwitterUser.cs b/src/BirdsiteLive/Models/DisplayTwitterUser.cs index 3a93875..a91a24d 100644 --- a/src/BirdsiteLive/Models/DisplayTwitterUser.cs +++ b/src/BirdsiteLive/Models/DisplayTwitterUser.cs @@ -8,6 +8,8 @@ public string Url { get; set; } public string ProfileImageUrl { get; set; } public bool Protected { get; set; } + public int FollowerCount { get; set; } + public string MostPopularServer { get; set; } public string InstanceHandle { get; set; } } diff --git a/src/BirdsiteLive/Views/Users/Index.cshtml b/src/BirdsiteLive/Views/Users/Index.cshtml index b99d3a5..a70e847 100644 --- a/src/BirdsiteLive/Views/Users/Index.cshtml +++ b/src/BirdsiteLive/Views/Users/Index.cshtml @@ -28,6 +28,9 @@
+
+ This account has @ViewData.Model.FollowerCount followers on the fediverse. The server with the most followers for this account is: @ViewData.Model.MostPopularServer +

@if (ViewData.Model.Protected) From 8ed901dc2e41280e0cf8ac43f28325796106e36a Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Sun, 23 Apr 2023 11:50:09 -0400 Subject: [PATCH 4/7] switch to .net 7 & other cleanups --- src/BSLManager/App.cs | 252 -------------- src/BSLManager/BSLManager.csproj | 28 -- src/BSLManager/Bootstrapper.cs | 94 ------ src/BSLManager/Domain/FollowersListState.cs | 81 ----- src/BSLManager/Program.cs | 39 --- src/BSLManager/Tools/BasicLogger.cs | 13 - src/BSLManager/Tools/ConsoleGui.cs | 15 - src/BSLManager/Tools/SettingsManager.cs | 123 ------- .../BirdsiteLive.ActivityPub.csproj | 2 +- .../BirdsiteLive.Common.csproj | 2 +- .../BirdsiteLive.Cryptography.csproj | 2 +- .../BirdsiteLive.Domain.csproj | 2 +- .../BirdsiteLive.Moderation.csproj | 2 +- .../BirdsiteLive.Pipeline.csproj | 2 +- .../BirdsiteLive.Twitter.csproj | 2 +- src/BirdsiteLive.sln | 13 - src/BirdsiteLive/BirdsiteLive.csproj | 2 +- .../BirdsiteLive.DAL.Postgres.csproj | 2 +- .../BSLManager.Tests/BSLManager.Tests.csproj | 20 -- .../Domain/FollowersListStateTests.cs | 307 ------------------ .../BirdsiteLive.ActivityPub.Tests.csproj | 2 +- .../BirdsiteLive.Common.Tests.csproj | 2 +- .../BirdsiteLive.Cryptography.Tests.csproj | 2 +- .../BirdsiteLive.DAL.Postgres.Tests.csproj | 2 +- .../BirdsiteLive.DAL.Tests.csproj | 2 +- .../BirdsiteLive.Domain.Tests.csproj | 2 +- .../BirdsiteLive.Moderation.Tests.csproj | 2 +- .../BirdsiteLive.Pipeline.Tests.csproj | 2 +- .../BirdsiteLive.Twitter.Tests.csproj | 2 +- 29 files changed, 18 insertions(+), 1003 deletions(-) delete mode 100644 src/BSLManager/App.cs delete mode 100644 src/BSLManager/BSLManager.csproj delete mode 100644 src/BSLManager/Bootstrapper.cs delete mode 100644 src/BSLManager/Domain/FollowersListState.cs delete mode 100644 src/BSLManager/Program.cs delete mode 100644 src/BSLManager/Tools/BasicLogger.cs delete mode 100644 src/BSLManager/Tools/ConsoleGui.cs delete mode 100644 src/BSLManager/Tools/SettingsManager.cs delete mode 100644 src/Tests/BSLManager.Tests/BSLManager.Tests.csproj delete mode 100644 src/Tests/BSLManager.Tests/Domain/FollowersListStateTests.cs diff --git a/src/BSLManager/App.cs b/src/BSLManager/App.cs deleted file mode 100644 index 37697cc..0000000 --- a/src/BSLManager/App.cs +++ /dev/null @@ -1,252 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using BirdsiteLive.DAL.Contracts; -using BirdsiteLive.DAL.Models; -using BirdsiteLive.Moderation.Actions; -using BSLManager.Domain; -using BSLManager.Tools; -using Terminal.Gui; - -namespace BSLManager -{ - public class App - { - private readonly IFollowersDal _followersDal; - private readonly IRemoveFollowerAction _removeFollowerAction; - - private readonly FollowersListState _state = new FollowersListState(); - - #region Ctor - public App(IFollowersDal followersDal, IRemoveFollowerAction removeFollowerAction) - { - _followersDal = followersDal; - _removeFollowerAction = removeFollowerAction; - } - #endregion - - public void Run() - { - Application.Init(); - var top = Application.Top; - - // Creates the top-level window to show - var win = new Window("BSL Manager") - { - X = 0, - Y = 1, // Leave one row for the toplevel menu - - // By using Dim.Fill(), it will automatically resize without manual intervention - Width = Dim.Fill(), - Height = Dim.Fill() - }; - - top.Add(win); - - // Creates a menubar, the item "New" has a help menu. - var menu = new MenuBar(new MenuBarItem[] - { - new MenuBarItem("_File", new MenuItem[] - { - new MenuItem("_Quit", "", () => - { - if (Quit()) top.Running = false; - }) - }), - //new MenuBarItem ("_Edit", new MenuItem [] { - // new MenuItem ("_Copy", "", null), - // new MenuItem ("C_ut", "", null), - // new MenuItem ("_Paste", "", null) - //}) - }); - top.Add(menu); - - static bool Quit() - { - var n = MessageBox.Query(50, 7, "Quit BSL Manager", "Are you sure you want to quit?", "Yes", "No"); - return n == 0; - } - - RetrieveUserList(); - - var list = new ListView(_state.GetDisplayableList()) - { - X = 1, - Y = 3, - Width = Dim.Fill(), - Height = Dim.Fill() - }; - - list.KeyDown += _ => - { - if (_.KeyEvent.Key == Key.Enter) - { - OpenFollowerDialog(list.SelectedItem); - } - else if (_.KeyEvent.Key == Key.Delete - || _.KeyEvent.Key == Key.DeleteChar - || _.KeyEvent.Key == Key.Backspace - || _.KeyEvent.Key == Key.D) - { - OpenDeleteDialog(list.SelectedItem); - } - }; - - var listingFollowersLabel = new Label(1, 0, "Listing followers"); - var filterLabel = new Label("Filter: ") { X = 1, Y = 1 }; - var filterText = new TextField("") - { - X = Pos.Right(filterLabel), - Y = 1, - Width = 40 - }; - - filterText.KeyDown += _ => - { - var text = filterText.Text.ToString(); - if (_.KeyEvent.Key == Key.Enter && !string.IsNullOrWhiteSpace(text)) - { - _state.FilterBy(text); - ConsoleGui.RefreshUI(); - } - }; - - win.Add( - listingFollowersLabel, - filterLabel, - filterText, - list - ); - - Application.Run(); - } - - private void OpenFollowerDialog(int selectedIndex) - { - var close = new Button(3, 14, "Close"); - close.Clicked += () => Application.RequestStop(); - - var dialog = new Dialog("Info", 60, 18, close); - - var follower = _state.GetElementAt(selectedIndex); - - var name = new Label($"User: @{follower.Acct}@{follower.Host}") - { - X = 1, - Y = 1, - Width = Dim.Fill(), - Height = 1 - }; - var following = new Label($"Following Count: {follower.Followings.Count}") - { - X = 1, - Y = 3, - Width = Dim.Fill(), - Height = 1 - }; - var errors = new Label($"Posting Errors: {follower.PostingErrorCount}") - { - X = 1, - Y = 4, - Width = Dim.Fill(), - Height = 1 - }; - var inbox = new Label($"Inbox: {follower.InboxRoute}") - { - X = 1, - Y = 5, - Width = Dim.Fill(), - Height = 1 - }; - var sharedInbox = new Label($"Shared Inbox: {follower.SharedInboxRoute}") - { - X = 1, - Y = 6, - Width = Dim.Fill(), - Height = 1 - }; - - dialog.Add(name); - dialog.Add(following); - dialog.Add(errors); - dialog.Add(inbox); - dialog.Add(sharedInbox); - dialog.Add(close); - Application.Run(dialog); - } - - private void OpenDeleteDialog(int selectedIndex) - { - bool okpressed = false; - var ok = new Button(10, 14, "Yes"); - ok.Clicked += () => - { - Application.RequestStop(); - okpressed = true; - }; - - var cancel = new Button(3, 14, "No"); - cancel.Clicked += () => Application.RequestStop(); - - var dialog = new Dialog("Delete", 60, 18, cancel, ok); - - var follower = _state.GetElementAt(selectedIndex); - var name = new Label($"User: @{follower.Acct}@{follower.Host}") - { - X = 1, - Y = 1, - Width = Dim.Fill(), - Height = 1 - }; - var entry = new Label("Delete user and remove all their followings?") - { - X = 1, - Y = 3, - Width = Dim.Fill(), - Height = 1 - }; - dialog.Add(name); - dialog.Add(entry); - Application.Run(dialog); - - if (okpressed) - { - DeleteAndRemoveUser(selectedIndex); - } - } - - private void DeleteAndRemoveUser(int el) - { - Application.MainLoop.Invoke(async () => - { - try - { - var userToDelete = _state.GetElementAt(el); - - BasicLogger.Log($"Delete {userToDelete.Acct}@{userToDelete.Host}"); - await _removeFollowerAction.ProcessAsync(userToDelete); - BasicLogger.Log($"Remove user from list"); - _state.RemoveAt(el); - } - catch (Exception e) - { - BasicLogger.Log(e.Message); - } - - ConsoleGui.RefreshUI(); - }); - } - - private void RetrieveUserList() - { - Application.MainLoop.Invoke(async () => - { - var followers = await _followersDal.GetAllFollowersAsync(); - _state.Load(followers.ToList()); - ConsoleGui.RefreshUI(); - }); - } - } -} \ No newline at end of file diff --git a/src/BSLManager/BSLManager.csproj b/src/BSLManager/BSLManager.csproj deleted file mode 100644 index 885decf..0000000 --- a/src/BSLManager/BSLManager.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - Exe - net6 - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - diff --git a/src/BSLManager/Bootstrapper.cs b/src/BSLManager/Bootstrapper.cs deleted file mode 100644 index 7375cd6..0000000 --- a/src/BSLManager/Bootstrapper.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Net.Http; -using BirdsiteLive.Common.Settings; -using BirdsiteLive.Common.Structs; -using BirdsiteLive.DAL.Contracts; -using BirdsiteLive.DAL.Postgres.DataAccessLayers; -using BirdsiteLive.DAL.Postgres.Settings; -using Lamar; -using Lamar.Scanning.Conventions; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace BSLManager -{ - public class Bootstrapper - { - private readonly DbSettings _dbSettings; - private readonly InstanceSettings _instanceSettings; - - #region Ctor - public Bootstrapper(DbSettings dbSettings, InstanceSettings instanceSettings) - { - _dbSettings = dbSettings; - _instanceSettings = instanceSettings; - } - #endregion - - public Container Init() - { - var container = new Container(x => - { - x.For().Use(x => _dbSettings); - - x.For().Use(x => _instanceSettings); - - if (string.Equals(_dbSettings.Type, DbTypes.Postgres, StringComparison.OrdinalIgnoreCase)) - { - var connString = $"Host={_dbSettings.Host};Username={_dbSettings.User};Password={_dbSettings.Password};Database={_dbSettings.Name}"; - var postgresSettings = new PostgresSettings - { - ConnString = connString - }; - x.For().Use(x => postgresSettings); - - x.For().Use().Singleton(); - x.For().Use().Singleton(); - x.For().Use().Singleton(); - } - else - { - throw new NotImplementedException($"{_dbSettings.Type} is not supported"); - } - - var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider(); - x.For().Use(_ => serviceProvider.GetService()); - - x.For(typeof(ILogger<>)).Use(typeof(DummyLogger<>)); - - x.Scan(_ => - { - _.Assembly("BirdsiteLive.Twitter"); - _.Assembly("BirdsiteLive.Domain"); - _.Assembly("BirdsiteLive.DAL"); - _.Assembly("BirdsiteLive.DAL.Postgres"); - _.Assembly("BirdsiteLive.Moderation"); - - _.TheCallingAssembly(); - - _.WithDefaultConventions(); - - _.LookForRegistries(); - }); - }); - return container; - } - - public class DummyLogger : ILogger - { - public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) - { - } - - public bool IsEnabled(LogLevel logLevel) - { - return false; - } - - public IDisposable BeginScope(TState state) - { - return null; - } - } - } -} \ No newline at end of file diff --git a/src/BSLManager/Domain/FollowersListState.cs b/src/BSLManager/Domain/FollowersListState.cs deleted file mode 100644 index 02c2151..0000000 --- a/src/BSLManager/Domain/FollowersListState.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using BirdsiteLive.DAL.Models; - -namespace BSLManager.Domain -{ - public class FollowersListState - { - private readonly List _filteredDisplayableUserList = new List(); - - private List _sourceUserList = new List(); - private List _filteredSourceUserList = new List(); - - public void Load(List followers) - { - _sourceUserList = followers.OrderByDescending(x => x.Followings.Count).ToList(); - - ResetLists(); - } - - private void ResetLists() - { - _filteredSourceUserList = _sourceUserList.ToList(); - - _filteredDisplayableUserList.Clear(); - - foreach (var follower in _sourceUserList) - { - var displayedUser = $"{GetFullHandle(follower)} ({follower.Followings.Count}) (err:{follower.PostingErrorCount})"; - _filteredDisplayableUserList.Add(displayedUser); - } - } - - public List GetDisplayableList() - { - return _filteredDisplayableUserList; - } - - public void FilterBy(string pattern) - { - ResetLists(); - - if (!string.IsNullOrWhiteSpace(pattern)) - { - var elToRemove = _filteredSourceUserList - .Where(x => !GetFullHandle(x).Contains(pattern)) - .Select(x => x) - .ToList(); - - foreach (var el in elToRemove) - { - _filteredSourceUserList.Remove(el); - - var dElToRemove = _filteredDisplayableUserList.First(x => x.Contains(GetFullHandle(el))); - _filteredDisplayableUserList.Remove(dElToRemove); - } - } - } - - private string GetFullHandle(Follower follower) - { - return $"@{follower.Acct}@{follower.Host}"; - } - - public void RemoveAt(int index) - { - var displayableUser = _filteredDisplayableUserList[index]; - var sourceUser = _filteredSourceUserList[index]; - - _filteredDisplayableUserList.Remove(displayableUser); - - _filteredSourceUserList.Remove(sourceUser); - _sourceUserList.Remove(sourceUser); - } - - public Follower GetElementAt(int index) - { - return _filteredSourceUserList[index]; - } - } -} \ No newline at end of file diff --git a/src/BSLManager/Program.cs b/src/BSLManager/Program.cs deleted file mode 100644 index 629ff25..0000000 --- a/src/BSLManager/Program.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using BirdsiteLive.Common.Settings; -using BirdsiteLive.DAL.Contracts; -using BSLManager.Tools; -using Microsoft.Extensions.Configuration; -using NStack; -using Terminal.Gui; - -namespace BSLManager -{ - class Program - { - static async Task Main(string[] args) - { - Console.OutputEncoding = Encoding.Default; - - var settingsManager = new SettingsManager(); - var settings = settingsManager.GetSettings(); - - //var builder = new ConfigurationBuilder() - // .AddEnvironmentVariables(); - //var configuration = builder.Build(); - - //var dbSettings = configuration.GetSection("Db").Get(); - //var instanceSettings = configuration.GetSection("Instance").Get(); - - var bootstrapper = new Bootstrapper(settings.dbSettings, settings.instanceSettings); - var container = bootstrapper.Init(); - - var app = container.GetInstance(); - app.Run(); - } - } -} diff --git a/src/BSLManager/Tools/BasicLogger.cs b/src/BSLManager/Tools/BasicLogger.cs deleted file mode 100644 index dbb9265..0000000 --- a/src/BSLManager/Tools/BasicLogger.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.IO; - -namespace BSLManager.Tools -{ - public static class BasicLogger - { - public static void Log(string log) - { - File.AppendAllLines($"Log-{Guid.NewGuid()}.txt", new []{ log }); - } - } -} \ No newline at end of file diff --git a/src/BSLManager/Tools/ConsoleGui.cs b/src/BSLManager/Tools/ConsoleGui.cs deleted file mode 100644 index b6f7b6e..0000000 --- a/src/BSLManager/Tools/ConsoleGui.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Reflection; -using Terminal.Gui; - -namespace BSLManager.Tools -{ - public static class ConsoleGui - { - public static void RefreshUI() - { - typeof(Application) - .GetMethod("TerminalResized", BindingFlags.Static | BindingFlags.NonPublic) - .Invoke(null, null); - } - } -} \ No newline at end of file diff --git a/src/BSLManager/Tools/SettingsManager.cs b/src/BSLManager/Tools/SettingsManager.cs deleted file mode 100644 index 87daeba..0000000 --- a/src/BSLManager/Tools/SettingsManager.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.IO; -using System.Text.Json; -using System.Runtime.CompilerServices; -using BirdsiteLive.Common.Settings; - -namespace BSLManager.Tools -{ - public class SettingsManager - { - private const string LocalFileName = "ManagerSettings.json"; - - public (DbSettings dbSettings, InstanceSettings instanceSettings) GetSettings() - { - var localSettingsData = GetLocalSettingsFile(); - if (localSettingsData != null) return Convert(localSettingsData); - - Console.WriteLine("We need to set up the manager"); - Console.WriteLine("Please provide the following information as provided in the docker-compose file"); - - LocalSettingsData data; - do - { - data = GetDataFromUser(); - Console.WriteLine(); - Console.WriteLine("Please check if all is ok:"); - Console.WriteLine(); - Console.WriteLine($"Db Host: {data.DbHost}"); - Console.WriteLine($"Db Name: {data.DbName}"); - Console.WriteLine($"Db User: {data.DbUser}"); - Console.WriteLine($"Db Password: {data.DbPassword}"); - Console.WriteLine($"Instance Domain: {data.InstanceDomain}"); - Console.WriteLine(); - - string resp; - do - { - Console.WriteLine("Is it valid? (yes, no)"); - resp = Console.ReadLine()?.Trim().ToLowerInvariant(); - - if (resp == "n" || resp == "no") data = null; - - } while (resp != "y" && resp != "yes" && resp != "n" && resp != "no"); - - } while (data == null); - - SaveLocalSettings(data); - return Convert(data); - } - - private LocalSettingsData GetDataFromUser() - { - var data = new LocalSettingsData(); - - Console.WriteLine("Db Host:"); - data.DbHost = Console.ReadLine(); - - Console.WriteLine("Db Name:"); - data.DbName = Console.ReadLine(); - - Console.WriteLine("Db User:"); - data.DbUser = Console.ReadLine(); - - Console.WriteLine("Db Password:"); - data.DbPassword = Console.ReadLine(); - - Console.WriteLine("Instance Domain:"); - data.InstanceDomain = Console.ReadLine(); - - return data; - } - - private (DbSettings dbSettings, InstanceSettings instanceSettings) Convert(LocalSettingsData data) - { - var dbSettings = new DbSettings - { - Type = data.DbType, - Host = data.DbHost, - Name = data.DbName, - User = data.DbUser, - Password = data.DbPassword - }; - var instancesSettings = new InstanceSettings - { - Domain = data.InstanceDomain - }; - return (dbSettings, instancesSettings); - } - - private LocalSettingsData GetLocalSettingsFile() - { - try - { - if (!File.Exists(LocalFileName)) return null; - - var jsonContent = File.ReadAllText(LocalFileName); - var content = JsonSerializer.Deserialize(jsonContent); - return content; - } - catch (Exception) - { - return null; - } - } - - private void SaveLocalSettings(LocalSettingsData data) - { - var jsonContent = JsonSerializer.Serialize(data); - File.WriteAllText(LocalFileName, jsonContent); - } - } - - internal class LocalSettingsData - { - public string DbType { get; set; } = "postgres"; - public string DbHost { get; set; } - public string DbName { get; set; } - public string DbUser { get; set; } - public string DbPassword { get; set; } - - public string InstanceDomain { get; set; } - } -} \ No newline at end of file diff --git a/src/BirdsiteLive.ActivityPub/BirdsiteLive.ActivityPub.csproj b/src/BirdsiteLive.ActivityPub/BirdsiteLive.ActivityPub.csproj index ec55c83..c69dfd9 100644 --- a/src/BirdsiteLive.ActivityPub/BirdsiteLive.ActivityPub.csproj +++ b/src/BirdsiteLive.ActivityPub/BirdsiteLive.ActivityPub.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 diff --git a/src/BirdsiteLive.Common/BirdsiteLive.Common.csproj b/src/BirdsiteLive.Common/BirdsiteLive.Common.csproj index a546d7a..8268829 100644 --- a/src/BirdsiteLive.Common/BirdsiteLive.Common.csproj +++ b/src/BirdsiteLive.Common/BirdsiteLive.Common.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 diff --git a/src/BirdsiteLive.Cryptography/BirdsiteLive.Cryptography.csproj b/src/BirdsiteLive.Cryptography/BirdsiteLive.Cryptography.csproj index 43b50a5..b17ba22 100644 --- a/src/BirdsiteLive.Cryptography/BirdsiteLive.Cryptography.csproj +++ b/src/BirdsiteLive.Cryptography/BirdsiteLive.Cryptography.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 diff --git a/src/BirdsiteLive.Domain/BirdsiteLive.Domain.csproj b/src/BirdsiteLive.Domain/BirdsiteLive.Domain.csproj index f401973..a914f94 100644 --- a/src/BirdsiteLive.Domain/BirdsiteLive.Domain.csproj +++ b/src/BirdsiteLive.Domain/BirdsiteLive.Domain.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 diff --git a/src/BirdsiteLive.Moderation/BirdsiteLive.Moderation.csproj b/src/BirdsiteLive.Moderation/BirdsiteLive.Moderation.csproj index 0c6da67..a585597 100644 --- a/src/BirdsiteLive.Moderation/BirdsiteLive.Moderation.csproj +++ b/src/BirdsiteLive.Moderation/BirdsiteLive.Moderation.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 diff --git a/src/BirdsiteLive.Pipeline/BirdsiteLive.Pipeline.csproj b/src/BirdsiteLive.Pipeline/BirdsiteLive.Pipeline.csproj index b189b1b..fe3f487 100644 --- a/src/BirdsiteLive.Pipeline/BirdsiteLive.Pipeline.csproj +++ b/src/BirdsiteLive.Pipeline/BirdsiteLive.Pipeline.csproj @@ -1,7 +1,7 @@  - net6 + net7.0 latest diff --git a/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj b/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj index 6d1746d..000fc37 100644 --- a/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj +++ b/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 diff --git a/src/BirdsiteLive.sln b/src/BirdsiteLive.sln index afd49a7..77a6067 100644 --- a/src/BirdsiteLive.sln +++ b/src/BirdsiteLive.sln @@ -47,10 +47,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BirdsiteLive.Moderation.Tes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BirdsiteLive.Common.Tests", "Tests\BirdsiteLive.Common.Tests\BirdsiteLive.Common.Tests.csproj", "{C69F7582-6050-44DC-BAAB-7C8F0BDA525C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BSLManager", "BSLManager\BSLManager.csproj", "{4A84D351-E91B-4E58-8E20-211F0F4991D7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BSLManager.Tests", "Tests\BSLManager.Tests\BSLManager.Tests.csproj", "{D4457271-620E-465A-B08E-7FC63C99A2F6}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BirdsiteLive.Twitter.Tests", "Tests\BirdsiteLive.Twitter.Tests\BirdsiteLive.Twitter.Tests.csproj", "{2DFA0BFD-88F5-4434-A6E3-C93B5750E88C}" EndProject Global @@ -131,14 +127,6 @@ Global {C69F7582-6050-44DC-BAAB-7C8F0BDA525C}.Debug|Any CPU.Build.0 = Debug|Any CPU {C69F7582-6050-44DC-BAAB-7C8F0BDA525C}.Release|Any CPU.ActiveCfg = Release|Any CPU {C69F7582-6050-44DC-BAAB-7C8F0BDA525C}.Release|Any CPU.Build.0 = Release|Any CPU - {4A84D351-E91B-4E58-8E20-211F0F4991D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4A84D351-E91B-4E58-8E20-211F0F4991D7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4A84D351-E91B-4E58-8E20-211F0F4991D7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4A84D351-E91B-4E58-8E20-211F0F4991D7}.Release|Any CPU.Build.0 = Release|Any CPU - {D4457271-620E-465A-B08E-7FC63C99A2F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D4457271-620E-465A-B08E-7FC63C99A2F6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D4457271-620E-465A-B08E-7FC63C99A2F6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D4457271-620E-465A-B08E-7FC63C99A2F6}.Release|Any CPU.Build.0 = Release|Any CPU {2DFA0BFD-88F5-4434-A6E3-C93B5750E88C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2DFA0BFD-88F5-4434-A6E3-C93B5750E88C}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DFA0BFD-88F5-4434-A6E3-C93B5750E88C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -165,7 +153,6 @@ Global {4BE541AC-8A93-4FA3-98AC-956CC2D5B748} = {DA3C160C-4811-4E26-A5AD-42B81FAF2D7C} {0A311BF3-4FD9-4303-940A-A3778890561C} = {A32D3458-09D0-4E0A-BA4B-8C411B816B94} {C69F7582-6050-44DC-BAAB-7C8F0BDA525C} = {A32D3458-09D0-4E0A-BA4B-8C411B816B94} - {D4457271-620E-465A-B08E-7FC63C99A2F6} = {A32D3458-09D0-4E0A-BA4B-8C411B816B94} {2DFA0BFD-88F5-4434-A6E3-C93B5750E88C} = {A32D3458-09D0-4E0A-BA4B-8C411B816B94} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/BirdsiteLive/BirdsiteLive.csproj b/src/BirdsiteLive/BirdsiteLive.csproj index b5a2998..15207ad 100644 --- a/src/BirdsiteLive/BirdsiteLive.csproj +++ b/src/BirdsiteLive/BirdsiteLive.csproj @@ -1,7 +1,7 @@  - net6 + net7.0 d21486de-a812-47eb-a419-05682bb68856 Linux 1.0 diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/BirdsiteLive.DAL.Postgres.csproj b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/BirdsiteLive.DAL.Postgres.csproj index c4c49db..dd319cf 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/BirdsiteLive.DAL.Postgres.csproj +++ b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/BirdsiteLive.DAL.Postgres.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 diff --git a/src/Tests/BSLManager.Tests/BSLManager.Tests.csproj b/src/Tests/BSLManager.Tests/BSLManager.Tests.csproj deleted file mode 100644 index 1c5177e..0000000 --- a/src/Tests/BSLManager.Tests/BSLManager.Tests.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net6 - - false - - - - - - - - - - - - - - diff --git a/src/Tests/BSLManager.Tests/Domain/FollowersListStateTests.cs b/src/Tests/BSLManager.Tests/Domain/FollowersListStateTests.cs deleted file mode 100644 index a0171a4..0000000 --- a/src/Tests/BSLManager.Tests/Domain/FollowersListStateTests.cs +++ /dev/null @@ -1,307 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using BirdsiteLive.DAL.Models; -using BSLManager.Domain; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace BSLManager.Tests -{ - [TestClass] - public class FollowersListStateTests - { - [TestMethod] - public void FilterBy() - { - #region Stub - var followers = new List - { - new Follower - { - Id = 0, - Acct = "test", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 1, - Acct = "test", - Host = "host2", - Followings = new List() - }, - new Follower - { - Id = 2, - Acct = "user1", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 3, - Acct = "user2", - Host = "host1", - Followings = new List() - } - }; - #endregion - - var state = new FollowersListState(); - state.Load(followers); - - state.FilterBy("test"); - - #region Validate - Assert.AreEqual(2, state.GetDisplayableList().Count); - #endregion - } - - [TestMethod] - public void FilterBy_GetElement() - { - #region Stub - var followers = new List - { - new Follower - { - Id = 0, - Acct = "test", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 1, - Acct = "test", - Host = "host2", - Followings = new List() - }, - new Follower - { - Id = 2, - Acct = "user1", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 3, - Acct = "user2", - Host = "host1", - Followings = new List() - } - }; - #endregion - - var state = new FollowersListState(); - state.Load(followers); - - state.FilterBy("test"); - var el = state.GetElementAt(1); - - #region Validate - Assert.AreEqual(followers[1].Id, el.Id); - #endregion - } - - [TestMethod] - public void GetElement() - { - #region Stub - var followers = new List - { - new Follower - { - Id = 0, - Acct = "test", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 1, - Acct = "test", - Host = "host2", - Followings = new List() - }, - new Follower - { - Id = 2, - Acct = "user1", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 3, - Acct = "user2", - Host = "host1", - Followings = new List() - } - }; - #endregion - - var state = new FollowersListState(); - state.Load(followers); - - var el = state.GetElementAt(2); - - #region Validate - Assert.AreEqual(followers[2].Id, el.Id); - #endregion - } - - [TestMethod] - public void FilterBy_RemoveAt() - { - #region Stub - var followers = new List - { - new Follower - { - Id = 0, - Acct = "test", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 1, - Acct = "test", - Host = "host2", - Followings = new List() - }, - new Follower - { - Id = 2, - Acct = "user1", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 3, - Acct = "user2", - Host = "host1", - Followings = new List() - } - }; - #endregion - - var state = new FollowersListState(); - state.Load(followers.ToList()); - - state.FilterBy("test"); - state.RemoveAt(1); - - var list = state.GetDisplayableList(); - - #region Validate - Assert.AreEqual(1, list.Count); - Assert.IsTrue(list[0].Contains("@test@host1")); - #endregion - } - - [TestMethod] - public void RemoveAt() - { - #region Stub - var followers = new List - { - new Follower - { - Id = 0, - Acct = "test", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 1, - Acct = "test", - Host = "host2", - Followings = new List() - }, - new Follower - { - Id = 2, - Acct = "user1", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 3, - Acct = "user2", - Host = "host1", - Followings = new List() - } - }; - #endregion - - var state = new FollowersListState(); - state.Load(followers.ToList()); - - state.RemoveAt(1); - - var list = state.GetDisplayableList(); - - #region Validate - Assert.AreEqual(3, list.Count); - Assert.IsTrue(list[0].Contains("@test@host1")); - Assert.IsFalse(list[1].Contains("@test@host2")); - #endregion - } - - [TestMethod] - public void FilterBy_ResetFilter() - { - #region Stub - var followers = new List - { - new Follower - { - Id = 0, - Acct = "test", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 1, - Acct = "test", - Host = "host2", - Followings = new List() - }, - new Follower - { - Id = 2, - Acct = "user1", - Host = "host1", - Followings = new List() - }, - new Follower - { - Id = 3, - Acct = "user2", - Host = "host1", - Followings = new List() - } - }; - #endregion - - var state = new FollowersListState(); - state.Load(followers.ToList()); - - #region Validate - state.FilterBy("data"); - var list = state.GetDisplayableList(); - Assert.AreEqual(0, list.Count); - - state.FilterBy(string.Empty); - list = state.GetDisplayableList(); - Assert.AreEqual(4, list.Count); - #endregion - } - } -} diff --git a/src/Tests/BirdsiteLive.ActivityPub.Tests/BirdsiteLive.ActivityPub.Tests.csproj b/src/Tests/BirdsiteLive.ActivityPub.Tests/BirdsiteLive.ActivityPub.Tests.csproj index bf7140a..2b4a949 100644 --- a/src/Tests/BirdsiteLive.ActivityPub.Tests/BirdsiteLive.ActivityPub.Tests.csproj +++ b/src/Tests/BirdsiteLive.ActivityPub.Tests/BirdsiteLive.ActivityPub.Tests.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 false diff --git a/src/Tests/BirdsiteLive.Common.Tests/BirdsiteLive.Common.Tests.csproj b/src/Tests/BirdsiteLive.Common.Tests/BirdsiteLive.Common.Tests.csproj index cee9667..04c3fa7 100644 --- a/src/Tests/BirdsiteLive.Common.Tests/BirdsiteLive.Common.Tests.csproj +++ b/src/Tests/BirdsiteLive.Common.Tests/BirdsiteLive.Common.Tests.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 false diff --git a/src/Tests/BirdsiteLive.Cryptography.Tests/BirdsiteLive.Cryptography.Tests.csproj b/src/Tests/BirdsiteLive.Cryptography.Tests/BirdsiteLive.Cryptography.Tests.csproj index 4d81b7d..1640a76 100644 --- a/src/Tests/BirdsiteLive.Cryptography.Tests/BirdsiteLive.Cryptography.Tests.csproj +++ b/src/Tests/BirdsiteLive.Cryptography.Tests/BirdsiteLive.Cryptography.Tests.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 false diff --git a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/BirdsiteLive.DAL.Postgres.Tests.csproj b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/BirdsiteLive.DAL.Postgres.Tests.csproj index 910e256..71e3383 100644 --- a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/BirdsiteLive.DAL.Postgres.Tests.csproj +++ b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/BirdsiteLive.DAL.Postgres.Tests.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 false diff --git a/src/Tests/BirdsiteLive.DAL.Tests/BirdsiteLive.DAL.Tests.csproj b/src/Tests/BirdsiteLive.DAL.Tests/BirdsiteLive.DAL.Tests.csproj index b7427d6..d1139d9 100644 --- a/src/Tests/BirdsiteLive.DAL.Tests/BirdsiteLive.DAL.Tests.csproj +++ b/src/Tests/BirdsiteLive.DAL.Tests/BirdsiteLive.DAL.Tests.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 false diff --git a/src/Tests/BirdsiteLive.Domain.Tests/BirdsiteLive.Domain.Tests.csproj b/src/Tests/BirdsiteLive.Domain.Tests/BirdsiteLive.Domain.Tests.csproj index fd8c60d..d32c5fa 100644 --- a/src/Tests/BirdsiteLive.Domain.Tests/BirdsiteLive.Domain.Tests.csproj +++ b/src/Tests/BirdsiteLive.Domain.Tests/BirdsiteLive.Domain.Tests.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 11 false diff --git a/src/Tests/BirdsiteLive.Moderation.Tests/BirdsiteLive.Moderation.Tests.csproj b/src/Tests/BirdsiteLive.Moderation.Tests/BirdsiteLive.Moderation.Tests.csproj index be5c246..7227ddc 100644 --- a/src/Tests/BirdsiteLive.Moderation.Tests/BirdsiteLive.Moderation.Tests.csproj +++ b/src/Tests/BirdsiteLive.Moderation.Tests/BirdsiteLive.Moderation.Tests.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 false diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/BirdsiteLive.Pipeline.Tests.csproj b/src/Tests/BirdsiteLive.Pipeline.Tests/BirdsiteLive.Pipeline.Tests.csproj index 5c398bb..c6b988f 100644 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/BirdsiteLive.Pipeline.Tests.csproj +++ b/src/Tests/BirdsiteLive.Pipeline.Tests/BirdsiteLive.Pipeline.Tests.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 false diff --git a/src/Tests/BirdsiteLive.Twitter.Tests/BirdsiteLive.Twitter.Tests.csproj b/src/Tests/BirdsiteLive.Twitter.Tests/BirdsiteLive.Twitter.Tests.csproj index 3185e3d..54fb623 100644 --- a/src/Tests/BirdsiteLive.Twitter.Tests/BirdsiteLive.Twitter.Tests.csproj +++ b/src/Tests/BirdsiteLive.Twitter.Tests/BirdsiteLive.Twitter.Tests.csproj @@ -1,7 +1,7 @@ - net6 + net7.0 false From 7ce2453ceb1445ff37a65f4e404677ee59ad06ef Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Sun, 23 Apr 2023 14:01:47 -0400 Subject: [PATCH 5/7] removed FollowingsSyncStatus --- .../BusinessUseCases/ProcessFollowUser.cs | 3 - .../BusinessUseCases/ProcessUnfollowUser.cs | 3 - .../Actions/RemoveTwitterAccountAction.cs | 3 - .../SubTasks/SaveProgressionTask.cs | 61 ----- .../DataAccessLayers/FollowersPostgresDal.cs | 22 +- .../Contracts/IFollowersDal.cs | 3 +- .../BirdsiteLive.DAL/Models/Follower.cs | 1 - .../FollowersPostgresDalTests.cs | 61 ++--- .../ProcessFollowUserTests.cs | 11 +- .../ProcessUnfollowUserTests.cs | 6 +- .../RemoveTwitterAccountActionTests.cs | 3 - .../SaveProgressionProcessorTests.cs | 227 ------------------ .../SubTasks/SendTweetsToInboxTaskTests.cs | 7 - .../SubTasks/SendTweetsToSharedInboxTests.cs | 21 -- 14 files changed, 30 insertions(+), 402 deletions(-) delete mode 100644 src/BirdsiteLive.Pipeline/Processors/SubTasks/SaveProgressionTask.cs delete mode 100644 src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SaveProgressionProcessorTests.cs diff --git a/src/BirdsiteLive.Domain/BusinessUseCases/ProcessFollowUser.cs b/src/BirdsiteLive.Domain/BusinessUseCases/ProcessFollowUser.cs index c6618d9..f8604ea 100644 --- a/src/BirdsiteLive.Domain/BusinessUseCases/ProcessFollowUser.cs +++ b/src/BirdsiteLive.Domain/BusinessUseCases/ProcessFollowUser.cs @@ -42,9 +42,6 @@ namespace BirdsiteLive.Domain.BusinessUseCases var twitterUserId = twitterUser.Id; if(!follower.Followings.Contains(twitterUserId)) follower.Followings.Add(twitterUserId); - - if(!follower.FollowingsSyncStatus.ContainsKey(twitterUserId)) - follower.FollowingsSyncStatus.Add(twitterUserId, -1); // Save Follower await _followerDal.UpdateFollowerAsync(follower); diff --git a/src/BirdsiteLive.Domain/BusinessUseCases/ProcessUnfollowUser.cs b/src/BirdsiteLive.Domain/BusinessUseCases/ProcessUnfollowUser.cs index a8a53b4..652e2be 100644 --- a/src/BirdsiteLive.Domain/BusinessUseCases/ProcessUnfollowUser.cs +++ b/src/BirdsiteLive.Domain/BusinessUseCases/ProcessUnfollowUser.cs @@ -36,9 +36,6 @@ namespace BirdsiteLive.Domain.BusinessUseCases if (follower.Followings.Contains(twitterUserId)) follower.Followings.Remove(twitterUserId); - if (follower.FollowingsSyncStatus.ContainsKey(twitterUserId)) - follower.FollowingsSyncStatus.Remove(twitterUserId); - // Save or delete Follower if (follower.Followings.Any()) await _followerDal.UpdateFollowerAsync(follower); diff --git a/src/BirdsiteLive.Moderation/Actions/RemoveTwitterAccountAction.cs b/src/BirdsiteLive.Moderation/Actions/RemoveTwitterAccountAction.cs index 714cca6..629750d 100644 --- a/src/BirdsiteLive.Moderation/Actions/RemoveTwitterAccountAction.cs +++ b/src/BirdsiteLive.Moderation/Actions/RemoveTwitterAccountAction.cs @@ -41,9 +41,6 @@ namespace BirdsiteLive.Moderation.Actions if (follower.Followings.Contains(twitterUserId)) follower.Followings.Remove(twitterUserId); - if (follower.FollowingsSyncStatus.ContainsKey(twitterUserId)) - follower.FollowingsSyncStatus.Remove(twitterUserId); - if (follower.Followings.Any()) await _followersDal.UpdateFollowerAsync(follower); else diff --git a/src/BirdsiteLive.Pipeline/Processors/SubTasks/SaveProgressionTask.cs b/src/BirdsiteLive.Pipeline/Processors/SubTasks/SaveProgressionTask.cs deleted file mode 100644 index 583ea93..0000000 --- a/src/BirdsiteLive.Pipeline/Processors/SubTasks/SaveProgressionTask.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using BirdsiteLive.DAL.Contracts; -using BirdsiteLive.Pipeline.Contracts; -using BirdsiteLive.Pipeline.Models; -using Microsoft.Extensions.Logging; - -namespace BirdsiteLive.Pipeline.Processors.SubTasks -{ - public class SaveProgressionTask : ISaveProgressionTask - { - private readonly ITwitterUserDal _twitterUserDal; - private readonly ILogger _logger; - - #region Ctor - public SaveProgressionTask(ITwitterUserDal twitterUserDal, ILogger logger) - { - _twitterUserDal = twitterUserDal; - _logger = logger; - } - #endregion - - public async Task ProcessAsync(UserWithDataToSync userWithTweetsToSync, CancellationToken ct) - { - try - { - if (userWithTweetsToSync.Tweets.Length == 0) - { - _logger.LogWarning("No tweets synchronized"); - return; - } - if(userWithTweetsToSync.Followers.Length == 0) - { - _logger.LogWarning("No Followers found for {User}", userWithTweetsToSync.User.Acct); - return; - } - - var userId = userWithTweetsToSync.User.Id; - var followingSyncStatuses = userWithTweetsToSync.Followers.Select(x => x.FollowingsSyncStatus[userId]).ToList(); - - if (followingSyncStatuses.Count == 0) - { - _logger.LogWarning("No Followers sync found for {User}, Id: {UserId}", userWithTweetsToSync.User.Acct, userId); - return; - } - - var lastPostedTweet = userWithTweetsToSync.Tweets.Select(x => x.Id).Max(); - var minimumSync = followingSyncStatuses.Min(); - var now = DateTime.UtcNow; - await _twitterUserDal.UpdateTwitterUserAsync(userId, lastPostedTweet, minimumSync, userWithTweetsToSync.User.FetchingErrorCount, now); - } - catch (Exception e) - { - _logger.LogError(e, "SaveProgressionProcessor.ProcessAsync() Exception"); - throw; - } - } - } -} \ No newline at end of file diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs index 9bb99db..8710366 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs @@ -21,12 +21,9 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers } #endregion - public async Task CreateFollowerAsync(string acct, string host, string inboxRoute, string sharedInboxRoute, string actorId, int[] followings = null, Dictionary followingSyncStatus = null) + public async Task CreateFollowerAsync(string acct, string host, string inboxRoute, string sharedInboxRoute, string actorId, int[] followings = null) { if(followings == null) followings = new int[0]; - if(followingSyncStatus == null) followingSyncStatus = new Dictionary(); - - var serializedDic = JsonSerializer.Serialize(followingSyncStatus); acct = acct.ToLowerInvariant(); host = host.ToLowerInvariant(); @@ -34,8 +31,8 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers using (var dbConnection = Connection) { await dbConnection.ExecuteAsync( - $"INSERT INTO {_settings.FollowersTableName} (acct,host,inboxRoute,sharedInboxRoute,followings,followingsSyncStatus,actorId) VALUES(@acct,@host,@inboxRoute,@sharedInboxRoute,@followings,CAST(@followingsSyncStatus as json),@actorId)", - new { acct, host, inboxRoute, sharedInboxRoute, followings, followingsSyncStatus = serializedDic, actorId }); + $"INSERT INTO {_settings.FollowersTableName} (acct,host,inboxRoute,sharedInboxRoute,followings,actorId) VALUES(@acct,@host,@inboxRoute,@sharedInboxRoute,@followings,@actorId)", + new { acct, host, inboxRoute, sharedInboxRoute, followings, actorId }); } } @@ -78,13 +75,10 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers if (!await reader.ReadAsync()) return null; - string syncStatusString = reader["followingsSyncStatus"] as string; - var syncStatus = System.Text.Json.JsonSerializer.Deserialize>(syncStatusString); return new Follower { Id = reader["id"] as int? ?? default, Followings = (reader["followings"] as int[] ?? new int[0]).ToList(), - FollowingsSyncStatus = syncStatus, ActorId = reader["actorId"] as string, Acct = reader["acct"] as string, Host = reader["host"] as string, @@ -112,12 +106,10 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers while (await reader.ReadAsync()) { string syncStatusString = reader["followingsSyncStatus"] as string; - var syncStatus = System.Text.Json.JsonSerializer.Deserialize>(syncStatusString); followers.Add(new Follower { Id = reader["id"] as int? ?? default, Followings = (reader["followings"] as int[] ?? new int[0]).ToList(), - FollowingsSyncStatus = syncStatus, ActorId = reader["actorId"] as string, Acct = reader["acct"] as string, Host = reader["host"] as string, @@ -147,14 +139,12 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers if (follower == default) throw new ArgumentException("follower"); if (follower.Id == default) throw new ArgumentException("id"); - var serializedDic = System.Text.Json.JsonSerializer.Serialize(follower.FollowingsSyncStatus); - var query = $"UPDATE {_settings.FollowersTableName} SET followings = $1, followingsSyncStatus = CAST($2 as json), postingErrorCount = $3 WHERE id = $4"; + var query = $"UPDATE {_settings.FollowersTableName} SET followings = $1, postingErrorCount = $2 WHERE id = $3"; await using var connection = DataSource.CreateConnection(); await connection.OpenAsync(); await using var command = new NpgsqlCommand(query, connection) { Parameters = { new() { Value = follower.Followings}, - new() { Value = serializedDic}, new() { Value = follower.PostingErrorCount}, new() { Value = follower.Id} } @@ -204,7 +194,6 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers ActorId = follower.ActorId, SharedInboxRoute = follower.SharedInboxRoute, Followings = follower.Followings.ToList(), - FollowingsSyncStatus = JsonSerializer.Deserialize>(follower.FollowingsSyncStatus), PostingErrorCount = follower.PostingErrorCount }; } @@ -212,10 +201,7 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers internal class SerializedFollower { public int Id { get; set; } - public int[] Followings { get; set; } - public string FollowingsSyncStatus { get; set; } - public string Acct { get; set; } public string Host { get; set; } public string InboxRoute { get; set; } diff --git a/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/IFollowersDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/IFollowersDal.cs index fe87b28..de191ac 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/IFollowersDal.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/IFollowersDal.cs @@ -7,8 +7,7 @@ namespace BirdsiteLive.DAL.Contracts public interface IFollowersDal { Task GetFollowerAsync(string acct, string host); - Task CreateFollowerAsync(string acct, string host, string inboxRoute, string sharedInboxRoute, string actorId, int[] followings = null, - Dictionary followingSyncStatus = null); + Task CreateFollowerAsync(string acct, string host, string inboxRoute, string sharedInboxRoute, string actorId, int[] followings = null); Task GetFollowersAsync(int followedUserId); Task GetAllFollowersAsync(); Task UpdateFollowerAsync(Follower follower); diff --git a/src/DataAccessLayers/BirdsiteLive.DAL/Models/Follower.cs b/src/DataAccessLayers/BirdsiteLive.DAL/Models/Follower.cs index 357e32e..9ac5bab 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL/Models/Follower.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL/Models/Follower.cs @@ -7,7 +7,6 @@ namespace BirdsiteLive.DAL.Models public int Id { get; set; } public List Followings { get; set; } - public Dictionary FollowingsSyncStatus { get; set; } public string ActorId { get; set; } public string Acct { get; set; } diff --git a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/FollowersPostgresDalTests.cs b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/FollowersPostgresDalTests.cs index 3927f13..cd85e71 100644 --- a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/FollowersPostgresDalTests.cs +++ b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/FollowersPostgresDalTests.cs @@ -44,7 +44,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var actorId = $"https://{host}/{acct}"; var dal = new FollowersPostgresDal(_settings); - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetFollowerAsync(acct, host); @@ -57,9 +57,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(0, result.PostingErrorCount); Assert.AreEqual(following.Length, result.Followings.Count); Assert.AreEqual(following[0], result.Followings[0]); - Assert.AreEqual(followingSync.Count, result.FollowingsSyncStatus.Count); - Assert.AreEqual(followingSync.First().Key, result.FollowingsSyncStatus.First().Key); - Assert.AreEqual(followingSync.First().Value, result.FollowingsSyncStatus.First().Value); } [TestMethod] @@ -72,7 +69,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var actorId = $"https://{host}/{acct}"; var dal = new FollowersPostgresDal(_settings); - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, null, null); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, null); var result = await dal.GetFollowerAsync(acct, host); @@ -83,7 +80,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(inboxRoute, result.InboxRoute); Assert.AreEqual(sharedInboxRoute, result.SharedInboxRoute); Assert.AreEqual(0, result.Followings.Count); - Assert.AreEqual(0, result.FollowingsSyncStatus.Count); Assert.AreEqual(0, result.PostingErrorCount); } @@ -112,7 +108,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var actorId = $"https://{host}/{acct}"; var dal = new FollowersPostgresDal(_settings); - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetFollowerAsync(acct, host); @@ -124,9 +120,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(sharedInboxRoute, result.SharedInboxRoute); Assert.AreEqual(following.Length, result.Followings.Count); Assert.AreEqual(following[0], result.Followings[0]); - Assert.AreEqual(followingSync.Count, result.FollowingsSyncStatus.Count); - Assert.AreEqual(followingSync.First().Key, result.FollowingsSyncStatus.First().Key); - Assert.AreEqual(followingSync.First().Value, result.FollowingsSyncStatus.First().Value); Assert.AreEqual(0, result.PostingErrorCount); } @@ -143,7 +136,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var inboxRoute = "/myhandle1/inbox"; var sharedInboxRoute = "/inbox"; var actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); //User 2 acct = "myhandle2"; @@ -152,7 +145,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers inboxRoute = "/myhandle2/inbox"; sharedInboxRoute = "/inbox2"; actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); //User 2 acct = "myhandle3"; @@ -161,7 +154,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers inboxRoute = "/myhandle3/inbox"; sharedInboxRoute = "/inbox3"; actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetFollowersAsync(2); Assert.AreEqual(2, result.Length); @@ -186,7 +179,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var inboxRoute = "/myhandle1/inbox"; var sharedInboxRoute = "/inbox"; var actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); //User 2 acct = "myhandle2"; @@ -195,7 +188,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers inboxRoute = "/myhandle2/inbox"; sharedInboxRoute = "/inbox2"; actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); //User 2 acct = "myhandle3"; @@ -204,7 +197,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers inboxRoute = "/myhandle3/inbox"; sharedInboxRoute = "/inbox3"; actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetAllFollowersAsync(); Assert.AreEqual(3, result.Length); @@ -226,7 +219,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var inboxRoute = "/myhandle1/inbox"; var sharedInboxRoute = "/inbox"; var actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); //User 2 acct = "myhandle2"; @@ -235,7 +228,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers inboxRoute = "/myhandle2/inbox"; sharedInboxRoute = "/inbox2"; actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); //User 3 acct = "myhandle3"; @@ -244,7 +237,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers inboxRoute = "/myhandle3/inbox"; sharedInboxRoute = "/inbox3"; actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); result = await dal.GetFollowersCountAsync(); Assert.AreEqual(3, result); @@ -266,7 +259,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var inboxRoute = "/myhandle1/inbox"; var sharedInboxRoute = "/inbox"; var actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); //User 2 acct = "myhandle2"; @@ -275,7 +268,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers inboxRoute = "/myhandle2/inbox"; sharedInboxRoute = "/inbox2"; actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var follower = await dal.GetFollowerAsync(acct, host); follower.PostingErrorCount = 1; @@ -288,7 +281,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers inboxRoute = "/myhandle3/inbox"; sharedInboxRoute = "/inbox3"; actorId = $"https://{host}/{acct}"; - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); follower = await dal.GetFollowerAsync(acct, host); follower.PostingErrorCount = 50; @@ -315,7 +308,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var actorId = $"https://{host}/{acct}"; var dal = new FollowersPostgresDal(_settings); - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetFollowerAsync(acct, host); var updatedFollowing = new List { 12, 19, 23, 24 }; @@ -326,7 +319,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers {24, 173L} }; result.Followings = updatedFollowing.ToList(); - result.FollowingsSyncStatus = updatedFollowingSync; result.PostingErrorCount = 10; await dal.UpdateFollowerAsync(result); @@ -334,9 +326,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(updatedFollowing.Count, result.Followings.Count); Assert.AreEqual(updatedFollowing[0], result.Followings[0]); - Assert.AreEqual(updatedFollowingSync.Count, result.FollowingsSyncStatus.Count); - Assert.AreEqual(updatedFollowingSync.First().Key, result.FollowingsSyncStatus.First().Key); - Assert.AreEqual(updatedFollowingSync.First().Value, result.FollowingsSyncStatus.First().Value); Assert.AreEqual(10, result.PostingErrorCount); } @@ -357,7 +346,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var actorId = $"https://{host}/{acct}"; var dal = new FollowersPostgresDal(_settings); - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetFollowerAsync(acct, host); var updatedFollowing = new List { 12, 19, 23, 24 }; @@ -368,7 +357,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers {24, 173L} }; result.Followings = updatedFollowing.ToList(); - result.FollowingsSyncStatus = updatedFollowingSync; result.PostingErrorCount = 32768; await dal.UpdateFollowerAsync(result); @@ -376,9 +364,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(updatedFollowing.Count, result.Followings.Count); Assert.AreEqual(updatedFollowing[0], result.Followings[0]); - Assert.AreEqual(updatedFollowingSync.Count, result.FollowingsSyncStatus.Count); - Assert.AreEqual(updatedFollowingSync.First().Key, result.FollowingsSyncStatus.First().Key); - Assert.AreEqual(updatedFollowingSync.First().Value, result.FollowingsSyncStatus.First().Value); Assert.AreEqual(32768, result.PostingErrorCount); } @@ -399,7 +384,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var actorId = $"https://{host}/{acct}"; var dal = new FollowersPostgresDal(_settings); - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetFollowerAsync(acct, host); var updatedFollowing = new[] { 12, 19 }; @@ -409,7 +394,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers {19, 171L} }; result.Followings = updatedFollowing.ToList(); - result.FollowingsSyncStatus = updatedFollowingSync; result.PostingErrorCount = 5; await dal.UpdateFollowerAsync(result); @@ -417,9 +401,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(updatedFollowing.Length, result.Followings.Count); Assert.AreEqual(updatedFollowing[0], result.Followings[0]); - Assert.AreEqual(updatedFollowingSync.Count, result.FollowingsSyncStatus.Count); - Assert.AreEqual(updatedFollowingSync.First().Key, result.FollowingsSyncStatus.First().Key); - Assert.AreEqual(updatedFollowingSync.First().Value, result.FollowingsSyncStatus.First().Value); Assert.AreEqual(5, result.PostingErrorCount); } @@ -440,7 +421,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var actorId = $"https://{host}/{acct}"; var dal = new FollowersPostgresDal(_settings); - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetFollowerAsync(acct, host); Assert.AreEqual(0, result.PostingErrorCount); @@ -495,7 +476,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var actorId = $"https://{host}/{acct}"; var dal = new FollowersPostgresDal(_settings); - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetFollowerAsync(acct, host); Assert.IsNotNull(result); @@ -522,7 +503,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var actorId = $"https://{host}/{acct}"; var dal = new FollowersPostgresDal(_settings); - await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync); + await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following); var result = await dal.GetFollowerAsync(acct, host); Assert.IsNotNull(result); diff --git a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs index 17c4fec..1b22956 100644 --- a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs +++ b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs @@ -30,7 +30,6 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases SharedInboxRoute = followerInbox, InboxRoute = inbox, Followings = new List(), - FollowingsSyncStatus = new Dictionary() }; var twitterUser = new SyncTwitterUser @@ -56,14 +55,12 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases It.Is(y => y == followerInbox), It.Is(y => y == inbox), It.Is(y => y == actorId), - null, - null)) + null )) .Returns(Task.CompletedTask); followersDalMock .Setup(x => x.UpdateFollowerAsync( - It.Is(y => y.Followings.Contains(twitterUser.Id) - && y.FollowingsSyncStatus[twitterUser.Id] == -1) + It.Is(y => y.Followings.Contains(twitterUser.Id)) )) .Returns(Task.CompletedTask); @@ -108,7 +105,6 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases SharedInboxRoute = followerInbox, InboxRoute = inbox, Followings = new List(), - FollowingsSyncStatus = new Dictionary() }; var twitterUser = new SyncTwitterUser @@ -128,8 +124,7 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases followersDalMock .Setup(x => x.UpdateFollowerAsync( - It.Is(y => y.Followings.Contains(twitterUser.Id) - && y.FollowingsSyncStatus[twitterUser.Id] == -1) + It.Is(y => y.Followings.Contains(twitterUser.Id) ) )) .Returns(Task.CompletedTask); diff --git a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessUnfollowUserTests.cs b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessUnfollowUserTests.cs index 9bd83e3..84d644b 100644 --- a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessUnfollowUserTests.cs +++ b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessUnfollowUserTests.cs @@ -52,7 +52,6 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases Acct = username, Host = domain, Followings = new List(), - FollowingsSyncStatus = new Dictionary() }; #endregion @@ -91,7 +90,6 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases Acct = username, Host = domain, Followings = new List { 2, 3 }, - FollowingsSyncStatus = new Dictionary { { 2, 460 }, { 3, 563} } }; var twitterUser = new SyncTwitterUser @@ -117,8 +115,7 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases followersDalMock .Setup(x => x.UpdateFollowerAsync( - It.Is(y => !y.Followings.Contains(twitterUser.Id) - && !y.FollowingsSyncStatus.ContainsKey(twitterUser.Id)) + It.Is(y => !y.Followings.Contains(twitterUser.Id) ) )) .Returns(Task.CompletedTask); @@ -155,7 +152,6 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases Acct = username, Host = domain, Followings = new List { 2 }, - FollowingsSyncStatus = new Dictionary { { 2, 460 } } }; var twitterUser = new SyncTwitterUser diff --git a/src/Tests/BirdsiteLive.Moderation.Tests/Actions/RemoveTwitterAccountActionTests.cs b/src/Tests/BirdsiteLive.Moderation.Tests/Actions/RemoveTwitterAccountActionTests.cs index c0f5920..67c7e94 100644 --- a/src/Tests/BirdsiteLive.Moderation.Tests/Actions/RemoveTwitterAccountActionTests.cs +++ b/src/Tests/BirdsiteLive.Moderation.Tests/Actions/RemoveTwitterAccountActionTests.cs @@ -27,7 +27,6 @@ namespace BirdsiteLive.Moderation.Tests.Actions { Id = 48, Followings = new List{ 24 }, - FollowingsSyncStatus = new Dictionary { { 24, 1024 } } } }; #endregion @@ -84,7 +83,6 @@ namespace BirdsiteLive.Moderation.Tests.Actions { Id = 48, Followings = new List{ 24, 36 }, - FollowingsSyncStatus = new Dictionary { { 24, 1024 }, { 36, 24 } } } }; #endregion @@ -100,7 +98,6 @@ namespace BirdsiteLive.Moderation.Tests.Actions .Setup(x => x.UpdateFollowerAsync( It.Is(y => y.Id == 48 && y.Followings.Count == 1 - && y.FollowingsSyncStatus.Count == 1 ))) .Returns(Task.CompletedTask); diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SaveProgressionProcessorTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SaveProgressionProcessorTests.cs deleted file mode 100644 index 3f8b06a..0000000 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SaveProgressionProcessorTests.cs +++ /dev/null @@ -1,227 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using BirdsiteLive.DAL.Contracts; -using BirdsiteLive.DAL.Models; -using BirdsiteLive.Pipeline.Models; -using BirdsiteLive.Pipeline.Processors.SubTasks; -using BirdsiteLive.Twitter.Models; -using Castle.DynamicProxy.Contributors; -using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace BirdsiteLive.Pipeline.Tests.Processors -{ - [TestClass] - public class SaveProgressionProcessorTests - { - [TestMethod] - public async Task ProcessAsync_Test() - { - #region Stubs - var user = new SyncTwitterUser - { - Id = 1 - }; - var tweet1 = new ExtractedTweet - { - Id = 36 - }; - var tweet2 = new ExtractedTweet - { - Id = 37 - }; - var follower1 = new Follower - { - FollowingsSyncStatus = new Dictionary - { - {1, 37} - } - }; - - var usersWithTweets = new UserWithDataToSync - { - Tweets = new [] - { - tweet1, - tweet2 - }, - Followers = new [] - { - follower1 - }, - User = user - }; - - var loggerMock = new Mock>(); - #endregion - - #region Mocks - var twitterUserDalMock = new Mock(MockBehavior.Strict); - twitterUserDalMock - .Setup(x => x.UpdateTwitterUserAsync( - It.Is(y => y == user.Id), - It.Is(y => y == tweet2.Id), - It.Is(y => y == tweet2.Id), - It.Is(y => y == 0), - It.IsAny() - )) - .Returns(Task.CompletedTask); - #endregion - - var processor = new SaveProgressionTask(twitterUserDalMock.Object, loggerMock.Object); - await processor.ProcessAsync(usersWithTweets, CancellationToken.None); - - #region Validations - twitterUserDalMock.VerifyAll(); - loggerMock.VerifyAll(); - #endregion - } - - [TestMethod] - public async Task ProcessAsync_PartiallySynchronized_Test() - { - #region Stubs - var user = new SyncTwitterUser - { - Id = 1 - }; - var tweet1 = new ExtractedTweet - { - Id = 36 - }; - var tweet2 = new ExtractedTweet - { - Id = 37 - }; - var tweet3 = new ExtractedTweet - { - Id = 38 - }; - var follower1 = new Follower - { - FollowingsSyncStatus = new Dictionary - { - {1, 37} - } - }; - - var usersWithTweets = new UserWithDataToSync - { - Tweets = new[] - { - tweet1, - tweet2, - tweet3 - }, - Followers = new[] - { - follower1 - }, - User = user - }; - #endregion - - #region Mocks - var twitterUserDalMock = new Mock(MockBehavior.Strict); - twitterUserDalMock - .Setup(x => x.UpdateTwitterUserAsync( - It.Is(y => y == user.Id), - It.Is(y => y == tweet3.Id), - It.Is(y => y == tweet2.Id), - It.Is(y => y == 0), - It.IsAny() - )) - .Returns(Task.CompletedTask); - - var loggerMock = new Mock>(); - #endregion - - var processor = new SaveProgressionTask(twitterUserDalMock.Object, loggerMock.Object); - await processor.ProcessAsync(usersWithTweets, CancellationToken.None); - - #region Validations - twitterUserDalMock.VerifyAll(); - loggerMock.VerifyAll(); - #endregion - } - - [TestMethod] - public async Task ProcessAsync_PartiallySynchronized_MultiUsers_Test() - { - #region Stubs - var user = new SyncTwitterUser - { - Id = 1 - }; - var tweet1 = new ExtractedTweet - { - Id = 36 - }; - var tweet2 = new ExtractedTweet - { - Id = 37 - }; - var tweet3 = new ExtractedTweet - { - Id = 38 - }; - var follower1 = new Follower - { - FollowingsSyncStatus = new Dictionary - { - {1, 37} - } - }; - var follower2 = new Follower - { - FollowingsSyncStatus = new Dictionary - { - {1, 38} - } - }; - - var usersWithTweets = new UserWithDataToSync - { - Tweets = new[] - { - tweet1, - tweet2, - tweet3 - }, - Followers = new[] - { - follower1, - follower2 - }, - User = user - }; - #endregion - - #region Mocks - var twitterUserDalMock = new Mock(MockBehavior.Strict); - twitterUserDalMock - .Setup(x => x.UpdateTwitterUserAsync( - It.Is(y => y == user.Id), - It.Is(y => y == tweet3.Id), - It.Is(y => y == tweet2.Id), - It.Is(y => y == 0), - It.IsAny() - )) - .Returns(Task.CompletedTask); - - var loggerMock = new Mock>(); - #endregion - - var processor = new SaveProgressionTask(twitterUserDalMock.Object, loggerMock.Object); - await processor.ProcessAsync(usersWithTweets, CancellationToken.None); - - #region Validations - twitterUserDalMock.VerifyAll(); - loggerMock.VerifyAll(); - #endregion - } - } -} \ No newline at end of file diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToInboxTaskTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToInboxTaskTests.cs index da1cfb7..a7013c1 100644 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToInboxTaskTests.cs +++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToInboxTaskTests.cs @@ -57,7 +57,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, InboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }; var settings = new InstanceSettings @@ -139,7 +138,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, InboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }; var settings = new InstanceSettings { }; @@ -218,7 +216,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, InboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }; var settings = new InstanceSettings @@ -301,7 +298,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, InboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }; var settings = new InstanceSettings @@ -375,7 +371,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, InboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 10 } } }; var settings = new InstanceSettings @@ -456,7 +451,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, InboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 10 } } }; var settings = new InstanceSettings @@ -560,7 +554,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, InboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }; var settings = new InstanceSettings diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToSharedInboxTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToSharedInboxTests.cs index 4846de1..db99872 100644 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToSharedInboxTests.cs +++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SubTasks/SendTweetsToSharedInboxTests.cs @@ -61,21 +61,18 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }, new Follower { Id = 2, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 8 } } }, new Follower { Id = 3, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 7 } } } }; @@ -161,21 +158,18 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }, new Follower { Id = 2, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 8 } } }, new Follower { Id = 3, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 7 } } } }; @@ -262,21 +256,18 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }, new Follower { Id = 2, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 8 } } }, new Follower { Id = 3, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 7 } } } }; @@ -350,21 +341,18 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary {{twitterUserId, 10}} }, new Follower { Id = 2, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary {{twitterUserId, 8}} }, new Follower { Id = 3, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary {{twitterUserId, 7}} } }; @@ -447,21 +435,18 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary {{twitterUserId, 10}} }, new Follower { Id = 2, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary {{twitterUserId, 8}} }, new Follower { Id = 3, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary {{twitterUserId, 7}} } }; @@ -568,21 +553,18 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }, new Follower { Id = 2, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 8 } } }, new Follower { Id = 3, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 7 } } } }; @@ -648,21 +630,18 @@ namespace BirdsiteLive.Pipeline.Tests.Processors.SubTasks Id = 1, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 9 } } }, new Follower { Id = 2, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 8 } } }, new Follower { Id = 3, Host = host, SharedInboxRoute = inbox, - FollowingsSyncStatus = new Dictionary { { twitterUserId, 7 } } } }; From ad79d183b4c706d0484ccc194ddf4f16ee92ccda Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Sun, 23 Apr 2023 14:18:00 -0400 Subject: [PATCH 6/7] fix ISaveProgressionTask --- .../Contracts/ISaveProgressionTask.cs | 11 ----------- .../StatusPublicationPipeline.cs | 4 +--- .../SendTweetsToFollowersProcessorTests.cs | 12 ------------ .../StatusPublicationPipelineTests.cs | 4 +--- 4 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 src/BirdsiteLive.Pipeline/Contracts/ISaveProgressionTask.cs diff --git a/src/BirdsiteLive.Pipeline/Contracts/ISaveProgressionTask.cs b/src/BirdsiteLive.Pipeline/Contracts/ISaveProgressionTask.cs deleted file mode 100644 index f920c81..0000000 --- a/src/BirdsiteLive.Pipeline/Contracts/ISaveProgressionTask.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using BirdsiteLive.Pipeline.Models; - -namespace BirdsiteLive.Pipeline.Contracts -{ - public interface ISaveProgressionTask - { - Task ProcessAsync(UserWithDataToSync userWithTweetsToSync, CancellationToken ct); - } -} \ No newline at end of file diff --git a/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs b/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs index cbdd169..fdbb9bd 100644 --- a/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs +++ b/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs @@ -21,16 +21,14 @@ namespace BirdsiteLive.Pipeline private readonly IRetrieveTweetsProcessor _retrieveTweetsProcessor; private readonly IRetrieveFollowersProcessor _retrieveFollowersProcessor; private readonly ISendTweetsToFollowersProcessor _sendTweetsToFollowersProcessor; - private readonly ISaveProgressionTask _saveProgressionTask; private readonly ILogger _logger; #region Ctor - public StatusPublicationPipeline(IRetrieveTweetsProcessor retrieveTweetsProcessor, IRetrieveTwitterUsersProcessor retrieveTwitterAccountsProcessor, IRetrieveFollowersProcessor retrieveFollowersProcessor, ISendTweetsToFollowersProcessor sendTweetsToFollowersProcessor, ISaveProgressionTask saveProgressionTask, ILogger logger) + public StatusPublicationPipeline(IRetrieveTweetsProcessor retrieveTweetsProcessor, IRetrieveTwitterUsersProcessor retrieveTwitterAccountsProcessor, IRetrieveFollowersProcessor retrieveFollowersProcessor, ISendTweetsToFollowersProcessor sendTweetsToFollowersProcessor, ILogger logger) { _retrieveTweetsProcessor = retrieveTweetsProcessor; _retrieveFollowersProcessor = retrieveFollowersProcessor; _sendTweetsToFollowersProcessor = sendTweetsToFollowersProcessor; - _saveProgressionTask = saveProgressionTask; _retrieveTwitterAccountsProcessor = retrieveTwitterAccountsProcessor; _logger = logger; diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SendTweetsToFollowersProcessorTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SendTweetsToFollowersProcessorTests.cs index 2121831..c131c2b 100644 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SendTweetsToFollowersProcessorTests.cs +++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/SendTweetsToFollowersProcessorTests.cs @@ -77,7 +77,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors var followersDalMock = new Mock(MockBehavior.Strict); var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { @@ -165,7 +164,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors ParallelFediversePosts = 1 }; - var saveProgressMock = new Mock(); var removeFollowerMock = new Mock(MockBehavior.Strict); #endregion @@ -250,7 +248,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors .Returns(Task.CompletedTask); var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { @@ -343,7 +340,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { ParallelFediversePosts = 1 @@ -440,7 +436,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { ParallelFediversePosts = 1 @@ -519,7 +514,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors var followersDalMock = new Mock(MockBehavior.Strict); var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { @@ -600,7 +594,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors var followersDalMock = new Mock(MockBehavior.Strict); var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { @@ -689,7 +682,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors .Returns(Task.CompletedTask); var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { @@ -775,7 +767,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors var followersDalMock = new Mock(MockBehavior.Strict); var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { @@ -865,7 +856,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors var followersDalMock = new Mock(MockBehavior.Strict); var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { @@ -959,7 +949,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors .Returns(Task.CompletedTask); var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { @@ -1054,7 +1043,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors .Returns(Task.CompletedTask); var loggerMock = new Mock>(); - var saveProgressMock = new Mock(); var settings = new InstanceSettings { diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs index 31f52c5..a0d2129 100644 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs +++ b/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs @@ -30,18 +30,16 @@ namespace BirdsiteLive.Pipeline.Tests var retrieveTweetsProcessor = new Mock(MockBehavior.Strict); var retrieveFollowersProcessor = new Mock(MockBehavior.Strict); var sendTweetsToFollowersProcessor = new Mock(MockBehavior.Strict); - var saveProgressionProcessor = new Mock(MockBehavior.Strict); var logger = new Mock>(); #endregion - var pipeline = new StatusPublicationPipeline(retrieveTweetsProcessor.Object, retrieveTwitterUserProcessor.Object, retrieveFollowersProcessor.Object, sendTweetsToFollowersProcessor.Object, saveProgressionProcessor.Object, logger.Object); + var pipeline = new StatusPublicationPipeline(retrieveTweetsProcessor.Object, retrieveTwitterUserProcessor.Object, retrieveFollowersProcessor.Object, sendTweetsToFollowersProcessor.Object, logger.Object); await pipeline.ExecuteAsync(ct.Token); #region Validations retrieveTweetsProcessor.VerifyAll(); retrieveFollowersProcessor.VerifyAll(); sendTweetsToFollowersProcessor.VerifyAll(); - saveProgressionProcessor.VerifyAll(); logger.VerifyAll(); #endregion } From 06bb1013ed88681e19fa9facba0f0a3723b3a061 Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Fri, 28 Apr 2023 12:14:47 -0400 Subject: [PATCH 7/7] db structure v3 --- .../Processors/RetrieveTweetsProcessor.cs | 10 ++-- .../DbInitializerPostgresDal.cs | 52 +++++++++++++++++-- .../DataAccessLayers/FollowersPostgresDal.cs | 1 - .../TwitterUserPostgresDal.cs | 15 ++---- .../Settings/PostgresSettings.cs | 3 ++ .../Contracts/ITwitterUserDal.cs | 2 +- .../Models/SyncTwitterUser.cs | 1 - .../Base/PostgresTestingBase.cs | 3 ++ .../TwitterUserPostgresDalTests.cs | 29 +++-------- .../ProcessFollowUserTests.cs | 2 - .../ProcessUnfollowUserTests.cs | 2 - 11 files changed, 72 insertions(+), 48 deletions(-) diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs index 15c8d12..deb50f9 100644 --- a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs +++ b/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs @@ -61,25 +61,25 @@ namespace BirdsiteLive.Pipeline.Processors.SubTasks { // skip the first time to avoid sending backlog of tweet var tweetId = tweets.Last().Id; - await _twitterUserDal.UpdateTwitterUserAsync(user.Id, tweetId, tweetId, user.FetchingErrorCount, now); + await _twitterUserDal.UpdateTwitterUserAsync(user.Id, tweetId, user.FetchingErrorCount, now); } else if (tweets.Length > 0 && user.LastTweetPostedId != -1) { userWtData.Tweets = tweets; usersWtTweets.Add(userWtData); var tweetId = tweets.Last().Id; - await _twitterUserDal.UpdateTwitterUserAsync(user.Id, tweetId, tweetId, user.FetchingErrorCount, now); + await _twitterUserDal.UpdateTwitterUserAsync(user.Id, tweetId, user.FetchingErrorCount, now); } else { - await _twitterUserDal.UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, user.LastTweetSynchronizedForAllFollowersId, user.FetchingErrorCount, now); + await _twitterUserDal.UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, user.FetchingErrorCount, now); } } catch(Exception e) { _logger.LogError(e.Message); - await _twitterUserDal.UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, user.LastTweetSynchronizedForAllFollowersId, user.FetchingErrorCount, now); + await _twitterUserDal.UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, user.FetchingErrorCount, now); } }); todo.Add(t); @@ -104,7 +104,7 @@ namespace BirdsiteLive.Pipeline.Processors.SubTasks if (user.LastTweetPostedId == -1) tweets = await _twitterTweetsService.GetTimelineAsync(user.Acct); else - tweets = await _twitterTweetsService.GetTimelineAsync(user.Acct, user.LastTweetSynchronizedForAllFollowersId); + tweets = await _twitterTweetsService.GetTimelineAsync(user.Acct, user.LastTweetPostedId); } catch (Exception e) { diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/DbInitializerPostgresDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/DbInitializerPostgresDal.cs index d088545..f00b2aa 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/DbInitializerPostgresDal.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/DbInitializerPostgresDal.cs @@ -23,7 +23,7 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers public class DbInitializerPostgresDal : PostgresBase, IDbInitializerDal { private readonly PostgresTools _tools; - private readonly Version _currentVersion = new Version(2, 5); + private readonly Version _currentVersion = new Version(3, 0); private const string DbVersionType = "db-version"; #region Ctor @@ -136,7 +136,8 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers new Tuple(new Version(2,1), new Version(2,2)), new Tuple(new Version(2,2), new Version(2,3)), new Tuple(new Version(2,3), new Version(2,4)), - new Tuple(new Version(2,4), new Version(2,5)) + new Tuple(new Version(2,4), new Version(2,5)), + new Tuple(new Version(2,5), new Version(3,0)) }; } @@ -179,6 +180,48 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers await _tools.ExecuteRequestAsync(alterTwitterUserId); } + else if (from == new Version(2, 5) && to == new Version(3, 0)) + { + var dropFollowingSyncStatus = $@"ALTER TABLE {_settings.FollowersTableName} DROP COLUMN followingssyncstatus"; + await _tools.ExecuteRequestAsync(dropFollowingSyncStatus); + + var dropLastTweet = $@"ALTER TABLE {_settings.TwitterUserTableName} DROP COLUMN lasttweetsynchronizedforallfollowersid"; + await _tools.ExecuteRequestAsync(dropLastTweet); + + var addFediverseEquivalent = $@"ALTER TABLE {_settings.TwitterUserTableName} ADD fediverseaccount text"; + await _tools.ExecuteRequestAsync(addFediverseEquivalent); + + var createWorkers = $@"CREATE TABLE {_settings.WorkersTableName} + ( + id BIGINT PRIMARY KEY, + rangeStart INTEGER, + rangeEnd INTEGER, + lastSeen TIMESTAMP (2) WITHOUT TIME ZONE, + name text + );"; + await _tools.ExecuteRequestAsync(createWorkers); + + var createWorkerInstance = $@" INSERT INTO {_settings.WorkersTableName} (id,rangeStart,rangeEnd) VALUES(0,0, 100) "; + await _tools.ExecuteRequestAsync(createWorkerInstance); + + var createInstagram = $@"CREATE TABLE {_settings.InstagramUserTableName} + ( + id SERIAL PRIMARY KEY, + acct VARCHAR(20) UNIQUE, + + data JSONB + );"; + await _tools.ExecuteRequestAsync(createInstagram); + + var createInstagramPost = $@"CREATE TABLE {_settings.CachedInstaPostsTableName} + ( + id VARCHAR(30) PRIMARY KEY, + acct VARCHAR(20) UNIQUE, + + data JSONB + );"; + await _tools.ExecuteRequestAsync(createInstagramPost); + } else { throw new NotImplementedException(); @@ -207,7 +250,10 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers $@"DROP TABLE {_settings.DbVersionTableName};", $@"DROP TABLE {_settings.TwitterUserTableName};", $@"DROP TABLE {_settings.FollowersTableName};", - $@"DROP TABLE {_settings.CachedTweetsTableName};" + $@"DROP TABLE {_settings.CachedTweetsTableName};", + $@"DROP TABLE {_settings.InstagramUserTableName};", + $@"DROP TABLE {_settings.CachedInstaPostsTableName};", + $@"DROP TABLE {_settings.WorkersTableName};" }; foreach (var r in dropsRequests) diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs index 8710366..e8c3529 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/FollowersPostgresDal.cs @@ -105,7 +105,6 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers var followers = new List(); while (await reader.ReadAsync()) { - string syncStatusString = reader["followingsSyncStatus"] as string; followers.Add(new Follower { Id = reader["id"] as int? ?? default, diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/TwitterUserPostgresDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/TwitterUserPostgresDal.cs index b8f2047..5fe3b6c 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/TwitterUserPostgresDal.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/TwitterUserPostgresDal.cs @@ -27,8 +27,8 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers using (var dbConnection = Connection) { await dbConnection.ExecuteAsync( - $"INSERT INTO {_settings.TwitterUserTableName} (acct,lastTweetPostedId,lastTweetSynchronizedForAllFollowersId) VALUES(@acct,@lastTweetPostedId,@lastTweetSynchronizedForAllFollowersId)", - new { acct, lastTweetPostedId, lastTweetSynchronizedForAllFollowersId = lastTweetPostedId }); + $"INSERT INTO {_settings.TwitterUserTableName} (acct,lastTweetPostedId) VALUES(@acct,@lastTweetPostedId)", + new { acct, lastTweetPostedId }); } } @@ -53,7 +53,6 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers Acct = reader["acct"] as string, TwitterUserId = reader["twitterUserId"] as long? ?? default, LastTweetPostedId = reader["lastTweetPostedId"] as long? ?? default, - LastTweetSynchronizedForAllFollowersId = reader["lastTweetSynchronizedForAllFollowersId"] as long? ?? default, LastSync = reader["lastSync"] as DateTime? ?? default, FetchingErrorCount = reader["fetchingErrorCount"] as int? ?? default, }; @@ -79,7 +78,6 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers Acct = reader["acct"] as string, TwitterUserId = reader["twitterUserId"] as long? ?? default, LastTweetPostedId = reader["lastTweetPostedId"] as long? ?? default, - LastTweetSynchronizedForAllFollowersId = reader["lastTweetSynchronizedForAllFollowersId"] as long? ?? default, LastSync = reader["lastSync"] as DateTime? ?? default, FetchingErrorCount = reader["fetchingErrorCount"] as int? ?? default, }; @@ -143,7 +141,6 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers Acct = reader["acct"] as string, TwitterUserId = reader["twitterUserId"] as long? ?? default, LastTweetPostedId = reader["lastTweetPostedId"] as long? ?? default, - LastTweetSynchronizedForAllFollowersId = reader["lastTweetSynchronizedForAllFollowersId"] as long? ?? default, LastSync = reader["lastSync"] as DateTime? ?? default, FetchingErrorCount = reader["fetchingErrorCount"] as int? ?? default, } @@ -189,21 +186,19 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers await command.ExecuteNonQueryAsync(); } - public async Task UpdateTwitterUserAsync(int id, long lastTweetPostedId, long lastTweetSynchronizedForAllFollowersId, int fetchingErrorCount, DateTime lastSync) + public async Task UpdateTwitterUserAsync(int id, long lastTweetPostedId, int fetchingErrorCount, DateTime lastSync) { if(id == default) throw new ArgumentException("id"); if(lastTweetPostedId == default) throw new ArgumentException("lastTweetPostedId"); - if(lastTweetSynchronizedForAllFollowersId == default) throw new ArgumentException("lastTweetSynchronizedForAllFollowersId"); if(lastSync == default) throw new ArgumentException("lastSync"); - var query = $"UPDATE {_settings.TwitterUserTableName} SET lastTweetPostedId = $1, lastTweetSynchronizedForAllFollowersId = $2, fetchingErrorCount = $3, lastSync = $4 WHERE id = $5"; + var query = $"UPDATE {_settings.TwitterUserTableName} SET lastTweetPostedId = $1, fetchingErrorCount = $2, lastSync = $3 WHERE id = $4"; await using var connection = DataSource.CreateConnection(); await connection.OpenAsync(); await using var command = new NpgsqlCommand(query, connection) { Parameters = { new() { Value = lastTweetPostedId}, - new() { Value = lastTweetSynchronizedForAllFollowersId}, new() { Value = fetchingErrorCount}, new() { Value = lastSync.ToUniversalTime()}, new() { Value = id}, @@ -215,7 +210,7 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers public async Task UpdateTwitterUserAsync(SyncTwitterUser user) { - await UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, user.LastTweetSynchronizedForAllFollowersId, user.FetchingErrorCount, user.LastSync); + await UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, user.FetchingErrorCount, user.LastSync); } public async Task DeleteTwitterUserAsync(string acct) diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/Settings/PostgresSettings.cs b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/Settings/PostgresSettings.cs index c7504ef..ffa0b8e 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/Settings/PostgresSettings.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/Settings/PostgresSettings.cs @@ -6,6 +6,9 @@ public string DbVersionTableName { get; set; } = "db_version"; public string TwitterUserTableName { get; set; } = "twitter_users"; + public string InstagramUserTableName { get; set; } = "instagram_users"; + public string WorkersTableName { get; set; } = "workers"; + public string CachedInstaPostsTableName { get; set; } = "cached_insta_posts"; public string FollowersTableName { get; set; } = "followers"; public string CachedTweetsTableName { get; set; } = "cached_tweets"; } diff --git a/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/ITwitterUserDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/ITwitterUserDal.cs index 9e82b74..1b64cc8 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/ITwitterUserDal.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL/Contracts/ITwitterUserDal.cs @@ -12,7 +12,7 @@ namespace BirdsiteLive.DAL.Contracts Task GetAllTwitterUsersWithFollowersAsync(int maxNumber, int nStart, int nEnd, int m); Task GetAllTwitterUsersAsync(int maxNumber); Task GetAllTwitterUsersAsync(); - Task UpdateTwitterUserAsync(int id, long lastTweetPostedId, long lastTweetSynchronizedForAllFollowersId, int fetchingErrorCount, DateTime lastSync); + Task UpdateTwitterUserAsync(int id, long lastTweetPostedId, int fetchingErrorCount, DateTime lastSync); Task UpdateTwitterUserIdAsync(string username, long twitterUserId); Task UpdateTwitterUserAsync(SyncTwitterUser user); Task DeleteTwitterUserAsync(string acct); diff --git a/src/DataAccessLayers/BirdsiteLive.DAL/Models/SyncTwitterUser.cs b/src/DataAccessLayers/BirdsiteLive.DAL/Models/SyncTwitterUser.cs index 06b7a0b..d7a8f24 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL/Models/SyncTwitterUser.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL/Models/SyncTwitterUser.cs @@ -9,7 +9,6 @@ namespace BirdsiteLive.DAL.Models public string Acct { get; set; } public long LastTweetPostedId { get; set; } - public long LastTweetSynchronizedForAllFollowersId { get; set; } public DateTime LastSync { get; set; } diff --git a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/Base/PostgresTestingBase.cs b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/Base/PostgresTestingBase.cs index 15105e3..6ccc988 100644 --- a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/Base/PostgresTestingBase.cs +++ b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/Base/PostgresTestingBase.cs @@ -19,6 +19,9 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers.Base CachedTweetsTableName = "CachedTweetsTableName" + RandomGenerator.GetString(4), FollowersTableName = "FollowersTableName" + RandomGenerator.GetString(4), TwitterUserTableName = "TwitterUserTableName" + RandomGenerator.GetString(4), + InstagramUserTableName = "InstagramUserTableName" + RandomGenerator.GetString(4), + CachedInstaPostsTableName = "CachedInstaPosts" + RandomGenerator.GetString(4), + WorkersTableName = "workers" + RandomGenerator.GetString(4), }; _tools = new PostgresTools(_settings); } diff --git a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/TwitterUserPostgresDalTests.cs b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/TwitterUserPostgresDalTests.cs index d5422ce..4f96fa8 100644 --- a/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/TwitterUserPostgresDalTests.cs +++ b/src/Tests/BirdsiteLive.DAL.Postgres.Tests/DataAccessLayers/TwitterUserPostgresDalTests.cs @@ -48,7 +48,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(acct, result.Acct); Assert.AreEqual(lastTweetId, result.LastTweetPostedId); - Assert.AreEqual(lastTweetId, result.LastTweetSynchronizedForAllFollowersId); Assert.AreEqual(0, result.FetchingErrorCount); Assert.IsTrue(result.Id > 0); } @@ -67,7 +66,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(acct, resultById.Acct); Assert.AreEqual(lastTweetId, resultById.LastTweetPostedId); - Assert.AreEqual(lastTweetId, resultById.LastTweetSynchronizedForAllFollowersId); Assert.AreEqual(result.Id, resultById.Id); } @@ -87,13 +85,12 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var updatedLastSyncId = 1550L; var now = DateTime.Now; var errors = 15; - await dal.UpdateTwitterUserAsync(result.Id, updatedLastTweetId, updatedLastSyncId, errors, now); + await dal.UpdateTwitterUserAsync(result.Id, updatedLastTweetId, errors, now); result = await dal.GetTwitterUserAsync(acct); Assert.AreEqual(acct, result.Acct); Assert.AreEqual(updatedLastTweetId, result.LastTweetPostedId); - Assert.AreEqual(updatedLastSyncId, result.LastTweetSynchronizedForAllFollowersId); Assert.AreEqual(errors, result.FetchingErrorCount); Assert.IsTrue(Math.Abs((now.ToUniversalTime() - result.LastSync).Milliseconds) < 100); } @@ -116,7 +113,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var errors = 15; result.LastTweetPostedId = updatedLastTweetId; - result.LastTweetSynchronizedForAllFollowersId = updatedLastSyncId; result.FetchingErrorCount = errors; result.LastSync = now; await dal.UpdateTwitterUserAsync(result); @@ -125,7 +121,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(acct, result.Acct); Assert.AreEqual(updatedLastTweetId, result.LastTweetPostedId); - Assert.AreEqual(updatedLastSyncId, result.LastTweetSynchronizedForAllFollowersId); Assert.AreEqual(errors, result.FetchingErrorCount); Assert.IsTrue(Math.Abs((now.ToUniversalTime() - result.LastSync).Milliseconds) < 100); } @@ -148,7 +143,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers var errors = 32768; result.LastTweetPostedId = updatedLastTweetId; - result.LastTweetSynchronizedForAllFollowersId = updatedLastSyncId; result.FetchingErrorCount = errors; result.LastSync = now; await dal.UpdateTwitterUserAsync(result); @@ -157,7 +151,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.AreEqual(acct, result.Acct); Assert.AreEqual(updatedLastTweetId, result.LastTweetPostedId); - Assert.AreEqual(updatedLastSyncId, result.LastTweetSynchronizedForAllFollowersId); Assert.AreEqual(errors, result.FetchingErrorCount); Assert.IsTrue(Math.Abs((now.ToUniversalTime() - result.LastSync).Milliseconds) < 100); } @@ -167,7 +160,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers public async Task Update_NoId() { var dal = new TwitterUserPostgresDal(_settings); - await dal.UpdateTwitterUserAsync(default, default, default, default, DateTime.UtcNow); + await dal.UpdateTwitterUserAsync(default, default, default, DateTime.UtcNow); } [TestMethod] @@ -175,23 +168,16 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers public async Task Update_NoLastTweetPostedId() { var dal = new TwitterUserPostgresDal(_settings); - await dal.UpdateTwitterUserAsync(12, default, default, default, DateTime.UtcNow); + await dal.UpdateTwitterUserAsync(12, default, default, DateTime.UtcNow); } - [TestMethod] - [ExpectedException(typeof(ArgumentException))] - public async Task Update_NoLastTweetSynchronizedForAllFollowersId() - { - var dal = new TwitterUserPostgresDal(_settings); - await dal.UpdateTwitterUserAsync(12, 9556, default, default, DateTime.UtcNow); - } [TestMethod] [ExpectedException(typeof(ArgumentException))] public async Task Update_NoLastSync() { var dal = new TwitterUserPostgresDal(_settings); - await dal.UpdateTwitterUserAsync(12, 9556, 65, default, default); + await dal.UpdateTwitterUserAsync(12, 9556, 65, default); } [TestMethod] @@ -261,7 +247,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.IsFalse(result[0].Id == default); Assert.IsFalse(result[0].Acct == default); Assert.IsFalse(result[0].LastTweetPostedId == default); - Assert.IsFalse(result[0].LastTweetSynchronizedForAllFollowersId == default); } [TestMethod] @@ -318,7 +303,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers { var user = allUsers[i]; var date = i % 2 == 0 ? oldest : newest; - await dal.UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, user.LastTweetSynchronizedForAllFollowersId, 0, date); + await dal.UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, 0, date); } var result = await dal.GetAllTwitterUsersAsync(10); @@ -326,7 +311,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.IsFalse(result[0].Id == default); Assert.IsFalse(result[0].Acct == default); Assert.IsFalse(result[0].LastTweetPostedId == default); - Assert.IsFalse(result[0].LastTweetSynchronizedForAllFollowersId == default); foreach (var acc in result) Assert.IsTrue(Math.Abs((acc.LastSync - oldest.ToUniversalTime()).TotalMilliseconds) < 1000); @@ -349,7 +333,6 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers Assert.IsFalse(result[0].Id == default); Assert.IsFalse(result[0].Acct == default); Assert.IsFalse(result[0].LastTweetPostedId == default); - Assert.IsFalse(result[0].LastTweetSynchronizedForAllFollowersId == default); } [TestMethod] @@ -382,7 +365,7 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers if (i == 0 || i == 2 || i == 3) { var t = await dal.GetTwitterUserAsync(acct); - await dal.UpdateTwitterUserAsync(t.Id ,1L,2L, 50+i*2, DateTime.Now); + await dal.UpdateTwitterUserAsync(t.Id ,1L, 50+i*2, DateTime.Now); } } diff --git a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs index 1b22956..1394ba9 100644 --- a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs +++ b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessFollowUserTests.cs @@ -37,7 +37,6 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases Id = 2, Acct = twitterName, LastTweetPostedId = -1, - LastTweetSynchronizedForAllFollowersId = -1 }; #endregion @@ -112,7 +111,6 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases Id = 2, Acct = twitterName, LastTweetPostedId = -1, - LastTweetSynchronizedForAllFollowersId = -1 }; #endregion diff --git a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessUnfollowUserTests.cs b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessUnfollowUserTests.cs index 84d644b..b71223b 100644 --- a/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessUnfollowUserTests.cs +++ b/src/Tests/BirdsiteLive.Domain.Tests/BusinessUseCases/ProcessUnfollowUserTests.cs @@ -97,7 +97,6 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases Id = 2, Acct = twitterName, LastTweetPostedId = 460, - LastTweetSynchronizedForAllFollowersId = 460 }; var followerList = new List @@ -159,7 +158,6 @@ namespace BirdsiteLive.Domain.Tests.BusinessUseCases Id = 2, Acct = twitterName, LastTweetPostedId = 460, - LastTweetSynchronizedForAllFollowersId = 460 }; var followerList = new List();