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 2017/06/22 00:33:06 UTC
[whimsy] branch master updated: First pass at using mlist utility
module
This is an automated email from the ASF dual-hosted git repository.
sebb 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 29077b4 First pass at using mlist utility module
29077b4 is described below
commit 29077b488b90a47a2498195c7a63905b77169ddf
Author: Sebb <se...@apache.org>
AuthorDate: Thu Jun 22 01:33:04 2017 +0100
First pass at using mlist utility module
Other code still needs converting
---
www/board/subscriptions.cgi | 5 ++---
www/incubator/moderators.cgi | 7 ++-----
www/members/subscriptions.cgi | 5 ++---
www/roster/models/committer.rb | 42 +++++-------------------------------------
4 files changed, 11 insertions(+), 48 deletions(-)
diff --git a/www/board/subscriptions.cgi b/www/board/subscriptions.cgi
index 921c68e..2b020e9 100755
--- a/www/board/subscriptions.cgi
+++ b/www/board/subscriptions.cgi
@@ -3,8 +3,7 @@
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
require 'wunderbar'
require 'whimsy/asf'
-
-SUBSCRIPTIONS = '/srv/subscriptions/board'
+require 'whimsy/asf/mlist'
ARCHIVERS = %w(
board-archive@apache.org
@@ -73,7 +72,7 @@ _html do
ids = []
maillist = ASF::Mail.list
- File.readlines(SUBSCRIPTIONS).each do |line|
+ ASF::MLIST.board_subscribers do |line|
person = maillist[line.downcase.strip]
person ||= maillist[line.downcase.strip.sub(/\+\w+@/,'@')]
if person
diff --git a/www/incubator/moderators.cgi b/www/incubator/moderators.cgi
index 21623d9..bc169fa 100755
--- a/www/incubator/moderators.cgi
+++ b/www/incubator/moderators.cgi
@@ -4,6 +4,7 @@ PAGETITLE = "Incubator Mailing List Moderators" # Wvisible:incubator mail
$LOAD_PATH.unshift File.realpath(File.expand_path('../../../lib', __FILE__))
require 'wunderbar'
require 'whimsy/asf'
+require 'whimsy/asf/mlist'
require 'nokogiri'
user = ASF::Person.new($USER)
@@ -13,7 +14,6 @@ unless user.asf_member? or ASF::Committee['incubator'].members.include? user
exit
end
-SUBSCRIPTIONS = '/srv/subscriptions/list-mods'
PODLINGS = "#{ASF::SVN['asf/incubator/public/trunk/content']}/podlings.xml"
exceptions = {
@@ -68,10 +68,7 @@ _html do
_h1 'Apache Incubator moderators'
- moderators = Hash[File.read(SUBSCRIPTIONS).split(/\n\n/).
- select {|k,v| k =~ /incubator.apache.org/ && k !~ /\/infra-(dev2?|[a-z])\//}.
- map {|stanza| [stanza[/incubator.apache.org\/(.*)\//,1],
- stanza.scan(/^(.*@.*)/).flatten]}]
+ moderators = ASF::MLIST.incubator_mods
_h1 'Index'
diff --git a/www/members/subscriptions.cgi b/www/members/subscriptions.cgi
index 185d4d3..3009453 100755
--- a/www/members/subscriptions.cgi
+++ b/www/members/subscriptions.cgi
@@ -4,11 +4,10 @@ $LOAD_PATH.unshift File.realpath(File.expand_path('../../../lib', __FILE__))
require 'wunderbar'
require 'whimsy/asf'
+require 'whimsy/asf/mlist'
require 'wunderbar/bootstrap'
require 'wunderbar/jquery/stupidtable'
-SUBSCRIPTIONS = '/srv/subscriptions/members'
-
ARCHIVERS = %w(
members-archive@apache.org
archive-asf-private@cust-asf.ponee.io
@@ -68,7 +67,7 @@ _html do
maillist = ASF::Mail.list
subscriptions = []
- File.readlines(SUBSCRIPTIONS).each do |line|
+ ASF::MLIST.members_subscribers do |line|
person = maillist[line.downcase.strip]
person ||= maillist[line.downcase.strip.sub(/\+\w+@/,'@')]
if person
diff --git a/www/roster/models/committer.rb b/www/roster/models/committer.rb
index 43c5989..01da135 100644
--- a/www/roster/models/committer.rb
+++ b/www/roster/models/committer.rb
@@ -1,5 +1,4 @@
class Committer
- LIST_SUBS = '/srv/subscriptions/list-subs'
def self.serialize(id, env)
response = {}
@@ -126,44 +125,13 @@ class Committer
if ASF::Person.find(env.user).asf_member? or env.user = id
response[:moderates] = {}
- if File.exist? LIST_MODS
- response[:modtime] = File.mtime(LIST_MODS)
- moderators = File.read(LIST_MODS).split(/\n\n/).map do |stanza|
- # list names can include '-': empire-db
- 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
+ require 'whimsy/asf/mlist'
+ ASF::MLIST.moderates(person.all_mail, response)
end
- if env.user == id and File.exists? LIST_SUBS
- response[:subscriptions] = []
- response[:subtime] = File.mtime(LIST_SUBS)
- emails = person.all_mail
-
- # File format
- # blank line
- # /home/apmail/lists/accumulo.apache.org/commits
- # archive@mail-archive.com
- # ...
- File.read(LIST_SUBS).split(/\n\n/).each do |stanza|
- # list names can include '-': empire-db
- list = stanza.match(/\/([-\w]*\.?apache\.org)\/(.*?)(\n|\Z)/)
-
- subs = stanza.scan(/^(.*@.*)/).flatten
- emails.each do |email|
- if subs.include? email
- response[:subscriptions] << ["#{list[2]}@#{list[1]}", email]
- end
- end
- end
+ if env.user == id
+ require 'whimsy/asf/mlist'
+ ASF::MLIST.subscriptions(person.all_mail, response)
end
response
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].