[Rt-commit] rt branch, 4.0/mail-threading, created. rt-4.0.2-119-g93d452a
Ruslan Zakirov
ruz at bestpractical.com
Thu Sep 29 16:38:45 EDT 2011
The branch, 4.0/mail-threading has been created
at 93d452ac5739cc2d7daa9f705d73fb770c6eeb83 (commit)
- Log -----------------------------------------------------------------
commit 93d452ac5739cc2d7daa9f705d73fb770c6eeb83
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Sep 30 00:37:16 2011 +0400
thread notifications better
make sure we put pseudo reference all the time
diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index 553b736..b121128 100644
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -1016,6 +1016,7 @@ sub SetReferencesHeaders {
@references = split( /\s+/m, $top->GetHeader('References') || '' );
@msgid = split( /\s+/m, $top->GetHeader('Message-ID') || '' );
} else {
+ $self->SetHeader( References => $self->PseudoReference );
return (undef);
}
diff --git a/t/mail/threading.t b/t/mail/threading.t
new file mode 100644
index 0000000..25904ab
--- /dev/null
+++ b/t/mail/threading.t
@@ -0,0 +1,90 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use utf8;
+
+use RT::Test tests => 22;
+RT->Config->Set( NotifyActor => 1 );
+
+my $queue = RT::Test->load_or_create_queue(
+ Name => 'General',
+ CorrespondAddress => 'rt-recipient at example.com',
+ CommentAddress => 'rt-recipient at example.com',
+);
+ok $queue && $queue->id, 'loaded or created queue';
+
+my $user = RT::Test->load_or_create_user(
+ Name => 'root',
+ EmailAddress => 'root at localhost',
+);
+ok $user && $user->id, 'loaded or created user';
+
+{
+ my $mail = <<EOF;
+From: root\@localhost
+Subject: a ticket
+Message-ID: <some-message-id>
+
+Foob!
+EOF
+ my ($status, $id) = RT::Test->send_via_mailgate($mail);
+ ok $id, "created a ticket";
+
+ my @mail = RT::Test->fetch_caught_mails;
+ is scalar @mail, 1, "autoreply";
+ like $mail[0], qr{^In-Reply-To:\s*<some-message-id>$}mi;
+ like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>}mi;
+
+ my $ticket = RT::Ticket->new( RT->SystemUser );
+ $ticket->Load( $id );
+ ok $ticket->id, "loaded ticket";
+
+ my ($status, $msg) = $ticket->Correspond( Content => 'boo' );
+ ok $status, "replied to the ticket";
+
+ @mail = RT::Test->fetch_caught_mails;
+ is scalar @mail, 1, "reply";
+ like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>$}mi,
+ "no context, so only pseudo header is referenced";
+}
+
+{
+ my ($ticket) = RT::Test->create_ticket(
+ Queue => $queue->id,
+ Requestor => $user->EmailAddress
+ );
+ my $id = $ticket->id;
+ ok $id, "created a ticket";
+
+ my @mail = RT::Test->fetch_caught_mails;
+ is scalar @mail, 1, "autoreply";
+ like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>}mi;
+}
+
+{
+ my $scrip = RT::Scrip->new(RT->SystemUser);
+ my ($status, $msg) = $scrip->Create(
+ Description => "Notify requestor on status change",
+ ScripCondition => 'On Status Change',
+ ScripAction => 'Notify Requestors',
+ Template => 'Transaction',
+ Stage => 'TransactionCreate',
+ Queue => 0,
+ );
+ ok($status, "Scrip created");
+
+ my ($ticket) = RT::Test->create_ticket(
+ Queue => $queue->id,
+ Requestor => $user->EmailAddress,
+ );
+ my $id = $ticket->id;
+ ok $id, "created a ticket";
+
+ RT::Test->fetch_caught_mails;
+ ($status, $msg) = $ticket->SetStatus('open');
+ ok $status, "changed status";
+
+ my @mail = RT::Test->fetch_caught_mails;
+ is scalar @mail, 1, "status change notification";
+ like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>}mi;
+}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list