diff --git a/.vscode/settings.json b/.vscode/settings.json index bb386a29a..842ae0e3f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -107,6 +107,7 @@ "factorybot", "helpdesk", "katex", - "turbolinks" + "turbolinks", + "Unsets" ] } \ No newline at end of file diff --git a/app/mailers/user_cleaner_mailer.rb b/app/mailers/user_cleaner_mailer.rb index f8535ccc2..0ee8a6931 100644 --- a/app/mailers/user_cleaner_mailer.rb +++ b/app/mailers/user_cleaner_mailer.rb @@ -5,24 +5,22 @@ class UserCleanerMailer < ApplicationMailer # # @param [Integer] num_days_until_deletion: # The number of days until the account will be deleted. - def pending_deletion_email(num_days_until_deletion) - user = params[:user] + def pending_deletion_email(user_email, user_locale, num_days_until_deletion) sender = "#{t("mailer.warning")} <#{DefaultSetting::PROJECT_EMAIL}>" - I18n.locale = user.locale + I18n.locale = user_locale @num_days_until_deletion = num_days_until_deletion subject = t("mailer.pending_deletion_subject", num_days_until_deletion: @num_days_until_deletion) - mail(from: sender, to: user.email, subject: subject, priority: "high") + mail(from: sender, to: user_email, subject: subject, priority: "high") end # Creates an email to inform a user that their account has been deleted. - def deletion_email - user = params[:user] + def deletion_email(user_email, user_locale) sender = "#{t("mailer.warning")} <#{DefaultSetting::PROJECT_EMAIL}>" - I18n.locale = user.locale + I18n.locale = user_locale subject = t("mailer.deletion_subject") - mail(from: sender, to: user.email, subject: subject, priority: "high") + mail(from: sender, to: user_email, subject: subject, priority: "high") end end diff --git a/app/models/user_cleaner.rb b/app/models/user_cleaner.rb index 566d0c8cd..39d930890 100644 --- a/app/models/user_cleaner.rb +++ b/app/models/user_cleaner.rb @@ -76,8 +76,9 @@ def set_deletion_date_for_inactive_users .find_each do |user| user.update(deletion_date: Date.current + 40.days) - if user.generic? # rubocop:disable Style/IfUnlessModifier - UserCleanerMailer.with(user: user).pending_deletion_email(40).deliver_later + if user.generic? + UserCleanerMailer.pending_deletion_email(user.email, user.locale, 40) + .deliver_later end end end @@ -114,7 +115,7 @@ def delete_users_according_to_deletion_date! User.where(deletion_date: ..Date.current).find_each do |user| next unless user.generic? - UserCleanerMailer.with(user: user).deletion_email.deliver_later + UserCleanerMailer.deletion_email(user.email, user.locale).deliver_later user.destroy num_deleted_users += 1 end