/[notice-sender]/trunk/Nos.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/Nos.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 75 by dpavlin, Wed Aug 24 21:27:40 2005 UTC revision 77 by dpavlin, Thu Aug 25 00:37:48 2005 UTC
# Line 27  use Email::Simple; Line 27  use Email::Simple;
27  use Email::Address;  use Email::Address;
28  use Mail::DeliveryStatus::BounceParser;  use Mail::DeliveryStatus::BounceParser;
29  use Class::DBI::AbstractSearch;  use Class::DBI::AbstractSearch;
30    use SQL::Abstract;
31  use Mail::Alias;  use Mail::Alias;
32  use Cwd qw(abs_path);  use Cwd qw(abs_path);
33    
# Line 116  sub new { Line 117  sub new {
117    
118          $self->{'hash_len'} ||= 8;          $self->{'hash_len'} ||= 8;
119    
         $self->{'loader'}->find_class('received')->set_sql(  
                 'received' => qq{  
                         select  
                                 received.id as id,  
                                 lists.name as list,  
                                 users.ext_id as ext_id,  
                                 users.email as email,  
                                 bounced,received.date as date  
                         from received  
                         join lists on lists.id = list_id  
                         join users on users.id = user_id  
                 },  
         );  
   
120          $self ? return $self : return undef;          $self ? return $self : return undef;
121  }  }
122    
# Line 727  Returns all received messages for given Line 714  Returns all received messages for given
714          email => "john.doe@example.com",          email => "john.doe@example.com",
715   );   );
716    
717  This method is used by C<sender.pl> when receiving e-mail messages.  Each element in returned array will have following structure:
718    
719     {
720            id => 42,                       # unique ID of received message
721            list => 'My list',              # useful only of filtering by email
722            ext_id => 9999,                 # ext_id from message user
723            email => 'jdoe@example.com',    # e-mail of user
724            bounced => 0,                   # true value if message is bounce
725            date => '2005-08-24 18:57:24',  # date of recival in ISO format
726     }
727    
728    
729  =cut  =cut
730    
731  sub received_messages {  sub received_messages {
732          my $self = shift;          my $self = shift;
733    
734          my $arg = {@_};          my $arg = {@_} if (@_);
735    
736          croak "need list name or email" unless ($arg->{'list'} || $arg->{'email'});  #       croak "need list name or email" unless ($arg->{'list'} || $arg->{'email'});
737    
738          $arg->{'list'} = lc($arg->{'list'});          my $sql = qq{
739          $arg->{'email'} = lc($arg->{'email'});                          select
740                                    received.id as id,
741                                    lists.name as list,
742                                    users.ext_id as ext_id,
743                                    users.email as email,
744                                    bounced,received.date as date
745                            from received
746                            join lists on lists.id = list_id
747                            join users on users.id = user_id
748            };
749    
750            my $where;
751    
752          my $rcvd = $self->{'loader'}->find_class('received')->search_received();          $where->{'lists.name'} = lc($arg->{'list'}) if ($arg->{'list'});
753            $where->{'users.email'} = lc($arg->{'email'}) if ($arg->{'email'});
754    
755          return $rcvd;          # hum, yammy one-liner
756            my($stmt, @bind)  = SQL::Abstract->new->where($where);
757    
758            my $dbh = $self->{'loader'}->find_class('received')->db_Main;
759    
760            my $sth = $dbh->prepare($sql . $stmt);
761            $sth->execute(@bind);
762            return $sth->fetchall_hash;
763  }  }
764    
765    
# Line 1152  This is a stub for documentation of unim Line 1168  This is a stub for documentation of unim
1168    
1169  You can specify just C<list> or C<email> or any combination of those.  You can specify just C<list> or C<email> or any combination of those.
1170    
1171  It will return array of hashes with following structure:  For format of returned array element see C<received_messages>.
   
  {  
         id => 42,                       # unique ID of received message  
         list => 'My list',              # useful only of filtering by email  
         ext_id => 9999,                 # ext_id from message user  
         email => 'jdoe@example.com',    # e-mail of user  
         bounced => 0,                   # true value if message is bounce  
         date => '2005-08-24 18:57:24',  # date of recival in ISO format  
  }  
1172    
1173  =head2 MessagesReceivedByDate  =head2 MessagesReceivedByDate
1174    

Legend:
Removed from v.75  
changed lines
  Added in v.77

  ViewVC Help
Powered by ViewVC 1.1.26