Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reneeb/7308b1cb390a26c1bfe5 to your computer and use it in GitHub Desktop.
Save reneeb/7308b1cb390a26c1bfe5 to your computer and use it in GitHub Desktop.
Sample Postmaster filter
$Self->{'PostMaster::PostFilterModule'}->{'9931313-SetQueue'} = {
Module => 'Kernel::System::PostMaster::Filter::SetQueue',
};
# --
# Kernel/System/PostMaster/Filter/SetQueue.pm - the global PostMaster module for OTRS
# Copyright (C) 2016 Perl-Services.de, http://perl-services.de
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
package Kernel::System::PostMaster::Filter::SetQueue;
use strict;
our @ObjectDependencies = qw(
Kernel::System::Ticket
Kernel::System::Log
);
sub new {
my $Type = shift;
my %Param = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
my $LogObject = $Kernel::OM->Get('Kernel::System::Log');
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
for my $Needed (qw(TicketID JobConfig GetParam)) {
if ( !$Param{$Needed} ) {
$LogObject->Log(
Priority => 'error',
Message => "Need $Needed!",
);
return;
}
}
my %Ticket = $TicketObject->TicketGet(
TicketID => $Param{TicketID},
UserID => 1,
);
return 1 if $Ticket{Queue} ne 'Queue1';
return 1 if $Ticket{StateType} ne 'closed';
$TicketObject->TicketQueueSet(
TicketID => $Param{TicketID},
Queue => 'NewQueue',
UserID => 1,
);
$TicketObject->TicketStateSet(
TicketID => $Param{TicketID},
State => 'open',
UserID => 1,
);
return 1;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment