This commit is contained in:
2024-10-14 00:08:40 +02:00
parent dbfba56f66
commit 1462d52e13
4572 changed files with 2658864 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::PostMaster::FollowUpCheck::Attachments;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::Ticket',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
$Self->{ParserObject} = $Param{ParserObject} || die "Got no ParserObject";
# Get communication log object.
$Self->{CommunicationLogObject} = $Param{CommunicationLogObject} || die "Got no CommunicationLogObject!";
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
# Ignore all inline parts as these are actually part of the email body.
my @Attachments = $Self->{ParserObject}->GetAttachments();
@Attachments = grep { defined $_->{ContentDisposition} && $_->{ContentDisposition} ne 'inline' } @Attachments;
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::Attachments',
Value => 'Searching for TicketNumber in email attachments.',
);
ATTACHMENT:
for my $Attachment (@Attachments) {
my $Tn = $TicketObject->GetTNByString( $Attachment->{Content} );
next ATTACHMENT if !$Tn;
my $TicketID = $TicketObject->TicketCheckNumber( Tn => $Tn );
if ($TicketID) {
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::Attachments',
Value =>
"Found valid TicketNumber '$Tn' (TicketID '$TicketID') in email attachment '$Attachment->{Filename}'.",
);
return $TicketID;
}
}
return;
}
1;

View File

@@ -0,0 +1,66 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::PostMaster::FollowUpCheck::Body;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::Ticket',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
$Self->{ParserObject} = $Param{ParserObject} || die "Got no ParserObject";
# Get communication log object.
$Self->{CommunicationLogObject} = $Param{CommunicationLogObject} || die "Got no CommunicationLogObject!";
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::Body',
Value => 'Searching for TicketNumber in email body.',
);
my $Tn = $TicketObject->GetTNByString( $Self->{ParserObject}->GetMessageBody() );
return if !$Tn;
my $TicketID = $TicketObject->TicketCheckNumber( Tn => $Tn );
if ($TicketID) {
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::Body',
Value => "Found valid TicketNumber '$Tn' (TicketID '$TicketID') in email body.",
);
return $TicketID;
}
return;
}
1;

View File

@@ -0,0 +1,154 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::PostMaster::FollowUpCheck::BounceEmail;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::Log',
'Kernel::System::Ticket',
'Kernel::System::Ticket::Article',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
$Self->{ParserObject} = $Param{ParserObject} || die "Got no ParserObject";
# Get communication log object.
$Self->{CommunicationLogObject} = $Param{CommunicationLogObject} || die "Got no CommunicationLogObject!";
# Get Article backend object.
$Self->{ArticleBackendObject} =
$Kernel::OM->Get('Kernel::System::Ticket::Article')->BackendForChannel( ChannelName => 'Email' );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
$Self->_AddCommunicationLog( Message => 'Searching for header X-OTRS-Bounce.' );
return if !$Param{GetParam}->{'X-OTRS-Bounce'};
my $BounceMessageID = $Param{GetParam}->{'X-OTRS-Bounce-OriginalMessageID'};
$Self->_AddCommunicationLog(
Message => sprintf(
'Searching for article with message id "%s".',
$BounceMessageID,
),
);
# Look for the article that is associated with the BounceMessageID
my %Article = $Self->{ArticleBackendObject}->ArticleGetByMessageID(
MessageID => $BounceMessageID,
);
return if !%Article;
$Self->_AddCommunicationLog(
Message => sprintf(
'Found corresponding article ID "%s".',
$Article{ArticleID},
),
);
$Self->_SetArticleTransmissionSendError(
%Param,
ArticleID => $Article{ArticleID},
);
return $Article{TicketID};
}
sub _SetArticleTransmissionSendError {
my ( $Self, %Param ) = @_;
my $ArticleID = $Param{ArticleID};
my $ArticleObject = $Kernel::OM->Get('Kernel::System::Ticket::Article');
my $ArticleBackendObject = $ArticleObject->BackendForChannel(
ChannelName => 'Email',
);
my $BounceError = $Param{GetParam}->{'X-OTRS-Bounce-ErrorMessage'};
my $BounceMessageID = $Param{GetParam}->{'X-OTRS-Bounce-OriginalMessageID'};
my $CurrentStatus = $ArticleBackendObject->ArticleGetTransmissionError(
ArticleID => $ArticleID,
);
if ($CurrentStatus) {
my $Result = $ArticleBackendObject->ArticleUpdateTransmissionError(
ArticleID => $ArticleID,
Message => $BounceError,
);
if ( !$Result ) {
my $ErrorMessage = sprintf(
'Error while updating transmission error for article "%s"!',
$ArticleID,
);
$Self->_AddCommunicationLog(
Message => $ErrorMessage,
Priority => 'Error',
);
}
return;
}
my $Result = $ArticleBackendObject->ArticleCreateTransmissionError(
ArticleID => $ArticleID,
MessageID => $BounceMessageID,
Message => $BounceError,
);
if ( !$Result ) {
my $ErrorMessage = sprintf(
'Error while creating transmission error for article "%s"!',
$ArticleID,
);
$Self->_AddCommunicationLog(
Message => $ErrorMessage,
Priority => 'Error',
);
return;
}
return;
}
sub _AddCommunicationLog {
my ( $Self, %Param ) = @_;
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => $Param{Priority} || 'Debug',
Key => ref($Self),
Value => $Param{Message},
);
return;
}
1;

View File

@@ -0,0 +1,66 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::PostMaster::FollowUpCheck::RawEmail;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::Ticket',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
$Self->{ParserObject} = $Param{ParserObject} || die "Got no ParserObject";
# Get communication log object.
$Self->{CommunicationLogObject} = $Param{CommunicationLogObject} || die "Got no CommunicationLogObject!";
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::RawEmail',
Value => 'Searching for TicketNumber in raw email.',
);
my $Tn = $TicketObject->GetTNByString( $Self->{ParserObject}->GetPlainEmail() );
return if !$Tn;
my $TicketID = $TicketObject->TicketCheckNumber( Tn => $Tn );
if ($TicketID) {
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::RawEmail',
Value => "Found valid TicketNumber '$Tn' (TicketID '$TicketID') in raw email.",
);
return $TicketID;
}
return;
}
1;

View File

@@ -0,0 +1,75 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::PostMaster::FollowUpCheck::References;
use strict;
use warnings;
use Kernel::System::ObjectManager; # prevent used once warning
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::Ticket::Article',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
$Self->{ParserObject} = $Param{ParserObject} || die "Got no ParserObject";
# Get communication log object.
$Self->{CommunicationLogObject} = $Param{CommunicationLogObject} || die "Got no CommunicationLogObject!";
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::References',
Value => 'Searching for TicketID in email references.',
);
my @References = $Self->{ParserObject}->GetReferences();
return if !@References;
my $ArticleBackendObject = $Kernel::OM->Get('Kernel::System::Ticket::Article')->BackendForChannel(
ChannelName => 'Email',
);
for my $Reference (@References) {
my %Article = $ArticleBackendObject->ArticleGetByMessageID(
MessageID => "<$Reference>",
);
if (%Article) {
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::References',
Value => "Found valid TicketID '$Article{TicketID}' in email references.",
);
return $Article{TicketID};
}
}
return;
}
1;

View File

@@ -0,0 +1,66 @@
# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::PostMaster::FollowUpCheck::Subject;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::Ticket',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# Get communication log object.
$Self->{CommunicationLogObject} = $Param{CommunicationLogObject} || die "Got no CommunicationLogObject!";
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::Subject',
Value => 'Searching for TicketNumber in email subject.',
);
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
my $Subject = $Param{GetParam}->{Subject} || '';
my $Tn = $TicketObject->GetTNByString($Subject);
return if !$Tn;
my $TicketID = $TicketObject->TicketCheckNumber( Tn => $Tn );
if ($TicketID) {
$Self->{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::PostMaster::FollowUpCheck::Subject',
Value => "Found valid TicketNumber '$Tn' (TicketID '$TicketID') in email subject.",
);
return $TicketID;
}
return;
}
1;