[Bps-public-commit] rt-extension-notificationmatrix branch, master, updated. 91bfa3259acf2f77346bb4c278ce4cb15206a3ed

Chia-liang Kao clkao at bestpractical.com
Sun Sep 5 04:09:15 EDT 2010


The branch, master has been updated
       via  91bfa3259acf2f77346bb4c278ce4cb15206a3ed (commit)
      from  3f63b35580865887682b89999f583c7ae31dd759 (commit)

Summary of changes:
 lib/RT/Extension/NotificationMatrix/Rule.pm        |    9 +++++++++
 .../NotificationMatrix/Rule/TicketCommented.pm     |    1 +
 t/basic.t                                          |    3 ++-
 3 files changed, 12 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 91bfa3259acf2f77346bb4c278ce4cb15206a3ed
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Sun Sep 5 16:11:28 2010 +0800

    support sending as comment, for the TicketCommented Rule

diff --git a/lib/RT/Extension/NotificationMatrix/Rule.pm b/lib/RT/Extension/NotificationMatrix/Rule.pm
index aafa626..27f6b1d 100644
--- a/lib/RT/Extension/NotificationMatrix/Rule.pm
+++ b/lib/RT/Extension/NotificationMatrix/Rule.pm
@@ -90,6 +90,8 @@ sub DefaultExternalTemplate {
     $_[0]->DefaultTemplate;
 }
 
+sub SendAsComment { 0 }
+
 sub LoadTemplate {
     my ($self, $external) = @_;
     my $template = RT::Template->new($self->CurrentUser);
@@ -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;
 }
 
diff --git a/lib/RT/Extension/NotificationMatrix/Rule/TicketCommented.pm b/lib/RT/Extension/NotificationMatrix/Rule/TicketCommented.pm
index bdb970c..5ed4e86 100644
--- a/lib/RT/Extension/NotificationMatrix/Rule/TicketCommented.pm
+++ b/lib/RT/Extension/NotificationMatrix/Rule/TicketCommented.pm
@@ -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;
diff --git a/t/basic.t b/t/basic.t
index 7f2cc1b..d049425 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -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 at example.com');
 
 use_ok('RT::Extension::NotificationMatrix');
 
@@ -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 at example.com',
     bcc => 'user_c at example.com',
     subject => qr/a test/,
     body => qr/foobar/,

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list