Class: ASF::Mail

Inherits:
Object
  • Object
show all
Defined in:
lib/whimsy/asf/mail.rb

Class Method Summary collapse

Class Method Details

.configureObject

common configuration for sending mail



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/whimsy/asf/mail.rb', line 53

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

.listObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/whimsy/asf/mail.rb', line 6

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 {|mail| list[mail.downcase] ||= Person[id]}
  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) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/whimsy/asf/mail.rb', line 39

def self.lists(public_private= false)
  apmail_bin = ASF::SVN['infra/infrastructure/apmail/trunk/bin']
  file = File.join(apmail_bin, '.archives')
  if not @lists or File.mtime(file) != @list_mtime
    @list_mtime = File.mtime(file)
    @lists = Hash[File.read(file).scan(
      /^\s+"(\w[-\w]+)", "\/home\/apmail\/(public|private)-arch\//
    )]
  end

  public_private ? @lists : @lists.keys
end