move.sh exports with 0.19.3, rewrites and imports with 1.0, takes the sign-ups again through their form on a site only the host reaches, and holds the store to the export. What that site would have mailed is posted to sink.py and let go: left in the store, it goes out when gdo first dials. README.md has the order of the switch and what it waits for: no gdo or kron release dials a 1.0 site yet. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L5fbDjTQg4CJsNqEo7hhE7
28 lines
1.6 KiB
Python
28 lines
1.6 KiB
Python
# Takes what a 1.0 site posts from its outboxes (DHD_HOOKS) and lets each row go:
|
|
# sink.py <port> on 127.0.0.1; SIGUSR1 prints `count <mail rows so far>`, SIGTERM the sums.
|
|
# Nothing is delivered and nothing kept: it counts rows per outbox, and for
|
|
# mail how many addresses and which subjects. Never an address or a body.
|
|
import sys, json, hashlib, collections, http.server, signal
|
|
port=int(sys.argv[1]); rows=collections.Counter(); who=collections.defaultdict(set); subj=collections.Counter(); keys=collections.defaultdict(set)
|
|
class H(http.server.BaseHTTPRequestHandler):
|
|
def do_POST(s):
|
|
b=s.rfile.read(int(s.headers.get('Content-Length',0))); o=s.headers.get('Dhd-Outbox','?'); rows[o]+=1
|
|
try:
|
|
d=json.loads(b); keys[o].update(d.keys())
|
|
if o=='mail':
|
|
to=d.get('to'); to=to if isinstance(to,list) else [to]
|
|
for t in to: who[o].add(hashlib.sha256(str(t).encode()).hexdigest())
|
|
subj[str(d.get('subject'))[:60]]+=1
|
|
except Exception: pass
|
|
s.send_response(204); s.end_headers()
|
|
def log_message(s,*a): pass
|
|
def done(*a):
|
|
print(f'mail: {rows["mail"]} rows to {len(who["mail"])} different addresses; subjects {dict(subj)}')
|
|
for o,n in rows.items():
|
|
if o!='mail': print(f'{o}: {n} rows; fields {sorted(keys[o])}')
|
|
sys.stdout.flush(); sys.exit(0)
|
|
def count(*a): print('count',rows['mail']); sys.stdout.flush()
|
|
signal.signal(signal.SIGUSR1,count)
|
|
signal.signal(signal.SIGTERM,done); signal.signal(signal.SIGINT,done)
|
|
http.server.HTTPServer(('127.0.0.1',port),H).serve_forever()
|