Ask Bjørn Hansen wrote:
On Jan 18, 2006, at 12:30 AM, Ulrich Stärk wrote:
Hi Ulrich,
Thanks for contributing your plugin; it or something like it would
make a good addition I think. (Like many other modules posted to the
list for that matter :-) ...).
I didn't know how likely those where to collide so I decided to use a
generetad artificial ID. Using an integer as key should be
significantly
faster too on most database systems when retrieving a specific mail.
Anyone out there who knows how likely key collisions are when using the
message-id header as key?
Very likely (the same message sent to different recipients). It
wouldn't have to be a unique key though.
cyrus won't allow the same msg id sent to different recipients.
I have to test for whether a message originates here, and then
I know I can't pass an "old" id.
list threading depends on keeping "old" message id in some
header. At the moment I can't remember how I reconcile
that, but it's possible. Maybe the old id gets bumped into
an X header. I can't remember but I had to fix that to please
a listserver administrator(to preserve threading).
A few comments:
1) In register() it'd be neater to just "slurp" the configuration
into a hash (%conf = @args).
2) It doesn't handle losing the database connection between register
and hook_data_post. Just cache the database connection, something like:
my $dbh;
sub db_connect {
return $dbh if $dbh and $dbh->ping;
return $dbh = DBI->connect( ... );
}
and then just call db_connect every time you need a dbh.
3) You should use placeholders in the SQL. (As it is it'll break if
someone sends a mail with ' in the subject).
4) Why store the mail both in the database and in a file?
5) I forget what it's called, but there's a driver independent way to
do $dbh->{mysql_insertid} in DBI now.
- ask