user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
7b97e25322d8395aad6a3a777132e2476de64715 blob 2284 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
#!/usr/bin/perl -w
# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
# This should not require any other PublicInbox code, but may use
# PublicInbox::Config if ~/.public-inbox/config exists or
# PI_CONFIG is pointed to an appropriate location
use strict;
use Plack::Builder;
use PublicInbox::Unsubscribe;
my $app = PublicInbox::Unsubscribe->new(
	pi_config => eval { # optional, for pointing out archives
		require PublicInbox::Config;
		# uses ~/.public-inbox/config by default,
		# can override with PI_CONFIG or here since
		# I run this .psgi as the mlmmj user while the
		# public-inbox-mda code which actually writes to
		# the archives runs as a different user.
		PublicInbox::Config->new('/home/pi/.public-inbox/config')
	},
	# change if you fork
	code_url => 'https://public-inbox.org/public-inbox.git',
	owner_email => 'BOFH@example.com',
	confirm => 0,

	# First 8 bytes is for the key, next 8 bytes is for the IV
	# using Blowfish.  We want as short URLs as possible to avoid
	# copy+paste errors
	# umask 077 && dd if=/dev/urandom bs=16 count=1 of=.unsubscribe.key
	key_file => '/home/mlmmj/.unsubscribe.key',

	# this runs as whatever user has perms to run /usr/bin/mlmmj-unsub
	# users of other mailing lists.  Returns '' on success.
	unsubscribe => sub {
		my ($user_addr, $list_addr) = @_;

		# map list_addr to mlmmj spool, I use:
		# /home/mlmmj/spool/$LIST here
		my ($list, $domain) = split('@', $list_addr, 2);
		my $spool = "/home/mlmmj/spool/$list";

		return "Invalid list: $list" unless -d $spool;

		# -c to send a confirmation email, -s is important
		# in case a user is click-happy and clicks twice.
		my @cmd = (qw(/usr/bin/mlmmj-unsub -c -s),
				'-L', $spool, '-a', $user_addr);

		# we don't know which version they're subscribed to,
		# try both non-digest and digest
		my $normal = system(@cmd);
		my $digest = system(@cmd, '-d');

		# success if either succeeds:
		return '' if ($normal == 0 || $digest == 0);

		# missing executable or FS error,
		# otherwise -s always succeeds, right?
		return 'Unknown error, contact admin';
	},
);

builder {
	mount '/u' => builder {
		eval { enable 'ReverseProxy' }; # optional
		enable 'Head';
		sub { $app->call(@_) };
	};
};
debug log:

solving 7b97e2532 ...
found 7b97e2532 in public-inbox.git

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git