demarches-normaliennes/lib/tasks/token_expiration_email.rake
2023-03-16 16:16:45 +01:00

15 lines
409 B
Ruby

require Rails.root.join("lib", "tasks", "task_helper")
namespace :token_expiration_email do
task send_warning: :environment do
admin_tokens = APIToken
.includes(:administrateur)
.where(version: [1, 2])
.to_a
.group_by(&:administrateur)
admin_tokens.each do |admin, tokens|
AdministrateurMailer.api_token_expiration(admin.user, tokens).deliver_later
end
end
end