diff --git a/app/services/broadcasts/welcome_notification/generator.rb b/app/services/broadcasts/welcome_notification/generator.rb index 3e6be1cee..e6ecf6b82 100644 --- a/app/services/broadcasts/welcome_notification/generator.rb +++ b/app/services/broadcasts/welcome_notification/generator.rb @@ -31,6 +31,7 @@ module Broadcasts return if received_notification?(welcome_broadcast) || commented_on_welcome_thread? || user.created_at > 3.hours.ago Notification.send_welcome_notification(user.id, welcome_broadcast.id) + # Setting @notification_enqueued here prevents us from sending a user two welcome notifications in one day. @notification_enqueued = true end @@ -45,6 +46,7 @@ module Broadcasts return if user_is_following_tags? || received_notification?(customize_feed_broadcast) || user.created_at > 3.days.ago Notification.send_welcome_notification(user.id, customize_feed_broadcast.id) + @notification_enqueued = true end def send_ux_customization_notification diff --git a/spec/services/broadcasts/welcome_notification/generator_spec.rb b/spec/services/broadcasts/welcome_notification/generator_spec.rb index 6ca1acddd..76c7ecdf6 100644 --- a/spec/services/broadcasts/welcome_notification/generator_spec.rb +++ b/spec/services/broadcasts/welcome_notification/generator_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Broadcasts::WelcomeNotification::Generator, type: :service do end.to not_change(user.notifications, :count) end - it "does not send a notification and if no active broadcast exists" do + it "does not send a notification if no active broadcast exists" do welcome_broadcast.update!(active: false) expect do sidekiq_perform_enqueued_jobs { described_class.call(user.id) }