X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=scripts%2Fmailbot;h=87797baecd666bc87167142cfd62eb32ec8ee8e5;hb=3a12e4f52430b52398eb2f91b9fefedbaa0f408f;hp=864704a62d4789b8d4f47fcccf9b7dcb7ddba8be;hpb=11fd9d0a8a4b0e4d32cd8b1b3e48ece900ff4c89;p=pciids.git diff --git a/scripts/mailbot b/scripts/mailbot index 864704a..87797ba 100755 --- a/scripts/mailbot +++ b/scripts/mailbot @@ -1,7 +1,7 @@ #!/usr/bin/perl # Mail robot for processing of PCI ID submissions # (c) 2001--2002 Martin Mares -# 2008 Michal Vaner +# (c) 2008 Michal Vaner use Mail::Header; use Getopt::Long; @@ -43,12 +43,13 @@ sub getAuthor( $ ) { my( $mail ) = @_; $hasAuth->execute( $mail ); if( my( $id ) = $hasAuth->fetchrow_array ) { + tlog( "mailbot: Active user ($mail) id: $id" ); return $id; } else { tlog( "mailbot: Creating user $mail" ); $addAuth->execute( $mail ); my $nid = $tables->dbh->last_insert_id( undef, undef, undef, undef ); - tlog( "mailbot: User ($mail) id: $nid" ); + tlog( "mailbot: Active user ($mail) id: $nid" ); return $nid; } } @@ -59,11 +60,17 @@ sub submitItem( $$$$$ ) { $id =~ s/(.{8})(.+)/$1\/$2/; $id =~ s/(.{4})(.+)/$1\/$2/; $id = "PC/$id"; + if( length $id > 12 ) { + my( $vendor ) = ( $id =~ /^PC\/....\/....\/(....)/ ); + $vendor = "PC/$vendor"; + $hasItem->execute( $vendor ); + error( "Missing subsystem vendor" ) unless( $hasItem->fetchrow_array ); + } $hasItem->execute( $id ); unless( $hasItem->fetchrow_array ) { tlog( "mailbot: Item created (empty) $id" ); my $parent = $id; - $parent =~ s/\/[^\/]*//; + $parent =~ s/\/[^\/]*$//; $addItem->execute( $id, $parent ); $created = 1; } @@ -71,6 +78,9 @@ sub submitItem( $$$$$ ) { my $hid = $tables->last(); tlog( "mailbot: History created $hid $id ".logEscape( $name )." ".logEscape( $description )." ".logEscape( $text ) ); notify( $tables, $id, $hid, $created ? 2 : 1, $created ? 0 : 1 ); + if( !$tables->notifExists( $author, $id ) ) { + $tables->submitNotification( $author, $id, { 'recursive' => 0, 'notification' => 0, 'way' => 0 } ); + } } if (!$patch) { @@ -104,9 +114,9 @@ if (!$patch) { $author = $reply_plain; } -$tprefix = "tmp/mbot-$$"; -$home = "~/"; -mkdir("tmp", 0777); +$home = "$ENV{HOME}/"; +$tprefix = "${home}tmp/mbot-$$"; +mkdir("${home}tmp", 0777); mkdir($tprefix, 0777) || error("Cannot create tmpdir"); chdir($tprefix) || error("Cannot chdir to tmpdir");