Build / Build (push) Successful in 30s
- Services, controllers and jobs take their dependencies through primary constructors and use them directly; where a method already named a local after a dependency, the dependency takes its type's name. - Every async method takes a CancellationToken last and passes it down to MongoDB, HTTP and the job queue. The setup claim is still given back when a request is cancelled. - The federation and media options are read through IOptionsMonitor. - The Mastodon entities keep sending "" for empty strings, and every model field where null means something says so. - The inbox's 503 with Retry-After, which other servers retry, is the one server error left, and says why. - Arasaka.HouseRules.Analyzers checks all of this in every build, here and in PrivaPub.ClientModels as decePubClient builds it. Checked against GoToSocial in the pasture: 64 passed, 0 failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
using MongoDB.Entities;
|
|
|
|
using PrivaPub.Models.User;
|
|
using PrivaPub.StaticServices;
|
|
|
|
namespace PrivaPub.Services
|
|
{
|
|
public interface IRootRemoval
|
|
{
|
|
Task<bool> Remove(string rootId, CancellationToken token);
|
|
}
|
|
|
|
// Deleting a root deletes everything public it had (owner decision 2026-10-04): each of its personas goes as a persona
|
|
// is deleted (PersonaRemoval: each group it owns, a Delete of the actor to everyone who follows it and everyone it
|
|
// follows, its posts emptied, its name kept reserved and its documents answering 410). The root's sessions end first, so
|
|
// nothing acts as it while it goes, and it keeps only a deleted-{id} name.
|
|
public class RootRemoval(
|
|
DbEntities dbEntities,
|
|
IRootSessions sessions,
|
|
IPersonaRemoval personas) : IRootRemoval
|
|
{
|
|
public async Task<bool> Remove(string rootId, CancellationToken token)
|
|
{
|
|
var root = await dbEntities.RootUsers.MatchID(rootId).Match(u => u.DeletedAt == null).ExecuteFirstAsync(token);
|
|
if (root == default)
|
|
return false;
|
|
await sessions.Revoke(root.ID, token);
|
|
var now = DateTime.UtcNow;
|
|
|
|
var avatarIds = (await dbEntities.RootToAvatars.Match(ra => ra.RootId == root.ID).ExecuteAsync(token)).Select(ra => ra.AvatarId).ToList();
|
|
foreach (var avatarId in avatarIds)
|
|
await personas.Remove(avatarId, token);
|
|
|
|
await DB.Default.Update<RootUser>().MatchID(root.ID)
|
|
.Modify(u => u.UserName, $"deleted-{root.ID}")//unique, so a second deletion never collides with the first
|
|
.Modify(u => u.Email, null)
|
|
.Modify(u => u.HashedPassword, null)
|
|
.Modify(u => u.Policies, new List<string>())
|
|
.Modify(u => u.IsBanned, false)
|
|
.Modify(u => u.IsEmailValidated, false)
|
|
.Modify(u => u.DeletedAt, now)
|
|
.ExecuteAsync(token);
|
|
await DB.Default.DeleteAsync<EmailRecovery>(r => r.RootUserId == root.ID);
|
|
await Domain.Moderation.Restrictions.Reload(CancellationToken.None);
|
|
return true;
|
|
}
|
|
}
|
|
}
|