From b2c3675a9ba9d1703a8cd88f6ff2e44797ca69cb Mon Sep 17 00:00:00 2001 From: Luay Bseiso Date: Tue, 23 Jan 2024 11:21:47 +0300 Subject: [PATCH] include batch_id header when sending emails --- lib/sendgrid.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/sendgrid.rb b/lib/sendgrid.rb index 7c68943..998cdec 100644 --- a/lib/sendgrid.rb +++ b/lib/sendgrid.rb @@ -28,7 +28,7 @@ class << self :default_footer_text, :default_spamcheck_score, :default_sg_unique_args end attr_accessor :sg_category, :sg_options, :sg_disabled_options, :sg_recipients, :sg_substitutions, - :subscriptiontrack_text, :footer_text, :spamcheck_score, :sg_unique_args, :sg_send_at + :subscriptiontrack_text, :footer_text, :spamcheck_score, :sg_unique_args, :sg_send_at, :sg_batch_id end # NOTE: This commented-out approach may be a "safer" option for Rails 3, but it @@ -108,6 +108,11 @@ def sendgrid_send_at(utc_timestamp) @sg_send_at = utc_timestamp end + # Call within mailer method to set send time for this mail + def sendgrid_batch_id(batch_id) + @sg_batch_id = batch_id + end + # Call within mailer method to set unique args for this email. # Merged with class-level unique args, if any exist. def sendgrid_unique_args(unique_args = {}) @@ -228,6 +233,7 @@ def sendgrid_json_headers(mail) #Set send_at if set by the user header_opts[:send_at] = @sg_send_at unless @sg_send_at.blank? + header_opts[:batch_id] = @sg_batch_id unless @sg_batch_id.blank? # Set multi-recipients if @sg_recipients && !@sg_recipients.empty?