module ASF::MLIST

Constants

ARCHIVERS

Standard ASF archivers

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() click to toggle source

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

# File lib/whimsy/asf/mlist.rb, line 13
def self.board_subscribers
  return list_filter('sub', 'apache.org', 'board'), (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))
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 71
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
    next unless "#{mail_domain}.apache.org" == dom 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
members_subscribers() click to toggle source

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

# File lib/whimsy/asf/mlist.rb, line 18
def self.members_subscribers
  return list_filter('sub', 'apache.org', 'members'), (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 moderators N.B. not the same format as the subscriptions() method

# File lib/whimsy/asf/mlist.rb, line 55
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))
  list_parse('mod') do |dom, list, emails|
    matching = (user_emails & emails) # grab entries common to both
    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

# File lib/whimsy/asf/mlist.rb, line 24
def self.private_subscribers(pmc, archivers=false)
  return list_filter('sub', "#{pmc}.apache.org", 'private', 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 33
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))

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