Fixed RecordHit to update last_hit
[clearscm.git] / maps / bin / maps
index 22a7bb8..17047f4 100755 (executable)
@@ -122,6 +122,12 @@ sub ValidDomainUser($) {
   return defined $uid ? 1 : 0;
 } # ValidDomainUser
 
+sub formatRule($) {
+  my ($rec) = @_;
+
+  return "Rule: $rec->{pattern}\@$rec->{domain}:$rec->{sequence}/$rec->{hit_count}";
+} # formatRule
+
 sub ProcessMsgs ($$$) {
   my ($msgfile, $username, $user_email) = @_;
 
@@ -130,7 +136,7 @@ sub ProcessMsgs ($$$) {
   while (!eof $msgfile) {
     my ($sender, $sender_long, $reply_to, $subject, $data) = ReadMsg ($msgfile);
 
-    my ($onlist, $rule, $sequence, $hit_count);
+    my ($onlist, $rec, $sequence, $hit_count);
 
     # Algorithm change: We now first check to see if the sender is not found
     # in the message and skip it if so. Then we handle if we are the sender
@@ -156,20 +162,22 @@ sub ProcessMsgs ($$$) {
             (lc ($sender_long) !~ lc ("\"$username\" <$user_email>") and
              lc ($sender_long) !~ lc ("$username <$user_email>"))) {
       $log->msg("Nulllisting message from sender ($sender_long) pretending to be $user_email");
+
       Nulllist $sender;
+
       next;
     } # if
 
     # Check whitelist:
-    ($onlist, $rule, $sequence, $hit_count) = OnWhitelist $sender;
+    ($onlist, $rec) = OnWhitelist $sender;
 
     if ($onlist) {
       if (ValidDomainUser $sender) {
-        $log->msg("Whitelisting $sender");
+        $log->msg("Whitelisting $sender - Rule: " . formatRule($rec));
 
-        Whitelist $sender, $data, $sequence, $hit_count;
+        Whitelist $sender, $data, $rec->{sequence}, $rec->{hit_count};
       } else {
-        $log->msg("Sender from this domain but user not found");
+        $log->msg("Sender ($sender) from this domain but user not found");
 
         Nulllist $sender;
       } # if
@@ -178,16 +186,16 @@ sub ProcessMsgs ($$$) {
     } # if
 
     # Check blacklist:
-    ($onlist, $rule, $sequence, $hit_count) = OnBlacklist $sender;
+    ($onlist, $rec) = OnBlacklist $sender;
 
     if ($onlist) {
-      $log->msg("Blacklisting $sender");
+      $log->msg("Blacklisting $sender - Rule: " . formatRule($rec));
 
       Blacklist(
         userid    => $userid,
         sender    => $sender,
-        sequence  => $sequence,
-        hit_count => $hit_count,
+        sequence  => $rec->{sequence},
+        hit_count => $rec->{hit_count},
         data      => $data,
       );
 
@@ -195,11 +203,13 @@ sub ProcessMsgs ($$$) {
     } # if 
 
     # Check nulllist:
-    ($onlist, $rule, $sequence, $hit_count) = OnNulllist $sender;
+    ($onlist, $rec) = OnNulllist $sender;
 
     if ($onlist) {
-      $log->msg("Nulllisting $sender");
-      Nulllist $sender, $sequence, $hit_count;
+      $log->msg("Nulllisting $sender - Rule: " . formatRule($rec));
+
+      Nulllist $sender, $rec->{sequence}, $rec->{hit_count};
+
       next;
     } # if