# private functions below
-sub r404 { r(404, 'Not Found') }
+sub r404 {
+ my ($ctx) = @_;
+ if ($ctx && $ctx->{mid}) {
+ require PublicInbox::ExtMsg;
+ return PublicInbox::ExtMsg::ext_msg($ctx);
+ }
+ r(404, 'Not Found');
+}
# simple response for errors
sub r { [ $_[0], ['Content-Type' => 'text/plain'], [ join(' ', @_, "\n") ] ] }
sub invalid_list_mid {
my ($ctx, $listname, $mid) = @_;
my $ret = invalid_list($ctx, $listname, $mid);
- $ctx->{mid} = uri_unescape($mid) unless $ret;
- $ret;
+ return $ret if $ret;
+
+ $ctx->{mid} = $mid = uri_unescape($mid);
+ if ($mid =~ /\A[a-f0-9]{40}\z/) {
+ if ($mid = mid2blob($ctx)) {
+ require Email::Simple;
+ use PublicInbox::MID qw/mid_clean/;
+ $mid = Email::Simple->new($mid);
+ $ctx->{mid} = mid_clean($mid->header('Message-ID'));
+ }
+ }
+ undef;
}
# /$LISTNAME/new.atom -> Atom feed, includes replies
# /$LISTNAME/$MESSAGE_ID/raw -> raw mbox
sub get_mid_txt {
my ($ctx) = @_;
- my $x = mid2blob($ctx) or return r404();
+ my $x = mid2blob($ctx) or return r404($ctx);
require PublicInbox::Mbox;
PublicInbox::Mbox::emit1($x);
}
# /$LISTNAME/$MESSAGE_ID/ -> HTML content (short quotes)
sub get_mid_html {
my ($ctx) = @_;
- my $x = mid2blob($ctx) or return r404();
+ my $x = mid2blob($ctx) or return r404($ctx);
require PublicInbox::View;
my $foot = footer($ctx);
# /$LISTNAME/$MESSAGE_ID/f/ -> HTML content (fullquotes)
sub get_full_html {
my ($ctx) = @_;
- my $x = mid2blob($ctx) or return r404();
+ my $x = mid2blob($ctx) or return r404($ctx);
require PublicInbox::View;
my $foot = footer($ctx);