about summary refs log tree commit diff
path: root/app/services/process_interaction_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/process_interaction_service.rb')
-rw-r--r--app/services/process_interaction_service.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb
index 3d3cccb6a..11ec0d2dd 100644
--- a/app/services/process_interaction_service.rb
+++ b/app/services/process_interaction_service.rb
@@ -30,7 +30,7 @@ class ProcessInteractionService < BaseService
 
       case verb(xml)
       when :follow
-        follow!(account, target_account) unless target_account.locked?
+        follow!(account, target_account) unless target_account.locked? || target_account.blocking?(account)
       when :unfollow
         unfollow!(account, target_account)
       when :favorite
@@ -41,6 +41,10 @@ class ProcessInteractionService < BaseService
         add_post!(body, account) unless status(xml).nil?
       when :delete
         delete_post!(xml, account)
+      when :block
+        reflect_block!(account, target_account)
+      when :unblock
+        reflect_unblock!(account, target_account)
       end
     end
   rescue Goldfinger::Error, HTTP::Error, OStatus2::BadSalmonError
@@ -74,6 +78,15 @@ class ProcessInteractionService < BaseService
     account.unfollow!(target_account)
   end
 
+  def reflect_block!(account, target_account)
+    UnfollowService.new.call(target_account, account) if target_account.following?(account)
+    account.block!(target_account)
+  end
+
+  def reflect_unblock!(account, target_account)
+    UnblockService.new.call(account, target_account)
+  end
+
   def delete_post!(xml, account)
     status = Status.find(xml.at_xpath('//xmlns:id', xmlns: TagManager::XMLNS).content)