Class: SystemMailer
- Inherits:
-
InternalNotificationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- InternalNotificationMailer
- SystemMailer
- Defined in:
- app/mailers/system_mailer.rb
Overview
Platform/system alerts: migrations, bounces, inbound-email issues, generic.
Extracted from the former InternalMailer god object.
Constant Summary collapse
- TEAM_EMAIL =
Internal team distribution list for ops / system notifications.
'heatwaveteam@warmlyyours.com'
Instance Method Summary collapse
- #abandoned_cart_problems_alert(problems) ⇒ Object
- #blog_comment(post_comment) ⇒ Object
- #contact_spanish_form(contact, form_params, upload) ⇒ Object
-
#data_migration_event(migration_id, event, error_message = nil) ⇒ Mail::Message?
Notifies the team of a background data migration lifecycle event (:started, :succeeded, :failed).
- #email_address_bounced_notification(communication_recipient) ⇒ Object
- #generic_mailer(options) ⇒ Object
- #inbound_email_processing_issues(failed_emails = nil) ⇒ Object
-
#legacy_review_link_clicked(link_type:, order_reference:, clicked_at:, request_ip: nil, user_agent: nil) ⇒ Object
Notifies team when a customer clicks a legacy review link from an old email This helps identify customers who need to be sent a new Reviews.io review request.
Methods inherited from InternalNotificationMailer
Methods included from SendgridSmtpApi::InternalMailerHeaders
Methods inherited from ApplicationMailer
Instance Method Details
#abandoned_cart_problems_alert(problems) ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/mailers/system_mailer.rb', line 43 def abandoned_cart_problems_alert(problems) @problems = problems mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'Heatwave Team <heatwaveteam@warmlyyours.com>', subject: 'Unable to send abandoned cart email') end |
#blog_comment(post_comment) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'app/mailers/system_mailer.rb', line 74 def blog_comment(post_comment) @post_comment = post_comment @post = @post_comment.post @user = @post_comment.user mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'blog_comments@warmlyyours.com', cc: @user.present? ? @user.try(:primary_sales_rep).try(:email) : nil, subject: "New Comment on Blog Post '#{@post.subject}'") end |
#contact_spanish_form(contact, form_params, upload) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'app/mailers/system_mailer.rb', line 102 def contact_spanish_form(contact, form_params, upload) @upload = upload @contact = contact @content = form_params mail(from: ADMINISTRATOR_EMAIL, to: 'info+en+espanol@warmlyyours.com', subject: 'New contact through spanish form') end |
#data_migration_event(migration_id, event, error_message = nil) ⇒ Mail::Message?
Notifies the team of a background data migration lifecycle event
(:started, :succeeded, :failed). Wired from the online_migrations
notification subscribers + error_handler in
+config/initializers/online_migrations.rb+. Reloads the migration so the
email reflects current status / progress; the body links to the admin
dashboard for live tracking.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/mailers/system_mailer.rb', line 23 def data_migration_event(migration_id, event, = nil) @event = event.to_s @migration = OnlineMigrations::BackgroundDataMigrations::Migration.find_by(id: migration_id) return if @migration.nil? @error_message = .presence || @migration..presence @dashboard_url = admin_background_migration_url(@migration) verb = { 'started' => 'started', 'succeeded' => 'completed', 'failed' => 'FAILED' }.fetch(@event, @event) mail(to: TEAM_EMAIL, subject: "[Data migration] #{@migration.migration_name} #{verb}") end |
#email_address_bounced_notification(communication_recipient) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/mailers/system_mailer.rb', line 85 def email_address_bounced_notification(communication_recipient) @communication = communication_recipient.communication @email_address = communication_recipient.detail @reason = communication_recipient.state_response sender = @communication.sender_party&.email || @communication.sender @customer = communication_recipient.contact_point.try(:party).try(:customer) @rep = @customer&.primary_sales_rep notify_emails = [sender, @rep&.email].compact.uniq fallback_email = @customer&.customer_service_manager&.email_with_name notify_emails << fallback_email if notify_emails.empty? && fallback_email.present? return null_mail if notify_emails.blank? mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: notify_emails.uniq.join(','), subject: "Email communication bounced for #{@email_address}") end |
#generic_mailer(options) ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/mailers/system_mailer.rb', line 35 def generic_mailer() @subject = [:subject] || 'No Subject' @body = [:body] || 'Empty' [:from] ||= ADMINISTRATOR_EMAIL [:to] ||= ADMINISTRATOR_EMAIL mail() end |
#inbound_email_processing_issues(failed_emails = nil) ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/mailers/system_mailer.rb', line 51 def inbound_email_processing_issues(failed_emails = nil) @failed_emails = failed_emails || ActionMailbox::InboundEmail.where(status: 'failed') mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'Heatwave Team <heatwaveteam@warmlyyours.com>', subject: 'Inbound Email Processing Issues') end |
#legacy_review_link_clicked(link_type:, order_reference:, clicked_at:, request_ip: nil, user_agent: nil) ⇒ Object
Notifies team when a customer clicks a legacy review link from an old email
This helps identify customers who need to be sent a new Reviews.io review request
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/mailers/system_mailer.rb', line 61 def legacy_review_link_clicked(link_type:, order_reference:, clicked_at:, request_ip: nil, user_agent: nil) @link_type = link_type @order_reference = order_reference @clicked_at = clicked_at @request_ip = request_ip @user_agent = user_agent @order = Order.find_by(reference_number: order_reference) if order_reference.present? mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'heatwaveteam@warmlyyours.com', subject: "Legacy Review Link Clicked - Order #{order_reference || 'Unknown'}") end |