[siesta-commit] siesta/lib/Siesta Message.pm,1.35,1.36 User.pm,1.18,1.19

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

From: clampr
Subject: [siesta-commit] siesta/lib/Siesta Message.pm,1.35,1.36 User.pm,1.18,1.19
Date: 02:23 on 16 Mar 2003
Update of /cvsroot/siesta/siesta/lib/Siesta
In directory sc8-pr-cvs1:/tmp/cvs-serv657a/lib/Siesta

Modified Files:
	Message.pm User.pm 
Log Message:
more towards deferred, plus a method generator that auto-chomps lines

Index: Message.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/Message.pm,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- Message.pm	16 Mar 2003 00:47:54 -0000	1.35
+++ Message.pm	16 Mar 2003 02:23:46 -0000	1.36
@@ -25,12 +25,28 @@
 
 =cut
 
+# make a bunch of header-based accessors
+for (qw( To_raw From_raw Subject siesta_deferred_for )) {
+    my $header = $_;
+    my $sub_name = $header;
+    $header   =~ s/_raw$//;
+    $sub_name =~ s/^siesta_//;
+    my $sub = sub {
+        my $self = shift;
+        if (@_) {
+            $self->head->replace( $header, shift );
+        }
+        my $val = $self->head->get( $header ) || '';
+        chomp $val;
+        return $val;
+    };
+    no strict 'refs';
+    *{ lc $sub_name } = $sub;
+}
+
 sub to {
     my $self = shift;
-    if (@_) {
-        $self->head->replace( 'To', shift );
-    }
-    map { $_->address } Mail::Address->parse( $self->head->get('To') );
+    map { $_->address } Mail::Address->parse( $self->to_raw(@_) );
 }
 
 =head2 from
@@ -39,24 +55,11 @@
 
 sub from {
     my $self = shift;
-    if (@_) {
-        $self->head->replace( 'From', shift );
-    }
-    map { $_->address } Mail::Address->parse( $self->head->get('From') );
+    map { $_->address } Mail::Address->parse( $self->from_raw(@_) );
 }
 
 =head2 subject
 
-=cut
-
-sub subject {
-    my $self = shift;
-    if (@_) {
-        $self->head->replace( 'Subject', shift );
-    }
-    $self->head->get('Subject');
-}
-
 =head2 reply
 
 =cut
@@ -107,20 +110,29 @@
 
 sub defer {
     my $self = shift;
+    my %args = @_;
 
     my $list = $self->list->name;
+
+    my $for = delete $args{for} || die "need to know why we're deferring";
+    $self->deferred_for( $for );
+
+
     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
+    # hacky, hopefully this'll go in: http://rt.cpan.org/NoAuth/Bug.html?id=2236
     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!";
+}
+
+sub confirmed {
+    1;
 }
 
 1;

Index: User.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/User.pm,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- User.pm	15 Mar 2003 20:15:44 -0000	1.18
+++ User.pm	16 Mar 2003 02:23:46 -0000	1.19
@@ -98,7 +98,6 @@
     # need to populate id
     $self->id( Siesta->storage->user_id_from_email( $self->email ) );
     return $res;
-
 }
 
 =head2 ->delete



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