discourse/app/services/upcoming_changes/track.rb
Martin Brennan c6d8fcf95f
FIX: Do not notify admins of upcoming changes on new sites (#38890)
There is point in notifying admins on brand new sites (< 1h old), the
upcoming change system is more about notifying admins of changes to
established sites.

This commit uses the Migration::Helpers.new_site? helper to determine
whether to notify of available & promotions for upcoming changes.
2026-03-27 12:32:12 +10:00

43 lines
1.3 KiB
Ruby
Vendored

# frozen_string_literal: true
# Handles tracking the addition, removal, and status changes of upcoming changes,
# via UpcomingChangeEvent records, and subsequently notifying admins that the
# upcoming change is available for them to opt-in to, based on certain criteria
# that are explained in the Action classes.
#
# Called from the Jobs::Scheduled::CheckUpcomingChanges job.
class UpcomingChanges::Track
include Service::Base
model :all_admins
model :added_changes, optional: true
model :removed_changes, optional: true
model :status_changes, optional: true
private
def fetch_all_admins
User.human_users.admins
end
def fetch_added_changes(all_admins:)
result = UpcomingChanges::Action::TrackNotifyAddedChanges.call(all_admins:)
context[:notified_admins_for_added_changes] = result[:notified_changes]
result[:added_changes]
end
def fetch_removed_changes
UpcomingChanges::Action::TrackRemovedChanges.call
end
def fetch_status_changes(added_changes:, removed_changes:, all_admins:)
result =
UpcomingChanges::Action::TrackNotifyStatusChanges.call(
all_admins:,
added_changes:,
removed_changes:,
)
context[:notified_admins_for_added_changes] += result[:notified_changes]
result[:status_changes]
end
end