Change DXUser->get* to DXUser::get*
[spider.git] / cmd / uncatchup.pl
1 #
2 # catchup some or all of the non-private messages for a node.
3 #
4 # in other words mark all messages as being already received
5 # by this node.
6 #
7 #
8 #
9 # Copyright (c) 1999 Dirk Koopman G1TLH
10 #
11
12 my ($self, $line) = @_;
13 return (1, $self->msg('e5')) if $self->priv < 5;
14
15 my @f = split /\s+/, $line;
16 return (1, "usage: catchup <node call> all|[<msgno ...]") unless @f >= 2;
17
18 my $call = uc shift @f;
19 my $user = DXUser::get_current($call);
20 return (1, "$call not a node") unless $user && $user->sort ne 'U';
21
22 my @out;
23 my $ref;
24 my @ref;
25
26 # get a more or less valid set of messages
27 foreach my $msgno (@f) {
28         if ($msgno =~ /^al/oi) {
29                 @ref = DXMsg::get_all();
30                 last;
31         } elsif (my ($f, $t) = $msgno =~ /(\d+)-(\d+)/) {
32                 while ($f <= $t) {
33                         $ref = DXMsg::get($f++);
34                         push @ref, $ref if $ref;
35                 }
36         } else {
37                 $ref = DXMsg::get($msgno);
38                 unless ($ref) {
39                         push @out, $self->msg('m13', $msgno);
40                         next;
41                 }
42                 push @ref, $ref;
43         }
44 }
45
46 foreach $ref (@ref) {
47         next if $ref->{private};
48         if (grep {$_ eq $call} @{$ref->{gotit}}) {
49                 $ref->{gotit} = [ grep {$_ ne $call} @{$ref->{gotit}} ]; # mark this up as NOT being received
50                 $ref->store( [ $ref->read_msg_body() ] );       # re- store the file
51                 push @out, $self->msg('m15', $ref->{msgno}, $call);
52         }
53 }
54
55 return (1, @out);
56