[Bps-public-commit] rt-extension-excelfeed branch remove-buildemail-overlay created. 0.07-1-g5c0588e

BPS Git Server git at git.bestpractical.com
Thu Aug 25 17:11:08 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-excelfeed".

The branch, remove-buildemail-overlay has been created
        at  5c0588ed14d3dda284a41a33fed1163a7c58eda6 (commit)

- Log -----------------------------------------------------------------
commit 5c0588ed14d3dda284a41a33fed1163a7c58eda6
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Aug 25 13:07:02 2022 -0400

    Call the core BuildEmail to automatically get RT updates
    
    Monkey patch BuildEmail rather than completely overlaying
    so we can automatically pick up changes in RT without
    having to update this extension.

diff --git a/lib/RT/Dashboard/Mailer_Vendor.pm b/lib/RT/Dashboard/Mailer_Vendor.pm
index d0fe02c..1221775 100644
--- a/lib/RT/Dashboard/Mailer_Vendor.pm
+++ b/lib/RT/Dashboard/Mailer_Vendor.pm
@@ -179,7 +179,15 @@ SUMMARY
     );
 }
 
-sub BuildEmail {
+
+my $original_build_email = \&RT::Dashboard::Mailer::BuildEmail;
+
+*BuildEmail = sub {
+
+    # First process normally
+    my $entity = &$original_build_email( @_ );
+
+    # Now add an excel attachment, if we have one
     my $self = shift;
     my %args = (
         Content => undef,
@@ -190,73 +198,6 @@ sub BuildEmail {
         @_,
     );
 
-    my @parts;
-    my %cid_of;
-
-    my $content = HTML::RewriteAttributes::Resources->rewrite($args{Content}, sub {
-            my $uri = shift;
-
-            # already attached this object
-            return "cid:$cid_of{$uri}" if $cid_of{$uri};
-
-            my ($data, $filename, $mimetype, $encoding) = GetResource($uri);
-            return $uri unless defined $data;
-
-            $cid_of{$uri} = time() . $$ . int(rand(1e6));
-
-            # Encode textual data in UTF-8, and downgrade (treat
-            # codepoints as codepoints, and ensure the UTF-8 flag is
-            # off) everything else.
-            my @extra;
-            if ( $mimetype =~ m{text/} ) {
-                $data = Encode::encode( "UTF-8", $data );
-                @extra = ( Charset => "UTF-8" );
-            } else {
-                utf8::downgrade( $data, 1 ) or $RT::Logger->warning("downgrade $data failed");
-            }
-
-            push @parts, MIME::Entity->build(
-                Top          => 0,
-                Data         => $data,
-                Type         => $mimetype,
-                Encoding     => $encoding,
-                Disposition  => 'inline',
-                Name         => RT::Interface::Email::EncodeToMIME( String => $filename ),
-                'Content-Id' => $cid_of{$uri},
-                @extra,
-            );
-
-            return "cid:$cid_of{$uri}";
-        },
-        inline_css => sub {
-            my $uri = shift;
-            my ($content) = GetResource($uri);
-            return defined $content ? $content : "";
-        },
-        inline_imports => 1,
-    );
-
-    my $entity = MIME::Entity->build(
-        From    => Encode::encode("UTF-8", $args{From}),
-        To      => Encode::encode("UTF-8", $args{To}),
-        Subject => RT::Interface::Email::EncodeToMIME( String => $args{Subject} ),
-        Type    => "multipart/mixed",
-    );
-
-    $entity->attach(
-        Type        => 'text/html',
-        Charset     => 'UTF-8',
-        Data        => Encode::encode("UTF-8", $content),
-        Disposition => 'inline',
-        Encoding    => "base64",
-    );
-
-    for my $part (@parts) {
-        $entity->add_part($part);
-    }
-
-    $entity->make_singlepart;
-
     if ( defined $args{'Attachments'} and @{$args{'Attachments'}} ){
         foreach my $attachment (@{$args{'Attachments'}}){
             $entity->attach(
@@ -269,7 +210,8 @@ sub BuildEmail {
     }
 
     return $entity;
-}
+};
+
 
 1;
 

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


hooks/post-receive
-- 
rt-extension-excelfeed


More information about the Bps-public-commit mailing list