about summary refs log tree commit diff
path: root/app/services/follow_service.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-07-21 00:53:28 +0200
committerHolly 'Frinkel' Lotor <admin@frinkel.tech>2020-01-20 16:55:55 -0500
commitb0630ddc8261250c5edbf2907648695041649e98 (patch)
tree9ca374e4e98598efced200e4a993875245ab93b6 /app/services/follow_service.rb
parent9447566b8ed8e532c13dd97ecd53681029fdcec0 (diff)
Original upstream merge
Diffstat (limited to 'app/services/follow_service.rb')
-rw-r--r--app/services/follow_service.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb
index 93f5b6b16..e3f4bf19d 100644
--- a/app/services/follow_service.rb
+++ b/app/services/follow_service.rb
@@ -13,7 +13,7 @@ class FollowService < BaseService
     target_account = ResolveAccountService.new.call(target_account, skip_webfinger: true)
 
     raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id || target_account.suspended?
-    raise Mastodon::NotPermittedError  if target_account.blocking?(source_account) || source_account.blocking?(target_account) || target_account.moved?
+    raise Mastodon::NotPermittedError  if target_account.blocking?(source_account) || source_account.blocking?(target_account) || target_account.moved? || (!target_account.local? && target_account.ostatus?)
 
     target_account.mark_known! unless !Setting.auto_mark_known || target_account.known?
 
@@ -35,9 +35,11 @@ class FollowService < BaseService
     ActivityTracker.increment('activity:interactions')
 
     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
+      direct_follow(source_account, target_account, reblogs: reblogs)
+#      follow = source_account.follow!(target_account, reblogs: reblogs)
+#      LocalNotificationWorker.perform_async(target_account.id, follow.id, follow.class.name)
+#      MergeWorker.perform_async(target_account.id, source_account.id)
+#      follow
     else
       request_follow(source_account, target_account, reblogs: reblogs)
     end
@@ -50,13 +52,22 @@ class FollowService < BaseService
 
     if target_account.local?
       LocalNotificationWorker.perform_async(target_account.id, follow_request.id, follow_request.class.name)
-    else
+    elsif target_account.activitypub?
       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)
+
+    LocalNotificationWorker.perform_async(target_account.id, follow.id, follow.class.name)
+    MergeWorker.perform_async(target_account.id, source_account.id)
+
+    follow
+  end
+
   def build_json(follow_request)
     Oj.dump(serialize_payload(follow_request, ActivityPub::FollowSerializer))
   end