]> git.donarmstrong.com Git - debbugs.git/commitdiff
add usertags support to process.in
authorDon Armstrong <don@archimedes>
Sat, 21 Oct 2006 03:50:01 +0000 (20:50 -0700)
committerDon Armstrong <don@archimedes>
Sat, 21 Oct 2006 03:50:01 +0000 (20:50 -0700)
Debbugs/User.pm
scripts/process.in

index 7591e4d113030df4cfeedc729e1b079f029b57e1..d55860b2cd409b4556576237912590facaa1db6b 100644 (file)
@@ -49,7 +49,7 @@ BEGIN {
     $DEBUG = 0 unless defined $DEBUG;
 
     @EXPORT = ();
-    @EXPORT_OK = qw(is_valid_user open);
+    @EXPORT_OK = qw(is_valid_user open read_usertags write_usertags);
     $EXPORT_TAGS{all} = [@EXPORT_OK];
 }
 
index 5cd9f1358f35bc95599685dfdd6962e1ba002bea..eeb195dfc23b0cb6f82ec292ea83a13980893233 100755 (executable)
@@ -12,6 +12,7 @@ use MIME::Parser;
 use Debbugs::MIME qw(decode_rfc1522 create_mime_message);
 use Debbugs::Mail qw(send_mail_message encode_headers);
 use Debbugs::Packages qw(getpkgsrc);
+use Debbugs::User qw(read_usertags write_usertags);
 
 my $config_path = '/etc/debbugs';
 my $lib_path = '/usr/lib/debbugs';
@@ -151,7 +152,7 @@ for my $phline (@bodylines)
     print DEBUG ">$fn|$fv|\n";
     $fn = lc $fn;
     # Don't lc owner or forwarded
-    $fv = lc $fv unless $fh =~ /^(?:owner|forwarded)$/;
+    $fv = lc $fv unless $fh =~ /^(?:owner|forwarded|usertags)$/;
     $pheader{$fn} = $fv;
     print DEBUG ">$fn~$fv<\n";
 }
@@ -647,6 +648,29 @@ END
     $data->{subject} = $subject;
     $data->{msgid} = $header{'message-id'};
     writebug($ref, $data);
+    # Deal with usertags
+    if (exists $pheader{usertags}) {
+        my $user = $replyto;
+        $user =~ s/,.*//;
+        $user =~ s/^.*<(.*)>.*$/$1/;
+        $user =~ s/[(].*[)]//;
+        $user =~ s/^\s*(\S+)\s+.*$/$1/;
+        $user = "" unless (Debbugs::User::is_valid_user($user));
+        if ($user ne '') {
+             $pheader{usertags} =~ s/(?:^\s+|\s+$)//g;
+             my %user_tags;
+             read_usertags(\%user_tags,$user);
+             for my $tag (split /[,\s]+/, $pheader{usertags}) {
+                  if ($tag =~ /^[a-zA-Z0-9.+\@-]+/) {
+                       my %bugs_with_tag; 
+                       @bugs_with_tag{@{$user_tags{$tag}}} = (1) x @{$user_tags{$tag}};
+                       $bugs_with_tag{$ref} = 1;
+                       $user_tags{$tag} = [keys %bugs_with_tag];
+                  }
+             }
+             write_usertags(\%usertags,$user);
+        }
+    }
     &overwrite("db-h/$hash/$ref.report",
                join("\n",@msg)."\n");
 }