]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: implement XPATH
authorEric Wong <e@80x24.org>
Sat, 19 Sep 2015 02:03:36 +0000 (02:03 +0000)
committerEric Wong <e@80x24.org>
Sat, 19 Sep 2015 04:18:42 +0000 (04:18 +0000)
This may be helpful for sorting out duplicates.

lib/PublicInbox/NNTP.pm

index 939fc3a6b700bbbbaf6c4d2cd0744efe27dbfa2a..094d26dfea274e6edf30c124a802799164c341f9 100644 (file)
@@ -653,6 +653,19 @@ sub cmd_xover ($;$) {
        });
 }
 
+sub cmd_xpath ($$) {
+       my ($self, $mid) = @_;
+       return r501 unless $mid =~ /\A<(.+)>\z/;
+       $mid = $1;
+       my @paths;
+       foreach my $ng (values %{$self->{nntpd}->{groups}}) {
+               my $n = $ng->mm->num_for($mid);
+               push @paths, "$ng->{name}/$n" if defined $n;
+       }
+       return '430 no such article on server' unless @paths;
+       '223 '.join(' ', @paths);
+}
+
 sub res ($$) {
        my ($self, $line) = @_;
        do_write($self, $line . "\r\n");