whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: WHIMSY-74: Mailing list moderator maintenance
Date Mon, 17 Apr 2017 13:24:23 GMT
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  37afdbf   WHIMSY-74: Mailing list moderator maintenance
37afdbf is described below

commit 37afdbf94267708ab5e93487869f3c6d6d827f09
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Mon Apr 17 09:23:18 2017 -0400

    WHIMSY-74: Mailing list moderator maintenance
    
    Show list of moderators on PMC, Podling, and committer pages.
---
 lib/whimsy/asf/mail.rb           |  2 +-
 www/roster/main.rb               |  2 ++
 www/roster/models/committee.rb   | 21 ++++++++++++++++-----
 www/roster/models/committer.rb   | 18 ++++++++++++++++++
 www/roster/models/ppmc.rb        | 15 ++++++++++++++-
 www/roster/views/person.js.rb    | 16 ++++++++++++++++
 www/roster/views/pmc/main.js.rb  | 39 ++++++++++++++++++++++++++++++++-------
 www/roster/views/ppmc/main.js.rb | 38 +++++++++++++++++++++++++++++++-------
 8 files changed, 130 insertions(+), 21 deletions(-)

diff --git a/lib/whimsy/asf/mail.rb b/lib/whimsy/asf/mail.rb
index abbce2f..0e76f39 100644
--- a/lib/whimsy/asf/mail.rb
+++ b/lib/whimsy/asf/mail.rb
@@ -128,7 +128,7 @@ module ASF
     end
 
     def all_mail
-      active_emails + obsolete_emails
+      (active_emails + obsolete_emails + ["#{id}@apache.org"]).uniq
     end
   end
 
diff --git a/www/roster/main.rb b/www/roster/main.rb
index 727c208..c3b2658 100755
--- a/www/roster/main.rb
+++ b/www/roster/main.rb
@@ -23,6 +23,8 @@ require_relative 'models'
 
 ASF::Mail.configure
 
+LIST_MODS = '/srv/subscriptions/list-mods'
+
 get '/' do
   if env['REQUEST_URI'].end_with? '/'
     @committers = ASF::Person.list
diff --git a/www/roster/models/committee.rb b/www/roster/models/committee.rb
index 1cf291f..110a011 100644
--- a/www/roster/models/committee.rb
+++ b/www/roster/models/committee.rb
@@ -13,10 +13,20 @@ class Committee
       list =~ /^#{pmc.mail_list}\b/
     end
 
-    unless
-      pmc.roster.include? env.user or
-      ASF::Person.find(env.user).asf_member?
-    then
+    moderators = nil
+
+    if pmc.roster.include? env.user or ASF::Person.find(env.user).asf_member?
+      if File.exist? LIST_MODS
+         mail_list = "#{pmc.mail_list}.apache.org"
+         moderators = File.read(LIST_MODS).split(/\n\n/).map do |stanza|
+           list = stanza.match(/(\w+\.apache\.org)\/(.*?)\//)
+           next unless list[1] == mail_list
+ 
+           ["#{list[2]}@#{list[1]}", stanza.scan(/^(.*@.*)/).flatten.sort]
+        end
+        moderators = moderators.compact.to_h
+      end
+    else
       lists = lists.select {|list, mode| mode == 'public'}
     end
 
@@ -33,7 +43,8 @@ class Committee
       committers: Hash[committers.map {|person| [person.id, person.cn]}],
       asfmembers: (ASF.members & people).map(&:id),
       roster: pmc.roster,
-      mail: Hash[lists.sort]
+      mail: Hash[lists.sort],
+      moderators: moderators,
     }
 
     response
diff --git a/www/roster/models/committer.rb b/www/roster/models/committer.rb
index f239ed5..215eed2 100644
--- a/www/roster/models/committer.rb
+++ b/www/roster/models/committer.rb
@@ -118,6 +118,24 @@ class Committer
 
     end
 
+    if ASF::Person.find(env.user).asf_member? or env.user = id
+      response[:moderates] = {}
+
+      if File.exist? LIST_MODS
+        moderators = File.read(LIST_MODS).split(/\n\n/).map do |stanza|
+          list = stanza.match(/(\w+\.apache\.org)\/(.*?)\//)
+
+          ["#{list[2]}@#{list[1]}", stanza.scan(/^(.*@.*)/).flatten]
+        end
+
+       user_emails = person.all_mail
+        moderators.each do |mail_list, list_moderators|
+          matches = (list_moderators & user_emails)
+          response[:moderates][mail_list] = matches unless matches.empty?
+        end
+      end
+    end
+
     response
   end
 end
diff --git a/www/roster/models/ppmc.rb b/www/roster/models/ppmc.rb
index f22a27d..fa8432d 100644
--- a/www/roster/models/ppmc.rb
+++ b/www/roster/models/ppmc.rb
@@ -9,7 +9,19 @@ class PPMC
     end
 
     user = ASF::Person.find(env.user)
-    unless user.asf_member? or ppmc.members.include? user
+    if user.asf_member? or ppmc.members.include? user
+      if File.exist? LIST_MODS
+         mail_list = ppmc.mail_list
+         moderators = File.read(LIST_MODS).split(/\n\n/).map do |stanza|
+           list = stanza.match(/(\w+)\.apache\.org\/(.*?)\//)
+           next unless list[1] == mail_list or list[2] =~ /^#{mail_list}-/
+ 
+           ["#{list[2]}@#{list[1]}.apache.org", 
+             stanza.scan(/^(.*@.*)/).flatten.sort]
+        end
+        moderators = moderators.compact.to_h
+      end
+    else
       lists = lists.select {|list, mode| mode == 'public'}
     end
 
@@ -25,6 +37,7 @@ class PPMC
         [person.id, {name: person.public_name, member: person.asf_member?}]
       }.to_h,
       mail: Hash[lists.sort],
+      moderators: moderators,
     }
 
     response
diff --git a/www/roster/views/person.js.rb b/www/roster/views/person.js.rb
index d00b87d..cd28e72 100644
--- a/www/roster/views/person.js.rb
+++ b/www/roster/views/person.js.rb
@@ -75,6 +75,22 @@ class Person < React
           _PersonEmail person: self
         end
 
+        # Moderates
+        if @committer.moderates
+          _tr do
+            _td 'Moderates'
+            _td do
+              _ul @committer.moderates.keys() do |list|
+                _li do
+                  _span list
+                  _span " as "
+                  _span @committer.moderates[list].join(', ')
+                end
+              end
+            end
+          end
+        end
+
         # PGP keys
         if @committer.pgp
           _PersonPgpKeys person: self
diff --git a/www/roster/views/pmc/main.js.rb b/www/roster/views/pmc/main.js.rb
index 9114eff..5192e1f 100644
--- a/www/roster/views/pmc/main.js.rb
+++ b/www/roster/views/pmc/main.js.rb
@@ -44,13 +44,38 @@ class PMC < React
     _PMCMembers auth: auth, committee: @committee
     _PMCCommitters auth: auth, committee: @committee
 
-    _h2.mail! 'Mail lists'
-    _ul do
-      for mail_name in @committee.mail
-        parsed = mail_name.match(/^(.*?)-(.*)/)
-        _li do
-          _a mail_name, href: 'https://lists.apache.org/list.html?' +
-            "#{parsed[2]}@#{parsed[1]}.apache.org"
+    # mailing lists
+    if @committee.moderators
+      _h2.mail! 'Mail list moderators'
+      _table do
+        _thead do
+          _tr do
+            _th 'list name'
+            _th 'moderators'
+          end
+        end
+        _tbody do
+          for list_name in @committee.moderators
+            _tr do
+              _td do
+                _a list_name, href: 'https://lists.apache.org/list.html?' +
+                  list_name
+              end
+              _td @committee.moderators[list_name].join(', ')
+            end
+          end
+        end
+      end
+    else
+      _h2.mail! 'Mail lists'
+      _ul do
+        for mail_name in @committee.mail
+          parsed = mail_name.match(/^(.*?)-(.*)/)
+          list_name = "#{parsed[2]}@#{parsed[1]}.apache.org"
+          _li do
+            _a list_name, href: 'https://lists.apache.org/list.html?' +
+              list_name
+          end
         end
       end
     end
diff --git a/www/roster/views/ppmc/main.js.rb b/www/roster/views/ppmc/main.js.rb
index d4192d4..ad2de5c 100644
--- a/www/roster/views/ppmc/main.js.rb
+++ b/www/roster/views/ppmc/main.js.rb
@@ -31,13 +31,37 @@ class PPMC < React
     _PPMCMembers auth: auth, ppmc: @ppmc
 
     # mailing lists
-    _h2.mail! 'Mail lists'
-    _ul do
-      for mail_name in @ppmc.mail
-        parsed = mail_name.match(/^(.*?)-(.*)/)
-        _li do
-          _a mail_name, href: 'https://lists.apache.org/list.html?' +
-            "#{parsed[2]}@#{parsed[1]}.apache.org"
+    if @ppmc.moderators
+      _h2.mail! 'Mail list moderators'
+      _table do
+        _thead do
+          _tr do
+            _th 'list name'
+            _th 'moderators'
+          end
+        end
+        _tbody do
+          for list_name in @ppmc.moderators
+            _tr do
+              _td do
+                _a list_name, href: 'https://lists.apache.org/list.html?' +
+                  list_name
+              end
+              _td @ppmc.moderators[list_name].join(', ')
+            end
+          end
+        end
+      end
+    else
+      _h2.mail! 'Mail lists'
+      _ul do
+        for mail_name in @ppmc.mail
+          parsed = mail_name.match(/^(.*?)-(.*)/)
+          mail_list = "#{parsed[2]}@#{parsed[1]}.apache.org"
+          _li do
+            _a mail_list, href: 'https://lists.apache.org/list.html?' +
+              mail_list
+          end
         end
       end
     end

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message