-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from NicolasConstant/develop
0.20.0 PR
- Loading branch information
Showing
34 changed files
with
1,330 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace BirdsiteLive.ActivityPub.Models | ||
{ | ||
public class ActivityDelete : Activity | ||
{ | ||
[JsonProperty("object")] | ||
public object apObject { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/BirdsiteLive.Domain/BusinessUseCases/ProcessDeleteUser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using BirdsiteLive.DAL.Contracts; | ||
using BirdsiteLive.DAL.Models; | ||
|
||
namespace BirdsiteLive.Domain.BusinessUseCases | ||
{ | ||
public interface IProcessDeleteUser | ||
{ | ||
Task ExecuteAsync(Follower follower); | ||
Task ExecuteAsync(string followerUsername, string followerDomain); | ||
} | ||
|
||
public class ProcessDeleteUser : IProcessDeleteUser | ||
{ | ||
private readonly IFollowersDal _followersDal; | ||
private readonly ITwitterUserDal _twitterUserDal; | ||
|
||
#region Ctor | ||
public ProcessDeleteUser(IFollowersDal followersDal, ITwitterUserDal twitterUserDal) | ||
{ | ||
_followersDal = followersDal; | ||
_twitterUserDal = twitterUserDal; | ||
} | ||
#endregion | ||
|
||
public async Task ExecuteAsync(string followerUsername, string followerDomain) | ||
{ | ||
// Get Follower and Twitter Users | ||
var follower = await _followersDal.GetFollowerAsync(followerUsername, followerDomain); | ||
if (follower == null) return; | ||
|
||
await ExecuteAsync(follower); | ||
} | ||
|
||
public async Task ExecuteAsync(Follower follower) | ||
{ | ||
// Remove twitter users if no more followers | ||
var followings = follower.Followings; | ||
foreach (var following in followings) | ||
{ | ||
var followers = await _followersDal.GetFollowersAsync(following); | ||
if (followers.Length == 1 && followers.First().Id == follower.Id) | ||
await _twitterUserDal.DeleteTwitterUserAsync(following); | ||
} | ||
|
||
// Remove follower from DB | ||
await _followersDal.DeleteFollowerAsync(follower.Id); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/BirdsiteLive.Domain/Exceptions/FollowerIsGoneException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
|
||
namespace BirdsiteLive.Domain | ||
{ | ||
public class FollowerIsGoneException : Exception | ||
{ | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/BirdsiteLive.Domain/Tools/SigValidationResultExtractor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Linq; | ||
|
||
namespace BirdsiteLive.Domain.Tools | ||
{ | ||
public class SigValidationResultExtractor | ||
{ | ||
public static string GetUserName(SignatureValidationResult result) | ||
{ | ||
return result.User.preferredUsername.ToLowerInvariant().Trim(); | ||
} | ||
|
||
public static string GetHost(SignatureValidationResult result) | ||
{ | ||
return result.User.url.Replace("https://", string.Empty).Split('/').First(); | ||
} | ||
|
||
public static string GetSharedInbox(SignatureValidationResult result) | ||
{ | ||
return result.User?.endpoints?.sharedInbox; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.