Closed miguelcnf closed 8 years ago
Was it totally broken?
Yep iirc.
Preferably since params is defined in the main function just pull the prefix_subject into the main function and revert everything else back.
This error occurs also in handler-mailer-mailgun.rb
, my local fix looks like this.
diff --git a/bin/handler-mailer-mailgun.rb b/bin/handler-mailer-mailgun.rb
index 62ca7e9..fb0bde7 100755
--- a/bin/handler-mailer-mailgun.rb
+++ b/bin/handler-mailer-mailgun.rb
@@ -41,14 +41,6 @@ class Mailer < Sensu::Handler
@event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
end
- def prefix_subject
- if params[:subject_prefix]
- params[:subject_prefix] + ' '
- else
- ''
- end
- end
-
def handle
params = {
mail_to: settings['mailer-mailgun']['mail_to'],
@@ -68,6 +60,7 @@ class Mailer < Sensu::Handler
Status: #{@event['check']['status']}
Occurrences: #{@event['occurrences']}
BODY
+ prefix_subject = params[:subject_prefix] + ' ' if params[:subject_prefix]
subject = "#{prefix_subject}#{action_to_string} - #{short_name}: #{@event['check']['notification']}"
mg_client = Mailgun::Client.new params[:mg_apikey]
diff --git a/bin/handler-mailer-ses.rb b/bin/handler-mailer-ses.rb
index f8457fe..2ab8173 100755
--- a/bin/handler-mailer-ses.rb
+++ b/bin/handler-mailer-ses.rb
@@ -24,14 +24,6 @@ class Mailer < Sensu::Handler
@event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
end
- def prefix_subject
- if params[:subject_prefix]
- params[:subject_prefix] + ' '
- else
- ''
- end
- end
-
def handle
params = {
mail_to: settings['mailer-ses']['mail_to'],
@@ -52,6 +44,7 @@ class Mailer < Sensu::Handler
Status: #{@event['check']['status']}
Occurrences: #{@event['occurrences']}
BODY
+ prefix_subject = params[:subject_prefix] + ' ' if params[:subject_prefix]
subject = "#{prefix_subject}#{action_to_string} - #{short_name}: #{@event['check']['notification']}"
ses = AWS::SES::Base.new(
@dpattmann put in a pull request for it and we will merge that
Pull request created https://github.com/sensu-plugins/sensu-plugins-mailer/pull/31
closed by #31
Happy to change if you guys prefer passing the params hash into prefix_subject as an argument.