Fix atom feeds after first message

Fixes COMMS-1115

Test Plan:
  * Create a new source that can generate atom feeds (or ask landon
    really nicely as he has one already set up)
  * Register rss feed in announcements for your course
  * Add a new item to the atom feed.
  * Run the following from the rails console

        e = ExternalFeed.find <id>
        e.refresh_at = 1.day.ago
        e.save!
        ExternalFeedAggregator.new.process

  * Reload your annoucement page and notice that a new announcement has
    been created from the atom feed
  * Add another atom feed and do it again. It was only the second+ items
    that were having issues.

Change-Id: I46bf417b095d66d7a030bfb0e025f8f9924e1a0b
Reviewed-on: https://gerrit.instructure.com/167108
Reviewed-by: Aaron Hsu <ahsu@instructure.com>
QA-Review: Steven Burnett <sburnett@instructure.com>
Product-Review: Steven Burnett <sburnett@instructure.com>
Tested-by: Jenkins
This commit is contained in:
Landon Gilbert-Bland 2018-10-04 10:57:45 -06:00
parent 37470d9b52
commit 5e39e31da1
1 changed files with 1 additions and 1 deletions

View File

@ -132,6 +132,7 @@ class ExternalFeed < ActiveRecord::Base
uuid = item.id || Digest::MD5.hexdigest("#{item.title}#{item.published.utc.strftime('%Y-%m-%d')}")
entry = self.external_feed_entries.where(uuid: uuid).first
entry ||= self.external_feed_entries.where(url: item.links.alternate.to_s).first
author = item.authors.first || OpenObject.new
description = entry && entry.message
if !description || description.empty?
description = "<a href='#{ERB::Util.h(item.links.alternate.to_s)}'>#{ERB::Util.h(t(:original_article, "Original article"))}</a><br/><br/>"
@ -150,7 +151,6 @@ class ExternalFeed < ActiveRecord::Base
end
return nil if self.header_match && !item.title.downcase.include?(self.header_match.downcase)
return nil if (item.published && self.created_at > item.published rescue false)
author = item.authors.first || OpenObject.new
description = "<a href='#{ERB::Util.h(item.links.alternate.to_s)}'>#{ERB::Util.h(t(:original_article, "Original article"))}</a><br/><br/>"
description += format_description(item.content || item.title)
entry = self.external_feed_entries.new(