mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 13:08:40 +08:00
Previously, the RSS Polling plugin's admin page predated Discourse's admin interface guidelines: it was a single inline-editable table with no breadcrumbs or page header, it truncated long feed URLs, it required horizontal scrolling on mobile, and it gave admins no way to verify a feed before saving it. This change rebuilds the page on the standard plugin "show route" structure (breadcrumbs, page header, and Settings + Feeds tabs) with a `d-table` feed list and dedicated FormKit new/edit routes, so the UI now matches the rest of the admin interface and works on mobile. It also: - Adds a **Test feed** dry-run that fetches a feed and previews which items would be imported or skipped, with plain-language reasons, so admins can validate a feed (and fix setup errors) before saving it. - Adds the `rss_polling_feed_request_timeout` and `rss_polling_verbose_logging` site settings. - Extracts the fetch/parse and import/skip logic into `FeedFetcher` and `FeedAnalyzer`, shared by the poll job and the new preview so the dry-run and the real import always agree. - Normalizes feed dates and categories so Atom feeds (which use `<updated>` and `term`-style `<category>` elements) are handled like RSS, and returns a clean error instead of a 500 when a feed cannot be read. --------- Co-authored-by: Martin Brennan <martin@discourse.org>
55 lines
1.4 KiB
Ruby
Vendored
55 lines
1.4 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseRssPolling
|
|
class RssFeed < ActiveRecord::Base
|
|
self.ignored_columns += %i[author]
|
|
|
|
belongs_to :user, optional: true
|
|
has_many :poll_attempts, class_name: "DiscourseRssPolling::PollAttempt", dependent: :delete_all
|
|
|
|
validates :url, presence: true
|
|
|
|
scope :enabled, -> { where(enabled: true) }
|
|
|
|
def user
|
|
super || Discourse.system_user
|
|
end
|
|
|
|
def poll(inline: false, force: false)
|
|
args = {
|
|
rss_feed_id: id,
|
|
feed_url: url,
|
|
user_id: user_id,
|
|
discourse_category_id: category_id,
|
|
discourse_tags: tags&.split(","),
|
|
feed_category_filter: category_filter,
|
|
force: force,
|
|
}
|
|
|
|
if inline
|
|
Jobs::DiscourseRssPolling::PollFeed.new.execute(args)
|
|
else
|
|
Jobs.enqueue("DiscourseRssPolling::PollFeed", args)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: discourse_rss_polling_rss_feeds
|
|
#
|
|
# id :bigint not null, primary key
|
|
# category_filter :string
|
|
# enabled :boolean default(TRUE), not null
|
|
# tags :string
|
|
# url :string not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# category_id :integer
|
|
# user_id :bigint
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_discourse_rss_polling_rss_feeds_on_user_id (user_id)
|
|
#
|