X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FAction%2FSendEmail.pm;h=8897cb9c1c355ca1488dffc1bda8ed9095b19f62;hp=80b0054ee059044f7855b774cccc71f5e853ad9e;hb=187086c479a09629b7d180eec513fb7657f4e291;hpb=0ed195595b5c7ea404c8848d9d1881ada4214489 diff --git a/rt/lib/RT/Action/SendEmail.pm b/rt/lib/RT/Action/SendEmail.pm index 80b0054ee..8897cb9c1 100755 --- a/rt/lib/RT/Action/SendEmail.pm +++ b/rt/lib/RT/Action/SendEmail.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -317,24 +317,21 @@ sub SendMessage { return (1); } -=head2 AddAttachments +=head2 AttachableFromTransaction -Takes any attachments to this transaction and attaches them to the message -we're building. +Function (not method) that takes an L and returns an +L collection of attachments suitable for attaching to an +email. =cut -sub AddAttachments { - my $self = shift; - - my $MIMEObj = $self->TemplateObj->MIMEObj; - - $MIMEObj->head->delete('RT-Attach-Message'); +sub AttachableFromTransaction { + my $txn = shift; my $attachments = RT::Attachments->new( RT->SystemUser ); $attachments->Limit( FIELD => 'TransactionId', - VALUE => $self->TransactionObj->Id + VALUE => $txn->Id ); # Don't attach anything blank @@ -344,7 +341,7 @@ sub AddAttachments { # We want to make sure that we don't include the attachment that's # being used as the "Content" of this message" unless that attachment's # content type is not like text/... - my $transaction_content_obj = $self->TransactionObj->ContentObj; + my $transaction_content_obj = $txn->ContentObj; if ( $transaction_content_obj && $transaction_content_obj->ContentType =~ m{text/}i ) @@ -368,6 +365,25 @@ sub AddAttachments { } } + return $attachments; +} + +=head2 AddAttachments + +Takes any attachments to this transaction and attaches them to the message +we're building. + +=cut + +sub AddAttachments { + my $self = shift; + + my $MIMEObj = $self->TemplateObj->MIMEObj; + + $MIMEObj->head->delete('RT-Attach-Message'); + + my $attachments = AttachableFromTransaction($self->TransactionObj); + # attach any of this transaction's attachments my $seen_attachment = 0; while ( my $attach = $attachments->Next ) {