--- trunk/sender.pl 2005/05/15 17:01:19 18 +++ trunk/sender.pl 2005/05/15 21:35:15 21 @@ -1,10 +1,9 @@ #!/usr/bin/perl -w use strict; -use Class::DBI::Loader::Pg; +use blib; +use Nos; use Getopt::Long; -use Email::Valid; -use Email::Send; =head1 NAME @@ -41,18 +40,16 @@ "email=s" => \$email_opt, ); - -my $loader = Class::DBI::Loader::Pg->new( - debug => $debug, - dsn => "dbi:Pg:dbname=notices", - user => "dpavlin", - password => "", - namespace => "Noticer", -# additional_classes => qw/Class::DBI::AbstractSearch/, -# additional_base_classes => qw/My::Stuff/, - relationships => 1, +my $nos = new Nos( + dsn => 'dbi:Pg:dbname=notices', + user => 'dpavlin', + passwd => '', + debug => $debug, + verbose => $verbose, ); +my $loader = $nos->{'loader'} || die "can't find loader?"; + my $lists = $loader->find_class('lists'); my $users = $loader->find_class('users'); my $user_list = $loader->find_class('user_list'); @@ -107,10 +104,10 @@ =cut } elsif ($add_opt) { - #my $noticer = $loader->find_class('Noticer') || die "can't find my class!"; my $list = $lists->find_or_create({ name => $add_opt, }) || die "can't add list $add_opt\n"; + if ($email_opt && $list->email ne $email_opt) { $list->email($email_opt); $list->update; @@ -236,15 +233,16 @@ foreach my $u ($user_list->search(list_id => $m->list_id)) { - my $hdr = "To: ".$u->user_id->full_name." <". $u->user_id->email. ">\n"; - if ($sent->search( message_id => $m->message_id, user_id => $u->user_id )) { print "SKIP ",$u->user_id->email," message allready sent\n"; } else { print "\t",$u->user_id->email,"\n"; + my $hdr = "From: " . $u->list_id->name . " <" . $u->list_id->email . ">\n" . + "To: " . $u->user_id->full_name . " <". $u->user_id->email. ">\n"; + # FIXME do real sending :-) - send IO => "$hdr\n$msg"; + $nos->send_email("$hdr\n$msg"); $sent->create({ message_id => $m->message_id,