about summary refs log tree commit diff
path: root/app/services/process_interaction_service.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-02-11 02:12:05 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-02-11 02:58:00 +0100
commit149887a0ffc81b588520ff82ab9fda8dff7bce6c (patch)
treefc1ba51d91fbadf729241381a8c46643121ad99f /app/services/process_interaction_service.rb
parentd551e43a9bc35b4785285e78f5ecd3157636b447 (diff)
Make follow requests federate
Diffstat (limited to 'app/services/process_interaction_service.rb')
-rw-r--r--app/services/process_interaction_service.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb
index 5f91e3127..27f0758ce 100644
--- a/app/services/process_interaction_service.rb
+++ b/app/services/process_interaction_service.rb
@@ -29,6 +29,10 @@ class ProcessInteractionService < BaseService
       case verb(xml)
       when :follow
         follow!(account, target_account) unless target_account.locked? || target_account.blocking?(account)
+      when :request_friend
+        follow_request!(account, target_account) unless !target_account.locked? || target_account.blocking?(account)
+      when :authorize
+        authorize_follow_request!(account, target_account)
       when :unfollow
         unfollow!(account, target_account)
       when :favorite
@@ -72,6 +76,16 @@ class ProcessInteractionService < BaseService
     NotifyService.new.call(target_account, follow)
   end
 
+  def follow_request(account, target_account)
+    follow_request = FollowRequest.create!(account: account, target_account: target_account)
+    NotifyService.new.call(target_account, follow_request)
+  end
+
+  def authorize_target_account!(account, target_account)
+    follow_request = FollowRequest.find_by(account: target_account, target_account: account)
+    follow_request&.authorize!
+  end
+
   def unfollow!(account, target_account)
     account.unfollow!(target_account)
   end