diff options
Diffstat (limited to 'app/services/follow_service.rb')
-rw-r--r-- | app/services/follow_service.rb | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index 92d8c864a..3494dce99 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -29,10 +29,12 @@ class FollowService < BaseService ActivityTracker.increment('activity:interactions') - if target_account.locked? || target_account.activitypub? - request_follow(source_account, target_account, reblogs: reblogs) + if target_account.local? && !target_account.locked? + follow = source_account.follow!(target_account, reblogs: reblogs) + LocalNotificationWorker.perform_async(target_account.id, follow.id, follow.class.name) + follow else - direct_follow(source_account, target_account, reblogs: reblogs) + request_follow(source_account, target_account, reblogs: reblogs) end end @@ -43,40 +45,13 @@ class FollowService < BaseService if target_account.local? LocalNotificationWorker.perform_async(target_account.id, follow_request.id, follow_request.class.name) - elsif target_account.ostatus? - NotificationWorker.perform_async(build_follow_request_xml(follow_request), source_account.id, target_account.id) - AfterRemoteFollowRequestWorker.perform_async(follow_request.id) - elsif target_account.activitypub? + else ActivityPub::DeliveryWorker.perform_async(build_json(follow_request), source_account.id, target_account.inbox_url) end follow_request end - def direct_follow(source_account, target_account, reblogs: true) - follow = source_account.follow!(target_account, reblogs: reblogs) - - if target_account.local? - LocalNotificationWorker.perform_async(target_account.id, follow.id, follow.class.name) - else - Pubsubhubbub::SubscribeWorker.perform_async(target_account.id) unless target_account.subscribed? - NotificationWorker.perform_async(build_follow_xml(follow), source_account.id, target_account.id) - AfterRemoteFollowWorker.perform_async(follow.id) - end - - MergeWorker.perform_async(target_account.id, source_account.id) - - follow - end - - def build_follow_request_xml(follow_request) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.follow_request_salmon(follow_request)) - end - - def build_follow_xml(follow) - OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.follow_salmon(follow)) - end - def build_json(follow_request) ActiveModelSerializers::SerializableResource.new( follow_request, |