discourse/config/initializers/015-track-upcoming-change-toggle.rb
David Battersby 5f710afcc3
FEATURE: better email subject lines (#36040)
When enabled, the email subject lines will be more concise, with a focus
on only essential information. This makes it easier for users to quickly
understand the purpose of the email at a glance.

This feature uses upcoming changes to roll out the changes to email
subjects.

The main change to be aware of is that when enabling this upcoming
change, it will update the site setting for `email_subject`. Disabling
the upcoming change will revert the email subject setting back to it's
default value, meaning that customizations to the setting could be lost.

Internal ref - /t/154689
2026-04-24 15:14:10 +04:00

31 lines
1.3 KiB
Ruby

# frozen_string_literal: true
Rails.application.config.after_initialize { UpcomingChanges.clear_caches! }
#
# Similar to 014-track-setting-changes.rb, we can react to upcoming changes
# being enabled/or disabled here for more complicated scenarios, where
# we are not just changing UI or behaviour when the state of the underlying
# setting is changed.
#
# We need to do this separately from 014-track-setting-changes.rb because
# we don't actually change the underlying setting value in the database
# when an upcoming change is automatically promoted. See UpcomingChanges::NotifyPromotions
# for further context.
#
# We do also send these events when admins manually opt-in or opt-out of an upcoming change
# via the UI and the UpcomingChanges::Toggle service.
DiscourseEvent.on(:upcoming_change_enabled) do |setting_name|
# Respond to event here, e.g. if setting_name == :enable_form_templates do X.
if setting_name == :simple_email_subject
SiteSetting::Action::SimpleEmailSubjectToggled.call(params: { setting_enabled: true })
end
end
DiscourseEvent.on(:upcoming_change_disabled) do |setting_name|
# Respond to event here, e.g. if setting_name == :enable_form_templates do X.
if setting_name == :simple_email_subject
SiteSetting::Action::SimpleEmailSubjectToggled.call(params: { setting_enabled: false })
end
end