[Rt-commit] r5689 - in rtir/branches/2.1-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Wed Aug 2 15:52:36 EDT 2006
Author: ruz
Date: Wed Aug 2 15:52:35 2006
New Revision: 5689
Added:
rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_FindIP.pm
Modified:
rtir/branches/2.1-EXPERIMENTAL/ (props changed)
Log:
r1540 at cubic-pc: cubic | 2006-08-02 07:00:38 +0400
* parse IPs from messages
Added: rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_FindIP.pm
==============================================================================
--- (empty file)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_FindIP.pm Wed Aug 2 15:52:35 2006
@@ -0,0 +1,46 @@
+package RT::Action::RTIR_FindIP;
+
+use strict;
+use warnings;
+
+use base qw(RT::Action::RTIR);
+
+use Regexp::Common qw(net);
+
+=head2 Prepare
+
+Always run this.
+
+=cut
+
+sub Prepare { return 1 }
+
+=head2 Commit
+
+Search for IP addresses in the transaction's content.
+
+=cut
+
+sub Commit {
+ my $self = shift;
+ my $ticket = $self->TicketObj;
+
+ my $cf = $ticket->LoadCustomFieldByIdentifier('_RTIR_IP');
+ return 1 unless $cf && $cf->id;
+
+ my $attach = $self->TransactionObj->ContentObj;
+ return 1 unless $attach && $attach->id;
+
+ my @IPs = ( $attach->Content =~ /($RE{net}{IPv4})/g );
+ foreach ( @IPs ) {
+ my ($status, $msg) = $ticket->AddCustomFieldValue(
+ Value => $_,
+ Field => $cf,
+ );
+ $RT::Logger->error("Couldn't add CF value: $msg") unless $status;
+ }
+
+ return 1;
+}
+
+1;
More information about the Rt-commit
mailing list