class ASF::Mail

Public Class Methods

_load_lists() click to toggle source

Parse the .archives file to get the list names

# File lib/whimsy/asf/mail.rb, line 44
def self._load_lists
  apmail_bin = ASF::SVN['infra/infrastructure/apmail/trunk/bin']
  file = File.join(apmail_bin, '.archives')
  if not @lists or File.mtime(file) != @list_mtime
    lists = Hash[File.read(file).scan(
      /^\s+"(\w[-\w]+)", "\/home\/apmail\/(public|private)-arch\//
    )]
    # Drop the infra test lists
    lists.delete_if {|list| list =~ /-infra-[a-z]$/ or list == 'incubator-infra-dev' }
    @lists = lists
    @list_mtime = File.mtime(file)
  end
end
cansub(member, pmc_chair) click to toggle source

which lists are available for subscription via Whimsy?

# File lib/whimsy/asf/mail.rb, line 74
def self.cansub(member, pmc_chair)
  Mail._load_lists
  if member
      lists = @lists.keys
      # These are not subscribable via Whimsy
      lists.delete_if {|list| list =~ /^(ea|secretary|president|treasurer|chairman|committers|pmc-chairs)$/ }
      lists.delete_if {|list| list =~ /(^|-)security$|^security(-|$)/ }
      lists
  else
      whitelist = ['infra-users', 'jobs', 'site-dev', 'committers-cvs', 'site-cvs', 'concom', 'party']
      # Can always subscribe to public lists and the whitelist
      lists = @lists.keys.select{|key| @lists[key] == 'public' or whitelist.include? key}
      # Chairs need the board lists
      if pmc_chair
        lists += ['board', 'board-commits', 'board-chat']
      end
      lists
  end
end
configure() click to toggle source

common configuration for sending mail; loads :sendmail configuration from ~/.whimsy if available; otherwise default to disable openssl verification as that is what it required in order to work on the infrastructure provided whimsy-vm.

# File lib/whimsy/asf/mail.rb, line 98
def self.configure
  # fetch overrides
  sendmail = ASF::Config.get(:sendmail)

  if sendmail
    # convert string keys to symbols
    options = Hash[sendmail.map {|key, value| [key.to_sym, value.untaint]}]

    # extract delivery method
    method = options.delete(:delivery_method).to_sym
  else
    # provide defaults that work on whimsy-vm* infrastructure.  Since
    # procmail is configured with a self-signed certificate, verification
    # isn't a possibility
    method = :smtp
    options = {openssl_verify_mode: 'none'}
  end

  ::Mail.defaults do
    delivery_method method, options
  end
end
deprecated() click to toggle source

list of mailing lists that aren't actively seeking new subscribers

# File lib/whimsy/asf/mail.rb, line 68
def self.deprecated
  apmail_bin = ASF::SVN['infra/infrastructure/apmail/trunk/bin']
  YAML.load_file(File.join(apmail_bin, 'deprecated_mailing_lists.yml'))
end
list() click to toggle source

return a Hash containing complete list of all known emails, and the ASF::Person that is associated with that email.

# File lib/whimsy/asf/mail.rb, line 8
def self.list
  begin
    return Hash[@list.to_a] if @list
  rescue NoMethodError, WeakRef::RefError
  end

  list = Hash.new

  # load info from LDAP
  people = ASF::Person.preload(['mail', 'asf-altEmail'])
  people.each do |person|
    (person.mail+person.alt_email).each do |mail|
      list[mail.downcase] = person
    end
  end

  # load all member emails in one pass
  ASF::Member.each do |id, text|
    Member.emails(text).each do |mail| 
      list[mail.downcase] ||= Person.find(id)
    end
  end

  # load all ICLA emails in one pass
  ASF::ICLA.each do |icla|
    person = Person.find(icla.id)
    list[icla.email.downcase] ||= person
    next if icla.id == 'notinavail'
    list["#{icla.id.downcase}@apache.org"] ||= person
  end

  @list = WeakRef.new(list)
  list
end
lists(public_private=false) click to toggle source

get a list of all mailing lists. If public_private is false this will be a simple list. If public_private is true, return a Hash where the values are either public or private.

# File lib/whimsy/asf/mail.rb, line 62
def self.lists(public_private=false)
  Mail._load_lists
  public_private ? @lists : @lists.keys
end
qmail_ids() click to toggle source
# File lib/whimsy/asf/mail.rb, line 121
def self.qmail_ids
  return [] unless File.exist? '/srv/subscriptions/qmail.ids'
  File.read('/srv/subscriptions/qmail.ids').split
end
taken?(id) click to toggle source
# File lib/whimsy/asf/mail.rb, line 126
def self.taken?(id)
  self.qmail_ids.include? id
end