[Rt-commit] rt branch, 4.2/smime-v2, updated. rt-4.0.4-356-g7d82251
Jason May
jasonmay at bestpractical.com
Tue Jan 10 11:17:46 EST 2012
The branch, 4.2/smime-v2 has been updated
via 7d822511400bd08e5e13de699c0be872984988d8 (commit)
from 103a3ed6c5e2d9eed9141a685e2912782ff80d8b (commit)
Summary of changes:
lib/RT/Interface/Email/Auth/Crypt.pm | 36 +++++++++++++++++----------------
1 files changed, 19 insertions(+), 17 deletions(-)
- Log -----------------------------------------------------------------
commit 7d822511400bd08e5e13de699c0be872984988d8
Author: Jason May <jasonmay at bestpractical.com>
Date: Tue Jan 10 11:17:03 2012 -0500
Factor sending templated errors for convenient future use
diff --git a/lib/RT/Interface/Email/Auth/Crypt.pm b/lib/RT/Interface/Email/Auth/Crypt.pm
index 429b72b..38cee41 100644
--- a/lib/RT/Interface/Email/Auth/Crypt.pm
+++ b/lib/RT/Interface/Email/Auth/Crypt.pm
@@ -232,20 +232,11 @@ sub CheckNoPrivateKey {
$RT::Logger->error("Couldn't decrypt a message: have no private key");
- my $address = (RT::Interface::Email::ParseSenderAddressFromHead( $args{'Message'}->head ))[0];
- my ($status) = RT::Interface::Email::SendEmailUsingTemplate(
- To => $address,
+ return EmailErrorToSender(
+ %args,
Template => 'Error: no private key',
- Arguments => {
- Message => $args{'Message'},
- TicketObj => $args{'Ticket'},
- },
- InReplyTo => $args{'Message'},
+ Arguments => { Message => $args{'Message'} },
);
- unless ( $status ) {
- $RT::Logger->error("Couldn't send 'Error: no private key'");
- }
- return 0;
}
sub CheckBadData {
@@ -258,14 +249,25 @@ sub CheckBadData {
$RT::Logger->error("Couldn't process a message: ". join ', ', @bad_data_messages );
+ return EmailErrorToSender(
+ %args,
+ Template => 'Error: bad GnuPG data',
+ Arguments => { Messages => [ @bad_data_messages ] },
+ );
+}
+
+sub EmailErrorToSender {
+ my $self = shift;
+ my %args = (@_);
+
+ $args{'Arguments'} ||= {};
+ $args{'Arguments'}{'TicketObj'} ||= $args{'Ticket'};
+
my $address = (RT::Interface::Email::ParseSenderAddressFromHead( $args{'Message'}->head ))[0];
my ($status) = RT::Interface::Email::SendEmailUsingTemplate(
To => $address,
- Template => 'Error: bad GnuPG data',
- Arguments => {
- Messages => [ @bad_data_messages ],
- TicketObj => $args{'Ticket'},
- },
+ Template => $args{'Template'},
+ Arguments => $args{'Arguments'},
InReplyTo => $args{'Message'},
);
unless ( $status ) {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list