[siesta-commit] siesta/lib/Siesta/Plugin Subscribe.pm,1.12,1.13

[prev] [thread] [next] [lurker] [Date index for 2002/10/10]

From: clampr
Subject: [siesta-commit] siesta/lib/Siesta/Plugin Subscribe.pm,1.12,1.13
Date: 12:20 on 10 Oct 2002
Update of /cvsroot/siesta/siesta/lib/Siesta/Plugin
In directory usw-pr-cvs1:/tmp/cvs-serv5501

Modified Files:
	Subscribe.pm 
Log Message:
From: Gavin Estey
Date: Thu Oct 10, 2002  03:52:13 Europe/London
Subject: [siesta-dev] Plugins/Subscribe.pm


Index: Subscribe.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/Plugin/Subscribe.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- Subscribe.pm	1 Oct 2002 10:12:01 -0000	1.12
+++ Subscribe.pm	10 Oct 2002 11:20:53 -0000	1.13
@@ -13,23 +13,20 @@
     my $self = shift;
     my $mail = shift;
     my $list = $mail->list;
-
-    my $user_id = $mail->from();
-
-    my $user = Siesta::User->new($user_id);
+    my $user_id = $mail->from;
 
     # check to see if they're already subbed
-    my %members = map { $_->id() => 1 } $list->members();
-
-    if ( $members{$user_id} ) {
+    if ( $list->is_member($user_id) ) {
         $self->already_subbed($mail);
         return 1;
     }
 
     # XXX should this be done implicitly by $list->add_member?
+    my $user = Siesta::User->new($user_id);
+
     unless ($user) {
         $user = Siesta::User->new_from_hash( id => $user_id );
-        $user->save();
+        $user->save;
     }
 
     # now check to see if there's a key for them
@@ -37,9 +34,9 @@
     my $value = $self->config( $mail, 'request' );
 
     # and get the value from subject
-    my ($sub) = $mail->subject() =~ /SUBSCRIBE\s+(.+)/;
+    my ($sub) = $mail->subject =~ /SUBSCRIBE\s+(.+)/;
 
-    # if there is 
+    # if there is
     if ( defined $sub ) {
 
         # are they the same
@@ -53,8 +50,6 @@
             # tell them that their key is invalid
             $self->invalid_key($mail);
         }
-
-        # otherwise
     }
     else {
 
@@ -63,7 +58,7 @@
     }
 
     # now go through the database and remove any old keys
-    my $clone = $mail->clone();
+    my $clone = $mail->clone;
 
     # remove the user and the list so that
     # we can clean as much up as possible
@@ -74,17 +69,17 @@
     my $date = time() - ( 60 * 60 * 24 * 31 );
 
     # $self->delete_config($clone, 'request', $date);
-    # TODO     
+    # TODO
 
 }
 
-# mail the person and the list owner and 
+# mail the person and the list owner and
 # tell them they've been subbed
 sub successfully_subbed {
     my $self = shift;
     my $mail = shift;
-    my $list = $mail->list();
-    my $user = $mail->user();
+    my $list = $mail->list;
+    my $user = $mail->user;
 
     # delete the key already in the db
     $self->delete_config( $mail, 'request' );
@@ -96,7 +91,7 @@
         return;
     }
 
-    # mail the listowner and tell them that someone subbed 
+    # mail the listowner and tell them that someone subbed
     $mail->reply( to   => $list->owner,
                   body => $user->id . "  JOIN " . $list->id );
 
@@ -116,7 +111,7 @@
 
     my $self = shift;
     my $mail = shift;
-    my $list = $mail->list();
+    my $list = $mail->list;
 
     # mail them and reject them
     $mail->reply( body => <<END);
@@ -133,10 +128,9 @@
 
 # Tell them that the key they passed was invalid
 sub invalid_key {
-
     my $self = shift;
     my $mail = shift;
-    my $list = $mail->list();
+    my $list = $mail->list;
 
     # mail them and reject them
     $mail->reply( body => <<END);
@@ -154,13 +148,13 @@
 sub send_key {
     my $self = shift;
     my $mail = shift;
-    my $list = $mail->list();
+    my $list = $mail->list;
 
-    # generate a unique value 
+    # generate a unique value
     my $value = md5_hex( $$ . time() . {} . rand() );
     $self->config( $mail, 'request', $value );
 
-    # mail them with a a request	
+    # mail them with a a request
     $mail->subject("SUBSCRIBE $value");
     $mail->reply( body => <<END);
 Hi,
@@ -170,7 +164,7 @@
 
  SUBSCRIBE $value
 
- Hitting 'reply' in most mail clients should suffice. 
+ Hitting 'reply' in most mail clients should suffice.
 
  - Siesta::Plugin::Subscribe
 END



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