<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>email-processor/feedback-loop-processor.pl</filename>
    </added>
    <added>
      <filename>email-processor/lib/bounce_db.pm</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1,2 @@
 /doc
+/email-processor/*.txt</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,11 @@
 #!/usr/bin/env perl
 
 use strict;
+use Cwd;
+use File::Basename;
+
+our $SELF_DIR = dirname(Cwd::abs_path(__FILE__));
+require $SELF_DIR . '/lib/bounce_db.pm';
 
 use DBI;
 use Mail::DeliveryStatus::BounceParser;
@@ -46,53 +51,3 @@ for my $report ($bounce-&gt;reports) {
 
 exit(0);
 
-#-------------------------------------------------------------------------------
-sub RegisterBounce($$$) {
-    my ($email, $reason, $dbh) = @_;
-    print &quot;BOUNCE: $email with reason $reason\n&quot;;
-    
-    my ($email_user, $email_domain) = split(/\@/, lc($email));
-    unless ($email_user &amp;&amp; $email_domain) {
-        print &quot;Invalid email address!\n&quot;;
-        exit(1);
-    }
-    my $domain_id = RegisterBounceDomain($email_domain, $dbh);
-    
-    my $level = ($reason eq 'over_quota') ? 'soft' : 'hard';
-    RegisterBounceEmail($email_user, $domain_id, $reason, $level, $dbh);
-}
-
-#-------------------------------------------------------------------------------
-sub RegisterBounceDomain($$) {
-    my ($domain, $dbh) = @_;
-    
-    # Lookup domain name
-    my $sth = $dbh-&gt;prepare(&quot;SELECT id FROM $domains_table WHERE name = ? AND name_crc32 = CRC32(?)&quot;);
-    $sth-&gt;execute($domain, $domain);
-    my $row = $sth-&gt;fetchrow_hashref;
-    return $row-&gt;{id} if $row;
-
-    # If not found, create it
-    print &quot;Registering domain: $domain\n&quot;;
-    $sth = $dbh-&gt;prepare(&quot;INSERT INTO $domains_table SET name = ?, name_crc32 = CRC32(?)&quot;);
-    $sth-&gt;execute($domain, $domain);
-    return $dbh-&gt;{'mysql_insertid'};
-}
-
-#-------------------------------------------------------------------------------
-sub RegisterBounceEmail($$$$$) {
-    my ($email_user, $domain_id, $reason, $level, $dbh) = @_;
-    
-    my $sql = &quot;
-        INSERT INTO $blacklist_table SET
-          domain_id = ?,
-          user_crc32 = CRC32(?),
-          user = ?,
-          source = 'bounce',
-          level = ?,
-          reason = ?,
-          created_at = NOW()
-    &quot;;
-    my $sth = $dbh-&gt;prepare($sql);
-    $sth-&gt;execute($domain_id, $email_user, $email_user, $level, $reason);
-}</diff>
      <filename>email-processor/bounce-processor.pl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>eafc2ff0ba88edd6ed54eed27fd615724a02fd3c</id>
    </parent>
  </parents>
  <author>
    <name>Alexey Kovyrin</name>
    <email>alexey@kovyrin.net</email>
  </author>
  <url>http://github.com/kovyrin/bounces-handler/commit/02c44480c685b86b35bf43b2725ae5db74d8eebf</url>
  <id>02c44480c685b86b35bf43b2725ae5db74d8eebf</id>
  <committed-date>2008-08-04T19:13:15-07:00</committed-date>
  <authored-date>2008-08-04T19:13:15-07:00</authored-date>
  <message>Simple feedback loops processor added</message>
  <tree>466591b4e08edb3efbba845cbb0664c851731bcc</tree>
  <committer>
    <name>Alexey Kovyrin</name>
    <email>alexey@kovyrin.net</email>
  </committer>
</commit>
