From f1c8ed9094bd0512582eededab457635d3eb8eaa Mon Sep 17 00:00:00 2001 From: Nick Reilingh Date: Fri, 19 May 2023 13:56:42 -0400 Subject: [PATCH 1/2] Fix incorrect return values in action conditions --- lib/RT/Action/AutoOpen.pm | 6 +++--- lib/RT/Action/LinearEscalate.pm | 10 +++++----- lib/RT/Action/SetStatus.pm | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/RT/Action/AutoOpen.pm b/lib/RT/Action/AutoOpen.pm index 096291db26e..bcfbaddd931 100644 --- a/lib/RT/Action/AutoOpen.pm +++ b/lib/RT/Action/AutoOpen.pm @@ -82,15 +82,15 @@ sub Prepare { my $ticket = $self->TicketObj; my $next = $ticket->FirstActiveStatus; - return 1 unless defined $next; + return 0 unless defined $next; # no change if the ticket is in initial status and the message is a mail # from a requestor - return 1 if $ticket->LifecycleObj->IsInitial($ticket->Status) + return 0 if $ticket->LifecycleObj->IsInitial($ticket->Status) && $self->TransactionObj->IsInbound; if ( my $msg = $self->TransactionObj->Message->First ) { - return 1 if ($msg->GetHeader('RT-Control') || '') =~ /\bno-autoopen\b/i; + return 0 if ($msg->GetHeader('RT-Control') || '') =~ /\bno-autoopen\b/i; } $self->{'set_status_to'} = $next; diff --git a/lib/RT/Action/LinearEscalate.pm b/lib/RT/Action/LinearEscalate.pm index 1072f5fa9c0..67f3ace8fef 100644 --- a/lib/RT/Action/LinearEscalate.pm +++ b/lib/RT/Action/LinearEscalate.pm @@ -157,22 +157,22 @@ sub Prepare { unless ( $ticket->DueObj->IsSet ) { $RT::Logger->debug('Due is not set. Not escalating.'); - return 1; + return 0; } my $priority_range = ($ticket->FinalPriority ||0) - ($ticket->InitialPriority ||0); unless ( $priority_range ) { $RT::Logger->debug('Final and Initial priorities are equal. Not escalating.'); - return 1; + return 0; } if ( $ticket->Priority >= $ticket->FinalPriority && $priority_range > 0 ) { $RT::Logger->debug('Current priority is greater than final. Not escalating.'); - return 1; + return 0; } elsif ( $ticket->Priority <= $ticket->FinalPriority && $priority_range < 0 ) { $RT::Logger->debug('Current priority is lower than final. Not escalating.'); - return 1; + return 0; } # TODO: compute the number of business days until the ticket is due @@ -186,7 +186,7 @@ sub Prepare { # do nothing if we didn't reach starts or created date if ( $starts > $now ) { $RT::Logger->debug('Starts(Created) is in future. Not escalating.'); - return 1; + return 0; } my $due = $ticket->DueObj->Unix; diff --git a/lib/RT/Action/SetStatus.pm b/lib/RT/Action/SetStatus.pm index 599dba7d704..1ac842da7b5 100644 --- a/lib/RT/Action/SetStatus.pm +++ b/lib/RT/Action/SetStatus.pm @@ -116,13 +116,13 @@ sub Prepare { ($next) = grep $lifecycle->$method($_), $lifecycle->Transitions($status); unless ( $next ) { $RT::Logger->info("No transition from '$status' to $argument set"); - return 1; + return 0; } } elsif ( $lifecycle->IsValid( $argument ) ) { unless ( $lifecycle->IsTransition( $status => $argument ) ) { $RT::Logger->warning("Transition '$status -> $argument' is not valid"); - return 1; + return 0; } $next = $argument; } From 6323eb59882bda0e66f46b7f632ece01e11fbff7 Mon Sep 17 00:00:00 2001 From: Nick Reilingh Date: Fri, 19 May 2023 14:40:21 -0400 Subject: [PATCH 2/2] Fix incorrect logic in AutoOpenInactive As documented, this action operates on inactive statuses. The previous logic would operate on initial statuses also. AutoOpen.pm is intended to work from initial statuses. --- lib/RT/Action/AutoOpenInactive.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/RT/Action/AutoOpenInactive.pm b/lib/RT/Action/AutoOpenInactive.pm index e8c9ca04d60..92f08ad1a0f 100644 --- a/lib/RT/Action/AutoOpenInactive.pm +++ b/lib/RT/Action/AutoOpenInactive.pm @@ -71,7 +71,7 @@ sub Prepare { my $self = shift; my $ticket = $self->TicketObj; - return 0 if $ticket->LifecycleObj->IsActive( $ticket->Status ); + return 0 unless $ticket->LifecycleObj->IsInactive( $ticket->Status ); if ( my $msg = $self->TransactionObj->Message->First ) { return 0