actually purge users on deletion
This commit is contained in:
@@ -78,9 +78,10 @@ namespace MareSynchronosServer.Discord
|
||||
var discordAuthedUser = await db.LodeStoneAuth.Include(u => u.User).FirstOrDefaultAsync(u => u.DiscordId == id);
|
||||
if (discordAuthedUser != null && discordAuthedUser.User != null)
|
||||
{
|
||||
logger.LogInformation("User will be purged on next round of deletions: " + discordAuthedUser.User);
|
||||
discordAuthedUser.User.LastLoggedIn = new DateTime(1900, 1, 1).ToUniversalTime();
|
||||
db.Remove(discordAuthedUser);
|
||||
logger.LogInformation("Purging user: " + discordAuthedUser.User.UID);
|
||||
|
||||
FileCleanupService.PurgeUser(discordAuthedUser.User, db, configuration);
|
||||
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
@@ -180,8 +181,6 @@ namespace MareSynchronosServer.Discord
|
||||
{
|
||||
embedBuilder.WithTitle("Failed to verify your character");
|
||||
embedBuilder.WithDescription("Did not find requested authentication key on your profile. Make sure you have saved *twice*, then do **/verify** again.");
|
||||
DiscordLodestoneMapping.TryRemove(id, out _);
|
||||
db.Remove(lodestoneAuth);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -113,6 +113,21 @@ namespace MareSynchronosServer
|
||||
}
|
||||
|
||||
foreach (var user in usersToRemove)
|
||||
{
|
||||
PurgeUser(user);
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation($"Cleanup complete");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static void PurgeUser(User user, MareDbContext dbContext, IConfiguration _configuration)
|
||||
{
|
||||
var lodestone = dbContext.LodeStoneAuth.SingleOrDefault(a => a.User.UID == user.UID);
|
||||
|
||||
@@ -153,16 +168,6 @@ namespace MareSynchronosServer
|
||||
dbContext.Remove(auth);
|
||||
dbContext.Remove(user);
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation($"Cleanup complete");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user