Account deletion

This commit is contained in:
2025-05-24 23:29:36 +08:00
parent 80b7812a87
commit 59bc9edd4b
13 changed files with 191 additions and 20 deletions

View File

@ -8,17 +8,18 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging.Abstractions;
using NodaTime;
namespace DysonNetwork.Sphere.Account;
public class AccountService(
AppDatabase db,
ICacheService cache,
IStringLocalizerFactory factory
MagicSpellService spells,
ICacheService cache
)
{
public const string AccountCachePrefix = "Account_";
public async Task PurgeAccountCache(Account account)
{
await cache.RemoveGroupAsync($"{AccountCachePrefix}{account.Id}");
@ -46,6 +47,18 @@ public class AccountService(
return profile?.Level;
}
public async Task RequestAccountDeletion(Account account)
{
var spell = await spells.CreateMagicSpell(
account,
MagicSpellType.AccountRemoval,
new Dictionary<string, object>(),
SystemClock.Instance.GetCurrentInstant().Plus(Duration.FromHours(24)),
preventRepeat: true
);
await spells.NotifyMagicSpell(spell);
}
/// Maintenance methods for server administrator
public async Task EnsureAccountProfileCreated()
{