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 5b6507a Add server post action for discuss
5b6507a is described below
commit 5b6507a33fe957d39a4d19adb5ba5374fea3361a
Author: Craig L Russell <[email protected]>
AuthorDate: Mon Jan 29 12:30:55 2018 -0800
Add server post action for discuss
---
www/project/icla/views/actions/discuss.json.rb | 114 +++++++++++++++++++++++++
www/project/icla/views/pages/invite.js.rb | 71 ++++++++++++---
2 files changed, 175 insertions(+), 10 deletions(-)
diff --git a/www/project/icla/views/actions/discuss.json.rb
b/www/project/icla/views/actions/discuss.json.rb
new file mode 100644
index 0000000..b76b36f
--- /dev/null
+++ b/www/project/icla/views/actions/discuss.json.rb
@@ -0,0 +1,114 @@
+require 'socket'
+require 'net/http'
+require 'pathname'
+
+# find pmc and user information
+# all ppmcs are also pmcs but not all pmcs are ppmcs
+
+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)
+
+
+begin
+ Socket.getaddrinfo(@iclaemail[/@(.*)/, 1].untaint, 'smtp')
+
+ if ASF::Person.find_by_email(@iclaemail)
+ _error "ICLA already on file for #{@iclaemail}"
+ end
+rescue
+ _error 'Invalid domain name in email address'
+ _focus :iclaemail
+end
+
+# validate vote link
+if @votelink and not @votelink.empty?
+
+# verify that the link refers to lists.apache.org message on the project list
+ if not @votelink=~ /.*lists\.apache\.org.*/
+ _error "Please link to a message via lists.apache.org"
+ end
+ if not @votelink=~ /.*#{pmc.mail_list}(\.incubator)?\.apache\.org.*/
+ _error "Please link to the [RESULT][VOTE] message sent to the private
list."
+ end
+
+ # attempt to fetch the page
+ if @votelink =~ /^https?:/i
+ uri = URI.parse(@votelink)
+ http = Net::HTTP.new(uri.host.untaint, uri.port)
+ if uri.scheme == 'https'
+ http.use_ssl = true
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ end
+ request = Net::HTTP::Get.new(uri.request_uri.untaint)
+ response = http.request(request)
+ unless response.code.to_i < 400
+ _error "HTTP status #{response.code} for #{@votelink}"
+ _focus :votelink
+ end
+ else
+ _error 'Only http(s) links are accepted for vote links'
+ _focus :votelink
+ end
+
+end
+
+# validate notice link
+if @noticelink and not @noticelink.empty?
+
+ # verify that the link refers to lists.apache.org message on the proper list
+ if not @noticelink=~ /.*lists\.apache\.org.*/
+ _error "Please link to a message via lists.apache.org"
+ end
+ if pmc_type == 'PMC' and not @noticelink=~ /.*board@apache\.org.*/
+ _error "Please link to the NOTICE message sent to the board list."
+ end
+ if pmc_type == 'PPMC' and not @noticelink=~
/.*private@incubator\.apache\.org.*/
+ _error "Please link to the NOTICE message sent to the incubator private
list."
+ end
+
+ # attempt to fetch the page
+ if @noticelink =~ /^https?:/i
+ uri = URI.parse(@noticelink)
+ http = Net::HTTP.new(uri.host.untaint, uri.port)
+ if uri.scheme == 'https'
+ http.use_ssl = true
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ end
+ request = Net::HTTP::Get.new(uri.request_uri.untaint)
+ response = http.request(request)
+ unless response.code.to_i < 400
+ _error "HTTP status #{response.code} for #{@noticelink}"
+ _focus :noticelink
+ end
+ else
+ _error 'Only http(s) links are accepted for notice links'
+ _focus :noticelink
+ end
+
+end
+
+# 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
+
+# generate an invitation token
+date = Date.new.inspect
+token = pmc.name + date + Digest::MD5.hexdigest(@iclaemail)[0..5]
+path = Pathname.new(env['REQUEST_URI']) + "../../form?token=#{token}"
+scheme = env['rack.url_scheme'] || 'https'
+link = "#{scheme}://#{env['HTTP_HOST']}#{path}"
+
+# add token and invitation to the response
+_token token
+_message %{Dear #{@iclaname},
+
+Click on this link to accept:
+#{link}
+
+Regards,
+#{user.public_name if user}
+On behalf of the #{pmc.name} project
+}
diff --git a/www/project/icla/views/pages/invite.js.rb
b/www/project/icla/views/pages/invite.js.rb
index 056bdfa..b7f9a40 100644
--- a/www/project/icla/views/pages/invite.js.rb
+++ b/www/project/icla/views/pages/invite.js.rb
@@ -18,6 +18,7 @@ class Invite < Vue
@pmcOrPpmc = ''
@phasePrefix = ''
@member = Server.data.member
+ @pmc_mail = Server.data.pmc_mail
# initialize conditional text
@showPMCVoteLink = false;
@@ -32,8 +33,9 @@ class Invite < Vue
@showVoteFrame = false;
@showPhaseFrame = false;
@showRoleFrame = false;
- @discussBody = ''
+ @discussComment = ''
@voteBody = ''
+ @bodyText = ''
end
def render
@@ -177,6 +179,8 @@ class Invite < Vue
onClick: -> {@role = :committer;
@subject = @subjectPhase + ' Invite ' + @iclaname +
' to become a committer for ' + @pmc
+ @bodyText = 'I propose to invite ' + @iclaname +
+ ' to become a committer.'
}
_span @phasePrefix +
' invite to become a committer'
@@ -187,6 +191,8 @@ class Invite < Vue
onClick: -> {@role = :pmc;
@subject = @subjectPhase + ' Invite ' + @iclaname +
' to become committer and ' + @pmcOrPPMC + ' member for ' + @pmc
+ @bodyText = 'I propose to invite ' + @iclaname +
+ ' to become a committer and ' + @pmcOrPPMC + ' member.'
}
_span @phasePrefix +
' invite to become a committer and ' + @pmcOrPPMC + ' member'
@@ -198,6 +204,8 @@ class Invite < Vue
onClick: -> {@role = :invite;
@subject = @subjectPhase + ' Invite ' + @iclaname +
' to submit an ICLA for ' + @pmc
+ @bodyText = 'I propose to invite ' + @iclaname +
+ ' to submit an ICLA.'
}
_span @phasePrefix +
' invite to submit an ICLA'
@@ -207,11 +215,16 @@ class Invite < Vue
end
end
if @showDiscussFrame
+ _div 'From: ' + @member
+ _div 'To: private@' + @pmc_mail[@pmc] + '.apache.org'
_div 'Subject: ' + @subject
+ _p
+ _span @bodyText
+ _p
_textarea.form_control rows: 4,
- placeholder: 'This is a discussion for the candidate',
- name: 'discussBody', value: @discussBody,
- onChange: self.setDiscussBody
+ placeholder: 'Here are my reasons:',
+ name: 'discussComment', value: @discussComment,
+ onChange: self.setdiscussComment
end
if @showVoteFrame
_div 'Subject: ' + @subject
@@ -272,6 +285,41 @@ class Invite < Vue
_p
end
+ #
+ # Hidden form: preview discussion email
+ #
+ _div.modal.fade.discussion_preview! do
+ _div.modal_dialog do
+ _div.modal_content do
+ _div.modal_header do
+ _button.close "\u00d7", type: 'button', data_dismiss: 'modal'
+ _h4 'Preview Discussion Email'
+ end
+
+ _div.modal_body do
+ # headers
+ _div do
+ _b 'From: '
+ _span @member
+ end
+ _div do
+ _b 'To: '
+ _span @pmcEmail
+ end
+ _div do
+ _b
+ _span @message
+ end
+ end
+
+ _div.modal_footer do
+ _button.btn.btn_default 'Cancel', data_dismiss: 'modal'
+ _button.btn.btn_primary 'Mock Send', onClick: self.mockSend
+ end
+ end
+ end
+ end
+ _p
# when the form is initially loaded, set the focus on the iclaname field
def mounted()
@@ -322,8 +370,8 @@ class Invite < Vue
@disabled = false;
end
- def setDiscussBody(event)
- @discussBody = event.target.value
+ def setdiscussComment(event)
+ @discussComment = event.target.value
end
def selectVote(event)
@@ -480,20 +528,23 @@ class Invite < Vue
iclaname: @iclaname,
iclaemail: @iclaemail,
pmc: @pmc,
- discussBody: @discussBody
+ proposer: @member,
+ subject: @subject,
+ discussComment: @discussComment
}
@disabled = true
@alert = nil
- post 'validate', data do |response|
+ post 'discuss', data do |response|
@disabled = false
@alert = response.error
@memberEmail = response.memberEmail
@pmcEmail = response.pmcEmail
- @invitation = response.invitation
+ @discussion = response.discussion
@token = response.token
+ console.log(@token)
document.getElementById(response.focus).focus() if response.focus
- jQuery('#invitation-preview').modal(:show) unless @alert
+ jQuery('#discussion-preview').modal(:show) unless @alert
end
end
def previewVote()
--
To stop receiving notification emails like this one, please contact
[email protected].