[rt-users] 3 emails sent by correspondance by user

L B bertignac at gmail.com
Tue Apr 7 09:59:06 EDT 2009


Ok, I modified Notify.pm . Note I'm note a perl guru, but heh, it works.

 This is what the patch does :
 - always send an email to the requestor for a correspondance ("Reply")
 - if user is requestor and owner, do not send to the owner (an email
has already been sent to the requestor)
 - if a user is requestor or owner and admincc, remove him from the
list of admincc (as he has already been notified either because he's a
requestor or a owner) and send the email to this list of admincc .

 That also means the template received by the user depends on his role
(sometimes he will receive the requestor template, sometimes the
owner, sometimes the admincc). But as basically it's the same thing,
we don't mind.

 This is the patch, it may be useful for others :

===============================================
# diff lib/RT/Action/Notify.pm local/lib/RT/Action/Notify.pm
88a89,93
>     my $requestor_emails = join(' ',($ticket->Requestors->MemberEmailAddresses));
>     my $admincc_emails = join(' ',($ticket->AdminCc->MemberEmailAddresses));
>     my $owner_email = join(' ',($ticket->OwnerObj->EmailAddress));
>     my $queueadmincc_emails = join(' ',($ticket->QueueObj->AdminCc->MemberEmailAddresses));
>     my @requestor_emails_array = split(/ /,$requestor_emails);
118c123
<     if ( $arg =~ /\bOwner\b/ && $ticket->OwnerObj->id != $RT::Nobody->id ) {
---
>     if ( $arg =~ /\bOwner\b/ && $ticket->OwnerObj->id != $RT::Nobody->id && $requestor_emails !~ $owner_email ){
131,132c136,147
<         push ( @Bcc, $ticket->AdminCc->MemberEmailAddresses  );
<         push ( @Bcc, $ticket->QueueObj->AdminCc->MemberEmailAddresses  );
---
>
> 	# Notification already sent for requestor
> 	foreach (@requestor_emails_array){
> 		$admincc_emails =~ s/$_//g;
> 		$queueadmincc_emails =~ s/$_//g;
> 	}
> 	# Notification already sent for owner
> 	$admincc_emails =~ s/$owner_email//g;
> 	$queueadmincc_emails =~ s/$owner_email//g;
>
>         push ( @Bcc, $admincc_emails );
>         push ( @Bcc, $queueadmincc_emails );

===============================================

This is the test matrix :

ROA | S | P |  T
000  | x  |  x  | x
001  | 1 |  1 | A
010  | 1 |  1 | O
011  | 2 |  1 | O
100  | 1 |  1 | R
101  | 2 |  1 | R
110  | 2 |  1 | R
111  | 3 |  1 | R

R : is requestor
O : is owner
A : is admincc

S : Number of emails sent with Standard notify.pm
P : Number of emails sent with Patched notify.pm
T : Template used (Requestor, Owner, AdminCc)


I've not managed the Cc part, and the comments because our main
problem was the duplicate emails generated by correspondences.

Any comments welcome
-- 
L.B.



More information about the rt-users mailing list