From 9158660a4f8a128749526c71147974ff7e5eeefb Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Mon, 20 Jan 2025 20:55:33 -0300 Subject: [PATCH] Code refactor of tag --- lib/GLPI/Agent/Task/NetInventory.pm | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/GLPI/Agent/Task/NetInventory.pm b/lib/GLPI/Agent/Task/NetInventory.pm index 7c924530c..ef007ffbc 100644 --- a/lib/GLPI/Agent/Task/NetInventory.pm +++ b/lib/GLPI/Agent/Task/NetInventory.pm @@ -348,21 +348,16 @@ sub _sendMessage { # Load GLPI::Agent::XML::Query as late as possible return unless GLPI::Agent::XML::Query->require(); - my $message; - if (defined($self->{config}->{tag}) && length($self->{config}->{tag})) { - $message = GLPI::Agent::XML::Query->new( - deviceid => $self->{deviceid} || 'foo', - query => 'SNMPQUERY', - tag => $self->{config}->{'tag'}, - content => $content - ); - } else { - $message = GLPI::Agent::XML::Query->new( - deviceid => $self->{deviceid} || 'foo', - query => 'SNMPQUERY', - content => $content - ); - } + my %message_params = ( + deviceid => $self->{deviceid} || 'foo', + query => 'SNMPQUERY', + content => $content + ); + $message_params{tag} = $self->{config}->{'tag'} + if defined($self->{config}->{tag}) && length($self->{config}->{tag}); + my $message = GLPI::Agent::XML::Query->new( + %message_params + ); if ($self->{target}->isType('local')) { my ($handle, $file);