<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 5, 2014 at 12:32 PM, Hugo Escobar <span dir="ltr"><<a href="mailto:hescobar@afslc.com" target="_blank">hescobar@afslc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Feb 5, 2014 at 10:23 AM, Kevin Falcone <span dir="ltr"><<a href="mailto:falcone@bestpractical.com" target="_blank">falcone@bestpractical.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>On Tue, Feb 04, 2014 at 04:02:05PM -0500, Hugo Escobar wrote:<br>
> $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, checks_failure => \$checks_failure,<br>
> results => \@results, CallbackName => 'Initial' );<br>
><br>
> which exists at the beginning of the <%INIT> section<br>
> My implementation of this callback creates a MIME::Entity and adds the file to it, then it<br>
> 'writes' the whole message to $session{'Attachments'}<br>
><br>
> I've been trying to do the right changes for this to work under 4.2.2 but no luck so far<br>
<br>
</div>You've not shown your code, so I'm guessing, but if you look at how<br>
4.2 stores attachments in the session, it uses a token to finally fix<br>
the bug of creating two tickets simultaneously and accidentally<br>
attaching the wrong attachments to the wrong ticket.<br>
<br>
$session{Attachments}{$ARGS{Token}}<br>
<br>
Relevant code is in ProcessAttachments and you can also see it used in<br>
CreateTicket.<span><font color="#888888"><br></font></span></blockquote><div><br></div></div></div><div>This is what I do:<br><br> my $Message = MIME::Entity->build(<br> Type => 'multipart/mixed',<br>
"Message-Id" => RT::Interface::Email::GenMessageId,<br> );<br> <br> my ( $filehandle, @ar_content, $buffer );<br> open( $filehandle, "<", \$content ); <br>
while ( my $bytesread = read( $filehandle, $buffer, 4096 ) ) {<br> push @ar_content, $buffer;<br> }<br> close $filehandle;<br> <br> $Message->attach(<br> Filename => $doc_path,<br>
Type => 'application/pdf',<br> Data => \@ar_content,<br> );<br> <br> # Attachment parts really shouldn't get a Message-ID<br> $Message->head->delete('Message-ID');<br>
$Message->make_singlepart;<br> RT::I18N::SetMIMEEntityToUTF8($Message); # convert text parts into utf-8<br><br><span style="color:rgb(0,0,255)"> $session{'Attachments'} = {<br> %{$session{'Attachments'} || {}}, <br>
$key . '.pdf' => $Message<br> };</span><br> <br> (...)<br></div><div><br></div><div>I changed the blue lines by the following:<br><br>session{'Attachments'}{Digest::MD5::md5_hex(rand(1024))}{$key . '.pdf'} = $Message;<br>
</div><div><br></div><div>The reason I create a token here is that at this point ('/Ticket/Display.html') there seems to be no 'Attachment' in $session<br></div><div> </div></div>The problem persists, post added without attachment<br clear="all">
</div><div class="im"><div class="gmail_extra"> <br></div></div></div></blockquote></div><br></div><div class="gmail_extra">Solved.<br><br></div><div class="gmail_extra">Adding the following lines solves the problem:<br>
<br> $ARGSRef->{'Token'} = Digest::MD5::md5_hex(rand(1024));<br> $session{'Attachments'}{$ARGSRef->{'Token'}}{$key . '.pdf'} = $Message;<br><br> $ARGSRef->{'UpdateType'} = 'response';<br>
$ARGSRef->{'UpdateAttach'} = '1';<br><br> $ARGSRef->{UpdateContent} = 'any text';<br></div><div class="gmail_extra"><br clear="all"><br></div><div class="gmail_extra">Thank you for your help, it pointed me in the right direction<br>
</div><div class="gmail_extra"><br>-- <br>Hugo Escobar<br><br><br><img title="AFS_logo.png" alt="AFS_logo.png" src="cid:ii_12ddc99660bf2d8d" height="35" width="171"><br><br>Follow us on Facebook and Linked-In<br clear="all">
<br><a href="http://www.facebook.com/pages/Miami-FL/ASSOCIATION-FINANCIAL/64952991864" target="_blank"><img title="facebook-24x24.png" alt="facebook-24x24.png" src="cid:ii_12ddc9e6256d137a"></a> <a href="http://www.linkedin.com/companies/1006276" target="_blank"><img title="linkedin-24x24.png" alt="linkedin-24x24.png" src="cid:ii_12ddc9cb29a3a5d5"></a><br>
</div></div>