about summary refs log tree commit homepage
path: root/lib/PublicInbox/Unsubscribe.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Unsubscribe.pm')
-rw-r--r--lib/PublicInbox/Unsubscribe.pm22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/PublicInbox/Unsubscribe.pm b/lib/PublicInbox/Unsubscribe.pm
index 945e7ae7..ddbd7a2e 100644
--- a/lib/PublicInbox/Unsubscribe.pm
+++ b/lib/PublicInbox/Unsubscribe.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Standalone PSGI app to handle HTTP(s) unsubscribe links generated
@@ -12,7 +12,8 @@ use warnings;
 use Crypt::CBC;
 use Plack::Util;
 use MIME::Base64 qw(decode_base64url);
-my $CODE_URL = 'https://public-inbox.org/public-inbox.git';
+my @CODE_URL = qw(http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git
+        https://public-inbox.org/public-inbox.git);
 my @CT_HTML = ('Content-Type', 'text/html; charset=UTF-8');
 
 sub new {
@@ -38,13 +39,15 @@ sub new {
         my $unsubscribe = $opt{unsubscribe} or
                 die "`unsubscribe' callback not given\n";
 
+        my $code_url = $opt{code_url} || \@CODE_URL;
+        $code_url = [ $code_url ] if ref($code_url) ne 'ARRAY';
         bless {
-                pi_config => $opt{pi_config}, # PublicInbox::Config
+                pi_cfg => $opt{pi_config}, # PublicInbox::Config
                 owner_email => $opt{owner_email},
                 cipher => $cipher,
                 unsubscribe => $unsubscribe,
                 contact => qq(<a\nhref="mailto:$e">$e</a>),
-                code_url => $opt{code_url} || $CODE_URL,
+                code_url => $code_url,
                 confirm => $opt{confirm},
         }, $class;
 }
@@ -78,10 +81,7 @@ sub _user_list_addr {
         }
         my $user = eval { $self->{cipher}->decrypt(decode_base64url($u)) };
         if (!defined $user || index($user, '@') < 1) {
-                my $err = quotemeta($@);
-                my $errors = $env->{'psgi.errors'};
-                $errors->print("error decrypting: $u\n");
-                $errors->print("$_\n") for split("\n", $err);
+                warn "error decrypting: $u: ", ($@ ? quotemeta($@) : ());
                 $u = Plack::Util::encode_html($u);
                 return r($self, 400, 'Bad request', "Failed to decrypt: $u");
         }
@@ -138,7 +138,7 @@ sub r {
                 "<html><head><title>$title</title></head><body><pre>".
                 join("\n", "<b>$title</b>\n", @body) . '</pre><hr>'.
                 "<pre>This page is available under AGPL-3.0+\n" .
-                "git clone $self->{code_url}\n" .
+                join('', map { "git clone $_\n" } @{$self->{code_url}}) .
                 qq(Email $self->{contact} if you have any questions).
                 '</pre></body></html>'
         ] ];
@@ -149,9 +149,9 @@ sub archive_info {
         my $archive_url = $self->{archive_urls}->{$list_addr};
 
         unless ($archive_url) {
-                if (my $config = $self->{pi_config}) {
+                if (my $cfg = $self->{pi_cfg}) {
                         # PublicInbox::Config::lookup
-                        my $ibx = $config->lookup($list_addr);
+                        my $ibx = $cfg->lookup($list_addr);
                         # PublicInbox::Inbox::base_url
                         $archive_url = $ibx->base_url if $ibx;
                 }