diff options
author | Eric Wong <e@80x24.org> | 2023-01-11 10:55:39 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-01-11 18:53:05 +0000 |
commit | 20ab293a131f0ec228932bf3448d1b09e280672b (patch) | |
tree | d9ff2c63a209dcd52044461c2d8cee6e50d6f775 /lib/PublicInbox/View.pm | |
parent | 563206c94db52f7e0e6d899fef2681c9e63f8fee (diff) | |
download | public-inbox-20ab293a131f0ec228932bf3448d1b09e280672b.tar.gz |
To ensure users aren't abusing the ability to reuse Message-IDs, provide a convenient front-end to `lei mail-diff' from WWW. Most of the time it's just list-appended signatures, so I expect this to be useful for /all/ users.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r-- | lib/PublicInbox/View.pm | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 071a2093..b8d6d85e 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -623,7 +623,8 @@ sub _msg_page_prepare { return; } $ctx->{-html_tip} = -"<pre>WARNING: multiple messages have this Message-ID\n</pre><pre>"; +qq[<pre>WARNING: multiple messages have this Message-ID (<a +href="d/">diff</a>)</pre><pre>]; } else { $ctx->{first_hdr} = $eml->header_obj; $ctx->{chash} = content_hash($eml) if $ctx->{smsg}; # reused MID @@ -1225,4 +1226,30 @@ sub ghost_index_entry { . '</pre>' . $end; } +# /$INBOX/$MSGID/d/ endpoint +sub diff_msg { + my ($ctx) = @_; + require PublicInbox::MailDiff; + my $ibx = $ctx->{ibx}; + my $over = $ibx->over or return no_over_html($ctx); + my ($id, $prev); + my $md = bless { ctx => $ctx }, 'PublicInbox::MailDiff'; + my $next_arg = $md->{next_arg} = [ $ctx->{mid}, \$id, \$prev ]; + my $smsg = $md->{smsg} = $over->next_by_mid(@$next_arg) or + return; # undef == 404 + $ctx->{-t_max} = $smsg->{ts}; + $ctx->{-upfx} = '../../'; + $ctx->{-apfx} = '//'; # fail on to_attr() + $ctx->{-linkify} = PublicInbox::Linkify->new; + my $mid = ascii_html($smsg->{mid}); + $ctx->{-title_html} = "diff for duplicates of <$mid>"; + PublicInbox::WwwStream::html_init($ctx); + print { $ctx->{zfh} } '<pre>diff for duplicates of <<a href="../">', + $mid, "</a>>\n\n"; + sub { + $ctx->attach($_[0]->([200, delete $ctx->{-res_hdr}])); + $md->begin_mail_diff; + }; +} + 1; |