diff options
Diffstat (limited to 'app/services/process_feed_service.rb')
-rw-r--r-- | app/services/process_feed_service.rb | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index fa0633b27..98d92f630 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -119,6 +119,7 @@ class ProcessFeedService < BaseService spoiler_text: content_warning(entry), created_at: published(entry), reply: thread?(entry), + language: content_language(entry), visibility: visibility_scope(entry) ) @@ -161,13 +162,7 @@ class ProcessFeedService < BaseService xml.xpath('./xmlns:link[@rel="mentioned"]', xmlns: TagManager::XMLNS).each do |link| next if [TagManager::TYPES[:group], TagManager::TYPES[:collection]].include? link['ostatus:object-type'] - url = Addressable::URI.parse(link['href']) - - mentioned_account = if TagManager.instance.web_domain?(url.host) - Account.find_local(url.path.gsub('/users/', '')) - else - Account.find_by(url: link['href']) || FetchRemoteAccountService.new.call(link['href']) - end + mentioned_account = account_from_href(link['href']) next if mentioned_account.nil? || processed_account_ids.include?(mentioned_account.id) @@ -178,6 +173,16 @@ class ProcessFeedService < BaseService end end + def account_from_href(href) + url = Addressable::URI.parse(href) + + if TagManager.instance.web_domain?(url.host) + Account.find_local(url.path.gsub('/users/', '')) + else + Account.find_by(uri: href) || Account.find_by(url: href) || FetchRemoteAccountService.new.call(href) + end + end + def hashtags_from_xml(parent, xml) tags = xml.xpath('./xmlns:category', xmlns: TagManager::XMLNS).map { |category| category['term'] }.select(&:present?) ProcessHashtagsService.new.call(parent, tags) @@ -234,6 +239,10 @@ class ProcessFeedService < BaseService xml.at_xpath('./xmlns:content', xmlns: TagManager::XMLNS).content end + def content_language(xml = @xml) + xml.at_xpath('./xmlns:content', xmlns: TagManager::XMLNS)['xml:lang']&.presence || 'en' + end + def content_warning(xml = @xml) xml.at_xpath('./xmlns:summary', xmlns: TagManager::XMLNS)&.content || '' end |