fix clean-up check on unfollow, fix #24

This commit is contained in:
Nicolas Constant 2021-01-04 21:45:48 -05:00
parent 9011bb7349
commit 893c27d4c3
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688

View file

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using BirdsiteLive.DAL.Contracts;
namespace BirdsiteLive.Domain.BusinessUseCases
@ -38,8 +39,16 @@ namespace BirdsiteLive.Domain.BusinessUseCases
if (follower.FollowingsSyncStatus.ContainsKey(twitterUserId))
follower.FollowingsSyncStatus.Remove(twitterUserId);
// Save Follower
await _followerDal.UpdateFollowerAsync(follower);
// Save or delete Follower
if (follower.Followings.Any())
await _followerDal.UpdateFollowerAsync(follower);
else
await _followerDal.DeleteFollowerAsync(followerUsername, followerDomain);
// Check if TwitterUser has still followers
var followers = await _followerDal.GetFollowersAsync(twitterUser.Id);
if (!followers.Any())
await _twitterUserDal.DeleteTwitterUserAsync(twitterUsername);
}
}
}