This is an automated email from the ASF dual-hosted git repository.
rubys 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 3cd6fb8 Enable the secretary to update the asf-secretary service group
3cd6fb8 is described below
commit 3cd6fb8cf64d7b4d151a7ff80ce7b4a616797378
Author: Sam Ruby <[email protected]>
AuthorDate: Fri Jun 30 18:19:31 2017 -0400
Enable the secretary to update the asf-secretary service group
---
www/roster/views/actions/service.json.rb | 56 ++++++++++++++++++++++++++++++++
www/roster/views/group.js.rb | 22 +++++++++----
2 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/www/roster/views/actions/service.json.rb
b/www/roster/views/actions/service.json.rb
new file mode 100644
index 0000000..d801686
--- /dev/null
+++ b/www/roster/views/actions/service.json.rb
@@ -0,0 +1,56 @@
+#
+# Add or remove a person from an service group in LDAP
+#
+
+if env.password
+ person = ASF::Person.find(@id)
+ service = ASF::Service.find(@group)
+
+ # update LDAP
+ ASF::LDAP.bind(env.user, env.password) do
+ if @action == 'add'
+ service.add(person)
+ elsif @action == 'remove'
+ service.remove(person)
+ end
+ end
+
+ # compose E-mail
+ action = (@action == 'add' ? 'added to' : 'removed from')
+ list = "#{@group} LDAP service"
+
+ details = [person.dn, service.dn]
+
+ from = ASF::Person.find(env.user)
+
+ # default to sending the message to the group
+ to = service.members
+ to << person unless to.include? person
+ to.delete from unless to.length == 1
+ to = to.map do |person|
+ "#{person.public_name} <#{person.id}@apache.org>".untaint
+ end
+
+ # other committees
+ to = '[email protected]' if service.id == 'asf-secretary'
+
+ # construct email
+ mail = Mail.new do
+ from "#{from.public_name} <#{from.id}@apache.org>".untaint
+ to to
+ bcc "[email protected]"
+ subject "#{person.public_name} #{action} #{list}"
+ body "Current roster can be found at:\n\n" +
+ " https://whimsy.apache.org/roster/group/#{service.id}\n\n" +
+ "LDAP details:\n\n #{details.join("\n ")}"
+ end
+
+ # Header for root@'s lovely email filters
+ mail.header['X-For-Root'] = 'yes'
+
+ # deliver email
+ mail.deliver!
+end
+
+# return updated committee info to the client
+Group.serialize(@group)
diff --git a/www/roster/views/group.js.rb b/www/roster/views/group.js.rb
index e7c04a2..afa7541 100644
--- a/www/roster/views/group.js.rb
+++ b/www/roster/views/group.js.rb
@@ -12,7 +12,7 @@ class Group < React
group = @group
members = group.members.keys().sort_by {|id| group.members[id]}
- if group.type == 'LDAP auth group'
+ if group.type == 'LDAP auth group' or group.id == 'asf-secretary'
auth = (members.include? @@auth.id or @@auth.secretary or @@auth.root)
else
auth = false
@@ -66,7 +66,7 @@ class Group < React
end
end
- _GroupConfirm group: group.id, update: self.update if auth
+ _GroupConfirm group: group, update: self.update if auth
end
# capture group on initial load
@@ -175,8 +175,8 @@ class GroupConfirm < React
_div.modal_body do
_p do
_span "#{@text} the "
- _code @@group
- _span " authorization group?"
+ _code @@group.id
+ _span " #{@@group.type}?"
end
end
@@ -204,17 +204,27 @@ class GroupConfirm < React
end
def post()
+ # identify the action
+ if @@group.type == 'LDAP auth group'
+ action = 'actions/authgroup'
+ elsif @@group.type == 'LDAP service'
+ action = 'actions/service'
+ else
+ alert "unsupported group type: #{@@group.type}"
+ return
+ end
+
# construct arguments to fetch
args = {
method: 'post',
credentials: 'include',
headers: {'Content-Type' => 'application/json'},
- body: {group: @@group, id: @id, action: @action}.inspect
+ body: {group: @@group.id, id: @id, action: @action}.inspect
}
@disabled = true
Polyfill.require(%w(Promise fetch)) do
- fetch('actions/authgroup', args).then {|response|
+ fetch(action, args).then {|response|
content_type = response.headers.get('content-type') || ''
if response.status == 200 and content_type.include? 'json'
response.json().then do |json|
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].