about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-02-11 13:55:07 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-02-11 13:55:07 +0100
commite610555e10356374d1f4e0e7ca11056580ec9f3b (patch)
treeae51a15ca18b200fb48a4133d51a87b7a37d2fc0 /app/services
parent514fdfa268989fad3a6dcf1a0bc5077ec23be6df (diff)
Fix processing of incoming authorizations/rejections
Diffstat (limited to 'app/services')
-rw-r--r--app/services/process_interaction_service.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb
index 27f0758ce..8420ca351 100644
--- a/app/services/process_interaction_service.rb
+++ b/app/services/process_interaction_service.rb
@@ -33,6 +33,8 @@ class ProcessInteractionService < BaseService
         follow_request!(account, target_account) unless !target_account.locked? || target_account.blocking?(account)
       when :authorize
         authorize_follow_request!(account, target_account)
+      when :reject
+        reject_follow_request!(account, target_account)
       when :unfollow
         unfollow!(account, target_account)
       when :favorite
@@ -76,14 +78,20 @@ class ProcessInteractionService < BaseService
     NotifyService.new.call(target_account, follow)
   end
 
-  def follow_request(account, target_account)
+  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)
+  def authorize_follow_request!(account, target_account)
     follow_request = FollowRequest.find_by(account: target_account, target_account: account)
     follow_request&.authorize!
+    SubscribeService.new.call(account) unless account.subscribed?
+  end
+
+  def reject_follow_request!(account, target_account)
+    follow_request = FollowRequest.find_by(account: target_account, target_account: account)
+    follow_request&.reject!
   end
 
   def unfollow!(account, target_account)