diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-02-11 15:43:09 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-02-11 15:43:09 +0100 |
commit | e6408b2e7ade3dac8dcf14bcda5b5c6a159fa74c (patch) | |
tree | 7ba827f801bea1556231d275a6a8a35471f8a954 /app/services/process_interaction_service.rb | |
parent | 0afed995ce60dec11bc7718f83ca5afde86f6228 (diff) | |
parent | 446aad4ce2cb7afd0ba8e4b508e4dcba57eac790 (diff) |
Merge branch 'feature-privacy-federation' into development
Diffstat (limited to 'app/services/process_interaction_service.rb')
-rw-r--r-- | app/services/process_interaction_service.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb index 5f91e3127..8420ca351 100644 --- a/app/services/process_interaction_service.rb +++ b/app/services/process_interaction_service.rb @@ -29,6 +29,12 @@ 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 :reject + reject_follow_request!(account, target_account) when :unfollow unfollow!(account, target_account) when :favorite @@ -72,6 +78,22 @@ 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_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) account.unfollow!(target_account) end |