about summary refs log tree commit diff
path: root/app/services/follow_remote_account_service.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-02-24 03:05:40 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-02-24 03:05:40 +0100
commit10eb47a33e2f0c7f0eba5302319c4321db41294c (patch)
tree9df1f0406af5706fa33448daed881cccfb6103ad /app/services/follow_remote_account_service.rb
parent784b9cca6ae490216f45e55786b96c5e03257373 (diff)
Do not PuSH-subscribe to remote accounts when creating them for salmon
Diffstat (limited to 'app/services/follow_remote_account_service.rb')
-rw-r--r--app/services/follow_remote_account_service.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/services/follow_remote_account_service.rb b/app/services/follow_remote_account_service.rb
index 405d6c62e..bb55362a6 100644
--- a/app/services/follow_remote_account_service.rb
+++ b/app/services/follow_remote_account_service.rb
@@ -1,7 +1,7 @@
 class FollowRemoteAccountService
   include ApplicationHelper
 
-  def call(uri)
+  def call(uri, subscribe = true)
     username, domain = uri.split('@')
     account = Account.where(username: username, domain: domain).first
 
@@ -19,9 +19,6 @@ class FollowRemoteAccountService
     account.public_key  = magic_key_to_pem(data.link('magic-public-key').href)
     account.private_key = nil
 
-    account.secret       = SecureRandom.hex
-    account.verify_token = SecureRandom.hex
-
     feed = get_feed(account.remote_url)
     hubs = feed.xpath('//xmlns:link[@rel="hub"]')
 
@@ -33,8 +30,15 @@ class FollowRemoteAccountService
     get_profile(feed, account)
     account.save!
 
-    subscription = account.subscription(subscription_url(account))
-    subscription.subscribe
+    if subscribe
+      account.secret       = SecureRandom.hex
+      account.verify_token = SecureRandom.hex
+
+      subscription = account.subscription(subscription_url(account))
+      subscription.subscribe
+
+      account.save!
+    end
 
     return account
   rescue Goldfinger::Error, HTTP::Error => e