DEV: Use strings for :user_email job type argument

Job arguments go via JSON, and so symbols will appear as strings in the Job's `#execute` method. The latest version of Sidekiq has started warning about this to reduce developer confusion.
This commit is contained in:
David Taylor 2022-02-04 17:34:38 +00:00
parent 3a85c4d680
commit c3a54eb30f
6 changed files with 8 additions and 8 deletions

View File

@ -444,7 +444,7 @@ class SessionController < ApplicationController
if user
RateLimiter.new(nil, "forgot-password-login-day-#{user.username}", 6, 1.day).performed!
email_token = user.email_tokens.create!(email: user.email, scope: EmailToken.scopes[:password_reset])
Jobs.enqueue(:critical_user_email, type: :forgot_password, user_id: user.id, email_token: email_token.token)
Jobs.enqueue(:critical_user_email, type: "forgot_password", user_id: user.id, email_token: email_token.token)
else
RateLimiter.new(nil, "forgot-password-login-hour-#{normalized_login_param}", 5, 1.hour).performed!
end

View File

@ -737,7 +737,7 @@ class UsersController < ApplicationController
session["user_created_message"] = activation.success_message
if existing_user = User.find_by_email(user.primary_email&.email)
Jobs.enqueue(:critical_user_email, type: :account_exists, user_id: existing_user.id)
Jobs.enqueue(:critical_user_email, type: "account_exists", user_id: existing_user.id)
end
render json: {
@ -932,7 +932,7 @@ class UsersController < ApplicationController
if user = User.with_email(params[:email]).admins.human_users.first
email_token = user.email_tokens.create!(email: user.email, scope: EmailToken.scopes[:email_login])
Jobs.enqueue(:critical_user_email, type: :admin_login, user_id: user.id, email_token: email_token.token)
Jobs.enqueue(:critical_user_email, type: "admin_login", user_id: user.id, email_token: email_token.token)
@message = I18n.t("admin_login.success")
else
@message = I18n.t("admin_login.errors.unknown_email_address")
@ -967,7 +967,7 @@ class UsersController < ApplicationController
email_token = user.email_tokens.create!(email: user.email, scope: EmailToken.scopes[:email_login])
Jobs.enqueue(:critical_user_email,
type: :email_login,
type: "email_login",
user_id: user.id,
email_token: email_token.token
)

View File

@ -13,7 +13,7 @@ module Jobs
client_ip: args[:client_ip])
::Jobs.enqueue(:critical_user_email,
type: :suspicious_login,
type: "suspicious_login",
user_id: args[:user_id],
client_ip: args[:client_ip],
user_agent: args[:user_agent])

View File

@ -10,7 +10,7 @@ module Jobs
users = target_user_ids
users.each do |user_id|
::Jobs.enqueue(:user_email, type: :digest, user_id: user_id)
::Jobs.enqueue(:user_email, type: "digest", user_id: user_id)
end
end

View File

@ -24,7 +24,7 @@ class EmailUpdater
if existing_user = User.find_by_email(email)
if SiteSetting.hide_email_address_taken
Jobs.enqueue(:critical_user_email, type: :account_exists, user_id: existing_user.id)
Jobs.enqueue(:critical_user_email, type: "account_exists", user_id: existing_user.id)
else
error_message = +'change_email.error'
error_message << '_staged' if existing_user.staged?

View File

@ -28,7 +28,7 @@ task "admin:invite", [:email] => [:environment] do |_, args|
puts "Sending email!"
email_token = user.email_tokens.create!(email: user.email, scope: EmailToken.scopes[:password_reset])
Jobs.enqueue(:user_email, type: :account_created, user_id: user.id, email_token: email_token.token)
Jobs.enqueue(:user_email, type: "account_created", user_id: user.id, email_token: email_token.token)
end
desc "Creates a forum administrator"