--- trunk/Nos.pm 2005/05/18 09:46:49 42 +++ trunk/Nos.pm 2005/05/18 12:29:35 43 @@ -175,6 +175,49 @@ return $this_user->id; } +=head2 list_members + + my @members = list_members( + list => 'My list', + ); + +Returns array of hashes with user informations like this: + + $member = { + full_name => 'Dobrica Pavlinusic', + email => 'dpavlin@rot13.org + } + +=cut + +sub list_members { + my $self = shift; + + my $args = {@_}; + + my $list_name = $args->{'list'} || confess "need list name"; + + my $lists = $self->{'loader'}->find_class('lists'); + my $user_list = $self->{'loader'}->find_class('user_list'); + + my $this_list = $lists->search( name => $list_name )->first || croak "can't find list $list_name\n"; + + my @results; + + foreach my $user_on_list ($user_list->search(list_id => $this_list->id)) { + my $row = { + full_name => $user_on_list->user_id->full_name, + email => $user_on_list->user_id->email, + }; + + push @results, $row; + } + + return @results; + +} + + =head2 add_message_to_list Adds message to one list's queue for later sending. @@ -370,7 +413,6 @@ $user_id = $sent_msg->user_id || carp "no user_id"; } -print "message_id: ",($message_id || "not found"),"\n"; my $is_bounce = 0; @@ -393,6 +435,9 @@ $this_received->dbi_commit; + print "message_id: ",($message_id || "not found")," -- $is_bounce\n"; + + warn "inbox is not yet implemented"; } @@ -469,6 +514,8 @@ package Nos::SOAP; +use Carp; + =head1 SOAP methods This methods are thin wrappers to provide SOAP calls. They are grouped in @@ -517,12 +564,13 @@ } } + =head2 AddMemberToList $member_id = AddMemberToList( - list => "My list", - email => "e-mail@example.com", - name => "Full Name" + list => 'My list', + email => 'e-mail@example.com', + name => 'Full Name' ); =cut @@ -539,6 +587,31 @@ } } + +=head2 ListMembers + + my @members = ListMembers( + list => 'My list', + ); + +Returns array of hashes with user informations, see C. + +=cut + +sub ListMembers { + my $self = shift; + + my $list_name; + + if ($_[0] !~ m/^HASH/) { + $list_name = shift; + } else { + $list_name = $_[0]->{'list'}; + } + + return $nos->list_members( list => $list_name ); +} + =head2 AddMessageToList $message_id = AddMessageToList(