mirror of
https://github.com/bitwarden/server.git
synced 2025-07-14 06:07:36 -05:00
Send APIs (#979)
* send work * fix sql proj file * update * updates * access id * delete job * fix delete job * local send storage * update sprocs for null checks
This commit is contained in:
47
src/Admin/Jobs/DeleteSendsJob.cs
Normal file
47
src/Admin/Jobs/DeleteSendsJob.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Jobs;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Quartz;
|
||||
|
||||
namespace Bit.Admin.Jobs
|
||||
{
|
||||
public class DeleteSendsJob : BaseJob
|
||||
{
|
||||
private readonly ISendRepository _sendRepository;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public DeleteSendsJob(
|
||||
ISendRepository sendRepository,
|
||||
IServiceProvider serviceProvider,
|
||||
ILogger<DatabaseExpiredGrantsJob> logger)
|
||||
: base(logger)
|
||||
{
|
||||
_sendRepository = sendRepository;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
protected async override Task ExecuteJobAsync(IJobExecutionContext context)
|
||||
{
|
||||
var sends = await _sendRepository.GetManyByDeletionDateAsync(DateTime.UtcNow);
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Deleting {0} sends.", sends.Count);
|
||||
if (!sends.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (var scope = _serviceProvider.CreateScope())
|
||||
{
|
||||
var sendService = scope.ServiceProvider.GetRequiredService<ISendService>();
|
||||
foreach (var send in sends)
|
||||
{
|
||||
await sendService.DeleteSendAsync(send);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user