+sub redirect ($$) {
+ my ($code, $url) = @_;
+ [ $code,
+ [ Location => $url, 'Content-Type' => 'text/plain' ],
+ [ "Redirecting to $url\n" ] ]
+}
+
+sub try_inbox {
+ my ($ibx, $arg) = @_;
+ return if scalar(@$arg) > 1;
+
+ # do not pass $env since HTTP_HOST may differ
+ my $url = $ibx->base_url or return;
+
+ my ($mid) = @$arg;
+ eval { $ibx->mm->num_for($mid) } or return;
+
+ # 302 since the same message may show up on
+ # multiple inboxes and inboxes can be added/reordered
+ $arg->[1] = redirect(302, $url .= mid_escape($mid) . '/');
+}
+