]> cat aescling's git repositories - mastodon.git/commitdiff
Fix when MoveWorker cannot get locale from remote account (#16576)
authorTakeshi Umeda <noel.yoshiba@gmail.com>
Sun, 8 Aug 2021 13:31:02 +0000 (22:31 +0900)
committerGitHub <noreply@github.com>
Sun, 8 Aug 2021 13:31:02 +0000 (15:31 +0200)
app/workers/move_worker.rb

index 53a6b87f194a2c093f53c03fe2f93572692e0a58..cc2c17d32bf6022031d9fe22c2709020029db1a8 100644 (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 || I18n.default_locale) do
         I18n.t('move_handler.copy_account_note_text', acct: @source_account.acct)
       end
 
@@ -84,7 +84,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 || I18n.default_locale) do
         I18n.t(id, acct: @source_account.acct)
       end
       AccountNote.create!(account: account, target_account: @target_account, comment: text)