mirror of
https://github.com/bitwarden/server.git
synced 2025-04-26 07:12:20 -05:00

* Move Api files * Move Core files * Move Infrastructure files * Move Sql Files * Move Api Sync files to Vault * Move test vault files * Update Sql.sqlproj paths * Update Codeowners * Fix vault file paths in sqlproj * Update CipherDetails.sql path in sqlproj * Update Core models and entities namespaces * Update namespaces Core Services and Repositories * Missed service namespaces * Update Api namespaces * Update Infrastructure namespaces * Move infrastructure queries that were missed * Tests namespace updates * Admin and Events namespace updates * Remove unused usings * Remove extra CiphersController usings * Rename folder * Fix CipherDetails namespace * Sqlproj fixes * Move stored procs into folders by table * using order fix
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using Bit.Core;
|
|
using Bit.Core.Jobs;
|
|
using Bit.Core.Vault.Repositories;
|
|
using Microsoft.Extensions.Options;
|
|
using Quartz;
|
|
|
|
namespace Bit.Admin.Jobs;
|
|
|
|
public class DeleteCiphersJob : BaseJob
|
|
{
|
|
private readonly ICipherRepository _cipherRepository;
|
|
private readonly AdminSettings _adminSettings;
|
|
|
|
public DeleteCiphersJob(
|
|
ICipherRepository cipherRepository,
|
|
IOptions<AdminSettings> adminSettings,
|
|
ILogger<DeleteCiphersJob> logger)
|
|
: base(logger)
|
|
{
|
|
_cipherRepository = cipherRepository;
|
|
_adminSettings = adminSettings?.Value;
|
|
}
|
|
|
|
protected async override Task ExecuteJobAsync(IJobExecutionContext context)
|
|
{
|
|
_logger.LogInformation(Constants.BypassFiltersEventId, "Execute job task: DeleteDeletedAsync");
|
|
var deleteDate = DateTime.UtcNow.AddDays(-30);
|
|
var daysAgoSetting = (_adminSettings?.DeleteTrashDaysAgo).GetValueOrDefault();
|
|
if (daysAgoSetting > 0)
|
|
{
|
|
deleteDate = DateTime.UtcNow.AddDays(-1 * daysAgoSetting);
|
|
}
|
|
await _cipherRepository.DeleteDeletedAsync(deleteDate);
|
|
_logger.LogInformation(Constants.BypassFiltersEventId, "Finished job task: DeleteDeletedAsync");
|
|
}
|
|
}
|