You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2016/05/11 21:55:13 UTC
[whimsy] branch master updated: Extract sendMail method
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 7e5afb1 Extract sendMail method
7e5afb1 is described below
commit 7e5afb14057165fef3dca31265419e89ce2f177d
Author: Sebb <se...@apache.org>
AuthorDate: Wed May 11 22:55:04 2016 +0100
Extract sendMail method
---
www/roster/public_json_common.rb | 44 ++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/www/roster/public_json_common.rb b/www/roster/public_json_common.rb
index 376dd36..2202004 100644
--- a/www/roster/public_json_common.rb
+++ b/www/roster/public_json_common.rb
@@ -81,6 +81,28 @@ def public_json_output_file(info, file)
end
+def sendMail(subject, body)
+ begin
+ require 'mail'
+ ASF::Mail.configure
+ ldaphost = ASF::LDAP.host()
+ mail = Mail.new do
+ from 'Public JSON file updates <de...@whimsical.apache.org>'
+ to 'Notification List <no...@whimsical.apache.org>'
+ subject subject
+ body body
+ end
+ # in spite of what the docs say, this does not seem to work in the body above
+ mail.charset = 'utf-8'
+ # Replace .mail suffix with more accurate one
+ mail.message_id = "<#{Mail.random_tag}@#{::Socket.gethostname}.apache.org>"
+ # deliver mail
+ mail.deliver!
+ rescue => e
+ Wunderbar.warn "sendMail failed with exception: #{e}"
+ end
+end
+
# Massage the strings to drop the timestamps so spurious changes are not reported/saved
def removeTimestamps(s)
return s.sub(/ "last_updated": "[^"]+",/, '')
@@ -111,25 +133,13 @@ def write_output(file, results)
stdin_data: results + "\n")
if err.empty? and rc.exitstatus == 1
puts "\n#{out}\n"
- require 'mail'
- ASF::Mail.configure
ldaphost = ASF::LDAP.host()
- mail = Mail.new do
- from 'Public JSON file updates <de...@whimsical.apache.org>'
- to 'Notification List <no...@whimsical.apache.org>'
- subject "Difference(s) in #{file}"
- if ldaphost
- body "\n#{ldaphost}\n\n#{out}\n"
- else
- body "\n#{out}\n"
- end
+ if ldaphost
+ body = "\n#{ldaphost}\n\n#{out}\n"
+ else
+ body = "\n#{out}\n"
end
- # in spite of what the docs say, this does not seem to work in the body above
- mail.charset = 'utf-8'
- # Replace .mail suffix with more accurate one
- mail.message_id = "<#{Mail.random_tag}@#{::Socket.gethostname}.apache.org>"
- # deliver mail
- mail.deliver!
+ sendMail("Difference(s) in #{file}", body)
end
rescue => e
Wunderbar.warn "Got exception #{e}"
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].