]> git.donarmstrong.com Git - debbugs.git/blobdiff - debbugs-service
[project @ 2004-08-05 15:09:30 by cjwatson]
[debbugs.git] / debbugs-service
index a9ed4e15f1a498d2d178a23c3d1a521271ef5667..ab5089b8fc9b91f89e31abf54fa243263c110a31 100755 (executable)
@@ -27,7 +27,9 @@ my $control;                                 #call to control or request
 
 my @body;                                  #list of commands
 my $replyto;                               #address of to send reply to
-my $transcript;                                    #building of return message
+my $transcript = '';                       #building of return message
+my %LTags;                                 #Tags Local to this email
+my @message;                               #holds copy of msg to apply tags
 
 #############################################################################
 #  Commandline parsing
@@ -64,6 +66,11 @@ $config = "./debbugs.cfg" if( $config eq '' );
 print "D1: config file=$config\n" if $Globals{ 'debug' };
 @config = Debbugs::Config::ParseConfigFile( $config );
 
+#############################################################################
+#  Load in template emails
+#############################################################################
+@notify_done_email = Debbugs::Email::LoadEmail( $Globals{ 'template-dir' }.'/'.$Globals{ 'not-don-con' } );
+
 #############################################################################
 #  Find file name and load input file
 #############################################################################
@@ -104,12 +111,30 @@ $inputmail->head->count('From') || &fail( "no From header" );
 ############################################################################
 #  Determine Reply To address
 ############################################################################
-$replyto= $inputmail->head->count( "Reply-to" ) ? $inputmail->head->get( "Reply-to" ) : $inputmail->head->get( "From" );
+my $header = $input->mail->head;
+$replyto= $header->count( "Reply-to" ) ? $header->get( "Reply-to" ) : $header->get( "From" );
+
+############################################################################
+#  Add Email info to Local Tags (LTags)
+############################################################################
+$LTags{ 'REPLY_TO' ) = $replyto;
+$LTags{ 'CC_TO' ) = $header->get( 'CC' ) if $header->count( 'CC' );
+$LTags{ 'MESSAGE_ID' } = $header->get( 'Message-id' ) if $header->count( 'Message-id' );
+$LTags{ 'MESSAGE_BODY' } = join( '\n', @body );
+$LTags( 'MESSAGE_DATA' } = "control";
+$LTags{ 'MESSAGE_DATE' } = $header->get( 'Date' ) if $header->count( 'Date');
+if ( $header->count( 'Subject' ) )
+{   $LTags{ 'MESSAGE_SUBJECT' } = $header->get( 'Subject' ); }
+else { &transcript( <<END ); }
+Your email does not include a Subject line in the header.  This is a 
+violation of the specifications and may cause your email to be rejected at
+some later date.
+
+END
 
 ############################################################################
 #  Start processing of commands 
 ############################################################################
-$transcript='';
 if ( $control ) { &transcript("Processing commands for control message:\n\n"); }
 else { &transcript("Processing commands for request message:\n\n"); }
 
@@ -127,10 +152,11 @@ for ( my $procline=0; $procline<=$#body; $procline++)
     $lowstate eq 'idle' || print "$lowstate ?\n";
     $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
 
-    #get first line
+    #get line
     $_= $msg[$procline]; 
     s/\s+$//;  #strip ending white space, including newlines
 
+    #cleanup line
     next unless m/\S/;     #skip blank lines
     next if m/^\s*\#/;     #skip comment-only lines
     &transcript("> $_\n");
@@ -143,11 +169,11 @@ for ( my $procline=0; $procline<=$#body; $procline++)
     } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) 
     {  $debug= $1+0;
         &transcript("Debug level $debug.\n\n");
-    } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
-        $ref= $2+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
-        &sendlynxdoc("db/$reffile.html","logs for $gBug#$ref");
-    } elsif (m/^send-detail\s+\#?(\d+)$/i) {
-        $ref= $1+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
+    } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) 
+    {  $ref= $2+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
+        &sendlynxdoc( "db/$reffile.html", "logs for $gBug#$ref" );
+    } elsif (m/^send-detail\s+\#?(\d+)$/i) 
+    {  $ref= $1+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
         &sendlynxdoc("db/$reffile-b.html","additional logs for $gBug#$ref");
     } elsif (m/^index(\s+full)?$/i) {
         &sendlynxdoc("db/ix/full.html",'full index');
@@ -264,39 +290,23 @@ END
     } elsif (m/^close\s+\#?(\d+)$/i) {
        $ok++;
        $ref= $1;
-       if (&setbug) {
-           if (length($s_done)) {
+       if ( &setbug ) {
+           if(length($s_done)) {
                &transcript("$gBug is already closed, cannot re-close.\n\n");
                 &nochangebug;
             } else {
                 $action= "$gBug closed, ack sent to submitter - they'd better know why !";
                 do {
+                   CLOSE BUG RECORD
                     &addmaintainers($s_package);
-                                       if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
-                                       0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
+                   if ( length( $gDoneList ) > 0 && length( $gListDomain ) > 0 ) 
+                   { &addccaddress("$gDoneList\@$gListDomain"); }
                     $s_done= $replyto;
-                   $message= <<END;
-From: $gMaintainerEmail ($gProject $gBug Tracking System)
-To: $s_originator
-Subject: $gBug#$ref acknowledged by developer
-         ($s_subject)
-References: $header{'message-id'} $s_msgid
-In-Reply-To: $s_msgid
-Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
-
-This is an automatic notification regarding your $gBug report.
-
-It has been marked as closed by one of the developers, namely
-$replyto.
-
-You should be hearing from them with a substantive response shortly,
-if you have not already done so.  If not, please contact them
-directly or myself.
-
-$gMaintainer
-(administrator, $gProject $gBugs database)
-END
-                    &sendmailmessage($message,$s_originator);
+                   @message = @notify_done_email;
+                   &Debbugs::Email::ProcessTags( \@message, \@BTags, "BTAG" );
+                   &Debbugs::Email::ProcessTags( \@message, \@LTags, "LTAG" );
+                    &sendmailmessage( join( "\n", @message), $s_originator );
+                   Save the bug record
                 } while (&getnextbug);
             }
         }