From 4b1aa7aa5c3b1c9981f3343f87739b86be339cc1 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Thu, 11 Feb 2021 23:02:06 -0500 Subject: [PATCH] testing unfollow --- src/BirdsiteLive.Domain/UserService.cs | 4 +++- .../Controllers/DebugingController.cs | 18 +++++++++++++++++- src/BirdsiteLive/Views/Debuging/Index.cshtml | 7 +++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/BirdsiteLive.Domain/UserService.cs b/src/BirdsiteLive.Domain/UserService.cs index 03abf21..ab435a7 100644 --- a/src/BirdsiteLive.Domain/UserService.cs +++ b/src/BirdsiteLive.Domain/UserService.cs @@ -25,6 +25,8 @@ namespace BirdsiteLive.Domain Actor GetUser(TwitterUser twitterUser); Task FollowRequestedAsync(string signature, string method, string path, string queryString, Dictionary requestHeaders, ActivityFollow activity, string body); Task UndoFollowRequestedAsync(string signature, string method, string path, string queryString, Dictionary requestHeaders, ActivityUndoFollow activity, string body); + + Task 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 SendRejectFollowAsync(ActivityFollow activity, string followerHost) + public async Task SendRejectFollowAsync(ActivityFollow activity, string followerHost) { var acceptFollow = new ActivityRejectFollow() { diff --git a/src/BirdsiteLive/Controllers/DebugingController.cs b/src/BirdsiteLive/Controllers/DebugingController.cs index 12ac90e..977687c 100644 --- a/src/BirdsiteLive/Controllers/DebugingController.cs +++ b/src/BirdsiteLive/Controllers/DebugingController.cs @@ -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 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 diff --git a/src/BirdsiteLive/Views/Debuging/Index.cshtml b/src/BirdsiteLive/Views/Debuging/Index.cshtml index cb56c56..5bcde75 100644 --- a/src/BirdsiteLive/Views/Debuging/Index.cshtml +++ b/src/BirdsiteLive/Views/Debuging/Index.cshtml @@ -16,4 +16,11 @@ + + + +
+ + +
\ No newline at end of file