mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-10-18 12:57:04 +02:00
Clean up orphaned non-global admins on the expire timer
This commit is contained in:
parent
e028441b56
commit
fd94ac8d2b
5 changed files with 29 additions and 1 deletions
|
|
@ -677,4 +677,24 @@ public class PermissionManager(IDatabaseProvider? databaseProvider)
|
|||
CS2_SimpleAdmin._logger?.LogCritical("Unable to remove expired admins");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes orphaned admins that are not global and have no server assignments left.
|
||||
/// </summary>
|
||||
public async Task DeleteOrphanedAdmins()
|
||||
{
|
||||
if (databaseProvider == null) return;
|
||||
|
||||
try
|
||||
{
|
||||
await using var connection = await databaseProvider.CreateConnectionAsync();
|
||||
|
||||
var sql = databaseProvider.GetDeleteOrphanedAdminsQuery();
|
||||
await connection.ExecuteAsync(sql);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CS2_SimpleAdmin._logger?.LogCritical("Unable to remove orphaned admins");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue