whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: WHIMSY-241 - Allow for GMail aliasing when checking subscriptions
Date Wed, 06 Mar 2019 17:07:52 GMT
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 fa168d0  WHIMSY-241 - Allow for GMail aliasing when checking subscriptions
fa168d0 is described below

commit fa168d06cf69c882fd34bdc699833b444f20faac
Author: Sebb <sebb@apache.org>
AuthorDate: Wed Mar 6 17:07:44 2019 +0000

    WHIMSY-241 - Allow for GMail aliasing when checking subscriptions
---
 lib/whimsy/asf/mlist.rb        | 12 ++++++++----
 www/roster/models/committee.rb | 12 ++++++++----
 www/roster/models/ppmc.rb      | 11 ++++++-----
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/lib/whimsy/asf/mlist.rb b/lib/whimsy/asf/mlist.rb
index c20b24e..358417e 100644
--- a/lib/whimsy/asf/mlist.rb
+++ b/lib/whimsy/asf/mlist.rb
@@ -49,8 +49,10 @@ module ASF
       response[:subtime] = (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))
 
       list_parse('sub') do |dom, list, subs|
+        # outside the loop
+        _subs = subs.map{|s| ASF::Mail.to_canonical(s.downcase)}
         emails.each do |email|
-          if downcase(subs).include? email.downcase
+          if _subs.include? ASF::Mail.to_canonical(email.downcase)
             response[:subscriptions] << ["#{list}@#{dom}", email]
           end
         end
@@ -71,8 +73,10 @@ module ASF
       response[:digtime] = (File.mtime(LIST_TIME) rescue File.mtime(LIST_DIGS))
 
       list_parse('dig') do |dom, list, subs|
+        # outside the loop
+        _subs = subs.map{|s| ASF::Mail.to_canonical(s.downcase)}
         emails.each do |email|
-          if downcase(subs).include? email.downcase
+          if _subs.include? ASF::Mail.to_canonical(email.downcase)
             response[:digests] << ["#{list}@#{dom}", email]
           end
         end
@@ -91,9 +95,9 @@ module ASF
 
       response[:moderates] = {}
       response[:modtime] = (File.mtime(LIST_TIME) rescue File.mtime(LIST_MODS))
-      user_emails.map!{|m| m.downcase} # outside loop
+      umails = user_emails.map{|m| ASF::Mail.to_canonical(m.downcase)} # outside loop
       list_parse('mod') do |dom, list, emails|
-        matching = emails.select{|m| user_emails.include? m.downcase}
+        matching = emails.select{|m| umails.include? ASF::Mail.to_canonical(m.downcase)}
         response[:moderates]["#{list}@#{dom}"] = matching unless matching.empty?
       end
       response
diff --git a/www/roster/models/committee.rb b/www/roster/models/committee.rb
index 76a64ff..55322ed 100644
--- a/www/roster/models/committee.rb
+++ b/www/roster/models/committee.rb
@@ -37,6 +37,7 @@ class Committee
       subscribers, subtime = ASF::MLIST.list_subscribers(pmc.mail_list) # counts only
       analysePrivateSubs = currentUser.asf_member?
       unless analysePrivateSubs # check for private moderator if not already allowed access
+        # TODO match using canonical emails
         user_mail = currentUser.all_mail || []
         pMods = moderators["private@#{pmc.mail_list}.apache.org"] || []
         analysePrivateSubs = !(pMods & user_mail).empty?
@@ -61,10 +62,13 @@ class Committee
         role: 'PMC member'
       }
       if analysePrivateSubs
-        allMail = person.all_mail.map{|m| m.downcase}
-        roster[person.id]['notSubbed'] = (allMail & pSubs).empty?
-        unMatchedSubs.delete_if {|k| allMail.include? k.downcase}
-        unMatchedSecSubs.delete_if {|k| allMail.include? k.downcase}
+        # Analyse the subscriptions, matching against canonicalised personal emails
+        allMail = person.all_mail.map{|m| ASF::Mail.to_canonical(m.downcase)}
+        # pSubs is already downcased
+        # TODO should it be canonicalised as well above?
+        roster[person.id]['notSubbed'] = (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty?
+        unMatchedSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)}
+        unMatchedSecSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)}
       end
       roster[person.id]['ldap'] = true
       roster[person.id]['githubUsername'] = (person.attrs['githubUsername'] || []).join(',
')
diff --git a/www/roster/models/ppmc.rb b/www/roster/models/ppmc.rb
index 4aaadcc..1a26a8f 100644
--- a/www/roster/models/ppmc.rb
+++ b/www/roster/models/ppmc.rb
@@ -32,6 +32,7 @@ class PPMC
       subscribers, subtime = ASF::MLIST.list_subscribers(ppmc.mail_list, true) # counts only
       analysePrivateSubs = currentUser.asf_member?
       unless analysePrivateSubs # check for private moderator if not already allowed access
+        # TODO match using canonical emails
         user_mail = currentUser.all_mail || []
         pMods = moderators["private@#{ppmc.mail_list}.apache.org"] || []
         analysePrivateSubs = !(pMods & user_mail).empty?
@@ -67,9 +68,9 @@ class PPMC
     owners.each do |person|
       notSubbed = false
       if analysePrivateSubs and owners.include? person
-        allMail = person.all_mail.map{|m| m.downcase}
-        notSubbed = (allMail & pSubs).empty?
-        unMatchedSubs.delete_if {|k| allMail.include? k.downcase}
+        allMail = person.all_mail.map{|m| ASF::Mail.to_canonical(m.downcase)}
+        notSubbed = (allMail & pSubs.map{|m| ASF::Mail.to_canonical(m)}).empty?
+        unMatchedSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)}
       end
       roster[person.id] = {
         notSubbed: notSubbed,
@@ -93,9 +94,9 @@ class PPMC
         githubUsername: (person.attrs['githubUsername'] || []).join(', ')
       }
       if analysePrivateSubs
-        allMail = person.all_mail.map{|m| m.downcase}
+        allMail = person.all_mail.map{|m| ASF::Mail.to_canonical(m.downcase)}
         roster[person.id]['notSubbed'] = (allMail & pSubs).empty?
-        unMatchedSubs.delete_if {|k| allMail.include? k.downcase}
+        unMatchedSubs.delete_if {|k| allMail.include? ASF::Mail.to_canonical(k.downcase)}
       end
     end
 


Mime
View raw message