mirror of
https://github.com/bitwarden/server
synced 2025-12-22 19:23:45 +00: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:
23
src/Api/SecretsManager/Jobs/EmptySecretsManagerTrashJob.cs
Normal file
23
src/Api/SecretsManager/Jobs/EmptySecretsManagerTrashJob.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Bit.Core.Jobs;
|
||||
using Bit.Core.SecretsManager.Repositories;
|
||||
using Quartz;
|
||||
|
||||
namespace Bit.Api.Jobs;
|
||||
|
||||
public class EmptySecretsManagerTrashJob : BaseJob
|
||||
{
|
||||
private ISecretRepository _secretRepository;
|
||||
private const uint DeleteAfterThisNumberOfDays = 30;
|
||||
|
||||
public EmptySecretsManagerTrashJob(ISecretRepository secretRepository, ILogger<EmptySecretsManagerTrashJob> logger) : base(logger)
|
||||
{
|
||||
_secretRepository = secretRepository;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteJobAsync(IJobExecutionContext context)
|
||||
{
|
||||
_logger.LogInformation("Execute job task: EmptySecretsManagerTrashJob: Start");
|
||||
await _secretRepository.EmptyTrash(DateTime.UtcNow, DeleteAfterThisNumberOfDays);
|
||||
_logger.LogInformation("Execute job task: EmptySecretsManagerTrashJob: End");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user