forked from Sarah/Lieb-Website
Added autodelete for users after one year inactivity
This commit is contained in:
parent
c886c6475e
commit
929ca9c0a7
7 changed files with 730 additions and 2 deletions
|
@ -318,5 +318,20 @@ namespace Lieb.Data
|
|||
return usableAccounts.First().GuildWars2AccountId;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DeleteInactiveUsers()
|
||||
{
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
List<LiebUser> users = context.LiebUsers.ToList();
|
||||
|
||||
foreach(LiebUser user in users)
|
||||
{
|
||||
if((user.LastSignUpAt == null && user.CreatedAt < DateTime.UtcNow.AddYears(-1))
|
||||
|| (user.LastSignUpAt != null && user.LastSignUpAt < DateTime.UtcNow.AddYears(-1)))
|
||||
{
|
||||
await DeleteUser(user.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue