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-09-20 00:39:03 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-20 00:43:36 +0200
commit059ebbf48dc56971b88e26a15303a75643de8b98 (patch)
treef0d46b941f298912094fe5a87b192d6fa8d4d304 /app/services/follow_remote_account_service.rb
parent1245ee42fb9f689ffa4956f42f44a7ab75e19075 (diff)
Separate PuSH subscriptions from following, add mastodon:push:refresh task,
respect hub.lease_seconds (fix #46)
Diffstat (limited to 'app/services/follow_remote_account_service.rb')
-rw-r--r--app/services/follow_remote_account_service.rb29
1 files changed, 5 insertions, 24 deletions
diff --git a/app/services/follow_remote_account_service.rb b/app/services/follow_remote_account_service.rb
index 00285f47a..f3a384ecc 100644
--- a/app/services/follow_remote_account_service.rb
+++ b/app/services/follow_remote_account_service.rb
@@ -3,22 +3,18 @@ class FollowRemoteAccountService < BaseService
   # When creating, look up the user's webfinger and fetch all
   # important information from their feed
   # @param [String] uri User URI in the form of username@domain
-  # @param [Boolean] subscribe Whether to initiate a PubSubHubbub subscription
   # @return [Account]
-  def call(uri, subscribe = true)
+  def call(uri)
     username, domain = uri.split('@')
 
     return Account.find_local(username) if domain == Rails.configuration.x.local_domain || domain.nil?
 
     account = Account.find_remote(username, domain)
 
-    if account.nil?
-      Rails.logger.debug "Creating new remote account for #{uri}"
-      account = Account.new(username: username, domain: domain)
-    elsif account.subscribed?
-      Rails.logger.debug "Already subscribed to remote account #{uri}"
-      return account
-    end
+    return account unless account.nil?
+
+    Rails.logger.debug "Creating new remote account for #{uri}"
+    account = Account.new(username: username, domain: domain)
 
     data = Goldfinger.finger("acct:#{uri}")
 
@@ -45,16 +41,6 @@ class FollowRemoteAccountService < BaseService
     get_profile(feed, account)
     account.save!
 
-    if subscribe
-      account.secret       = SecureRandom.hex
-      account.verify_token = SecureRandom.hex
-
-      subscription = account.subscription(api_subscription_url(account.id))
-      subscription.subscribe
-
-      account.save!
-    end
-
     return account
   end
 
@@ -90,8 +76,3 @@ class FollowRemoteAccountService < BaseService
   end
 end
 
-class NoAuthorFeedError < StandardError
-end
-
-class NoHubError < StandardError
-end