X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FREST%2F1.0%2FForms%2Fticket%2Fcomment;h=934cbfb68555709667017148b99cdc701fd14014;hp=b50135fec7e5f2d972fd1d3b39fc81dd24bbf310;hb=e9e0cf0989259b94d9758eceff448666a2e5a5cc;hpb=7588a4ac90a9b07c08a3107cd1107d773be1c991 diff --git a/rt/share/html/REST/1.0/Forms/ticket/comment b/rt/share/html/REST/1.0/Forms/ticket/comment index b50135fec..934cbfb68 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/comment +++ b/rt/share/html/REST/1.0/Forms/ticket/comment @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -53,10 +53,7 @@ $id <%INIT> use MIME::Entity; -use LWP::MediaTypes; use RT::Interface::REST; -use File::Temp qw(tempfile); -my @tmp_files; $RT::Logger->debug("Got ticket id=$id for comment"); $RT::Logger->debug("Got args @{[keys(%changes)]}."); @@ -89,44 +86,23 @@ if (!$changes{Text} && @atts == 0) { goto OUTPUT; } -my $cgi = $m->cgi_object; my $ent = MIME::Entity->build( Type => "multipart/mixed", 'X-RT-Interface' => 'REST', ); -$ent->attach(Data => $changes{Text}) if $changes{Text}; +$ent->attach( + 'Content-Type' => $changes{'Content-Type'} || 'text/plain', + Data => $changes{Text}, +) if $changes{Text}; -my $i = 1; -foreach my $att (@atts) { - local $/=undef; - my $file = $att; - $file =~ s#^.*[\\/]##; - my $fh = $cgi->upload("attachment_$i"); - if ($fh) { - my $buf; - my ($w, $tmp) = tempfile(); - my $info = $cgi->uploadInfo($fh); - push @tmp_files, $tmp; - - while (sysread($fh, $buf, 8192)) { - syswrite($w, $buf); - } - - $ent->attach( - Path => $tmp, - Type => $info->{'Content-Type'} || guess_media_type($tmp), - Filename => $file, - Disposition => "attachment" - ); - } - else { +{ + my ($status, $msg) = process_attachments($ent, @atts); + unless ( $status ) { $e = 1; - $c = "# No attachment for $att."; + $c = "# $msg"; goto OUTPUT; } - - $i++; } unless ($ticket->CurrentUserHasRight('ModifyTicket') || @@ -154,6 +130,5 @@ if ($changes{Status}) { OUTPUT: -unlink @tmp_files; return [ $c, $o, $k, $e ];