[rt-users] Editing Email.pm to not ParseTicketId if Requestor is equal to 'X'
Ruslan Zakirov
ruz at bestpractical.com
Thu Apr 5 06:36:25 EDT 2012
Hi,
I don't know when we lost this or patch was never applied, but
ParseTicketId is called with subject only.
ParseTicketId is called in one place:
$args{'ticket'} ||= ParseTicketId( $Subject );
Change the line to:
$args{'ticket'} ||= ParseTicketId( $Subject, $Message );
This way second argument will be MIME::Entity object and you would be
able to get head object by calling $entity->head method.
Good luck.
On Thu, Apr 5, 2012 at 11:25, Luong Bui Duc <luong.d.bui at gmail.com> wrote:
> Dear RT,
>
> I'm trying to edit /opt/rt4/lib/RT/Interface/Email.pm sub
> called ParseTicketId to not return ticket $id if Requestor email is equal to
> 'x at y.com' but unfortunately after editing it, mailgate start throwing me
> errors. Here is my code(in Bold is what i added to original RT code):
>
> sub ParseTicketId {
> my $Subject = shift;
> my $head = shift;
> my ( $Sender, $junk ) = ParseSenderAddressFromHead($head);
> my $rtname = RT->Config->Get('rtname');
> my $test_name = RT->Config->Get('EmailSubjectTagRegex') ||
> qr/\Q$rtname\E/i;
>
> my $id;
> if ( $Sender =~ m/x\@y\.com/ ) {
>
> return undef;
> } else {
> if ( $Subject =~ s/\[$test_name\s+\#(\d+)\s*\]//i ) {
> $id = $1;
> } else {
> foreach my $tag ( RT->System->SubjectTag ) {
> next unless $Subject =~ s/\[\Q$tag\E\s+\#(\d+)\s*\]//i;
> $id = $1;
> last;
> }
> }
> return undef unless $id;
>
> $RT::Logger->debug("Found a ticket ID. It's $id");
> return $id;
> }
> }
>
> And logs show following:
>
> RT server error.
>
> The RT server which handled your email did not behave as expected. It
> said:
>
> Can't call method "get" on an undefined value at
> /opt/rt4/sbin/../lib/RT/Interface/Email.pm line 1075.
>
> Stack:
> [/opt/rt4/sbin/../lib/RT/Interface/Email.pm:1075]
> [/opt/rt4/sbin/../lib/RT/Interface/Email.pm:1210]
> [/opt/rt4/sbin/../lib/RT/Interface/Email.pm:1439]
> [/opt/rt4/share/html/REST/1.0/NoAuth/mail-gateway:61]
>
> fetchmail: MDA returned nonzero status 75
>
>
> I'm pretty new to RT and Perl itself, so i hope you can point me to the
> right directions.
>
> --
> Thanks a lot,
>
> L
>
>
--
Best regards, Ruslan.
More information about the rt-users
mailing list