[Rt-commit] rt branch, create-action, updated. 44d18bef2718c16fb84a2a24fd542bf76133e9f2

sartak at bestpractical.com sartak at bestpractical.com
Thu Nov 5 17:10:02 EST 2009


The branch, create-action has been updated
       via  44d18bef2718c16fb84a2a24fd542bf76133e9f2 (commit)
      from  d5a14106b75306cdaa22dd12a321cba5ab6391aa (commit)

Summary of changes:
 lib/RT/Interface/Email.pm |   83 ------------------------------------------
 lib/RT/Interface/Web.pm   |   87 +++++++++++++++++++++++++++++++++++++++++++-
 lib/RT/Model/Ticket.pm    |    3 +-
 3 files changed, 87 insertions(+), 86 deletions(-)

- Log -----------------------------------------------------------------
commit 44d18bef2718c16fb84a2a24fd542bf76133e9f2
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Nov 5 17:08:32 2009 -0500

    Revert "Move make_mime_entity to RT::Interface::Email"
    
    This reverts commit 0db7157d6068ab22bc89078386dd275d2639a642.
    
    make_mime_entity pokes at $RT::Mason::CGI::Filename, so it doesn't fit
    into RT::Interface::Email.

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 595336e..8f229d7 100755
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1600,87 +1600,4 @@ sub is_correct_action {
     return ( 1, @actions );
 }
 
-=head2 make_mime_entity PARAMHASH
-
-Takes a paramhash subject, body and attachment_field_name.
-
-Also takes Form, cc and type as optional paramhash keys.
-
-  Returns a MIME::Entity.
-
-=cut
-
-sub make_mime_entity {
-
-    my %args = (
-        subject             => undef,
-        from                => undef,
-        cc                  => undef,
-        body                => undef,
-        attachment_field_name => undef,
-        type                => undef,
-        @_,
-    );
-    my $Message = MIME::Entity->build(
-        Type    => 'multipart/mixed',
-        Subject => $args{'subject'} || "",
-        From    => $args{'from'},
-        Cc      => $args{'cc'},
-    );
-
-    if ( defined $args{'body'} && length $args{'body'} ) {
-
-        # Make the update content have no 'weird' newlines in it
-        $args{'body'} =~ s/\r\n/\n/gs;
-
-        # MIME::Head is not happy in utf-8 domain.  This only happens
-        # when processing an incoming email (so far observed).
-        no utf8;
-        use bytes;
-        $Message->attach(
-            Type => $args{'type'} || 'text/plain',
-            Charset => 'UTF-8',
-            Data    => $args{'body'},
-        );
-    }
-
-    if ( $args{'attachment_field_name'} ) {
-
-        my $cgi_object = Jifty->handler->cgi;
-
-        if ( my $filehandle = $cgi_object->upload( $args{'attachment_field_name'} ) ) {
-
-            my ( @content, $buffer );
-            while ( my $bytesread = read( $filehandle, $buffer, 4096 ) ) {
-                push @content, $buffer;
-            }
-
-            my $uploadinfo = $cgi_object->uploadInfo($filehandle);
-
-            # Prefer the cached name first over CGI.pm stringification.
-            my $filename = $RT::Mason::CGI::Filename;
-            $filename = "$filehandle" unless defined($filename);
-            $filename = Encode::decode_utf8($filename);
-            $filename =~ s{^.*[\\/]}{};
-
-            $Message->attach(
-                Type     => $uploadinfo->{'Content-Type'},
-                Filename => $filename,
-                Data     => \@content,
-            );
-            if (   !$args{'subject'}
-                && !( defined $args{'body'} && length $args{'body'} ) )
-            {
-                $Message->head->set( 'Subject' => $filename );
-            }
-        }
-    }
-
-    $Message->make_singlepart;
-    RT::I18N::set_mime_entity_to_utf8($Message);    # convert text parts into utf-8
-
-    return ($Message);
-}
-
-
 1;
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 6754e08..a73e927 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -485,11 +485,94 @@ sub process_update_message {
     return @results;
 }
 
-# Provided for back-compat
+
+
+=head2 make_mime_entity PARAMHASH
+
+Takes a paramhash subject, body and attachment_field_name.
+
+Also takes Form, cc and type as optional paramhash keys.
+
+  Returns a MIME::Entity.
+
+=cut
+
 sub make_mime_entity {
-    RT::Interface::Email::make_mime_entity(@_);
+
+    my %args = (
+        subject             => undef,
+        from                => undef,
+        cc                  => undef,
+        body                => undef,
+        attachment_field_name => undef,
+        type                => undef,
+        @_,
+    );
+    my $Message = MIME::Entity->build(
+        Type    => 'multipart/mixed',
+        Subject => $args{'subject'} || "",
+        From    => $args{'from'},
+        Cc      => $args{'cc'},
+    );
+
+    if ( defined $args{'body'} && length $args{'body'} ) {
+
+        # Make the update content have no 'weird' newlines in it
+        $args{'body'} =~ s/\r\n/\n/gs;
+
+        # MIME::Head is not happy in utf-8 domain.  This only happens
+        # when processing an incoming email (so far observed).
+        no utf8;
+        use bytes;
+        $Message->attach(
+            Type => $args{'type'} || 'text/plain',
+            Charset => 'UTF-8',
+            Data    => $args{'body'},
+        );
+    }
+
+    if ( $args{'attachment_field_name'} ) {
+
+        my $cgi_object = Jifty->handler->cgi;
+
+        if ( my $filehandle = $cgi_object->upload( $args{'attachment_field_name'} ) ) {
+
+            my ( @content, $buffer );
+            while ( my $bytesread = read( $filehandle, $buffer, 4096 ) ) {
+                push @content, $buffer;
+            }
+
+            my $uploadinfo = $cgi_object->uploadInfo($filehandle);
+
+            # Prefer the cached name first over CGI.pm stringification.
+            my $filename = $RT::Mason::CGI::Filename;
+            $filename = "$filehandle" unless defined($filename);
+            $filename = Encode::decode_utf8($filename);
+            $filename =~ s{^.*[\\/]}{};
+            
+
+            $Message->attach(
+                Type     => $uploadinfo->{'Content-Type'},
+                Filename => $filename,
+                Data     => \@content,
+            );
+            if (   !$args{'subject'}
+                && !( defined $args{'body'} && length $args{'body'} ) )
+            {
+                $Message->head->set( 'Subject' => $filename );
+            }
+            
+        }
+    }
+
+    $Message->make_singlepart;
+    RT::I18N::set_mime_entity_to_utf8($Message);    # convert text parts into utf-8
+
+    return ($Message);
+
 }
 
+
 sub process_acl_changes {
     my $ARGSref = shift;
 
diff --git a/lib/RT/Model/Ticket.pm b/lib/RT/Model/Ticket.pm
index 3e07f9a..d8f2c94 100755
--- a/lib/RT/Model/Ticket.pm
+++ b/lib/RT/Model/Ticket.pm
@@ -482,7 +482,8 @@ sub create {
             current_user    => $self->current_user,
         );
 
-        $args{mime_obj} = RT::Interface::Email::make_mime_entity(
+        # XXX: move make_mime_entity somewhere sane
+        $args{mime_obj} = HTML::Mason::Commands::make_mime_entity(
             subject => $args{'subject'},
             from    => $args{'from'},
             cc      => $args{'cc'},

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


More information about the Rt-commit mailing list