elsa-core/src/modules/Elsa.Secrets.Management/Services/DefaultExpiredSecretsUpdater.cs
Sipke Schoorstra dd812645c7 Refactor imports to reduce use of Elsa.Common.Contracts
Consolidate imports by replacing Elsa.Common.Contracts with Elsa.Common and Elsa.Common.Multitenancy. This update streamlines import statements across various modules, improving code readability and maintainability.
2024-10-05 18:30:45 +02:00

26 lines
778 B
C#

using Elsa.Common;
namespace Elsa.Secrets.Management;
public class DefaultExpiredSecretsUpdater(ISecretStore store, ISystemClock systemClock) : IExpiredSecretsUpdater
{
public async Task UpdateExpiredSecretsAsync(CancellationToken cancellationToken = default)
{
var now = systemClock.UtcNow;
var filter = new SecretFilter
{
Status = SecretStatus.Active,
ExpiresAtLessThan = now
};
var secrets = (await store.FindManyAsync(filter, cancellationToken)).ToList();
foreach (var secret in secrets)
{
secret.Status = SecretStatus.Expired;
secret.UpdatedAt = now;
await store.UpdateAsync(secret, cancellationToken);
}
}
}