testing unfollow

This commit is contained in:
Nicolas Constant 2021-02-11 23:02:06 -05:00
parent 0e1178f128
commit 4b1aa7aa5c
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688
3 changed files with 27 additions and 2 deletions

View file

@ -25,6 +25,8 @@ namespace BirdsiteLive.Domain
Actor GetUser(TwitterUser twitterUser);
Task<bool> FollowRequestedAsync(string signature, string method, string path, string queryString, Dictionary<string, string> requestHeaders, ActivityFollow activity, string body);
Task<bool> UndoFollowRequestedAsync(string signature, string method, string path, string queryString, Dictionary<string, string> requestHeaders, ActivityUndoFollow activity, string body);
Task<bool> SendRejectFollowAsync(ActivityFollow activity, string followerHost);
}
public class UserService : IUserService
@ -190,7 +192,7 @@ namespace BirdsiteLive.Domain
result == HttpStatusCode.OK; //TODO: revamp this for better error handling
}
private async Task<bool> SendRejectFollowAsync(ActivityFollow activity, string followerHost)
public async Task<bool> SendRejectFollowAsync(ActivityFollow activity, string followerHost)
{
var acceptFollow = new ActivityRejectFollow()
{

View file

@ -19,13 +19,15 @@ namespace BirdsiteLive.Controllers
private readonly InstanceSettings _instanceSettings;
private readonly ICryptoService _cryptoService;
private readonly IActivityPubService _activityPubService;
private readonly IUserService _userService;
#region Ctor
public DebugingController(InstanceSettings instanceSettings, ICryptoService cryptoService, IActivityPubService activityPubService)
public DebugingController(InstanceSettings instanceSettings, ICryptoService cryptoService, IActivityPubService activityPubService, IUserService userService)
{
_instanceSettings = instanceSettings;
_cryptoService = cryptoService;
_activityPubService = activityPubService;
_userService = userService;
}
#endregion
@ -102,6 +104,20 @@ namespace BirdsiteLive.Controllers
return View("Index");
}
[HttpPost]
public async Task<IActionResult> PostRejectFollow()
{
var activityFollow = new ActivityFollow
{
type = "Follow",
actor = "https://mastodon.technology/users/testtest",
apObject = $"https://{_instanceSettings.Domain}/users/afp"
};
await _userService.SendRejectFollowAsync(activityFollow, "mastodon.technology");
return View("Index");
}
}
public static class HtmlHelperExtensions

View file

@ -16,4 +16,11 @@
<!-- Input and Submit elements -->
<button type="submit" value="Submit">Post Note</button>
</form>
<form asp-controller="Debuging" asp-action="PostRejectFollow" method="post">
<!-- Input and Submit elements -->
<button type="submit" value="Submit">Reject Follow</button>
</form>