<%init>
# we can't use the 'Default' callback from ShowMessageHeaders here
# because after the callback every header value runs through
# '/Elements/MakeClicky' which removes all html with
# RT::Interface::Web::EscapeUTF8 
foreach my $f (@headers) {
    next unless $f->{'Tag'} eq 'X-RT-Attach';

    $f->{'Value'} =~ s/(?:^\s*|\s*$)//g;

    my $att = RT::Attachment->new( $session{'CurrentUser'} );
    $att->Load($f->{'Value'});

    next unless $att->Id and $att->TransactionObj->CurrentUserCanSee;

    my $desc = $att->Filename . " ";
    $desc   .= loc( "[_1] ([_2]) by [_3]",
        $att->CreatedAsString,
        $att->FriendlyContentLength,
        $m->scomp('/Elements/ShowUser', User => $att->CreatorObj) );

    $f->{'Value'} = sprintf '<a href="%s/Ticket/Attachment/%d/%d/%s">%s</a>',
        RT->Config->Get('WebPath'), $att->TransactionObj->Id, $att->Id,
        $m->interp->apply_escapes($att->Filename, qw(u h)),
        $desc;

    # rename header for better display in ticket history
    $f->{'Tag'} = 'Attachment';
}
</%init>
<%args>
@headers => []
</%args>