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-17 16:36:10 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-17 16:36:10 +0200
commit8c0b19012bae203f41b75cf40d6baf121f67fdea (patch)
tree7dc72fd03f0d77d53875e8b44a85a47ec202050b /app/services/follow_remote_account_service.rb
parente906677092ca2f38abd918436ea5967c096d555f (diff)
Fix #41, debug #42
Diffstat (limited to 'app/services/follow_remote_account_service.rb')
-rw-r--r--app/services/follow_remote_account_service.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/follow_remote_account_service.rb b/app/services/follow_remote_account_service.rb
index c4330d7cf..0e23ed7d2 100644
--- a/app/services/follow_remote_account_service.rb
+++ b/app/services/follow_remote_account_service.rb
@@ -13,8 +13,10 @@ class FollowRemoteAccountService < BaseService
     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
 
@@ -29,7 +31,10 @@ class FollowRemoteAccountService < BaseService
     feed = get_feed(account.remote_url)
     hubs = feed.xpath('//xmlns:link[@rel="hub"]')
 
-    return nil if hubs.empty? || hubs.first.attribute('href').nil? || feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').nil?
+    if hubs.empty? || hubs.first.attribute('href').nil? || feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').nil?
+      Rails.logger.debug "Cannot find PuSH hub or author for #{uri}"
+      return nil
+    end
 
     account.uri     = feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').content
     account.hub_url = hubs.first.attribute('href').value
@@ -49,6 +54,7 @@ class FollowRemoteAccountService < BaseService
 
     return account
   rescue Goldfinger::Error, HTTP::Error
+    Rails.logger.debug "Error while fetching data for #{uri}"
     nil
   end