Skip to content

Commit

Permalink
Console command Admin::PostMasterFilter::Import now will also update …
Browse files Browse the repository at this point in the history
…existing filters instead of only create new ones. Thanks to @meisterheister for reporting the issue.
  • Loading branch information
jepf authored and dennykorsukewitz committed Aug 22, 2024
1 parent 02fc729 commit 1c5641c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 7.1.3 2024-??-??
- 2024-08-22 Console command Admin::PostMasterFilter::Import now will also update existing filters instead of only create new ones. Thanks to @meisterheister for reporting the issue. [#527](https://github.com/znuny/Znuny/issues/527)
- 2024-08-22 Added '--single-transaction' option to scripts/backup.pl for MySQL/MariaDB. The --single-transaction flag will start a transaction before running.
- 2024-08-21 Improved CSS for skin 'Dark'. [#584](https://github.com/znuny/Znuny/issues/584)
- 2024-08-21 Sector Nord AG: Fixed overflow of dynamic field groups in AgentTicketZoom process widget. Thanks to Sector Nord AG (@jsinagowitz). [PR#553](https://github.com/znuny/Znuny/pull/553)
Expand Down
2 changes: 1 addition & 1 deletion Kernel/System/ZnunyHelper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ sub _PostMasterFilterConfigImport {
}
return if !IsArrayRefWithData($Filter);

return $Self->_PostMasterFilterCreateIfNotExists( @{$Filter} );
return $Self->_PostMasterFilterCreate( @{$Filter} );
}

=head2 _GroupCreateIfNotExists()
Expand Down
62 changes: 58 additions & 4 deletions scripts/test/ZnunyHelper/PostMasterFilter.t
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ $Self->True(
'_PostMasterFilterCreateIfNotExists',
);

# _PostMasterFilterCreateIfNotExists yml
# _PostMasterFilterConfigImport yml
my $Name = 'PostmasterFilterYML' . $RandomNumber;
my $YML = "---
- Match:
Expand All @@ -114,7 +114,7 @@ $Result = $ZnunyHelperObject->_PostMasterFilterConfigImport(

$Self->True(
$Result,
'_PostMasterFilterCreateIfNotExists',
'_PostMasterFilterConfigImport',
);

%Data = $PMFilterObject->FilterGet(
Expand All @@ -130,7 +130,7 @@ $Self->IsDeeply(
'Value' => '333'
}
],
'Name' => 'PostmasterFilterYML' . $RandomNumber,
'Name' => $Name,
'Not' => [
{
'Key' => 'Body',
Expand All @@ -145,7 +145,61 @@ $Self->IsDeeply(
],
'StopAfterMatch' => 0
},
'_PostMasterFilterCreate',
'_PostMasterFilterConfigImport',
);

# Update filter with same name via _PostMasterFilterConfigImport
$YML = "---
- Match:
- Key: Body
Value: 444
Name: $Name
Not:
- Key: Body
Value: ~
Set:
- Key: X-OTRS-DynamicField-test2
Value: 555
StopAfterMatch: 0";

$Result = $ZnunyHelperObject->_PostMasterFilterConfigImport(
Filter => \$YML,
);

$Self->True(
$Result,
'_PostMasterFilterConfigImport',
);

%Data = $PMFilterObject->FilterGet(
Name => $Name
);

$Self->IsDeeply(
\%Data,
{
'Match' => [
{
'Key' => 'Body',
'Value' => '444'
}
],
'Name' => $Name,
'Not' => [
{
'Key' => 'Body',
'Value' => undef,
}
],
'Set' => [
{
'Key' => 'X-OTRS-DynamicField-test2',
'Value' => '555'
}
],
'StopAfterMatch' => 0
},
'_PostMasterFilterConfigImport',
);

1;

0 comments on commit 1c5641c

Please sign in to comment.