about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/activitypub/move_distribution_worker.rb2
-rw-r--r--app/workers/move_worker.rb27
-rw-r--r--app/workers/publish_announcement_reaction_worker.rb2
-rw-r--r--app/workers/publish_scheduled_announcement_worker.rb2
-rw-r--r--app/workers/unpublish_announcement_worker.rb2
5 files changed, 31 insertions, 4 deletions
diff --git a/app/workers/activitypub/move_distribution_worker.rb b/app/workers/activitypub/move_distribution_worker.rb
index bf1c0e7ae..65c5c0d1c 100644
--- a/app/workers/activitypub/move_distribution_worker.rb
+++ b/app/workers/activitypub/move_distribution_worker.rb
@@ -24,7 +24,7 @@ class ActivityPub::MoveDistributionWorker
   private
 
   def inboxes
-    @inboxes ||= @migration.account.followers.inboxes
+    @inboxes ||= (@migration.account.followers.inboxes + @migration.account.blocked_by.inboxes).uniq
   end
 
   def signed_payload
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
diff --git a/app/workers/publish_announcement_reaction_worker.rb b/app/workers/publish_announcement_reaction_worker.rb
index 418dc7127..03da56550 100644
--- a/app/workers/publish_announcement_reaction_worker.rb
+++ b/app/workers/publish_announcement_reaction_worker.rb
@@ -14,7 +14,7 @@ class PublishAnnouncementReactionWorker
     payload = Oj.dump(event: :'announcement.reaction', payload: payload)
 
     FeedManager.instance.with_active_accounts do |account|
-      redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}")
+      redis.publish("timeline:#{account.id}", payload) if redis.exists?("subscribed:timeline:#{account.id}")
     end
   rescue ActiveRecord::RecordNotFound
     true
diff --git a/app/workers/publish_scheduled_announcement_worker.rb b/app/workers/publish_scheduled_announcement_worker.rb
index 1392efed0..c23eae6af 100644
--- a/app/workers/publish_scheduled_announcement_worker.rb
+++ b/app/workers/publish_scheduled_announcement_worker.rb
@@ -15,7 +15,7 @@ class PublishScheduledAnnouncementWorker
     payload = Oj.dump(event: :announcement, payload: payload)
 
     FeedManager.instance.with_active_accounts do |account|
-      redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}")
+      redis.publish("timeline:#{account.id}", payload) if redis.exists?("subscribed:timeline:#{account.id}")
     end
   end
 
diff --git a/app/workers/unpublish_announcement_worker.rb b/app/workers/unpublish_announcement_worker.rb
index e99d70cf8..e58c07554 100644
--- a/app/workers/unpublish_announcement_worker.rb
+++ b/app/workers/unpublish_announcement_worker.rb
@@ -8,7 +8,7 @@ class UnpublishAnnouncementWorker
     payload = Oj.dump(event: :'announcement.delete', payload: announcement_id.to_s)
 
     FeedManager.instance.with_active_accounts do |account|
-      redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}")
+      redis.publish("timeline:#{account.id}", payload) if redis.exists?("subscribed:timeline:#{account.id}")
     end
   end
 end