2021-12-13 20:43:57 -05:00
|
|
|
|
using System.Threading.Tasks;
|
2021-02-05 01:12:54 -05:00
|
|
|
|
using BirdsiteLive.DAL.Models;
|
2021-12-13 20:43:57 -05:00
|
|
|
|
using BirdsiteLive.Domain.BusinessUseCases;
|
2021-02-05 01:12:54 -05:00
|
|
|
|
|
|
|
|
|
namespace BirdsiteLive.Moderation.Actions
|
|
|
|
|
{
|
|
|
|
|
public interface IRemoveFollowerAction
|
|
|
|
|
{
|
|
|
|
|
Task ProcessAsync(Follower follower);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class RemoveFollowerAction : IRemoveFollowerAction
|
|
|
|
|
{
|
2021-02-14 01:51:54 -05:00
|
|
|
|
private readonly IRejectAllFollowingsAction _rejectAllFollowingsAction;
|
2021-12-13 20:43:57 -05:00
|
|
|
|
private readonly IProcessDeleteUser _processDeleteUser;
|
2021-02-05 01:12:54 -05:00
|
|
|
|
|
|
|
|
|
#region Ctor
|
2021-12-13 20:43:57 -05:00
|
|
|
|
public RemoveFollowerAction(IRejectAllFollowingsAction rejectAllFollowingsAction, IProcessDeleteUser processDeleteUser)
|
2021-02-05 01:12:54 -05:00
|
|
|
|
{
|
2021-02-14 01:51:54 -05:00
|
|
|
|
_rejectAllFollowingsAction = rejectAllFollowingsAction;
|
2021-12-13 20:43:57 -05:00
|
|
|
|
_processDeleteUser = processDeleteUser;
|
2021-02-05 01:12:54 -05:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public async Task ProcessAsync(Follower follower)
|
|
|
|
|
{
|
|
|
|
|
// Perform undo following to user instance
|
2021-02-14 01:51:54 -05:00
|
|
|
|
await _rejectAllFollowingsAction.ProcessAsync(follower);
|
2021-02-05 01:12:54 -05:00
|
|
|
|
|
|
|
|
|
// Remove twitter users if no more followers
|
2021-12-13 20:43:57 -05:00
|
|
|
|
await _processDeleteUser.ExecuteAsync(follower);
|
2021-02-05 01:12:54 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|