[Rt-commit] rt branch, 4.2/email-attachments, created. rt-4.2.11-46-g2b8eb86
Shawn Moore
shawn at bestpractical.com
Fri Aug 7 19:21:06 EDT 2015
The branch, 4.2/email-attachments has been created
at 2b8eb8662ae484c391dabc4781bc4ac7277a4fa1 (commit)
- Log -----------------------------------------------------------------
commit 2b8eb8662ae484c391dabc4781bc4ac7277a4fa1
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Fri Aug 7 23:20:27 2015 +0000
Factor out AttachableFromTransaction
This can be used in templates to link to (rather than attach) each
attachment.
diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index cee612e..3bfe802 100644
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -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<RT::Transaction> and returns an
+L<RT::Attachments> 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 ) {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list