mirror of
https://github.com/bitwarden/server
synced 2025-12-25 12:43:14 +00:00
when ciphers are soft deleted, complete any associated security tasks (#6492)
This commit is contained in:
@@ -96,4 +96,24 @@ public class SecurityTaskRepository : Repository<Core.Vault.Entities.SecurityTas
|
||||
|
||||
return metrics ?? new Core.Vault.Entities.SecurityTaskMetrics(0, 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task MarkAsCompleteByCipherIds(IEnumerable<Guid> cipherIds)
|
||||
{
|
||||
if (!cipherIds.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var scope = ServiceScopeFactory.CreateScope();
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
|
||||
var cipherIdsList = cipherIds.ToList();
|
||||
|
||||
await dbContext.SecurityTasks
|
||||
.Where(st => st.CipherId.HasValue && cipherIdsList.Contains(st.CipherId.Value) && st.Status != SecurityTaskStatus.Completed)
|
||||
.ExecuteUpdateAsync(st => st
|
||||
.SetProperty(s => s.Status, SecurityTaskStatus.Completed)
|
||||
.SetProperty(s => s.RevisionDate, DateTime.UtcNow));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user