discourse/plugins/discourse-rss-polling/config
Régis Hanol 25bd06dadd
FIX: RSS polling breaks silently after a username rename (#39460)
The discourse-rss-polling plugin stored the feed author as a plain
`author` string with no link to the users table. When a user was
renamed, the polling job's `User.find_by_username(old_name)` returned
nil, the job bailed with no log, and the feed silently stopped importing
posts. We've hit this repeatedly on enterprise sites, and every time the
fix is the same manual cleanup in the admin UI.

This commit moves the feed -> user association onto a proper `user_id`
foreign key, so renames (and user deletion) no longer break polling. It
also brings the plugin up to current Discourse conventions: a service
object for the update action, an ApplicationSerializer for the admin
list view, and a fabricator for specs.

What's in this commit:

* Migration adds `user_id` and an index, backfills from the legacy
`author` string via a case-insensitive match, defaults the rest to the
system user, drops the default on `author`, and marks the column
readonly so it cannot drift again. Follow-up post-deploy migration will
drop the column.

* `RssFeed` gains `belongs_to :user`, delegates `author_username` to the
user, ignores the legacy `author` column, and owns `#poll` (moved here
from the deleted `FeedSetting` DTO).

* `PollFeed` job now looks up the author by `user_id` first and keeps a
short-lived `author_username` fallback for jobs enqueued before deploy.
When the user cannot be resolved it falls back to the system user and
logs a warning instead of silently returning.

* `PollAllFeeds` scheduled job iterates `RssFeed.includes(:user)`
directly — no finder indirection.

* `DiscourseRssPolling::FeedSetting::Update` service replaces the
controller's inline parse/resolve/assign/render logic. The contract
validates presence of `feed_url` and `author_username` (previously a
blank username was silently saved as `user_id: nil`), normalizes the
tag-chooser's array-of-hashes shape, and produces the CSV the `tags`
column expects. Unknown usernames surface as an `on_model_not_found`
match with a proper i18n error in the toast.

* `FeedSettingSerializer < ApplicationSerializer` replaces the
`FeedSetting` DTO for the admin list view and reads `author_username`
live from the user association on every request, so the UI never shows a
stale name.

* `FeedSettingFinder` is removed — `by_embed_url` was dead and `.all` is
now a one-liner at its two call sites.

Ref - t/182280
2026-05-05 18:42:56 +02:00
..
locales FIX: RSS polling breaks silently after a username rename (#39460) 2026-05-05 18:42:56 +02:00
routes.rb
settings.yml