|
3 | 3 | module ASF |
4 | 4 | # Convenience functions related to emails or mailing lists. |
5 | 5 | class Mail |
6 | | - # return a Hash containing complete list of all known emails, and the |
7 | | - # ASF::Person that is associated with that email. |
8 | | - def self.list |
9 | | - begin |
10 | | - return @list.to_h if @list |
11 | | - rescue NoMethodError, WeakRef::RefError |
12 | | - end |
13 | | - |
14 | | - list = {} |
15 | | - |
16 | | - # load info from LDAP |
17 | | - people = ASF::Person.preload(['mail', 'asf-altEmail']) |
18 | | - people.each do |person| |
19 | | - (person.mail + person.alt_email).each do |mail| |
20 | | - list[mail.downcase] = person |
21 | | - end |
22 | | - end |
23 | 6 |
|
24 | | - # load all member emails in one pass |
25 | | - ASF::Member.each do |id, text| |
26 | | - Member.emails(text).each do |mail| |
27 | | - list[mail.downcase] ||= Person.find(id) |
28 | | - end |
| 7 | + # return a list of people ids, their public-name, whether they are an ASF member, and email addresses |
| 8 | + def self.people_mails |
| 9 | + member_statuses = ASF::Member.member_statuses # cache the statuses. TODO: should be done in ASF.Member |
| 10 | + people = ASF::Person.preload(['cn', 'mail','asf-altEmail']) |
| 11 | + result = people.sort_by(&:id).map do |person| |
| 12 | + id = person.id |
| 13 | + mails = person.mail + person.alt_email + ["#{id}@apache.org"] |
| 14 | + entry = { |
| 15 | + id: id, |
| 16 | + name: person.public_name, |
| 17 | + mail: mails.map{|m| m.downcase}.uniq, |
| 18 | + } |
| 19 | + entry[:member] = true if member_statuses[id] |
| 20 | + entry |
29 | 21 | end |
| 22 | + result |
| 23 | + end |
30 | 24 |
|
31 | | - # load all ICLA emails in one pass |
32 | | - ASF::ICLA.each do |icla| |
33 | | - person = Person.find(icla.id) |
34 | | - icla.emails.each do |email| |
35 | | - list[email.downcase] ||= person |
36 | | - end |
37 | | - next if icla.noId? |
38 | | - |
39 | | - list["#{icla.id.downcase}@apache.org"] ||= person |
| 25 | + # return a list of people ids, their public-name, whether they are an ASF member, and email addresses |
| 26 | + # Also return GH settings |
| 27 | + # @param extra_mails additional emails derived from members and iclas |
| 28 | + def self.people_mails_github(extra_mails) |
| 29 | + member_statuses = ASF::Member.member_statuses # cache the statuses. TODO: should be done in ASF.Member |
| 30 | + people = ASF::Person.preload(['cn', 'mail','asf-altEmail','githubUsername', 'asf-githubStringID']) |
| 31 | + result = people.sort_by(&:id).map do |person| |
| 32 | + id = person.id |
| 33 | + mails = person.mail + person.alt_email + extra_mails.fetch(id, []) + ["#{id}@apache.org"] |
| 34 | + { |
| 35 | + id: id, |
| 36 | + name: person.public_name, |
| 37 | + mail: mails.map{|m| m.downcase}.uniq, |
| 38 | + githubUsername: person.attrs['githubUsername'] || [], |
| 39 | + asf_githubStringID: person.attrs['asf-githubStringID']&.first || '', |
| 40 | + asf_member_status: member_statuses[person.id], |
| 41 | + } |
40 | 42 | end |
41 | | - |
42 | | - @list = WeakRef.new(list) |
43 | | - list |
| 43 | + result |
44 | 44 | end |
45 | 45 |
|
46 | 46 | # list of mailing lists that aren't actively seeking new subscribers |
|
0 commit comments