From 43d170002ab853306a68ca0f5166ce1ad130b1f7 Mon Sep 17 00:00:00 2001 From: Ruy Diaz Date: Wed, 16 Mar 2016 19:54:15 -0700 Subject: [PATCH 1/3] Remove duplicate dependencies --- sendgrid.gemspec | 3 --- 1 file changed, 3 deletions(-) diff --git a/sendgrid.gemspec b/sendgrid.gemspec index ff125f0..a33430b 100644 --- a/sendgrid.gemspec +++ b/sendgrid.gemspec @@ -45,20 +45,17 @@ Gem::Specification.new do |s| s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, ["~> 1.0.0"]) s.add_development_dependency(%q, ["~> 1.5.1"]) - s.add_runtime_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, ["~> 1.0.0"]) s.add_dependency(%q, ["~> 1.5.1"]) - s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, ["~> 1.0.0"]) s.add_dependency(%q, ["~> 1.5.1"]) - s.add_dependency(%q, [">= 0"]) end end From 061d57e8ed1a408d4a724643a1c3129d3e7377b4 Mon Sep 17 00:00:00 2001 From: Bruce White Date: Mon, 7 Nov 2022 12:05:17 -0700 Subject: [PATCH 2/3] Add support for unsubscribe_group and bypass_unsubscribe_management --- lib/sendgrid.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/sendgrid.rb b/lib/sendgrid.rb index 7c68943..e8faecf 100644 --- a/lib/sendgrid.rb +++ b/lib/sendgrid.rb @@ -161,7 +161,18 @@ def sendgrid_ganalytics_options(options) @ganalytics_options = [] options.each { |option| @ganalytics_options << option if VALID_GANALYTICS_OPTIONS.include?(option[0].to_sym) } end - + + # Call within mailer method to set unsubscribe_group_id + def sendgrid_unsubscribe_group_id(unsubscribe_group_id) + @sg_asm_group_id = unsubscribe_group_id + end + + # Call within mailer method to bypass unsubscribe management + # IE email will be sent even if recipient is unsubscribed + def sendgrid_bypass_unsubscribe_management + @sg_bypass_unsubscribe_management = true + end + # only override the appropriate methods for the current ActionMailer version if ActionMailer::Base.respond_to?(:mail) @@ -206,7 +217,7 @@ def sendgrid_json_headers(mail) #if not called within the mailer method, this will be nil so we default to empty hash @sg_unique_args = @sg_unique_args || {} - + # set the unique arguments if @sg_unique_args || self.class.default_sg_unique_args unique_args = self.class.default_sg_unique_args || {} @@ -254,6 +265,12 @@ def sendgrid_json_headers(mail) header_opts[:filters] = filters if filters && !filters.empty? end + # Set unsubscribe group + header_opts[:asm_group_id] = @sg_asm_group_id if @sg_asm_group_id + + # Enable bypass unsubscribe management + header_opts[:filters][:bypass_unsubscribe_management] = true if @sg_bypass_unsubscribe_management + header_opts.to_json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3') end From 8e23aa0c3b5e2630893f5b07d974b561cd48d102 Mon Sep 17 00:00:00 2001 From: Bruce White Date: Mon, 28 Nov 2022 10:34:11 -0700 Subject: [PATCH 3/3] Remove bypass_unsubscribe_management --- lib/sendgrid.rb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/sendgrid.rb b/lib/sendgrid.rb index e8faecf..92d5e78 100644 --- a/lib/sendgrid.rb +++ b/lib/sendgrid.rb @@ -167,12 +167,6 @@ def sendgrid_unsubscribe_group_id(unsubscribe_group_id) @sg_asm_group_id = unsubscribe_group_id end - # Call within mailer method to bypass unsubscribe management - # IE email will be sent even if recipient is unsubscribed - def sendgrid_bypass_unsubscribe_management - @sg_bypass_unsubscribe_management = true - end - # only override the appropriate methods for the current ActionMailer version if ActionMailer::Base.respond_to?(:mail) @@ -268,9 +262,6 @@ def sendgrid_json_headers(mail) # Set unsubscribe group header_opts[:asm_group_id] = @sg_asm_group_id if @sg_asm_group_id - # Enable bypass unsubscribe management - header_opts[:filters][:bypass_unsubscribe_management] = true if @sg_bypass_unsubscribe_management - header_opts.to_json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3') end