diff options
author | Starfall <admin@plural.cafe> | 2020-07-01 12:06:19 -0500 |
---|---|---|
committer | Starfall <admin@plural.cafe> | 2020-07-01 12:06:19 -0500 |
commit | 4d93b5c442ff5c9f4d640b4c7d543f0c04c120df (patch) | |
tree | 4df391c12dc761ac99ca6421d53d8d31870b68ec /app/workers/move_worker.rb | |
parent | 5668836f56cddf3257f38a2483c1d42cacbad3a8 (diff) | |
parent | 39a0622de70dc24275808cee9526658bd68a55ed (diff) |
Merge branch 'glitch' into main
Diffstat (limited to 'app/workers/move_worker.rb')
-rw-r--r-- | app/workers/move_worker.rb | 17 |
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 |