Lines 346-364
Link Here
|
346 |
my @emailList = (@assigned_toList, @reporterList, |
346 |
my @emailList = (@assigned_toList, @reporterList, |
347 |
@qa_contactList, @ccList, @voterList); |
347 |
@qa_contactList, @ccList, @voterList); |
348 |
|
348 |
|
349 |
# only need one entry per person |
349 |
### start of BugMail.pm-resolveAlias.patch ### |
350 |
my @allEmail = (); |
350 |
# 25-May-04 patch added to prevent duplicate email addresses being sent to recipients. |
351 |
my %AlreadySeen = (); |
351 |
# written by agriffis@gentoo.org |
352 |
my $checkperson = ""; |
352 |
|
353 |
foreach my $person (@emailList) { |
353 |
# resolve aliases (also removes duplicates) |
354 |
# don't modify the original so it sends out with the right case |
354 |
my @allEmail = resolveAliases(@emailList); |
355 |
# based on who came first. |
355 |
|
356 |
$checkperson = lc($person); |
356 |
### patch continued below ### |
357 |
if ( !($AlreadySeen{$checkperson}) ) { |
|
|
358 |
push(@allEmail,$person); |
359 |
$AlreadySeen{$checkperson}++; |
360 |
} |
361 |
} |
362 |
|
357 |
|
363 |
#print LOG "\nbug $id email sent: " . join(',', @allEmail) . "\n"; |
358 |
#print LOG "\nbug $id email sent: " . join(',', @allEmail) . "\n"; |
364 |
|
359 |
|
Lines 407-412
Link Here
|
407 |
return { sent => \@sentlist, excluded => \@excludedAddresses }; |
402 |
return { sent => \@sentlist, excluded => \@excludedAddresses }; |
408 |
} |
403 |
} |
409 |
|
404 |
|
|
|
405 |
### continuation of BugMail.pm-resolveAlias.patch ### |
406 |
# 25-May-04 patch added to prevent duplicate email addresses being sent to recipients. |
407 |
# written by agriffis@gentoo.org |
408 |
|
409 |
# This is quite simple and assumes that all addresses are simply |
410 |
# blah@domain.com instead of the more complex quoted versions. This |
411 |
# should be fine since anything not resolved here will be resolved by |
412 |
# the MTA, albeit with the possibility of duplicate emails. |
413 |
sub resolveAliases { |
414 |
my (@origList) = @_; |
415 |
my (@resolvedList) = (); |
416 |
my ($aliasdir) = "/var/www/bugs.gentoo.org/Bugzilla/aliases"; |
417 |
my (%aliases, $lcPerson); |
418 |
|
419 |
# Read in the list of aliases available. |
420 |
# This should be rsynced from dev.gentoo.org:/var/mail/alias/misc |
421 |
opendir ALIASDIR, $aliasdir or return @origList; |
422 |
$aliases{grep /^[^\.]/, <ALIASDIR>} = undef; |
423 |
close ALIASDIR; |
424 |
|
425 |
# Check each address in the list for aliases and resolve them. |
426 |
# This might involve reading the particular alias file from the |
427 |
# disk if it hasn't been read yet. |
428 |
for (my $i = 0; $i < @origList; $i++) { |
429 |
|
430 |
# Preserve the case of the original address if it isn't an |
431 |
# alias |
432 |
$lcPerson = lc $origList[$i]; |
433 |
$lcPerson =~ s/\@gentoo\.org$//; |
434 |
|
435 |
# If this isn't an alias, then move along |
436 |
if (!exists $aliases{$lcPerson}) { |
437 |
push @resolvedList, $origList[$i]; |
438 |
next; |
439 |
} |
440 |
|
441 |
# If this is an alias and we've already resolved it, then move |
442 |
# along, no need to repeat ourselves... |
443 |
next if defined $aliases{$lcPerson}; |
444 |
|
445 |
# Each alias is defined by a separate file that lists the |
446 |
# recipients, one per line |
447 |
if (!open ALIASFILE, $aliasdir . '/' . $lcPerson) { |
448 |
# Eek! Let the MTA resolve it in that case. Sorry |
449 |
# it's already lowercase, but really this shouldn't |
450 |
# ever happen. |
451 |
push @resolvedList, $origList[$i]; |
452 |
next; |
453 |
} |
454 |
|
455 |
# Extract the list of addresses from the alias file |
456 |
$aliases{$lcPerson} = [ grep s/^([^#\s]+).*/$1/s, <ALIASFILE> ]; |
457 |
close ALIASFILE; |
458 |
|
459 |
if (@{$aliases{$lcPerson}} == 0) { |
460 |
# Um, an empty alias? Again, let the MTA resolve it |
461 |
push @resolvedList, $origList[$i]; |
462 |
next; |
463 |
} |
464 |
|
465 |
# At this point we have successfully resolved this alias. |
466 |
# Push on the end of origList so it's subject to recursive |
467 |
# resolution. There is no chance of a loop since we only |
468 |
# resolve each alias once. |
469 |
push @origList, @{$aliases{$lcPerson}}; |
470 |
|
471 |
# Free up some memory... we only need to keep this as a flag |
472 |
$aliases{$lcPerson} = 1; |
473 |
} |
474 |
|
475 |
# Get rid of duplicates |
476 |
my (@noDupList) = (); |
477 |
my (%alreadySeen); |
478 |
for my $person (@resolvedList) { |
479 |
$lcPerson = lc $person; |
480 |
if (!exists $alreadySeen{$lcPerson}) { |
481 |
push @noDupList, $person; |
482 |
$alreadySeen{$lcPerson} = 1; |
483 |
} |
484 |
} |
485 |
|
486 |
return @noDupList; |
487 |
} |
488 |
|
489 |
### end of BugMail.pm-resolveAlias.patch ### |
490 |
|
410 |
# When one person is in different fields on one bug, they may be |
491 |
# When one person is in different fields on one bug, they may be |
411 |
# excluded from email because of one relationship to the bug (eg |
492 |
# excluded from email because of one relationship to the bug (eg |
412 |
# they're the QA contact) but included because of another (eg they |
493 |
# they're the QA contact) but included because of another (eg they |