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 2019/09/30 00:13:07 UTC
[whimsy] branch master updated: Switch to using data file for mail
list karma
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 ce458a9 Switch to using data file for mail list karma
ce458a9 is described below
commit ce458a96d628a7533afa69ef8c3acbdec22d7b85
Author: Sebb <se...@apache.org>
AuthorDate: Mon Sep 30 01:12:57 2019 +0100
Switch to using data file for mail list karma
---
lib/spec/lib/mail/mail_spec.rb | 52 +++++++++++++++++++++++++++++++--
lib/test/subscriptions/list-flags | 3 ++
lib/whimsy/asf/mail.rb | 60 ++++++++++++++++++++++++---------------
3 files changed, 89 insertions(+), 26 deletions(-)
diff --git a/lib/spec/lib/mail/mail_spec.rb b/lib/spec/lib/mail/mail_spec.rb
index 45b4d71..bc2e6c7 100644
--- a/lib/spec/lib/mail/mail_spec.rb
+++ b/lib/spec/lib/mail/mail_spec.rb
@@ -26,10 +26,12 @@ describe ASF::Mail do
end
describe '.cansub(member, pmc_chair, ldap_pmcs)' do
+ committers = ['infra-users', 'jobs', 'site-dev', 'committers-cvs', 'site-cvs', 'party']
+ board = ['board', 'board-commits', 'board-chat']
+ members = ['members','press'] # partial list
+ notallowed = ['notallowed']
lists = ASF::Mail.cansub(false, false, nil)
it 'should return public lists only' do
- whitelist = ['infra-users', 'jobs', 'site-dev', 'committers-cvs', 'site-cvs', 'party']
- board = ['board', 'board-commits', 'board-chat']
if TEST_DATA
expect(lists.length).to be >= 7
else
@@ -37,8 +39,10 @@ describe ASF::Mail do
end
expect(lists).not_to include('private')
expect(lists).not_to include('security')
- expect(lists).to include(*whitelist)
+ expect(lists).to include(*committers)
expect(lists).not_to include(*board)
+ expect(lists).not_to include(*members)
+ expect(lists).not_to include(*notallowed)
end
it 'should return the same lists' do
mylists = ASF::Mail.cansub(false, false, []) - lists
@@ -48,6 +52,7 @@ describe ASF::Mail do
mylists = ASF::Mail.cansub(false, false, ['ant','whimsical']) - lists
expect(mylists.length).to be(2)
expect(mylists).to include('ant-private','whimsical-private')
+ expect(mylists).not_to include(*notallowed)
end
it 'should not return non-existent lists' do
mylists = ASF::Mail.cansub(false, false, ['xxxant','xxxwhimsical']) - lists
@@ -61,6 +66,47 @@ describe ASF::Mail do
end
mylists = ASF::Mail.cansub(false, false, podnames) - lists
expect(mylists.length).to be_between(podnames.length-2, podnames.length).inclusive # mailing list may not be set up yet
+ expect(mylists).not_to include(*notallowed)
+ end
+ it 'should return chair lists only' do
+ mylists = ASF::Mail.cansub(false, true, nil)
+ if TEST_DATA
+ expect(mylists.length).to be >= 7
+ else
+ expect(mylists.length).to be >= 1000
+ end
+ expect(mylists).not_to include('private')
+ expect(mylists).not_to include('security')
+ expect(mylists).to include(*committers)
+ expect(mylists).to include(*board)
+ expect(mylists).not_to include(*members)
+ expect(mylists).not_to include(*notallowed)
+ end
+ it 'should return member lists only' do
+ mylists = ASF::Mail.cansub(true, false, nil)
+ if TEST_DATA
+ expect(mylists.length).to be >= 7
+ else
+ expect(mylists.length).to be >= 1000
+ end
+ expect(mylists).not_to include('private')
+ expect(mylists).not_to include('security')
+ expect(mylists).to include(*committers)
+ expect(mylists).to include(*board)
+ expect(mylists).to include(*members)
+ expect(mylists).not_to include(*notallowed)
end
end
+
+ describe '.deprecated()' do
+ it 'should return some lists' do
+ depr = ASF::Mail.deprecated()
+ if TEST_DATA
+ expect(depr.length).to be(4) # locally fixed size
+ else
+ expect(depr.length).to be_between(0,10).inclusive # varies, but probably in that range
+ end
+ end
+ end
+
end
diff --git a/lib/test/subscriptions/list-flags b/lib/test/subscriptions/list-flags
index 61658ca..6206a05 100644
--- a/lib/test/subscriptions/list-flags
+++ b/lib/test/subscriptions/list-flags
@@ -8,6 +8,9 @@ F:-aBcdeFgHiJklmnOpqrsTuVWXYZ apache.org party
F:-aBcdEFgHiJklmnOpqrsTuVWxYZ apache.org board-chat
F:-aBcdEFgHiJklMnOpqrsTUVWXYz apache.org board-commits
F:-aBcDeFgHiJklmnOpqrsTuVWXYZ apache.org board
+F:-aBcDeFgHiJklmnOpqrsTuVWXYZ apache.org members
+F:-aBcDeFgHiJklmnOpqrsTuVWXYZ apache.org press
+F:-aBcDeFgHiJklmnOpqrSTuVWXYZ apache.org notallowed
F:-aBcdeFgHiJklmnOpqrStuVWxYZ ant.apache.org dev
F:-aBcdeFgHiJklmnOpqrSTuVWxYZ ant.apache.org ivy-user
F:-aBcdeFgHiJklMnOpqrSTUVWXYz ant.apache.org notifications
diff --git a/lib/whimsy/asf/mail.rb b/lib/whimsy/asf/mail.rb
index 9c530a3..07f60d2 100644
--- a/lib/whimsy/asf/mail.rb
+++ b/lib/whimsy/asf/mail.rb
@@ -75,22 +75,25 @@ module ASF
YAML.load_file(File.join(apmail_bin, 'deprecated_mailing_lists.yml'))
end
- # These are not subscribable via Whimsy
- # secretary, president etc are not actually mailing lists,
- # but they appear in .archives so need to be excluded
- CANNOT_SUB = %w(
- ea secretary president treasurer chairman
- committers
- pmc-chairs
- concom
- concom-private
- legal-internal
- )
-
- WHITELIST = ['infra-users', 'jobs', 'site-dev', 'committers-cvs', 'site-cvs', 'party']
-
- CHAIR_LIST = %w(board board-commits board-chat)
- MEMBER_LIST = %w(centralservices members operations press trademarks)
+ def self.cannot_sub
+ self._load_auto()
+ @auto[:disallowed]
+ end
+
+ def self.committers_allowed
+ self._load_auto()
+ @auto[:committers]
+ end
+
+ def self.chairs_allowed
+ self._load_auto()
+ @auto[:chairs]
+ end
+
+ def self.members_allowed
+ self._load_auto()
+ @auto[:members]+@auto[:chairs]
+ end
# which lists are available for subscription via Whimsy?
# member: true if member
@@ -102,17 +105,16 @@ module ASF
allowed = []
parse_flags do |dom,list,f|
lid = archivelistid(dom,list)
- next if CANNOT_SUB.include? lid # probably unnecessary
+ next if self.cannot_sub.include? lid # probably unnecessary
cansub = false
modsub = isModSub?(f)
if not modsub # subs not moderated; allow all
cansub = true
- elsif WHITELIST.include?(lid) # always allowed
+ elsif self.committers_allowed().include?(lid) # always allowed
cansub = true
else # subs are moderated
- # no need to check CANNOT_SUB
if member
- if list == 'private' or CHAIR_LIST.include?(lid) or MEMBER_LIST.include?(lid)
+ if list == 'private' or self.members_allowed.include?(lid)
cansub = true
end
else
@@ -120,7 +122,7 @@ module ASF
cansub = true if list == 'private' and ldap_pmcs.include? dom.sub('.apache.org','')
end
end
- if pmc_chair and CHAIR_LIST.include? lid
+ if pmc_chair and self.chairs_allowed.include? lid
cansub = true
end
end
@@ -134,7 +136,7 @@ module ASF
end
allowed
end
-
+
# common configuration for sending mail; loads <tt>:sendmail</tt>
# configuration from <tt>~/.whimsy</tt> if available; otherwise default
# to disable openssl verification as that is what it required in order
@@ -212,7 +214,19 @@ module ASF
private
- # Parse the flags file
+ # Load the auto-subscription file
+ def self._load_auto
+ apmail_bin = ASF::SVN['apmail_bin']
+ auto_file = File.join(apmail_bin, 'mail_list_autosub.yml')
+ auto_mtime = File.mtime(auto_file) # fetch this up front in case file updated during loading
+ if not @auto or auto_mtime != @auto_mtime
+ @auto = YAML.load_file(auto_file)
+ @auto_mtime = auto_mtime
+ end
+ end
+
+
+ # Load the flags file
def self._load_flags
# flags for each mailing list
@list_flags ||= File.join(ASF::Config[:subscriptions], 'list-flags')