]> cat aescling's git repositories - mastodon.git/commitdiff
Fix processing of incoming authorizations/rejections
authorEugen Rochko <eugen@zeonfederated.com>
Sat, 11 Feb 2017 12:55:07 +0000 (13:55 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 11 Feb 2017 12:55:07 +0000 (13:55 +0100)
app/services/process_interaction_service.rb

index 27f0758ceaadaaea4de0e7128d36387ff38efcf4..8420ca35193c605edfbc235527f8effcf8fecf0b 100644 (file)
@@ -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)