lib/PublicInbox/Feed.pm | 2 +- lib/PublicInbox/Inbox.pm | 17 ++++++----------- t/config.t | 2 -- diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index 4dd584d3478a2e2371be75de2375ac50793fc489..f570a25da560ded94d9a247e1b9fb23208a01865 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -80,7 +80,7 @@ sub recent_msgs { my ($ctx) = @_; my $ibx = $ctx->{ibx}; - my $max = $ibx->{feedmax}; + my $max = $ibx->{feedmax} // 25; return PublicInbox::View::paginate_recent($ctx, $max) if $ibx->over; # only for rare v1 inboxes which aren't indexed at all diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 586bd56110e5e548f3ea9c01bdf52e45915b5397..4e3c23f35a4820e96d87cb8f4b2c0f048ef9f5b0 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -74,16 +74,6 @@ $cleanup_timer //= PublicInbox::DS::later(\&cleanup_task); $CLEANUP->{"$self"} = $self; } -sub _set_uint ($$$) { - my ($opts, $field, $default) = @_; - my $val = $opts->{$field}; - if (defined $val) { - $val = $val->[-1] if ref($val) eq 'ARRAY'; - $val = undef if $val !~ /\A[0-9]+\z/; - } - $opts->{$field} = $val || $default; -} - sub _set_limiter ($$$) { my ($self, $pi_cfg, $pfx) = @_; my $lkey = "-${pfx}_limiter"; @@ -112,7 +102,12 @@ my $p = $opts->{-primary_address} = ref($v) eq 'ARRAY' ? $v->[0] : $v; $opts->{domain} = ($p =~ /\@(\S+)\z/) ? $1 : 'localhost'; my $pi_cfg = delete $opts->{-pi_cfg}; _set_limiter($opts, $pi_cfg, 'httpbackend'); - _set_uint($opts, 'feedmax', 25); + my $fmax = $opts->{feedmax}; + if (defined($fmax) && $fmax =~ /\A[0-9]+\z/) { + $opts->{feedmax} += 0; + } else { + delete $opts->{feedmax}; + } $opts->{nntpserver} ||= $pi_cfg->{'publicinbox.nntpserver'}; my $dir = $opts->{inboxdir}; if (defined $dir && -f "$dir/inbox.lock") { diff --git a/t/config.t b/t/config.t index ee51c6cc2628d8c663c47a90ab8a3cd12d6d7dc5..99a7fef45793ccc2b5e5e8d10c6eddf2922bb42e 100644 --- a/t/config.t +++ b/t/config.t @@ -41,7 +41,6 @@ 'domain' => 'public-inbox.org', 'url' => [ 'http://example.com/meta' ], -primary_address => 'meta@public-inbox.org', 'name' => 'meta', - feedmax => 25, -httpbackend_limiter => undef, nntpserver => undef, }, "lookup matches expected output"); @@ -58,7 +57,6 @@ -primary_address => 'try@public-inbox.org', 'inboxdir' => '/home/pi/test-main.git', 'domain' => 'public-inbox.org', 'name' => 'test', - feedmax => 25, 'url' => [ 'http://example.com/test' ], -httpbackend_limiter => undef, nntpserver => undef,