+
+# /$INBOX/$MESSAGE_ID/t.atom -> thread as Atom feed
+sub get_thread_atom {
+ my ($ctx) = @_;
+ searcher($ctx) or return need_search($ctx);
+ $ctx->{self_url} = $ctx->{cgi}->uri->as_string;
+ require PublicInbox::Feed;
+ PublicInbox::Feed::generate_thread_atom($ctx);
+}
+
+sub legacy_redirects {
+ my ($self, $ctx, $path_info) = @_;
+
+ # single-message pages
+ if ($path_info =~ m!$INBOX_RE/m/(\S+)/\z!o) {
+ r301($ctx, $1, $2);
+ } elsif ($path_info =~ m!$INBOX_RE/m/(\S+)/raw\z!o) {
+ r301($ctx, $1, $2, 'raw');
+
+ } elsif ($path_info =~ m!$INBOX_RE/f/(\S+)/\z!o) {
+ r301($ctx, $1, $2);
+
+ # thread display
+ } elsif ($path_info =~ m!$INBOX_RE/t/(\S+)/\z!o) {
+ r301($ctx, $1, $2, 't/#u');
+
+ } elsif ($path_info =~ m!$INBOX_RE/t/(\S+)/mbox(\.gz)?\z!o) {
+ r301($ctx, $1, $2, "t.mbox$3");
+
+ # even older legacy redirects
+ } elsif ($path_info =~ m!$INBOX_RE/m/(\S+)\.html\z!o) {
+ r301($ctx, $1, $2);
+
+ } elsif ($path_info =~ m!$INBOX_RE/t/(\S+)\.html\z!o) {
+ r301($ctx, $1, $2, 't/#u');
+
+ } elsif ($path_info =~ m!$INBOX_RE/f/(\S+)\.html\z!o) {
+ r301($ctx, $1, $2);
+
+ } elsif ($path_info =~ m!$INBOX_RE/(?:m|f)/(\S+)\.txt\z!o) {
+ r301($ctx, $1, $2, 'raw');
+
+ } elsif ($path_info =~ m!$INBOX_RE/t/(\S+)(\.mbox(?:\.gz)?)\z!o) {
+ r301($ctx, $1, $2, "t$3");
+
+ # legacy convenience redirects, order still matters
+ } elsif ($path_info =~ m!$INBOX_RE/m/(\S+)\z!o) {
+ r301($ctx, $1, $2);
+ } elsif ($path_info =~ m!$INBOX_RE/t/(\S+)\z!o) {
+ r301($ctx, $1, $2, 't/#u');
+ } elsif ($path_info =~ m!$INBOX_RE/f/(\S+)\z!o) {
+ r301($ctx, $1, $2);
+
+ # some Message-IDs have slashes in them and the HTTP server
+ # may try to be clever and unescape them :<
+ } elsif ($path_info =~ m!$INBOX_RE/(\S+/\S+)/$END_RE\z!o) {
+ msg_page($self, $ctx, $1, $2, $3);
+
+ # in case people leave off the trailing slash:
+ } elsif ($path_info =~ m!$INBOX_RE/(\S+/\S+)/(T|t)\z!o) {
+ r301($ctx, $1, $2, $3 eq 't' ? 't/#u' : $3);
+ } elsif ($path_info =~ m!$INBOX_RE/(\S+/\S+)/f\z!o) {
+ r301($ctx, $1, $2);
+ } else {
+ $self->news_www->call($ctx->{cgi}->{env});
+ }
+}
+
+sub r301 {
+ my ($ctx, $inbox, $mid, $suffix) = @_;
+ my $cgi = $ctx->{cgi};
+ my $obj = $ctx->{-inbox};
+ unless ($obj) {
+ my $r404 = invalid_inbox($ctx->{www}, $ctx, $inbox);
+ return $r404 if $r404;
+ $obj = $ctx->{-inbox};
+ }
+ my $url = $obj->base_url($cgi);
+ my $qs = $ctx->{env}->{QUERY_STRING};
+ $url .= (uri_escape_utf8($mid) . '/') if (defined $mid);
+ $url .= $suffix if (defined $suffix);
+ $url .= "?$qs" if $qs ne '';
+