[Rt-commit] rt branch, 4.4/rt-munge-attachments, updated. rt-4.4.3-44-gb50ab76e9

Craig Kaiser craig at bestpractical.com
Tue Nov 6 17:39:51 EST 2018


The branch, 4.4/rt-munge-attachments has been updated
       via  b50ab76e93d01b8d4d37c4bbdc3582a9111b3816 (commit)
       via  8ff98c5c5b8ba7787cd6d515924ef082a5da853c (commit)
      from  4f1157ffcc8ecb22a9e3dce49c17a314037f4467 (commit)

Summary of changes:
 lib/RT/Attachments.pm | 11 +++++++++++
 lib/RT/Transaction.pm |  4 ++++
 2 files changed, 15 insertions(+)

- Log -----------------------------------------------------------------
commit 8ff98c5c5b8ba7787cd6d515924ef082a5da853c
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Tue Nov 6 17:37:54 2018 -0500

    Add new transaction type for munging attachments

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 9f897c307..39cb3b71c 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1373,6 +1373,10 @@ sub _CanonicalizeRoleName {
         $principal->Load($self->Field);
         return ("Removed from group '[_1]'", $principal->Object->Name); #loc()
     },
+    Munge => sub {
+        my $self = shift;
+        return $self->loc("Attachment content modified");
+    },
 );
 
 

commit b50ab76e93d01b8d4d37c4bbdc3582a9111b3816
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Tue Nov 6 17:38:31 2018 -0500

    Record transaction when munging attachment content

diff --git a/lib/RT/Attachments.pm b/lib/RT/Attachments.pm
index 9389c49c7..188edfe69 100644
--- a/lib/RT/Attachments.pm
+++ b/lib/RT/Attachments.pm
@@ -287,15 +287,26 @@ sub ReplaceAttachments {
         SUBCLAUSE       => 'Attachments',
     ) unless !$args{Content};
 
+    my %tickets;
     while (my $attachment = $self->Next) {
+        my $content_replaced;
         if ( $args{Headers} ) {
             my ($ret, $msg) = $attachment->ReplaceHeaders(Search => $args{Search}, Replacement => $args{Replacement});
             RT::Logger->error($msg) unless $ret;
+            $content_replaced = $ret;
         }
         if ( $args{Content} ) {
             my ($ret, $msg) = $attachment->ReplaceContent(Search => $args{Search}, Replacement => $args{Replacement});
             RT::Logger->error($msg) unless $ret;
+            $content_replaced = $ret || $content_replaced;
         }
+        my $ticket = $attachment->TransactionObj->TicketObj;
+        $tickets{$ticket->Id} = $ticket if $content_replaced;
+    }
+    foreach my $ticket (values %tickets){
+        $ticket->_NewTransaction(
+            Type     => "Munge",
+        );
     }
     return;
 }

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


More information about the rt-commit mailing list