Skip to content
Snippets Groups Projects
Commit 10eb47a3 authored by Eugen Rochko's avatar Eugen Rochko
Browse files

Do not PuSH-subscribe to remote accounts when creating them for salmon

parent 784b9cca
No related branches found
No related tags found
No related merge requests found
class FollowRemoteAccountService class FollowRemoteAccountService
include ApplicationHelper include ApplicationHelper
def call(uri) def call(uri, subscribe = true)
username, domain = uri.split('@') username, domain = uri.split('@')
account = Account.where(username: username, domain: domain).first account = Account.where(username: username, domain: domain).first
...@@ -19,9 +19,6 @@ class FollowRemoteAccountService ...@@ -19,9 +19,6 @@ class FollowRemoteAccountService
account.public_key = magic_key_to_pem(data.link('magic-public-key').href) account.public_key = magic_key_to_pem(data.link('magic-public-key').href)
account.private_key = nil account.private_key = nil
account.secret = SecureRandom.hex
account.verify_token = SecureRandom.hex
feed = get_feed(account.remote_url) feed = get_feed(account.remote_url)
hubs = feed.xpath('//xmlns:link[@rel="hub"]') hubs = feed.xpath('//xmlns:link[@rel="hub"]')
...@@ -33,8 +30,15 @@ class FollowRemoteAccountService ...@@ -33,8 +30,15 @@ class FollowRemoteAccountService
get_profile(feed, account) get_profile(feed, account)
account.save! account.save!
subscription = account.subscription(subscription_url(account)) if subscribe
subscription.subscribe account.secret = SecureRandom.hex
account.verify_token = SecureRandom.hex
subscription = account.subscription(subscription_url(account))
subscription.subscribe
account.save!
end
return account return account
rescue Goldfinger::Error, HTTP::Error => e rescue Goldfinger::Error, HTTP::Error => e
......
...@@ -31,10 +31,12 @@ class ProcessFeedService ...@@ -31,10 +31,12 @@ class ProcessFeedService
def add_reblog!(entry, status) def add_reblog!(entry, status)
status.reblog = find_original_status(entry, target_id(entry)) status.reblog = find_original_status(entry, target_id(entry))
status.save! unless status.reblog.nil?
end end
def add_reply!(entry, status) def add_reply!(entry, status)
status.thread = find_original_status(entry, thread_id(entry)) status.thread = find_original_status(entry, thread_id(entry))
status.save! unless status.thread.nil?
end end
def find_original_status(xml, id) def find_original_status(xml, id)
...@@ -54,7 +56,8 @@ class ProcessFeedService ...@@ -54,7 +56,8 @@ class ProcessFeedService
end end
def fetch_remote_status(xml, id) def fetch_remote_status(xml, id)
# todo url = xml.at_xpath('./link[@rel="self"]').attribute('href').value
nil
end end
def local_id?(id) def local_id?(id)
...@@ -100,4 +103,8 @@ class ProcessFeedService ...@@ -100,4 +103,8 @@ class ProcessFeedService
rescue rescue
:post :post
end end
def follow_remote_account_service
FollowRemoteAccountService.new
end
end end
...@@ -13,7 +13,7 @@ class ProcessInteractionService ...@@ -13,7 +13,7 @@ class ProcessInteractionService
account = Account.find_by(username: username, domain: domain) account = Account.find_by(username: username, domain: domain)
if account.nil? if account.nil?
account = follow_remote_account_service.("acct:#{username}@#{domain}") account = follow_remote_account_service.("acct:#{username}@#{domain}", false)
return if account.nil? return if account.nil?
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment