--- trunk/Nos.pm 2005/05/16 22:32:58 32 +++ trunk/Nos.pm 2005/05/17 11:09:08 33 @@ -77,6 +77,35 @@ } +=head2 new_list + +Create new list + + $nos->new_list( + list => 'My list", + email => 'my-list@example.com', + ); + +Returns ID of newly created list. + +=cut + +sub new_list { + my $self = shift; + + my $arg = {@_}; + + confess "need list name" unless ($arg->{'list'}); + confess "need list email" unless ($arg->{'list'}); + + my $l = $self->_get_list($arg->{'list'}) || + $self->_add_list( @_ ) || + return undef; + + return $l->id; +} + + =head2 add_member_to_list Add new member to list @@ -105,7 +134,7 @@ my $list = $self->_get_list($list_name) || croak "list $list_name doesn't exist"; if (! Email::Valid->address($email)) { - carp "SKIPPING $name <$email>\n" if ($self->{'verbose'}); + carp "SKIPPING $name <$email>\n"; return 0; } @@ -116,9 +145,13 @@ my $this_user = $users->find_or_create({ email => $email, - full_name => $name, }) || croak "can't find or create member\n"; + if ($name && $this_user->full_name ne $name) { + $this_user->full_name($name || ''); + $this_user->update; + } + my $user_on_list = $user_list->find_or_create({ user_id => $this_user->id, list_id => $list->id,