From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A39FF1F59D for ; Fri, 29 Jul 2022 20:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1659127264; bh=ndRqnD0jnWCWTw8hxFo/fD0/VcXQDt/z8stKlfmlTAc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=3ZxopnC42tfAUhfHunYC6By/8n4Zxaue9dlbf3ki6Ms4Tz4EXS+ujg3/dMtCJF/C7 id/71IUK7SeAlZF/U0NQ5E7jldwpYprjZ9Iu0jIYQU2D2DcfJw3rzMd9x14AnThFnK 6SK+kVn6h6Cg9qBZHmyxipkN9ptlnzT9xjWKRH+Y= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] doc|www: flesh out POP3 documentation for servers and users Date: Fri, 29 Jul 2022 20:41:03 +0000 Message-Id: <20220729204104.8563-2-e@80x24.org> In-Reply-To: <20220729204104.8563-1-e@80x24.org> References: <20220729204104.8563-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Hopefully it makes sense to new users deploying or using POP3... --- Documentation/public-inbox-config.pod | 7 +++++++ lib/PublicInbox/Inbox.pm | 30 +++++++++++++++++++++++---- lib/PublicInbox/WwwText.pm | 26 +++++++++++++++++------ 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/Documentation/public-inbox-config.pod b/Documentation/public-inbox-config.pod index ed99b188..d8504e61 100644 --- a/Documentation/public-inbox-config.pod +++ b/Documentation/public-inbox-config.pod @@ -228,6 +228,13 @@ L instance. Default: none +=item publicinbox.pop3server + +Same as C, but for the hostname(s) of the +L instance. + +Default: none + =item publicinbox.pop3state See L diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index da81fb67..0ad68810 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -28,7 +28,7 @@ sub do_cleanup { check_inodes($ibx); } else { delete(@$ibx{qw(over mm description cloneurl - -imap_url -nntp_url)}); + -imap_url -nntp_url -pop3_url)}); } my $srch = $ibx->{search} // $ibx; delete @$srch{qw(xdb qp)}; @@ -230,9 +230,9 @@ sub base_url { $url; } -# imapserver, nntpserver, and pop3server configs are used here: +# imapserver, nntpserver configs are used here: sub _x_url ($$$) { - my ($self, $x, $ctx) = @_; # $x is "imap", "nntp", or "pop3" + my ($self, $x, $ctx) = @_; # $x is "imap" or "nntp" # no checking for nntp_usable here, we can point entirely # to non-local servers or users run by a different user my $ns = $self->{"${x}server"} // @@ -276,7 +276,29 @@ EOM # my ($self, $ctx) = @_; sub imap_url { $_[0]->{-imap_url} //= _x_url($_[0], 'imap', $_[1]) } sub nntp_url { $_[0]->{-nntp_url} //= _x_url($_[0], 'nntp', $_[1]) } -sub pop3_url { $_[0]->{-pop3_url} //= _x_url($_[0], 'pop3', $_[1]) } + +sub pop3_url { + my ($self, $ctx) = @_; + $self->{-pop3_url} //= do { + my $ps = $self->{'pop3server'} // + $ctx->{www}->{pi_cfg}->get_all('publicinbox.pop3server'); + my $group = $self->{newsgroup}; + my @urls; + ($ps && $group) and + @urls = map { m!\Apops?://! ? $_ : "pop://$_" } @$ps; + if (my $mi = $self->{'pop3mirror'}) { + my @m = map { m!\Apops?://! ? $_ : "pop://$_" } @$mi; + my %seen; # List::Util::uniq requires Perl 5.26+ + @urls = grep { !$seen{$_}++ } (@urls, @m); + } + my $n = 0; + for (@urls) { $n += s!/+\z!! } + warn < +# Copyright (C) all contributors # License: AGPL-3.0+ # used for displaying help texts and other non-mail content @@ -272,7 +272,7 @@ EOF @ret; # may be empty, this sub is called as an arg for join() } -sub _add_imap_nntp_urls ($$) { +sub _add_non_http_urls ($$) { my ($ctx, $txt) = @_; $ctx->{ibx}->can('nntp_url') or return; # TODO extindex can have IMAP my $urls = $ctx->{ibx}->imap_url($ctx); @@ -286,11 +286,25 @@ EOM } $urls = $ctx->{ibx}->nntp_url($ctx); if (@$urls) { - $$txt .= "\n"; - $$txt .= @$urls == 1 ? 'Newsgroup' : 'Newsgroups are'; + $$txt .= @$urls == 1 ? "\nNewsgroup" : "\nNewsgroups are"; $$txt .= ' available over NNTP:'; $$txt .= "\n " . join("\n ", @$urls) . "\n"; } + $urls = $ctx->{ibx}->pop3_url($ctx); + if (@$urls) { + $urls = join("\n ", @$urls); + $$txt .= <{ibx}->{newsgroup} +where \$(uuidgen) in the output of the `uuidgen' command on your system. +The UUID in the username functions as a private cookie (don't share it). +Idle accounts will expire periodically. +EOM + } } sub _add_onion_note ($) { @@ -379,7 +393,7 @@ EOM Example config snippet for mirrors: $cfg_link EOF - _add_imap_nntp_urls($ctx, $txt); + _add_non_http_urls($ctx, $txt); _add_onion_note($txt); my $code_url = prurl($ctx->{env}, $PublicInbox::WwwStream::CODE_URL); @@ -508,7 +522,7 @@ message threading EOF } # $over - _add_imap_nntp_urls($ctx, \(my $note = '')); + _add_non_http_urls($ctx, \(my $note = '')); $note and $note =~ s/^/ /gms and $$txt .= <