Fixed bug where adding a username only rule failed
[clearscm.git] / maps / lib / MAPS.pm
index 705196e..c0e3448 100644 (file)
@@ -291,7 +291,7 @@ sub AddList(%) {
 
   $rec{hit_count} //= $db->count(
     'email',
-    "userid = '$rec{userid}' and sender like '$rec{sender}%'"
+    "userid = '$rec{userid}' and sender like '%$rec{sender}%'"
   );
 
   ($rec{pattern}, $rec{domain}) = split /\@/, delete $rec{sender};
@@ -403,6 +403,8 @@ sub CheckEmail(;$$) {
   if ($username) {
     if ($username =~ /(.*)\@(.*)/) {
       return lc "$1\@$2";
+    } else {
+      return lc "$username\@";
     } # if
   } elsif ($domain) {
     if ($domain =~ /(.*)\@(.*)/) {
@@ -458,7 +460,9 @@ sub CheckOnList ($$;$) {
                    ? "$email_on_file\@"
                    : $email_on_file;
     if ($sender and $sender =~ /$search_for/i) {
-      $rule   = "Matching rule: ($listtype:$rec->{sequence}) \"$email_on_file\"";
+      my $comment = $rec->{comment} ? " - $rec->{comment}" : '';
+
+      $rule   = "Matching rule: ($listtype:$rec->{sequence}) \"$email_on_file$comment\"";
       $rule  .= " - $rec->{comment}" if $rec->{comment};
       $status = 1;
 
@@ -1013,7 +1017,7 @@ sub ResequenceList(%) {
   $db->lock('write', $table);
 
   # Get all records for $userid and $type
-  my $listrecs = $db->get($table, $condition);
+  my $listrecs = $db->get($table, $condition,'*', 'order by hit_count desc');
 
   # Delete all of the list entries for this $userid and $type
   my ($count, $msg) = $db->delete($table, $condition);