]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
pop3: limit default mailbox to 1K messages
authorEric Wong <e@80x24.org>
Thu, 14 Sep 2023 00:38:28 +0000 (00:38 +0000)
committerEric Wong <e@80x24.org>
Fri, 15 Sep 2023 20:38:55 +0000 (20:38 +0000)
This is probably friendlier to webmail providers which
support importing mail from POP3.

lib/PublicInbox/POP3.pm
lib/PublicInbox/WwwText.pm

index 4a21ef5e3b10adb9483453a320ff9ce6927d621e..f97eccfd85326b84728c278db62f5d47fe82ce04 100644 (file)
@@ -72,7 +72,7 @@ sub cmd_user ($$) {
        $user =~ tr/-//d; # most have dashes, some (dbus-uuidgen) don't
        $user =~ m!\A[a-f0-9]{32}\z!i or return \"-ERR user has no UUID\r\n";
 
-       my $limit = UID_SLICE;
+       my $limit;
        $mailbox =~ s/\?limit=([0-9]+)\z// and
                $limit = $1 > UID_SLICE ? UID_SLICE : $1;
 
@@ -86,10 +86,11 @@ sub cmd_user ($$) {
                my $tip = "$mailbox.$max";
                return \"-ERR $mailbox.$slice does not exist ($tip does)\r\n"
                        if $slice > $max;
+               $limit //= UID_SLICE;
                $self->{uid_base} = ($slice * UID_SLICE) + UID_SLICE - $limit;
                $self->{slice} = $slice;
-       } else { # latest $limit messages
-               my $base = $uidmax - $limit;
+       } else { # latest $limit messages, 1k if unspecified
+               my $base = $uidmax - ($limit // 1000);
                $self->{uid_base} = $base < 0 ? 0 : $base;
                $self->{slice} = -1;
        }
index c31a7f86ecd37fa4b1a13a599af6f0a79ca87bd1..f4508b3f65019c155933b955101a7a67e2bf6ee2 100644 (file)
@@ -293,6 +293,9 @@ The POP3 password is: anonymous
 The POP3 username is: \$(uuidgen)\@$ctx->{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).
+By default, only 1000 messages are retrieved.  You may download more
+by appending `?limit=NUM' (without quotes) to the username, where
+`NUM' is an integer between 1 and 50000.
 Idle accounts will expire periodically.
 EOM
        }