0
0
Fork 0

Prevent use locale with empty string (#18543)

Somehow user's locale could be an empty string, And empty string itself
are treated as true value.
This commit is contained in:
Jeong Arm 2022-05-28 21:32:08 +09:00 committed by GitHub
parent 0ac6e5d434
commit fed7380e9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 20 deletions

View file

@ -47,7 +47,7 @@ class MoveWorker
def copy_account_notes!
AccountNote.where(target_account: @source_account).find_each do |note|
text = I18n.with_locale(note.account.user&.locale || I18n.default_locale) do
text = I18n.with_locale(note.account.user&.locale.presence || I18n.default_locale) do
I18n.t('move_handler.copy_account_note_text', acct: @source_account.acct)
end
@ -90,7 +90,7 @@ class MoveWorker
def add_account_note_if_needed!(account, id)
unless AccountNote.where(account: account, target_account: @target_account).exists?
text = I18n.with_locale(account.user&.locale || I18n.default_locale) do
text = I18n.with_locale(account.user&.locale.presence || I18n.default_locale) do
I18n.t(id, acct: @source_account.acct)
end
AccountNote.create!(account: account, target_account: @target_account, comment: text)