From 77efdfa1104a77061f014bbc84268028597620cb Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 10 Oct 2016 19:09:11 +0200 Subject: [PATCH] Fixing namespaces issue --- app/services/process_feed_service.rb | 12 ++++++------ app/services/process_interaction_service.rb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index 334cde6b..cd9bd8e9 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -45,7 +45,7 @@ class ProcessFeedService < BaseService # Also record all media attachments for the status and for the reblogged status if present unless status.new_record? record_remote_mentions(status, entry.xpath('./xmlns:link[@rel="mentioned"]')) - record_remote_mentions(status.reblog, entry.xpath('./activity:object/xmlns:link[@rel="mentioned"]', activity: ACTIVITY_NS)) if status.reblog? + record_remote_mentions(status.reblog, entry.at_xpath('./activity:object', activity: ACTIVITY_NS).xpath('./xmlns:link[@rel="mentioned"]')) if status.reblog? process_attachments(entry, status) process_attachments(entry.xpath('./activity:object', activity: ACTIVITY_NS), status.reblog) if status.reblog? @@ -147,8 +147,8 @@ class ProcessFeedService < BaseService end def fetch_remote_status(xml) - username = xml.at_xpath('./activity:object/xmlns:author/xmlns:name', activity: ACTIVITY_NS).content - url = xml.at_xpath('./activity:object/xmlns:author/xmlns:uri', activity: ACTIVITY_NS).content + username = xml.at_xpath('./activity:object', activity: ACTIVITY_NS).at_xpath('./xmlns:author/xmlns:name').content + url = xml.at_xpath('./activity:object', activity: ACTIVITY_NS).at_xpath('./xmlns:author/xmlns:uri').content domain = Addressable::URI.parse(url).host account = Account.find_remote(username, domain) @@ -193,7 +193,7 @@ class ProcessFeedService < BaseService end def target_id(xml) - xml.at_xpath('.//activity:object/xmlns:id', activity: ACTIVITY_NS).content + xml.at_xpath('.//activity:object', activity: ACTIVITY_NS).at_xpath('./xmlns:id').content rescue nil end @@ -209,11 +209,11 @@ class ProcessFeedService < BaseService end def target_content(xml) - xml.at_xpath('.//activity:object/xmlns:content', activity: ACTIVITY_NS).content + xml.at_xpath('.//activity:object', activity: ACTIVITY_NS).at_xpath('./xmlns:content').content end def target_url(xml) - xml.at_xpath('.//activity:object/xmlns:link[@rel="alternate"]', activity: ACTIVITY_NS).attribute('href').value + xml.at_xpath('.//activity:object').at_xpath('./xmlns:link[@rel="alternate"]', activity: ACTIVITY_NS).attribute('href').value end def object_type(xml) diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb index 20ce3d00..06c8f66d 100644 --- a/app/services/process_interaction_service.rb +++ b/app/services/process_interaction_service.rb @@ -94,7 +94,7 @@ class ProcessInteractionService < BaseService end def activity_id(xml) - xml.at_xpath('//activity:object/xmlns:id', activity: ACTIVITY_NS).content + xml.at_xpath('//activity:object', activity: ACTIVITY_NS).at_xpath('./xmlns:id').content end def salmon