]> git.donarmstrong.com Git - debbugs.git/blobdiff - scripts/process
start mousifying log
[debbugs.git] / scripts / process
index 91b68613c2d01e27155db9852d838aae245b1345..69a1feccd0102298926c4cc85d163ce832127904 100755 (executable)
@@ -34,6 +34,7 @@ use Debbugs::Control qw(append_action_to_log);
 use Debbugs::Control::Service qw(valid_control control_line);
 use Debbugs::Recipients qw(determine_recipients);
 use Encode qw(encode_utf8 decode);
+use List::AllUtils qw(first uniqnum);
 
 =head1 NAME
 
@@ -1135,9 +1136,11 @@ sub appendlog {
     my $logfh = IO::File->new(">>$log_location") or
        die "Unable to open $log_location for appending: $!";
     write_log_records(logfh => $logfh,
-                     records => [{type => 'incoming-recv',
-                                  text => $msg,
-                                 }]);
+                     records => [Debbugs::Log::Record->
+                                 new(type => 'incoming-recv',
+                                     text => $msg,
+                                    )
+                                ]);
     close ($logfh) or die "Unable to close $log_location: $!";
 }
 
@@ -1218,15 +1221,21 @@ sub sendmessage {
     # RFC1522 encode the header.
     $msg = encode_headers($msg) unless $no_encode;
 
+    my $log = Debbugs::Log->new($ref);
+    $log->write(text=>stripbccs($msg),
+               type => 'recips',
+               recipients => [map {encode_utf8($_)} @{$recips}]
+              );
     my $hash = get_hashname($ref);
     #save email to the log
     my $logfh = IO::File->new(">>db-h/${hash}/${ref}.log") or
        die "opening db-h/$hash/${ref}.log: $!";
     write_log_records(logfh => $logfh,
-                     records => {text => stripbccs($msg),
-                                 type => 'recips',
-                                 recips => [map {encode_utf8($_)} @{$recips}],
-                                },
+                     records => [Debbugs::Log::Record->
+                     new(text => stripbccs($msg),
+                         type => 'recips',
+                         recipients => [map {encode_utf8($_)} @{$recips}],
+                     )],
                     );
     if (ref($bcc)) {
         shift @$recips if $recips->[0] eq '-t';
@@ -1273,20 +1282,15 @@ sub fill_template{
      my $variables = {config => \%config,
                      defined($ref)?(ref    => $ref):(),
                      defined($data)?(data  => $data):(),
-                     refs => [map {exists $clonebugs{$_}?$clonebugs{$_}:$_} keys %bug_affected],
+                     refs => [sort
+                              uniqnum(defined($ref)?($ref):(),
+                                      map {exists $clonebugs{$_}?$clonebugs{$_}:$_}
+                                      keys %bug_affected)],
                      %{$extra_var},
                     };
-     my $hole_var = {'&bugurl' =>
-                    sub{"$_[0]: ".
-                             $config{cgi_domain}.'/'.
-                                  Debbugs::CGI::bug_links(bug=>$_[0],
-                                                          links_only => 1,
-                                                         );
-                   }
-                   };
      return fill_in_template(template => $template,
                             variables => $variables,
-                            hole_var  => $hole_var,
+                            output_type => 'text',
                            );
 }