X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=debbugs-service;h=ab5089b8fc9b91f89e31abf54fa243263c110a31;hb=b427b1df9e0263f7002af35c516ecef77d13dda7;hp=9a90c6d150b3804c2bd01982afca305252f5941c;hpb=2743936deeb40949af395aea34d5b522c197f89e;p=debbugs.git diff --git a/debbugs-service b/debbugs-service index 9a90c6d..ab5089b 100755 --- a/debbugs-service +++ b/debbugs-service @@ -9,21 +9,27 @@ use Debbugs::Email; use Debbugs::DBase; use Debbugs::Common; use Getopt::Long; -use Mail::Address; +use MIME::Parser; ############################################################################# # Gloabal Variable Declaration ############################################################################# -my $VERSION = '3.01'; #External Version number -my $BANNER = "DebBugs v$VERSION"; #Version Banner - text form -my $FILE = 'debbugs-service1'; #File name +my $VERSION = '3.01'; #External Version number +my $BANNER = "DebBugs v$VERSION"; #Version Banner - text form +my $FILE = 'debbugs-service'; #File name my $config = ''; my @config = undef; -my $inputfilename; #file specified on commandline +my $inputfilename; #file specified on commandline my @inputfile; my @imputlog; -my $control; #call to control or request +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 %LTags; #Tags Local to this email +my @message; #holds copy of msg to apply tags ############################################################################# # Commandline parsing @@ -58,96 +64,116 @@ $Globals{ 'verbose' } = $verbose; ############################################################################# $config = "./debbugs.cfg" if( $config eq '' ); print "D1: config file=$config\n" if $Globals{ 'debug' }; -@config = ParseConfigFile( $config ); +@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 ############################################################################# $_=shift; -m/^[RC]\.\d+$/ || &quit("bad argument"); +m/^[RC]\.\d+$/ || &fail("bad argument"); $control= m/C/; $inputfilename = $_; if (!rename( $Globals{ 'spool-dir' }."G$inputfilename", $Globals{ 'spool-dir' }."P$inputfilename")) { $_=$!.''; m/no such file or directory/i && exit 0; &fail("renaming to lock: $!"); -} -open( M, "P$inputfilename" ); -@inputfile=; -@inputlog = @inputfile; -close( M ); - -####################################### HERE ############################### -grep((s/\n$//,s/\s+$//),@msg); #remove blank lines - -## DEBUG ## print "###\n",join("##\n",@msg),"\n###\n" if $debug; - - - +} -for ($i=0; $i<=$#msg; $i++) -{ $_ = $msg[$i]; - last unless length($_); - $fwd .= $_."\n"; - while ($msg[$i+1] =~ m/^\s/) - { $i++; - $_ .= ' '.$msg[$i]; - } - print ">$_<\n" if $debug; - if (s/^(\S+):\s*//) - { $v= $1; $v =~ y/A-Z/a-z/; - print ">$v=$_<\n" if $debug; - $header{$v}= $_; - } else { print "!>$_<\n" if $debug; } +############################################################################ +# Set up MIME Message class +############################################################################ +my $parser = new MIME::Parser; +$parser->output_dir("$ENV{HOME}/mimemail"); +$parser->output_prefix("part"); +$parser->output_to_core(100000); +my $inputmail = $parser->parse_in("P$inputfilename") or die "couldn't parse MIME file"; +#for use when stdin in stead of file is used +#my $inputmail = $parser->read(\*STDIN) or die "couldn't parse MIME stream"; + +############################################################################ +# Extract first part (if mime type) for processing. All else assumed junk +############################################################################ +if ( $inputmail->is_multipart ) +{ my $parts = $inputmail->parts( 0 ); + while( $parts->is_multipart ) { $parts = $parts->parts( 0 ); } + @body = $parts->bodyhandle->as_lines; } +else { @body = $inputmail->bodyhandle->as_lines; } + + +$inputmail->head->count('From') || &fail( "no From header" ); + +############################################################################ +# Determine Reply To address +############################################################################ +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( < $_\n"); + + $action= ''; if (m/^stop\s/i || m/^quit\s/i || m/^--/ || m/^thank\s/i) - { &transcript("Stopping processing here.\n\n"); + { &transcript("Stopping processing here.\n\n"); last; - } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) { - $dl= $1+0; - &transcript("Debug level $dl.\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/^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,^..,$&/$&,; &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= < - -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); } }