docbrown/app/workers/broadcasts/send_welcome_notifications_worker.rb
Michael Kohl 6dfabd578f
Rename SiteConfig to Settings::General (#13573)
* Rename SiteConfig

* More renaming

* Update spec

* Update mandatory settings mapping

* More renaming

* e2e test fixes

* You have a rename, and you have a rename

* Spec fix

* More changes

* Temporarily disable specs

* After-merge update

* Undo rename for migration

* undo rename of DUS

* Fix DUS

* Fix merge problem

* Remove redundant DUS

* Fix specs

* Remove unused code

* Change wrong class name

* More cleanup

* Re-add missing values to constant

* Fix constant

* Fix spec

* Remove obsolete fields

* Add accidentally removed field

* Update spec

* Move methods from Settings::General to ForemInstance

* Remove unneeded model

* Change mentions of 'site config'
2021-05-21 14:45:37 +02:00

21 lines
884 B
Ruby

module Broadcasts
class SendWelcomeNotificationsWorker
include Sidekiq::Worker
sidekiq_options queue: :medium_priority, retry: 15
def perform
# In order to prevent new users from receiving multiple welcome notifications in a day,
# a feature_live_date is required. The script will only be effective after feature_live_date
# and will ultimately be superseded by 7.days.ago when it's larger than feature_live_date.
return unless Settings::General.welcome_notifications_live_at
notifications_live_at = Settings::General.welcome_notifications_live_at
week_ago = 7.days.ago
latest_date = notifications_live_at > week_ago ? notifications_live_at : week_ago
User.select(:id).where("created_at > ?", latest_date).find_each do |user|
Broadcasts::WelcomeNotification::Generator.call(user.id)
end
end
end
end