about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/services/follow_remote_account_service.rb16
-rw-r--r--app/services/process_feed_service.rb9
-rw-r--r--app/services/process_interaction_service.rb2
3 files changed, 19 insertions, 8 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
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index aece43a57..b7952035b 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -31,10 +31,12 @@ class ProcessFeedService
 
   def add_reblog!(entry, status)
     status.reblog = find_original_status(entry, target_id(entry))
+    status.save! unless status.reblog.nil?
   end
 
   def add_reply!(entry, status)
     status.thread = find_original_status(entry, thread_id(entry))
+    status.save! unless status.thread.nil?
   end
 
   def find_original_status(xml, id)
@@ -54,7 +56,8 @@ class ProcessFeedService
   end
 
   def fetch_remote_status(xml, id)
-    # todo
+    url = xml.at_xpath('./link[@rel="self"]').attribute('href').value
+    nil
   end
 
   def local_id?(id)
@@ -100,4 +103,8 @@ class ProcessFeedService
   rescue
     :post
   end
+
+  def follow_remote_account_service
+    FollowRemoteAccountService.new
+  end
 end
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb
index cb149f9ab..ee04f01af 100644
--- a/app/services/process_interaction_service.rb
+++ b/app/services/process_interaction_service.rb
@@ -13,7 +13,7 @@ class ProcessInteractionService
     account  = Account.find_by(username: username, domain: domain)
 
     if account.nil?
-      account = follow_remote_account_service.("acct:#{username}@#{domain}")
+      account = follow_remote_account_service.("acct:#{username}@#{domain}", false)
       return if account.nil?
     end