diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 93dbba71cc..f2989c8f03 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -5,6 +5,8 @@ class ApplicationMailer < ActionMailer::Base OPERATIONS_EMAIL = "hcb@hackclub.com" + ENGINEERING_EMAIL = "hcb-engr@hackclub.com" + DOMAIN = Rails.env.production? ? "hackclub.com" : "staging.hcb.hackclub.com" default from: "HCB " layout "mailer/default" diff --git a/config/blazer.yml b/config/blazer.yml index a1cdb77680..b547c51f6c 100644 --- a/config/blazer.yml +++ b/config/blazer.yml @@ -79,7 +79,8 @@ user_method: blazer_current_user # before_action_method: require_admin # email to send checks from -from_email: hcb@hackclub.com +# Bounces and auto-replies land back here, so keep it off Intercom. +from_email: hcb-engr@hackclub.com # webhook for Slack # slack_webhook_url: <%= ENV["BLAZER_SLACK_WEBHOOK_URL"] %> diff --git a/config/initializers/blazer.rb b/config/initializers/blazer.rb new file mode 100644 index 0000000000..38ee9f6a08 --- /dev/null +++ b/config/initializers/blazer.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +Rails.application.config.to_prepare do + Blazer::Check.class_eval do + after_initialize do + self.emails = ApplicationMailer::ENGINEERING_EMAIL if new_record? && emails.blank? + end + end +end diff --git a/db/migrate/20260808175000_point_blazer_checks_at_engineering.rb b/db/migrate/20260808175000_point_blazer_checks_at_engineering.rb new file mode 100644 index 0000000000..b893ec9964 --- /dev/null +++ b/db/migrate/20260808175000_point_blazer_checks_at_engineering.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +# Existing checks still notify hcb@, which lands in Intercom. +# Migrate all checks that use operations email to use engr email. + +class PointBlazerChecksAtEngineering < ActiveRecord::Migration[8.1] + OPERATIONS_EMAIL = "hcb@hackclub.com" + ENGINEERING_EMAIL = "hcb-engr@hackclub.com" + + def up + Blazer::Check.where("emails ILIKE ?", "%#{OPERATIONS_EMAIL}%").find_each do |check| + recipients = check.emails.to_s.split(",").map { |email| email.strip.downcase } + rewritten = recipients.map { |email| email == OPERATIONS_EMAIL ? ENGINEERING_EMAIL : email }.uniq + next if rewritten == recipients + + check.update_columns(emails: rewritten.join(", ")) + end + end + + def down + end + +end diff --git a/db/schema.rb b/db/schema.rb index 6793989768..87e9ae2754 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,7 +12,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_08_05_120000) do +ActiveRecord::Schema[8.1].define(version: 2026_08_08_175000) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_catalog.plpgsql"