2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-16 15:36:27 +01:00
|
|
|
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
|