module ASF::MLIST

Constants

ARCHIVERS
ARCH_EXT_MAIL_ARCHIVE

Standard external archivers (necessarily public)

ARCH_EXT_MARKMAIL_RE
ARCH_MBOX_PRV
ARCH_MBOX_PUB

Standard ASF archivers

ARCH_MBOX_RST
ARCH_PONY_PRV
ARCH_PONY_PUB
LIST_DIGS
LIST_MODS

TODO alias archivers: either add list or use RE to filter them

LIST_SUBS
LIST_TIME

If this file exists, it is the time when the data was last extracted The mods and subs files are only updated if they have changed

Public Class Methods

board_subscribers(archivers=true) click to toggle source

Return an array of board subscribers followed by the file update time

# File lib/whimsy/asf/mlist.rb, line 24
def self.board_subscribers(archivers=true)
  return list_filter('sub', 'apache.org', 'board', archivers), (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))
end
digests(emails, response = {}) click to toggle source

return a hash of digest subscriptions for the list of emails provided the following keys are added to the response hash: :digtime - the timestamp when the data was last updated :digests - an array of pairs: [list name, subscriber email] N.B. not the same format as the moderates() method

# File lib/whimsy/asf/mlist.rb, line 80
def self.digests(emails, response = {})
  
  return response unless File.exists? LIST_DIGS

  response[:digests] = []
  response[:digtime] = (File.mtime(LIST_TIME) rescue File.mtime(LIST_DIGS))

  _emails = emails.map{|email| ASF::Mail.to_canonical(email.downcase)}
  list_parse('dig') do |dom, list, subs|
    subs.each do |sub|
      if _emails.include? ASF::Mail.to_canonical(sub.downcase)
        response[:digests] << ["#{list}@#{dom}", sub]
      end
    end
  end
  response
end
each_list() { |dom, list| ... } click to toggle source

return the [domain, list] for all entries in the subscriber listings the subscribers are not included

# File lib/whimsy/asf/mlist.rb, line 225
def self.each_list
  list_parse('sub') do |dom, list, subs|
    yield [dom, list]
  end
end
list_archivers() { |[dom, list, select {|s| is_archiver? s}| ... } click to toggle source
# File lib/whimsy/asf/mlist.rb, line 217
def self.list_archivers
  list_parse('sub') do |dom, list, subs|
    yield [dom, list, subs.select {|s| is_archiver? s}.map{|m| [m,archiver_type(m,dom,list)].flatten}]
  end
end
list_moderators(mail_domain, podling=false) click to toggle source

for a mail domain, extract related lists and their moderators also returns the time when the data was last checked If podling==true, then also check for old-style podling names

# File lib/whimsy/asf/mlist.rb, line 120
def self.list_moderators(mail_domain, podling=false)

  return nil, nil unless File.exist? LIST_MODS

  moderators = {}
  list_parse('mod') do |dom, list, subs|

    # drop infra test lists
    next if list =~ /^infra-[a-z]$/
    next if dom == 'incubator.apache.org' && list =~ /^infra-dev2?$/

    # normal tlp style:
    #/home/apmail/lists/commons.apache.org/dev/mod
    # possible podling styles (new, old):
    #/home/apmail/lists/batchee.apache.org/dev/mod
    #/home/apmail/lists/incubator.apache.org/blur-dev/mod
    #Apache lists (e.g. some non-PMCs)
    #/home/apmail/lists/apache.org/list/mod
    next unless "#{mail_domain}.apache.org" == dom or
       (dom == 'apache.org' &&  list =~ /^#{mail_domain}(-|$)/) or
       (podling && dom == 'incubator.apache.org' && list =~ /^#{mail_domain}-/)
    moderators["#{list}@#{dom}"] = subs.sort
  end
  return moderators.to_h, (File.mtime(LIST_TIME) rescue File.mtime(LIST_MODS))
end
list_subs(mail_domain, podling=false, list_subs=false) click to toggle source

for a mail domain, extract related lists and their subscribers (default only the count) also returns the time when the data was last checked N.B. excludes archivers For top-level apache.org lists, the mail_domain is either:

  • the full list name (e.g. press), or:

  • the list prefix (e.g. legal)

If podling==true, then also check for old-style podling names If ::list_subs==true, return subscriber emails else sub count Matches: {mail_domain}.apache.org/* apache.org/{mail_domain}(-.*)? (e.g. press, legal) incubator.apache.org/{mail_domain}-.* (if podling==true) Returns: {list}@{dom}

# File lib/whimsy/asf/mlist.rb, line 207
def self.list_subs(mail_domain, podling=false, list_subs=false)
  self.list_subscribers(mail_domain,podling,list_subs,true)
end
list_subscribers(mail_domain, podling=false, list_subs=false, skip_archivers=false) click to toggle source

for a mail domain, extract related lists and their subscribers (default only the count) also returns the time when the data was last checked N.B. by default includes archivers as subscribers For top-level apache.org lists, the mail_domain is either:

  • the full list name (e.g. press), or:

  • the list prefix (e.g. legal)

If podling==true, then also check for old-style podling names If ::list_subs==true, return subscriber emails else sub count If skip_archivers==true, exclude archivers Matches: {mail_domain}.apache.org/* apache.org/{mail_domain}(-.*)? (e.g. press, legal) incubator.apache.org/{mail_domain}-.* (if podling==true) Returns: {list}@{dom}

# File lib/whimsy/asf/mlist.rb, line 160
def self.list_subscribers(mail_domain, podling=false, list_subs=false, skip_archivers=false)

  return nil, nil unless File.exist? LIST_SUBS

  subscribers = {}
  list_parse('sub') do |dom, list, subs|

    # drop infra test lists
    next if list =~ /^infra-[a-z]$/
    next if dom == 'incubator.apache.org' && list =~ /^infra-dev2?$/

    # normal tlp style:
    #/home/apmail/lists/commons.apache.org/dev/mod

    # possible podling styles (new, old):
    #/home/apmail/lists/batchee.apache.org/dev/mod
    #/home/apmail/lists/incubator.apache.org/blur-dev/mod

    #Apache lists (e.g. some non-PMCs)
    #/home/apmail/lists/apache.org/list/mod

    next unless "#{mail_domain}.apache.org" == dom or
       (dom == 'apache.org' &&  list =~ /^#{mail_domain}(-|$)/) or
       (podling && dom == 'incubator.apache.org' && list =~ /^#{mail_domain}-/)

    if skip_archivers
      subscribers["#{list}@#{dom}"] = list_subs ? subs.reject{|sub| is_archiver?(sub)}.sort : subs.reject{|sub| is_archiver?(sub)}.size
    else
      subscribers["#{list}@#{dom}"] = list_subs ? subs.sort : subs.size
    end
  end
  return subscribers.to_h, (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))
end
list_time() click to toggle source

returns the list time (defaulting to list-subs time if the marker is not present)

# File lib/whimsy/asf/mlist.rb, line 213
def self.list_time
  File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS)
end
members_subscribers(archivers=true) click to toggle source

Return an array of members@ subscribers followed by the file update time

# File lib/whimsy/asf/mlist.rb, line 29
def self.members_subscribers(archivers=true)
  return list_filter('sub', 'apache.org', 'members', archivers), (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))
end
moderates(user_emails, response = {}) click to toggle source

return the mailing lists which are moderated by any of the list of emails the following keys are added to the response hash: :modtime - the timestamp when the data was last updated :moderates - a hash. key: list name; entry: array of emails that match a moderator for the list N.B. not the same format as the subscriptions() method

# File lib/whimsy/asf/mlist.rb, line 103
def self.moderates(user_emails, response = {})

  return response unless File.exists? LIST_MODS

  response[:moderates] = {}
  response[:modtime] = (File.mtime(LIST_TIME) rescue File.mtime(LIST_MODS))
  umails = user_emails.map{|m| ASF::Mail.to_canonical(m.downcase)} # outside loop
  list_parse('mod') do |dom, list, emails|
    matching = emails.select{|m| umails.include? ASF::Mail.to_canonical(m.downcase)}
    response[:moderates]["#{list}@#{dom}"] = matching unless matching.empty?
  end
  response
end
private_subscribers(pmc, archivers=false) click to toggle source

Return an array of private@pmc subscribers followed by the file update time By default does not return the standard archivers pmc can either be a pmc name, in which case it uses private@<pmc>.apache.org or it can be an ASF list name, e.g. w3c@apache.org

# File lib/whimsy/asf/mlist.rb, line 37
def self.private_subscribers(pmc, archivers=false)
  parts = pmc.split('@', 3) # want to detect trailing '@'
  if parts.length == 1
    return list_filter('sub', "#{pmc}.apache.org", 'private', archivers), (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))
  elsif parts.length == 2 && parts[1] == 'apache.org'
    return list_filter('sub', parts[1], parts[0], archivers), (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))
  else
    raise "Unexpected parameter: #{pmc}"
  end
end
security_subscribers(pmc, archivers=false) click to toggle source
# File lib/whimsy/asf/mlist.rb, line 48
def self.security_subscribers(pmc, archivers=false)
  return list_filter('sub', "#{pmc}.apache.org", 'security', archivers), (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))
end
subscriptions(emails, response = {}) click to toggle source

return a hash of subscriptions for the list of emails provided the following keys are added to the response hash: :subtime - the timestamp when the data was last updated :subscriptions - an array of pairs: [list name, subscriber email] N.B. not the same format as the moderates() method

# File lib/whimsy/asf/mlist.rb, line 57
def self.subscriptions(emails, response = {})
  
  return response unless File.exists? LIST_SUBS

  response[:subscriptions] = []
  response[:subtime] = (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))

  _emails = emails.map{|email| ASF::Mail.to_canonical(email.downcase)}
  list_parse('sub') do |dom, list, subs|
    subs.each do |sub|
      if _emails.include? ASF::Mail.to_canonical(sub.downcase)
        response[:subscriptions] << ["#{list}@#{dom}", sub]
      end
    end
  end
  response
end