rev 1804 - in trunk/Email-Store: . lib/Email/Store

[prev] [thread] [next] [lurker] [Date index for 2005/02/03]

From: richardc
Subject: rev 1804 - in trunk/Email-Store: . lib/Email/Store
Date: 15:13 on 03 Feb 2005
Author: richardc
Date: 2005-02-03 15:13:24 +0000 (Thu, 03 Feb 2005)
New Revision: 1804

Modified:
   trunk/Email-Store/Makefile.PL
   trunk/Email-Store/lib/Email/Store/Mail.pm
Log:
use Email::MessageID to make better fake messageids

Modified: trunk/Email-Store/Makefile.PL
===================================================================
--- trunk/Email-Store/Makefile.PL	2005-02-03 15:11:00 UTC (rev 1803)
+++ trunk/Email-Store/Makefile.PL	2005-02-03 15:13:24 UTC (rev 1804)
@@ -8,6 +8,7 @@
         Class::DBI::DATA::Schema => 0,
         DBD::SQLite => 0,
         Email::Address => 1.80,
+        Email::MessageID => 0,
         Email::MIME => 1.8,
         Email::MIME::Attachment::Stripper => 1.3,
         Email::Simple => 1.92,

Modified: trunk/Email-Store/lib/Email/Store/Mail.pm
===================================================================
--- trunk/Email-Store/lib/Email/Store/Mail.pm	2005-02-03 15:11:00 UTC (rev 1803)
+++ trunk/Email-Store/lib/Email/Store/Mail.pm	2005-02-03 15:13:24 UTC (rev 1804)
@@ -1,8 +1,7 @@
 package Email::Store::Mail;
+use strict;
+use warnings;
 use base 'Email::Store::DBI';
-use Time::HiRes;
-use strict; 
-use warnings;
 
 require Email::Store;
 
@@ -11,9 +10,10 @@
 Email::Store::Mail->columns(Primary => qw/message_id/);
 Email::Store::Mail->columns(TEMP => qw/simple/);
 use Module::Pluggable::Ordered search_path => ["Email::Store"], only => [ keys %Email::Store::only ];
-
 use Email::Simple;
+use Email::MessageID;
 
+
 sub _simple { Email::Simple->new(shift); } # RFC2822 -> Email::Simple
 
 sub simple {
@@ -34,8 +34,8 @@
         return $self;
     }
 
-    $self = $class->create ({ message_id => $msgid, 
-                              message    => $rfc822, 
+    $self = $class->create ({ message_id => $msgid,
+                              message    => $rfc822,
                               simple     => $simple });
     $self->call_plugins("on_store", $self);
     $self;
@@ -43,10 +43,13 @@
 
 sub fix_msg_id {
     my ($self, $simple) = @_;
-    my $id = $simple->header("Message-ID");
-    if ($id) { $id =~ s/.*<(.+)>.*/$1/ && return $id; }
-    my $fake = $$."-".time()."\@unknown";
-    $simple->header_set("Message-ID", "<$fake>");
+
+    if ( my $id = $simple->header("Message-ID") ) {
+        $id =~ s/.*<(.+)>.*/$1/ && return $id;
+    }
+    my $fake = Email::MessageID->new.'';
+    $simple->header_set("Message-ID", $fake);
+    $fake =~ s/^.(.*).$/$1/; # we don't want the <>
     return $fake;
 }
 

Generated at 16:00 on 03 Feb 2005 by mariachi 0.52