[siesta-commit] siesta/lib/Siesta List.pm,1.39,1.40 Message.pm,1.34,1.35

[prev] [thread] [next] [lurker] [Date index for 2003/03/16]

From: clampr
Subject: [siesta-commit] siesta/lib/Siesta List.pm,1.39,1.40 Message.pm,1.34,1.35
Date: 00:47 on 16 Mar 2003
Update of /cvsroot/siesta/siesta/lib/Siesta
In directory sc8-pr-cvs1:/tmp/cvs-serv5250/lib/Siesta

Modified Files:
	List.pm Message.pm 
Log Message:
start of a deferred framework

Index: List.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/List.pm,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- List.pm	15 Mar 2003 22:11:55 -0000	1.39
+++ List.pm	16 Mar 2003 00:47:53 -0000	1.40
@@ -1,6 +1,7 @@
 # $Id$
 package Siesta::List;
 use Siesta;
+use Siesta::Message;
 use Siesta::User;
 use strict;
 use vars qw(@fields);
@@ -210,6 +211,24 @@
     my $self = shift;
 
     return Siesta->storage->set_plugins( $self->id, @_ );
+}
+
+=head2 ->deferred
+
+All the deferred messages for a list
+
+=cut
+
+sub deferred {
+    my $self = shift;
+
+    my $name = $self->name;
+
+    return map {
+        local *FILE;
+        open FILE, $_ or die "couldn't open '$_': $!";
+        new Siesta::Message \*FILE;
+    } map { <$Siesta::Config::ROOT/queue/$name/$_/*> } qw( new cur );
 }
 
 1;

Index: Message.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/Message.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- Message.pm	15 Oct 2002 11:03:01 -0000	1.34
+++ Message.pm	16 Mar 2003 00:47:54 -0000	1.35
@@ -8,10 +8,23 @@
 use base 'Mail::Internet';
 use Storable qw(dclone);
 
+use Mail::LocalDelivery;
+use File::Path qw(mkpath);
+
 use constant debug => 0;
 
 use Class::MethodMaker get_set => [qw( list user )];
 
+=head1 NAME
+
+Siesta::Message - class to
+
+=head1 METHODS
+
+=head2 to
+
+=cut
+
 sub to {
     my $self = shift;
     if (@_) {
@@ -20,6 +33,10 @@
     map { $_->address } Mail::Address->parse( $self->head->get('To') );
 }
 
+=head2 from
+
+=cut
+
 sub from {
     my $self = shift;
     if (@_) {
@@ -28,6 +45,10 @@
     map { $_->address } Mail::Address->parse( $self->head->get('From') );
 }
 
+=head2 subject
+
+=cut
+
 sub subject {
     my $self = shift;
     if (@_) {
@@ -36,6 +57,10 @@
     $self->head->get('Subject');
 }
 
+=head2 reply
+
+=cut
+
 sub reply {
     my $self  = shift;
     my %args  = @_;
@@ -62,14 +87,41 @@
     $clone->send;
 }
 
+=head2 send
+
+=cut
+
 sub send {
     my $self = shift;
     return Siesta->sender->send( $self, @_ );
 }
 
+=head2 clone
+
+=cut
+
 sub clone {
     my $self = shift;
     return dclone($self);
 }
 
+sub defer {
+    my $self = shift;
+
+    my $list = $self->list->name;
+    my $queue = "$Siesta::Config::ROOT/queue";
+    eval { mkpath( $queue, 0, 0777 ) };
+    die "Couldn't mkpath '$queue'" if $@;
+
+    # this'll be fine so long as Siesta::Message remains a child
+    # of Mail::Internet
+    my $clone = $self->clone;
+    bless $clone, 'Mail::Internet';
+    my $ld = new Mail::LocalDelivery $clone;
+
+    # deliver to a maildir
+    $ld->deliver( "$queue/$list/" ) or die "LD failed!";
+}
+
 1;
+



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