whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject [whimsy] branch master updated: project/icla add mock mail delivery to discuss and vote actions
Date Thu, 01 Feb 2018 01:32:24 GMT
This is an automated email from the ASF dual-hosted git repository.

clr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new a70c4a6  project/icla add mock mail delivery to discuss and vote actions
a70c4a6 is described below

commit a70c4a6f782160dc673cf71a4bd6d7c578eabda7
Author: Craig L Russell <craig.russell@oracle.com>
AuthorDate: Wed Jan 31 17:32:15 2018 -0800

    project/icla add mock mail delivery to discuss and vote actions
---
 www/project/icla/main.rb                       |  3 +++
 www/project/icla/views/actions/discuss.json.rb | 24 ++++++++++++++++++++----
 www/project/icla/views/actions/vote.json.rb    | 21 +++++++++++----------
 3 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/www/project/icla/main.rb b/www/project/icla/main.rb
index 68959c1..4b6e097 100755
--- a/www/project/icla/main.rb
+++ b/www/project/icla/main.rb
@@ -10,6 +10,9 @@ require 'wunderbar/bootstrap/theme'
 require 'ruby2js/filter/functions'
 require 'ruby2js/filter/require'
 require 'json'
+require 'mail'
+
+ASF::Mail.configure
 
 disable :logging # suppress log of requests to stderr/error.log
 
diff --git a/www/project/icla/views/actions/discuss.json.rb b/www/project/icla/views/actions/discuss.json.rb
index 333d1e1..bf0d57a 100644
--- a/www/project/icla/views/actions/discuss.json.rb
+++ b/www/project/icla/views/actions/discuss.json.rb
@@ -2,6 +2,7 @@ require 'socket'
 require 'net/http'
 require 'pathname'
 require 'json'
+require 'mail'
 
 # find pmc and user information
 # all ppmcs are also pmcs but not all pmcs are ppmcs
@@ -11,7 +12,8 @@ ppmc = ASF::Podling.find(@pmc)
 pmc_type = if ppmc and ppmc.status == 'current' then 'PPMC' else 'PMC' end
 
 user = ASF::Person.find(env.user)
-
+user_email = user.id + '@apache.org'
+subject = params['subject']
 
 begin
   Socket.getaddrinfo(@iclaemail[/@(.*)/, 1].untaint, 'smtp')
@@ -31,7 +33,7 @@ comments = [{:member => @proposer, :timestamp => date, :comment =>
comment}]
 discussion = {
   :phase => 'discuss',
   :proposer => @proposer,
-  :subject => @subject,
+  :subject => subject,
   :project => @pmc,
   :contributor => contributor,
   :comments => comments
@@ -45,8 +47,6 @@ discussion_json = discussion.to_json
 file_name = '/srv/icla/' + token + '.json'
 File.open(file_name.untaint, 'w') {|f|f.write(discussion_json)}
 
-# create the email to the pmc
-
 # add user and pmc emails to the response
 _userEmail "#{user.public_name} <#{user.mail.first}>" if user
 _pmcEmail "private@#{pmc.mail_list}.apache.org" if pmc
@@ -54,6 +54,22 @@ _pmcEmail "private@#{pmc.mail_list}.apache.org" if pmc
 path = Pathname.new(env['REQUEST_URI']) + "../../?token=#{token}"
 scheme = env['rack.url_scheme'] || 'https'
 link = "#{scheme}://#{env['HTTP_HOST']}#{path}"
+body_text = %{#{comment}
+
+Use this link to discuss:
+#{link}
+}
+
+# create the email to the pmc
+mail = Mail.new do
+  to user_email
+  from user_email.untaint
+  subject subject
+  text_part do
+    body body_text
+  end
+end
+mail.deliver
 
 # add token and invitation to the response
 _token token
diff --git a/www/project/icla/views/actions/vote.json.rb b/www/project/icla/views/actions/vote.json.rb
index 658c5ba..7565e33 100644
--- a/www/project/icla/views/actions/vote.json.rb
+++ b/www/project/icla/views/actions/vote.json.rb
@@ -11,8 +11,8 @@ pmc = ASF::Committee.find(@pmc)
 ppmc = ASF::Podling.find(@pmc)
 pmc_type = if ppmc and ppmc.status == 'current' then 'PPMC' else 'PMC' end
 user = ASF::Person.find(env.user)
-useremail = user.id + '@apache.org'
-
+user_email = user.id + '@apache.org'
+subject = params['subject']
 
 begin
   Socket.getaddrinfo(@iclaemail[/@(.*)/, 1].untaint, 'smtp')
@@ -54,18 +54,19 @@ _pmcEmail "private@#{pmc.mail_list}.apache.org" if pmc
 path = Pathname.new(env['REQUEST_URI']) + "../../?token=#{token}"
 scheme = env['rack.url_scheme'] || 'https'
 link = "#{scheme}://#{env['HTTP_HOST']}#{path}"
+body_text = %{#{comment}
+
+Use this link to vote:
+#{link}
+}
 
 # create the email to the pmc
 mail = Mail.new do
-  to useremail
-  from useremail
-  subject @subject
+  to user_email
+  from user_email.untaint
+  subject subject
   text_part do
-    body %{#{comment}
-    Use this link to vote:
-
-    #{link}
-    }
+    body body_text
   end
 end
 mail.deliver

-- 
To stop receiving notification emails like this one, please contact
clr@apache.org.

Mime
View raw message