about summary refs log tree commit diff
path: root/app/workers/move_worker.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-07-01 00:18:49 +0200
committerGitHub <noreply@github.com>2020-07-01 00:18:49 +0200
commit814d3f343f8caae3366410900eec0b90b9bbbb7b (patch)
tree5d0b779a144afd2bff33503804cd5dcc58012ff6 /app/workers/move_worker.rb
parent10ede3eb27c5de5d4e3a283e333af2a54da6177d (diff)
parent3d7ce178dd7be9ef02d34bf6734365d0aefa3120 (diff)
Merge pull request #1366 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/workers/move_worker.rb')
-rw-r--r--app/workers/move_worker.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/workers/move_worker.rb b/app/workers/move_worker.rb
index 595730226..4d76461b0 100644
--- a/app/workers/move_worker.rb
+++ b/app/workers/move_worker.rb
@@ -12,6 +12,8 @@ class MoveWorker
     else
       queue_follow_unfollows!
     end
+
+    copy_account_notes!
   rescue ActiveRecord::RecordNotFound
     true
   end
@@ -34,4 +36,19 @@ class MoveWorker
       UnfollowFollowWorker.push_bulk(accounts.map(&:id)) { |follower_id| [follower_id, @source_account.id, @target_account.id, bypass_locked] }
     end
   end
+
+  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
+        I18n.t('move_handler.copy_account_note_text', acct: @source_account.acct)
+      end
+
+      new_note = AccountNote.find_by(account: note.account, target_account: @target_account)
+      if new_note.nil?
+        AccountNote.create!(account: note.account, target_account: @target_account, comment: [text, note.comment].join('\n'))
+      else
+        new_note.update!(comment: [text, note.comment, '\n', new_note.comment].join('\n'))
+      end
+    end
+  end
 end