1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

SM-503: Add EmptySecretsManagerTrashJob (#2863)

* SM-503: Add EmptySecretsManagerJob

* SM-503: Fix date logic and refactor a few lines

* SM-503: Add logging

* SM-503: Move EmptySecretsManagerTrashJob to src/Api/SecretsManager/Jobs

* SM-503: Update trigger time for EmptySecretsManagerTrashJob

* SM-503: Switch to scope on one line

* SM-768: Update EFCore and related packages to >= 7.0

* SM-768: Update more packages for the EF 7 upgrade

* SM-768: Update the PostgreSQL package

* SM-768: Run dotnet restore --force-evaluate

* SM-768: Revert package upgrades for 3 projects

* SM-768: Update the dotnet-ef tool

* SM-503: Switch to using ExecuteDeleteAsync and fix param name

* SM-503: Rename trigger to smTrashCleanupTrigger

* SM-503: Fix OSS job issue

* SM-503: Only add trigger if not OSS for SM Trash Job
This commit is contained in:
Colton Hurst
2023-07-18 15:32:47 -04:00
committed by GitHub
parent a095e02e86
commit 1fe2f0fb57
5 changed files with 49 additions and 0 deletions

View File

@ -293,6 +293,16 @@ public class SecretRepository : Repository<Core.SecretsManager.Entities.Secret,
return policy == null ? (false, false) : (policy.Read, policy.Write);
}
public async Task EmptyTrash(DateTime currentDate, uint deleteAfterThisNumberOfDays)
{
using var scope = ServiceScopeFactory.CreateScope();
var dbContext = GetDatabaseContext(scope);
await dbContext.Secret.Where(s => s.DeletedDate != null && s.DeletedDate < currentDate.AddDays(-deleteAfterThisNumberOfDays)).ExecuteDeleteAsync();
await dbContext.SaveChangesAsync();
}
private IQueryable<SecretPermissionDetails> SecretToPermissionDetails(IQueryable<Secret> query, Guid userId, AccessClientType accessType)
{
var secrets = accessType switch