X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FREST%2F1.0%2Fticket%2Fcomment;h=98b47dfd2d2fdd07310d8ea3f40ec03cfd8932c5;hp=c0a3c47471eb91f4bc8cba2b2714bd7813526ed1;hb=44dd00a3ff974a17999e86e64488e996edc71e3c;hpb=fc6209f398899f0211cfcedeb81a3cd65e04a941 diff --git a/rt/share/html/REST/1.0/ticket/comment b/rt/share/html/REST/1.0/ticket/comment index c0a3c4747..98b47dfd2 100755 --- a/rt/share/html/REST/1.0/ticket/comment +++ b/rt/share/html/REST/1.0/ticket/comment @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -52,11 +52,9 @@ $content <%INIT> use MIME::Entity; -use LWP::MediaTypes; use RT::Interface::REST; -use File::Temp qw(tempfile); -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); my $object = $r->path_info; my $status = "200 Ok"; my $output; @@ -106,39 +104,23 @@ if (!$k->{Text} && @atts == 0) { } my $cgi = $m->cgi_object; -my $ent = MIME::Entity->build(Type => "multipart/mixed"); -$ent->attach(Data => $k->{Text}) if $k->{Text}; +my $ent = MIME::Entity->build( + Type => "multipart/mixed", + 'X-RT-Interface' => 'REST', +); +$ent->attach( + Type => "text/plain", + Charset => "UTF-8", + Data => Encode::encode( "UTF-8", $k->{Text} ), +) if $k->{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(); - - 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 ($res, $msg) = process_attachments($ent, @atts); + unless ( $res ) { $status = "400 Bad Request"; - $output = "No attachment for $att.\n"; + $output = "$msg\n"; goto OUTPUT; } - - $i++; } $ticket->Load($object); @@ -171,6 +153,7 @@ if ($k->{Status}) { } OUTPUT: + RT/<% $RT::VERSION %> <% $status %>