mirror of
https://github.com/NicolasConstant/BirdsiteLive
synced 2025-06-05 21:49:16 +02:00
added delete action
This commit is contained in:
@@ -4,6 +4,7 @@ namespace BirdsiteLive.ActivityPub.Models
|
|||||||
{
|
{
|
||||||
public class ActivityDelete : Activity
|
public class ActivityDelete : Activity
|
||||||
{
|
{
|
||||||
|
public string[] to { get; set; }
|
||||||
[JsonProperty("object")]
|
[JsonProperty("object")]
|
||||||
public object apObject { get; set; }
|
public object apObject { get; set; }
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ namespace BirdsiteLive.Domain
|
|||||||
Task<HttpStatusCode> PostDataAsync<T>(T data, string targetHost, string actorUrl, string inbox = null);
|
Task<HttpStatusCode> PostDataAsync<T>(T data, string targetHost, string actorUrl, string inbox = null);
|
||||||
Task PostNewNoteActivity(Note note, string username, string noteId, string targetHost,
|
Task PostNewNoteActivity(Note note, string username, string noteId, string targetHost,
|
||||||
string targetInbox);
|
string targetInbox);
|
||||||
|
Task DeleteUserAsync(string username, string targetHost, string targetInbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WebFinger
|
public class WebFinger
|
||||||
@@ -82,6 +83,31 @@ namespace BirdsiteLive.Domain
|
|||||||
return actor;
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DeleteUserAsync(string username, string targetHost, string targetInbox)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var actor = UrlFactory.GetActorUrl(_instanceSettings.Domain, username);
|
||||||
|
|
||||||
|
var deleteUser = new ActivityDelete
|
||||||
|
{
|
||||||
|
context = "https://www.w3.org/ns/activitystreams",
|
||||||
|
id = $"{actor}#delete",
|
||||||
|
type = "Delete",
|
||||||
|
actor = actor,
|
||||||
|
to = new [] { "https://www.w3.org/ns/activitystreams#Public" },
|
||||||
|
apObject = actor
|
||||||
|
};
|
||||||
|
|
||||||
|
await PostDataAsync(deleteUser, targetHost, actor, targetInbox);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "Error deleting {Username} to {Host}{Inbox}", username, targetHost, targetInbox);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task PostNewNoteActivity(Note note, string username, string noteId, string targetHost, string targetInbox)
|
public async Task PostNewNoteActivity(Note note, string username, string noteId, string targetHost, string targetInbox)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@@ -125,6 +125,17 @@ namespace BirdsiteLive.Controllers
|
|||||||
await _userService.SendRejectFollowAsync(activityFollow, "mastodon.technology");
|
await _userService.SendRejectFollowAsync(activityFollow, "mastodon.technology");
|
||||||
return View("Index");
|
return View("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> PostDeleteUser()
|
||||||
|
{
|
||||||
|
var userName = "mastodon";
|
||||||
|
var host = "ioc.exchange";
|
||||||
|
var inbox = "/inbox";
|
||||||
|
|
||||||
|
await _activityPubService.DeleteUserAsync(userName, host, inbox);
|
||||||
|
return View("Index");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -24,3 +24,9 @@
|
|||||||
|
|
||||||
<button type="submit" value="Submit">Reject Follow</button>
|
<button type="submit" value="Submit">Reject Follow</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form asp-controller="Debuging" asp-action="PostDeleteUser" method="post">
|
||||||
|
<!-- Input and Submit elements -->
|
||||||
|
|
||||||
|
<button type="submit" value="Submit">Delete User</button>
|
||||||
|
</form>
|
Reference in New Issue
Block a user