A lot of fixes from a live test

This commit is contained in:
Eugen Rochko 2016-02-28 15:46:29 +01:00
parent f1654da7ad
commit 47d50b0e39
17 changed files with 59 additions and 27 deletions

View file

@ -9,7 +9,7 @@ class FollowService < BaseService
follow = source_account.follow!(target_account)
send_interaction_service.(follow.stream_entry, target_account)
source_account.ping!(atom_user_stream_url(id: source_account.id), HUB_URL)
source_account.ping!(atom_user_stream_url(id: source_account.id), [HUB_URL])
end
private

View file

@ -7,7 +7,7 @@ class PostStatusService < BaseService
def call(account, text, in_reply_to = nil)
status = account.statuses.create!(text: text, thread: in_reply_to)
process_mentions_service.(status)
account.ping!(atom_user_stream_url(id: account.id), HUB_URL)
account.ping!(atom_user_stream_url(id: account.id), [HUB_URL])
status
end

View file

@ -10,7 +10,7 @@ class ProcessFeedService < BaseService
end
xml.xpath('//xmlns:entry').each do |entry|
next unless [:note, :comment, :activity].includes? object_type(entry)
next unless [:note, :comment, :activity].include? object_type(entry)
status = Status.find_by(uri: activity_id(entry))
@ -88,7 +88,7 @@ class ProcessFeedService < BaseService
end
def thread_id(xml)
xml.at_xpath('./thr:in-reply-to-id').attribute('ref').value
xml.at_xpath('./thr:in-reply-to').attribute('ref').value
rescue
nil
end

View file

@ -43,7 +43,7 @@ class ProcessInteractionService < BaseService
end
def mentions_account?(xml, account)
xml.xpath('/xmlns:entry/xmlns:link[@rel="mentioned"]').each { |mention_link| return true if mention_link.attribute('ref') == profile_url(name: account.username) }
xml.xpath('/xmlns:entry/xmlns:link[@rel="mentioned"]').each { |mention_link| return true if mention_link.attribute('href').value == profile_url(account) }
false
end

View file

@ -5,7 +5,7 @@ class ReblogService < BaseService
# @return [Status]
def call(account, reblogged_status)
reblog = account.statuses.create!(reblog: reblogged_status, text: '')
account.ping!(atom_user_stream_url(id: account.id), HUB_URL)
account.ping!(atom_user_stream_url(id: account.id), [HUB_URL])
return reblog if reblogged_status.local?
send_interaction_service.(reblog.stream_entry, reblogged_status.account)
reblog

View file

@ -5,7 +5,7 @@ class SendInteractionService < BaseService
# @param [StreamEntry] stream_entry
# @param [Account] target_account
def call(stream_entry, target_account)
envelope = salmon.pack(entry_xml(stream_entry), target_account.keypair)
envelope = salmon.pack(entry_xml(stream_entry), stream_entry.account.keypair)
salmon.post(target_account.salmon_url, envelope)
end