I now have the following problem: We usually want to send an autoresponse to the customer when a new ticket is created. However, when a ticket is merged automatically we do _not_ want to send this auto-response. Is there a simple way to achieve this?
Many thanks in advance
PS: Code for the merge filter:
Code: Select all
package Kernel::System::PostMaster::MergeEagerCustomerMails;
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = 0.01;
use Kernel::System::Ticket;
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
$Self->{Debug} = $Param{Debug} || 0;
# get needed objects
for my $Object (
qw(ConfigObject LogObject DBObject TimeObject MainObject EncodeObject ParserObject)
)
{
$Self->{$Object} = $Param{$Object} || die "Got no $Object!";
}
$Self->{TicketObject} = Kernel::System::Ticket->new(%Param);
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
print STDERR %Param;
# FIXME: Not sure what is needed ...
for my $Needed (qw(TicketID)) {
if ( !$Param{$Needed} ) {
$Self->{LogObject}->Log(
Priority => 'error',
Message => "Need $Needed!",
);
return;
}
}
my %GetParam = %{ $Param{GetParam} };
# We'll only use the first 'from' address
my ( $EmailAddress ) = $Self->{ParserObject}->SplitAddressLine(
Line => $GetParam{From},
);
print STDERR $EmailAddress;
# search existing tickets for that email address. We only take the first ticket
# that we find and will merge with that one.
my @TicketIDs = $Self->{TicketObject}->TicketSearch(
Result => 'ARRAY',
From => $EmailAddress,
States => ['new'],
Limit => 20,
UserID => 1, # ???
);
my $TicketID;
for ( @TicketIDs ) {
if ( $_ != $Param{TicketID} ) {
$TicketID = $_;
}
}
if ( $TicketID ) {
print STDERR "Found Ticket with ID: " . $TicketID;
$Self->{TicketObject}->TicketMerge(
MainTicketID => $TicketID,
MergeTicketID => $Param{TicketID},
UserID => 1, # ???
);
} else {
print STDERR "Didn't found any tickets for email address " . $EmailAddress;
}
return 1;
}
1;