# (2) Added rules based paging (Stephen Johnson  Nov 14, 1998)
 # (3) Added checks against Acks and downtime (Stephen Johnson  Mar 17, 1999)
 #
-# $Id: spong-message.pl,v 1.30 2001/06/13 16:07:20 sljohnson Exp $
+# $Id: spong-message.pl,v 1.31 2001/06/21 17:05:00 supermathie Exp $
 
 use lib "@@LIBDIR@@";
 
 
       foreach $contact ( @{$rule->{contacts}} ) { 
          &debug("Calling add_contact for " . (ref($contact) eq 'HASH' ?
-             $contact->{'rcpt'} : $contact) );
+            "rcpt: " . $contact->{'rcpt'} . 
+            " delay: " . $contact->{'delay'} . 
+            " repeat: " . $contact->{'repeat'} .
+            " escalate: " . $contact->{'escalate'}
+            : $contact) );
          add_contact(\@con,$contact);
       }
 
 
    # Starting sending out the notifications
    foreach $contact ( @con ) {
-      if ($test) { 
-         if( ref($contact) eq 'HASH' ) {
-            &debug("Test mode: Skipping page to" . 
-               " rcpt: " . $contact->{'rcpt'} . 
-               " delay: " . $contact->{'delay'} . 
-               " repeat: " . $contact->{'repeat'} .
-               " escalate: " . $contact->{'escalate'} );
-         } else {
-            &debug("Test mode: Skipping page to $contact");
-         }
-         next;
-      }
-
       # If contact is a hash, pull out recipient as the contact
       if ( ref($contact) eq 'HASH') {
          $c = $contact->{'rcpt'};
             next; }   # next contact
       }
 
+      if ($test) { 
+         if( ref($contact) eq 'HASH' ) {
+            &debug("Test mode: Skipping page to" . 
+               " rcpt: " . $contact->{'rcpt'} . 
+               " delay: " . $contact->{'delay'} . 
+               " repeat: " . $contact->{'repeat'} .
+               " escalate: " . $contact->{'escalate'} );
+         } else {
+            &debug("Test mode: Skipping page to $contact");
+         }
+         next;
+      }
 
       #
       # Starting sending out the messages to $person