Deferred messages

[prev] [thread] [next] [lurker] [Date index for 2004/02/10]

From: Jody Belka
Subject: Deferred messages
Date: 12:26 on 10 Feb 2004
------=_20040210122629_68119
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

Hi,

As currently written, the deferred message system doesn't make a note of
which list a message is associated with, just which member. Now, although
the record of plugins that is made indirectly holds this information,
right now it is not the easiest thing you could do to get from a deferred
message back to a list.

Attached is a patch which makes the necessary changes to add this
functionality. If you could take a look and give me some feedback when you
have a chance i would be grateful.

Ta

-- 
Jody Belka
knew (at) pimb (dot) org
------=_20040210122629_68119
Content-Type: text/x-patch; name="Siesta-0.66.defer-list.diff"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="Siesta-0.66.defer-list.diff"

diff -rNu Siesta-0.66.orig/lib/Siesta/DBI.pm Siesta-0.66/lib/Siesta/DBI.pm
--- Siesta-0.66.orig/lib/Siesta/DBI.pm	2003-10-17 15:18:24.000000000 +0200
+++ Siesta-0.66/lib/Siesta/DBI.pm	2004-02-10 12:40:07.000000000 +0100
@@ -131,6 +131,7 @@
         id              INTEGER PRIMARY KEY auto_increment,
         expires         INTEGER,        # epoch time at which it's considered dead
         who             INTEGER NOT NULL,        # who can release it
+        list            INTEGER NOT NULL,        # which list is it associated with
         why             VARCHAR(255),   # just a comment?
         plugins         VARCHAR(255),   # this could become too small,
                                         # in the case of extreme installs
diff -rNu Siesta-0.66.orig/lib/Siesta/Deferred.pm Siesta-0.66/lib/Siesta/Deferred.pm
--- Siesta-0.66.orig/lib/Siesta/Deferred.pm	2003-10-17 15:18:25.000000000 +0200
+++ Siesta-0.66/lib/Siesta/Deferred.pm	2004-02-10 12:35:47.000000000 +0100
@@ -4,6 +4,7 @@
 
 __PACKAGE__->set_up_table('deferred');
 __PACKAGE__->has_a(who     => 'Siesta::Member' );
+__PACKAGE__->has_a(list    => 'Siesta::List' );
 __PACKAGE__->has_a(message => 'Siesta::Message',
                    deflate => 'as_string',
                   );
diff -rNu Siesta-0.66.orig/lib/Siesta/Message.pm Siesta-0.66/lib/Siesta/Message.pm
--- Siesta-0.66.orig/lib/Siesta/Message.pm	2003-10-17 15:18:23.000000000 +0200
+++ Siesta-0.66/lib/Siesta/Message.pm	2004-02-10 12:40:43.000000000 +0100
@@ -6,7 +6,7 @@
 use Carp qw( carp croak );
 use Storable qw(dclone);
 use base qw( Email::Simple Class::Accessor::Fast );
-__PACKAGE__->mk_accessors(qw( plugins ));
+__PACKAGE__->mk_accessors(qw( plugins list ));
 
 =head1 NAME
 
@@ -44,6 +44,7 @@
     $data =~ s/^From .+$//m;
 
     my $self = $class->SUPER::new( $data );
+    $self->list( undef );
     $self->plugins( [] );
     return $self;
 }
@@ -123,6 +124,7 @@
     Siesta::Deferred->create({
         @_,
         plugins => join(',', @{ $self->plugins } ),
+        list => $self->list,
         message => $self,
     });
 }
diff -rNu Siesta-0.66.orig/lib/Siesta/Plugin/Resume.pm Siesta-0.66/lib/Siesta/Plugin/Resume.pm
--- Siesta-0.66.orig/lib/Siesta/Plugin/Resume.pm	2003-10-17 15:18:25.000000000 +0200
+++ Siesta-0.66/lib/Siesta/Plugin/Resume.pm	2004-02-10 13:05:41.000000000 +0100
@@ -16,6 +16,11 @@
         # you don't own this message, so you can't resume it
         return 1;
     }
+    unless ($deferred->list eq $mail->list) {
+        # this message is intended for a different list,
+        # so you can't resume it
+        return 1;
+    }
     unless ( $deferred->hash eq $hash ) {
         # wrong magic cookie
         return 1;
diff -rNu Siesta-0.66.orig/lib/Siesta.pm Siesta-0.66/lib/Siesta.pm
--- Siesta-0.66.orig/lib/Siesta.pm	2003-10-17 15:35:51.000000000 +0200
+++ Siesta-0.66/lib/Siesta.pm	2004-02-10 12:33:21.000000000 +0100
@@ -60,6 +60,7 @@
     my $list   = Siesta::List->load( $args{list} );
 
     $self->log("processing $action", 1);
+    $mail->list( $list );
     $mail->plugins( [ $list->plugins( $action ) ] );
     $mail->process;
 }
diff -rNu Siesta-0.66.orig/t/09defer.t Siesta-0.66/t/09defer.t
--- Siesta-0.66.orig/t/09defer.t	2003-10-17 15:18:23.000000000 +0200
+++ Siesta-0.66/t/09defer.t	2004-02-10 13:03:05.000000000 +0100
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 22;
+use Test::More tests => 23;
 use lib qw(t/lib);
 use Siesta::Test;
 use Siesta;
@@ -12,6 +12,9 @@
 
 is( $message->subject, "yoohoo", "  on which the subject is correct" );
 
+my $list = Siesta::List->load('dealers');
+$message->list($list);
+
 my @deferred = Siesta::Deferred->retrieve_all;
 is( scalar @deferred, 0, "we have no deferred messages" );
 
@@ -29,6 +32,7 @@
 is( $def->message->subject, "yoohoo", "deferred message has correct subject" );
 is( $def->why, "the hell of it", "deferred message has correct deferred reason" );
 is( $def->id, $id, "id matches" );
+is( $def->list, $list, "list matches" );
 
 $def = Siesta::Deferred->retrieve($id);
 ok( $def, "fetch via id" );
@@ -61,7 +65,7 @@
 
 ## start and defer
 
-my $list = Siesta::List->find_or_create({
+$list = Siesta::List->find_or_create({
     name         => 'defer',
     owner        => $user,
     post_address => 'spangly',
diff -rNu Siesta-0.66.orig/t/10plugin_membersonly.t Siesta-0.66/t/10plugin_membersonly.t
--- Siesta-0.66.orig/t/10plugin_membersonly.t	2003-10-17 15:18:23.000000000 +0200
+++ Siesta-0.66/t/10plugin_membersonly.t	2004-02-10 13:00:28.000000000 +0100
@@ -24,6 +24,7 @@
 
 yoohoo
 MAIL
+$mail->list($list);
 
 my $list_id   = $list->name;
 my $mail_from = $mail->from;
------=_20040210122629_68119--

Generated at 13:56 on 01 Jul 2004 by mariachi 0.52