]> mj.ucw.cz Git - pciids.git/commitdiff
Merge branch 'master' of /home/vorner/pciids
authorThe PCI ID Mail Robot <pciids@ucw.cz>
Sat, 5 Sep 2009 18:45:44 +0000 (20:45 +0200)
committerThe PCI ID Mail Robot <pciids@ucw.cz>
Sat, 5 Sep 2009 18:45:44 +0000 (20:45 +0200)
help/mailsubmit
scripts/mailbot

index d12d0720ebc26e740b0078a58c6da0af681d9f71..61e12dc7df49df42765e40547efbc767ecbb24fb 100644 (file)
@@ -9,9 +9,9 @@ Please use unified diffs (<tt>diff -u</tt>) against the current <a href='/v2.2/p
 encoding which is currently not understood by the robot) and avoid mail agents which convert
 tabs to spaces or wrap long lines. The classical <tt>mail</tt> utility is a safe choice.
 <p>
-If you do not have an <a href='$HELP_URL$account'>account</a> yet, one will be created for you
-automatically. You will be also sent notifications when anybody modifies the items you have
-changed (of course you can tweak the notifications, look at their <a href='$HELP_URL$notifications'>documentation</a>).
+If you do not have an <a href='$HELP_URL$account'>account</a> yet, you will to <a href='$AC_URL$register'>create</a> it first.
+The robot talks only to registered people. It talked to anyone before, but that meant responding
+to lots of SPAM messages and bothering innocent people.
 <p>
 Please note that the robot currently understands only PCI ID's. Other types of ID's (classes etc.)
 must be entered via the web interface.
index 87797baecd666bc87167142cfd62eb32ec8ee8e5..256b161652728548bafda4e49c0a391eb2a41f42 100755 (executable)
@@ -34,26 +34,10 @@ my $subject = "";
 my $tables = PciIds::DBQ::new( connectDb() );
 
 my $hasAuth = $tables->dbh()->prepare( 'SELECT id FROM users WHERE email = ?' );
-my $addAuth = $tables->dbh()->prepare( "INSERT INTO users (email, passwd) VALUES(?, '')" );
 my $hasItem = $tables->dbh()->prepare( "SELECT 1 FROM locations WHERE id = ?" );
 my $addItem = $tables->dbh()->prepare( "INSERT INTO locations (id, parent) VALUES (?, ?)" );
 my $addComment = $tables->dbh()->prepare( "INSERT INTO history (owner, location, discussion, nodename, nodenote) VALUES (?, ?, ?, ?, ?)" );
 
-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: Active user ($mail) id: $nid" );
-               return $nid;
-       }
-}
-
 sub submitItem( $$$$$ ) {
        my( $id, $name, $description, $text, $author ) = @_;
        my $created;
@@ -116,6 +100,15 @@ if (!$patch) {
 
 $home = "$ENV{HOME}/";
 $tprefix = "${home}tmp/mbot-$$";
+# Little hack to stop spam: ignore everything from people not already in database
+$hasAuth->execute( $author );
+my( $authorId ) = ( $hasAuth->fetchrow_array );
+if( defined $authorId ) {
+       tlog( "mailbot: Active user ($author) id: $authorId" );
+} else {
+       blackhole("Dropping email from $author, not in database.\n");
+}
+
 mkdir("${home}tmp", 0777);
 mkdir($tprefix, 0777) || error("Cannot create tmpdir");
 chdir($tprefix) || error("Cannot chdir to tmpdir");
@@ -217,7 +210,6 @@ sub process
                        elsif (!$?) { error("No ID changes encountered."); }
                        open(DIFF, "diffs") || error("Cannot open the diff");
                        $subject = undef if $subject eq '';
-                       my $authorId = getAuthor( $author );
                        my $live = (!$emulate && !$debug);
                        while (<DIFF>) {
                                chomp;