got a working read message command WITH private marking (ie store works)
[spider.git] / cmd / read.pl
1 #
2 # read a message
3 #
4 # Copyright (c) Dirk Koopman G1TLH
5 #
6 # $Id$
7 #
8
9 my ($self, $line) = @_;
10 my @f = split /\s+/, $line;
11 my $msgno;
12 my @out;
13 my @body;
14 my $ref;
15
16 for $msgno (@f) {
17   $ref = DXMsg::get($msgno);
18   if (!$ref) {
19     push @out, "Msg $msgno not found";
20         next;
21   }
22   if ($ref->private && $self->priv < 9 && $ref->to ne $ref->call) {
23     push @out, "Msg $msgno not available";
24         next;
25   }
26   push @out, sprintf "Msg: %d From: %s Date: %6.6s %5.5s Subj: %-30.30s", $msgno,
27                      $ref->from, cldate($ref->t), ztime($ref->t), $ref->subject;
28   @body = $ref->read_msg_body;
29   push @out, @body;
30   
31   # mark my privates as read
32   if ($ref->private && $self->call eq $ref->to && $ref->read == 0) {
33     $ref->read(1);
34     $ref->store(\@body);    # note call by reference!
35   }
36 }
37
38 return (1, @out);