about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:54 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commitb1a86566fa4ffc45a2900f1de43c48c5be76905a (patch)
tree9eff67a95b359e6add67d1f3601fad27480e0d7c
parentb782d6f9d2e7fb515b589f0343109ac8681e4e14 (diff)
downloadpublic-inbox-b1a86566fa4ffc45a2900f1de43c48c5be76905a.tar.gz
Dummy messages make for bad user experience with MUAs which
still use sequence numbers.  Not being able to fetch a message
doesn't seem fatal in mutt, so just ignore (sometimes large)
gaps.
-rw-r--r--lib/PublicInbox/IMAP.pm61
-rw-r--r--t/imapd.t3
2 files changed, 6 insertions, 58 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 78042b9e..8307343c 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -9,8 +9,9 @@
 # data notes:
 # * NNTP article numbers are UIDs and message sequence numbers (MSNs)
 # * Message sequence numbers (MSNs) can be stable since we're read-only.
-#   Most IMAP clients use UIDs (I hope), and we can return a dummy
-#   message if a client requests a non-existent MSN.
+#   Most IMAP clients use UIDs (I hope).  We may return a dummy message
+#   in the future if a client requests a non-existent MSN, but that seems
+#   unecessary with mutt.
 
 package PublicInbox::IMAP;
 use strict;
@@ -398,22 +399,6 @@ sub fetch_body ($;$) {
         join('', @hold);
 }
 
-sub dummy_message ($$) {
-        my ($self, $seqno) = @_;
-        my $ret = <<EOF;
-From: nobody\@localhost\r
-To: nobody\@localhost\r
-Date: Thu, 01 Jan 1970 00:00:00 +0000\r
-Message-ID: <dummy-$seqno\@$self->{ibx}->{newsgroup}>\r
-Subject: dummy message #$seqno\r
-\r
-You're seeing this message because your IMAP client didn't use UIDs.\r
-The message which used to use this sequence number was likely spam\r
-and removed by the administrator.\r
-EOF
-        \$ret;
-}
-
 sub requeue_once ($) {
         my ($self) = @_;
         # COMPRESS users all share the same DEFLATE context.
@@ -437,8 +422,7 @@ sub uid_fetch_cb { # called by git->cat_async via git_async_cat
         if (!defined($oid)) {
                 # it's possible to have TOCTOU if an admin runs
                 # public-inbox-(edit|purge), just move onto the next message
-                return requeue_once($self) unless defined $want->{-seqno};
-                $bref = dummy_message($self, $smsg->{num});
+                return requeue_once($self);
         } else {
                 $smsg->{blob} eq $oid or die "BUG: $smsg->{blob} != $oid";
         }
@@ -764,42 +748,6 @@ sub cmd_uid_fetch ($$$;@) {
                 $args; # error
 }
 
-sub seq_fetch_m { # long_response
-        my ($self, $tag, $msgs, $range_info, $want) = @_;
-        while (!@$msgs) { # rare
-                if (my $end = refill_range($self, $msgs, $range_info)) {
-                        $self->write(\"$tag $end\r\n");
-                        return;
-                }
-        }
-        my $seq = $want->{-seqno}++;
-        my $cur_num = $msgs->[0]->{num};
-        if ($cur_num == $seq) { # as expected
-                git_async_cat($self->{ibx}->git, $msgs->[0]->{blob},
-                                \&uid_fetch_cb, \@_);
-        } elsif ($cur_num > $seq) {
-                # send dummy messages until $seq catches up to $cur_num
-                my $smsg = bless { num => $seq, ts => 0 }, 'PublicInbox::Smsg';
-                unshift @$msgs, $smsg;
-                my $bref = dummy_message($self, $seq);
-                uid_fetch_cb($bref, undef, undef, undef, \@_);
-                $smsg; # blessed response since uid_fetch_cb requeues
-        } else { # should not happen
-                die "BUG: cur_num=$cur_num < seq=$seq";
-        }
-}
-
-sub cmd_fetch ($$$;@) {
-        my ($self, $tag, $range_csv, @want) = @_;
-        my $args = fetch_common($self, $tag, $range_csv, \@want);
-        ref($args) eq 'ARRAY' ? do {
-                my $want = $args->[-1];
-                $want->{-seqno} = $args->[2]->[0]; # $beg == $range_info->[0];
-                long_response($self, \&seq_fetch_m, @$args)
-        } : $args; # error
-}
-
-
 sub parse_date ($) { # 02-Oct-1993
         my ($date_text) = @_;
         my ($dd, $mon, $yyyy) = split(/-/, $_[0], 3);
@@ -1147,5 +1095,6 @@ sub close {
 # we're read-only, so SELECT and EXAMINE do the same thing
 no warnings 'once';
 *cmd_select = \&cmd_examine;
+*cmd_fetch = \&cmd_uid_fetch;
 
 1;
diff --git a/t/imapd.t b/t/imapd.t
index 2546ab51..233be9f2 100644
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -348,8 +348,7 @@ is(scalar keys %$ret, 3, 'got all 3 messages');
         run_script(\@cmd, $env, $rdr) or BAIL_OUT('-learn rm');
 }
 my $r2 = $mic->fetch_hash('1:*', 'BODY.PEEK[]') or BAIL_OUT "FETCH $@";
-is(scalar keys %$r2, 3, 'still got all 3 messages');
-like($r2->{1}->{'BODY[]'}, qr/dummy message #1/, 'got dummy message 1');
+is(scalar keys %$r2, 2, 'did not get all 3 messages');
 is($r2->{2}->{'BODY[]'}, $ret->{2}->{RFC822}, 'message 2 unchanged');
 is($r2->{3}->{'BODY[]'}, $ret->{3}->{RFC822}, 'message 3 unchanged');
 $r2 = $mic->fetch_hash(2, 'BODY.PEEK[HEADER.FIELDS (message-id)]')