diff options
author | Thibaut Girka <thib@sitedethib.com> | 2020-07-01 19:23:14 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2020-07-01 19:23:14 +0200 |
commit | 45deca65b3fb8e9f19818e3db7d315cab0572d1a (patch) | |
tree | 1b9bab6ec764e8a6600d245595facd5694287e16 /app/workers/move_worker.rb | |
parent | 39a0622de70dc24275808cee9526658bd68a55ed (diff) | |
parent | 6d23d40420e4548778f3ca4ed9e8cb16e0eb0073 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/javascript/packs/public.js`: Conflict because part of that file has been split to `app/javascript/core/settings.js`. Ported those changes there.
Diffstat (limited to 'app/workers/move_worker.rb')
-rw-r--r-- | app/workers/move_worker.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/workers/move_worker.rb b/app/workers/move_worker.rb index 4d76461b0..39e321316 100644 --- a/app/workers/move_worker.rb +++ b/app/workers/move_worker.rb @@ -14,6 +14,8 @@ class MoveWorker end copy_account_notes! + carry_blocks_over! + carry_mutes_over! rescue ActiveRecord::RecordNotFound true end @@ -51,4 +53,29 @@ class MoveWorker end end end + + def carry_blocks_over! + @source_account.blocked_by_relationships.where(account: Account.local).find_each do |block| + unless block.account.blocking?(@target_account) || block.account.following?(@target_account) + BlockService.new.call(block.account, @target_account) + add_account_note_if_needed!(block.account, 'move_handler.carry_blocks_over_text') + end + end + end + + def carry_mutes_over! + @source_account.muted_by_relationships.where(account: Account.local).find_each do |mute| + MuteService.new.call(mute.account, @target_account, notifications: mute.hide_notifications) unless mute.account.muting?(@target_account) || mute.account.following?(@target_account) + add_account_note_if_needed!(mute.account, 'move_handler.carry_mutes_over_text') + end + end + + 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 + I18n.t(id, acct: @source_account.acct) + end + AccountNote.create!(account: account, target_account: @target_account, comment: text) + end + end end |