set twitter users' errors limit threshold in config

This commit is contained in:
Nicolas Constant 2021-11-15 23:29:39 -05:00
parent a94f524d17
commit 143d431f0f
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 9 additions and 4 deletions

View File

@ -11,5 +11,7 @@
public string UnlistedTwitterAccounts { get; set; }
public string SensitiveTwitterAccounts { get; set; }
public int FailingTwitterUserCleanUpThreshold { get; set; }
}
}

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using BirdsiteLive.Common.Settings;
using BirdsiteLive.DAL.Contracts;
using BirdsiteLive.DAL.Models;
using BirdsiteLive.Moderation.Actions;
@ -12,17 +13,18 @@ namespace BirdsiteLive.Pipeline.Processors
{
public class RefreshTwitterUserStatusProcessor : IRefreshTwitterUserStatusProcessor
{
private const int FetchingErrorCountThreshold = 300;
private readonly ICachedTwitterUserService _twitterUserService;
private readonly ITwitterUserDal _twitterUserDal;
private readonly IRemoveTwitterAccountAction _removeTwitterAccountAction;
private readonly InstanceSettings _instanceSettings;
#region Ctor
public RefreshTwitterUserStatusProcessor(ICachedTwitterUserService twitterUserService, ITwitterUserDal twitterUserDal, IRemoveTwitterAccountAction removeTwitterAccountAction)
public RefreshTwitterUserStatusProcessor(ICachedTwitterUserService twitterUserService, ITwitterUserDal twitterUserDal, IRemoveTwitterAccountAction removeTwitterAccountAction, InstanceSettings instanceSettings)
{
_twitterUserService = twitterUserService;
_twitterUserDal = twitterUserDal;
_removeTwitterAccountAction = removeTwitterAccountAction;
_instanceSettings = instanceSettings;
}
#endregion
@ -56,7 +58,7 @@ namespace BirdsiteLive.Pipeline.Processors
var dbUser = await _twitterUserDal.GetTwitterUserAsync(user.Acct);
dbUser.FetchingErrorCount++;
if (dbUser.FetchingErrorCount > FetchingErrorCountThreshold)
if (dbUser.FetchingErrorCount > _instanceSettings.FailingTwitterUserCleanUpThreshold)
{
await _removeTwitterAccountAction.ProcessAsync(user);
}

View File

@ -22,7 +22,8 @@
"PublishReplies": false,
"MaxUsersCapacity": 1000,
"UnlistedTwitterAccounts": null,
"SensitiveTwitterAccounts": null
"SensitiveTwitterAccounts": null,
"FailingTwitterUserCleanUpThreshold": 700
},
"Db": {
"Type": "postgres",