Skip to content

Commit

Permalink
support sending as comment, for the TicketCommented Rule
Browse files Browse the repository at this point in the history
  • Loading branch information
clkao committed Sep 5, 2010
1 parent 3f63b35 commit 91bfa32
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/RT/Extension/NotificationMatrix/Rule.pm
Expand Up @@ -90,6 +90,8 @@ sub DefaultExternalTemplate {
$_[0]->DefaultTemplate;
}

sub SendAsComment { 0 }

sub LoadTemplate {
my ($self, $external) = @_;
my $template = RT::Template->new($self->CurrentUser);
Expand Down Expand Up @@ -171,6 +173,13 @@ sub _PrepareSendEmail {

$email->{__ref} = $ref;
$email->Prepare;

if ($self->SendAsComment) {
$email->TemplateObj->MIMEObj->head->set('From', '');
$email->TemplateObj->MIMEObj->head->set('Reply-To', '');
$email->SetReturnAddress( is_comment => 1 );
}

return $email;
}

Expand Down
Expand Up @@ -6,6 +6,7 @@ use base 'RT::Extension::NotificationMatrix::Rule';
use constant NM_Entry => 'TicketCommented';
use constant DefaultTemplate => 'Admin Comment';
use constant Description => 'When ticket is commented';
use constant SendAsComment => 1;

sub ConditionMatched {
my $self = shift;
Expand Down
3 changes: 2 additions & 1 deletion t/basic.t
Expand Up @@ -16,6 +16,7 @@ RT->Config->Set( LogToScreen => 'debug' );
RT->Config->Set('Plugins',qw(RT::Extension::NotificationMatrix));
RT->Config->Set('NotifyActor',1);
RT->Config->Set('UseFriendlyToLine',0);
RT->Config->Set('CommentAddress', 'comment@example.com');

use_ok('RT::Extension::NotificationMatrix');

Expand Down Expand Up @@ -211,7 +212,7 @@ mail_ok {
$t2->Load($t->id);
my ($res, $msg) = $t2->Comment(Content => "foobar");
ok($res, $msg);
} { from => qr'USER_B via RT',
} { from => qr'USER_B via RT.*comment@example.com',
bcc => 'user_c@example.com',
subject => qr/a test/,
body => qr/foobar/,
Expand Down

0 comments on commit 91bfa32

Please sign in to comment.