[prev in list] [next in list] [prev in thread] [next in thread]
List: rt-commit
Subject: [Rt-commit] r6120 - in rtir/branches/2.1-EXPERIMENTAL: .
From: jesse () bestpractical ! com
Date: 2006-09-29 15:28:37
Message-ID: 20060929152837.187604D84B5 () diesel ! bestpractical ! com
[Download RAW message or body]
Author: jesse
Date: Fri Sep 29 11:28:36 2006
New Revision: 6120
Modified:
rtir/branches/2.1-EXPERIMENTAL/ (props changed)
rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_FindIP.pm
Log:
r27943@249: jesse | 2006-09-29 11:28:30 -0400
* Skip duplicated addresses when adding them to the IPs field
Modified: rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_FindIP.pm
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_FindIP.pm (original)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_FindIP.pm Fri Sep 29 11:28:36 2006
@@ -29,16 +29,23 @@
my $cf = $ticket->LoadCustomFieldByIdentifier('_RTIR_IP');
return 1 unless $cf && $cf->id;
+ my %existing;
+ for( @{$cf->ValuesForObject($ticket)->ItemsArrayRef} ) {
+ $existing{$_->Content} = 1;
+
+ }
my $attach = $self->TransactionObj->ContentObj;
return 1 unless $attach && $attach->id;
my @IPs = ( $attach->Content =~ /($RE{net}{IPv4})/go );
- foreach ( @IPs ) {
+ foreach my $ip ( @IPs ) {
+ next if ($existing{$ip}); # skip any IP we already had.
my ($status, $msg) = $ticket->AddCustomFieldValue(
- Value => $_,
+ Value => $ip,
Field => $cf,
);
$RT::Logger->error("Couldn't add CF value: $msg") unless $status;
+ $existing{$ip} = 1;
}
my @CIDRs = ( $attach->Content =~ /$RE{net}{CIDR}{IPv4}{-keep}/go );
_______________________________________________
Rt-commit mailing list
Rt-commit@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic