[rt-users] custom callback for ticket update not working after update 4.0.2 -> 4.2.2
Hugo Escobar
hescobar at afslc.com
Wed Feb 5 15:27:49 EST 2014
On Wed, Feb 5, 2014 at 12:32 PM, Hugo Escobar <hescobar at afslc.com> wrote:
>
> On Wed, Feb 5, 2014 at 10:23 AM, Kevin Falcone <falcone at bestpractical.com>wrote:
>
>> On Tue, Feb 04, 2014 at 04:02:05PM -0500, Hugo Escobar wrote:
>> > $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS,
>> checks_failure => \$checks_failure,
>> > results => \@results, CallbackName => 'Initial' );
>> >
>> > which exists at the beginning of the <%INIT> section
>> > My implementation of this callback creates a MIME::Entity and adds
>> the file to it, then it
>> > 'writes' the whole message to $session{'Attachments'}
>> >
>> > I've been trying to do the right changes for this to work under
>> 4.2.2 but no luck so far
>>
>> You've not shown your code, so I'm guessing, but if you look at how
>> 4.2 stores attachments in the session, it uses a token to finally fix
>> the bug of creating two tickets simultaneously and accidentally
>> attaching the wrong attachments to the wrong ticket.
>>
>> $session{Attachments}{$ARGS{Token}}
>>
>> Relevant code is in ProcessAttachments and you can also see it used in
>> CreateTicket.
>>
>
> This is what I do:
>
> my $Message = MIME::Entity->build(
> Type => 'multipart/mixed',
> "Message-Id" => RT::Interface::Email::GenMessageId,
> );
>
> my ( $filehandle, @ar_content, $buffer );
> open( $filehandle, "<", \$content );
> while ( my $bytesread = read( $filehandle, $buffer, 4096 ) ) {
> push @ar_content, $buffer;
> }
> close $filehandle;
>
> $Message->attach(
> Filename => $doc_path,
> Type => 'application/pdf',
> Data => \@ar_content,
> );
>
> # Attachment parts really shouldn't get a Message-ID
> $Message->head->delete('Message-ID');
> $Message->make_singlepart;
> RT::I18N::SetMIMEEntityToUTF8($Message); # convert text parts
> into utf-8
>
> $session{'Attachments'} = {
> %{$session{'Attachments'} || {}},
> $key . '.pdf' => $Message
> };
>
> (...)
>
> I changed the blue lines by the following:
>
> session{'Attachments'}{Digest::MD5::md5_hex(rand(1024))}{$key . '.pdf'} =
> $Message;
>
> The reason I create a token here is that at this point
> ('/Ticket/Display.html') there seems to be no 'Attachment' in $session
>
> The problem persists, post added without attachment
>
>
Solved.
Adding the following lines solves the problem:
$ARGSRef->{'Token'} = Digest::MD5::md5_hex(rand(1024));
$session{'Attachments'}{$ARGSRef->{'Token'}}{$key . '.pdf'} =
$Message;
$ARGSRef->{'UpdateType'} = 'response';
$ARGSRef->{'UpdateAttach'} = '1';
$ARGSRef->{UpdateContent} = 'any text';
Thank you for your help, it pointed me in the right direction
--
Hugo Escobar
[image: AFS_logo.png]
Follow us on Facebook and Linked-In
[image: facebook-24x24.png]<http://www.facebook.com/pages/Miami-FL/ASSOCIATION-FINANCIAL/64952991864>
[image: linkedin-24x24.png] <http://www.linkedin.com/companies/1006276>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20140205/9cc08e39/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AFS_logo.png
Type: image/png
Size: 3183 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20140205/9cc08e39/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linkedin-24x24.png
Type: image/png
Size: 875 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20140205/9cc08e39/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: facebook-24x24.png
Type: image/png
Size: 814 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20140205/9cc08e39/attachment-0002.png>
More information about the rt-users
mailing list