Update copy to post-July-2026 reality and notify on signups
All checks were successful
Build and Deploy PunktFri / build-and-deploy (push) Successful in 1m20s
All checks were successful
Build and Deploy PunktFri / build-and-deploy (push) Successful in 1m20s
- Rewrite copy from "this will happen" to "this has happened": direct registration closed 1 July 2026, transition ends 30 June 2028 - Fix timeline (30 June 2028, not 1 July), update FAQ + JSON-LD, add FAQ on registering new domains now - Send signup notification mail to henrik@i80.dk via smtp.i80.dk, with credentials from Consul KV - Fix CI health check URL (punktfri.dk) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
48
app.py
48
app.py
@@ -1,6 +1,9 @@
|
||||
import os
|
||||
import logging
|
||||
import smtplib
|
||||
import sqlite3
|
||||
import threading
|
||||
from email.message import EmailMessage
|
||||
from functools import wraps
|
||||
|
||||
from flask import Flask, render_template, request, redirect, url_for, g, Response, send_from_directory
|
||||
@@ -10,6 +13,12 @@ LOG_FILE = os.environ.get("LOG_FILE", "signups.log")
|
||||
ADMIN_USER = os.environ.get("ADMIN_USER", "admin")
|
||||
ADMIN_PASS = os.environ.get("ADMIN_PASS", "punktfri2024")
|
||||
PORT = int(os.environ.get("PORT", 5000))
|
||||
NOTIFY_EMAIL = os.environ.get("NOTIFY_EMAIL", "henrik@i80.dk")
|
||||
SMTP_HOST = os.environ.get("SMTP_HOST", "")
|
||||
SMTP_PORT = int(os.environ.get("SMTP_PORT", 587))
|
||||
SMTP_USER = os.environ.get("SMTP_USER", "")
|
||||
SMTP_PASS = os.environ.get("SMTP_PASS", "")
|
||||
SMTP_FROM = os.environ.get("SMTP_FROM", "") or SMTP_USER
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@@ -20,6 +29,41 @@ _fh.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
|
||||
signup_logger.addHandler(_fh)
|
||||
|
||||
|
||||
def build_notification(navn, email, domaener, egne_ns, kommentar):
|
||||
msg = EmailMessage()
|
||||
msg["Subject"] = f"PunktFri: ny tilmelding fra {navn}"
|
||||
msg["From"] = SMTP_FROM
|
||||
msg["To"] = NOTIFY_EMAIL
|
||||
msg["Reply-To"] = email
|
||||
msg.set_content(
|
||||
f"Ny interessetilkendegivelse på punktfri.dk\n\n"
|
||||
f"Navn: {navn}\n"
|
||||
f"E-mail: {email}\n"
|
||||
f"Antal domæner: {domaener}\n"
|
||||
f"Egne navneservere: {egne_ns}\n"
|
||||
f"Kommentar:\n{kommentar or '(ingen)'}\n"
|
||||
)
|
||||
return msg
|
||||
|
||||
|
||||
def _send(msg):
|
||||
try:
|
||||
with smtplib.SMTP(SMTP_HOST, SMTP_PORT, timeout=15) as s:
|
||||
s.starttls()
|
||||
if SMTP_USER:
|
||||
s.login(SMTP_USER, SMTP_PASS)
|
||||
s.send_message(msg)
|
||||
except Exception:
|
||||
app.logger.exception("Kunne ikke sende tilmeldingsnotifikation til %s", NOTIFY_EMAIL)
|
||||
|
||||
|
||||
def notify_signup(**fields):
|
||||
if not SMTP_HOST:
|
||||
app.logger.warning("SMTP_HOST ikke sat — springer notifikation over")
|
||||
return
|
||||
threading.Thread(target=_send, args=(build_notification(**fields),), daemon=True).start()
|
||||
|
||||
|
||||
def get_db():
|
||||
db = getattr(g, "_database", None)
|
||||
if db is None:
|
||||
@@ -105,6 +149,10 @@ def index():
|
||||
f"SIGNUP navn={navn!r} email={email!r} domaener={domaener} "
|
||||
f"egne_ns={egne_ns} kommentar={kommentar!r}"
|
||||
)
|
||||
notify_signup(
|
||||
navn=navn, email=email, domaener=domaener,
|
||||
egne_ns=egne_ns, kommentar=kommentar,
|
||||
)
|
||||
return redirect(url_for("tak"))
|
||||
|
||||
return render_template("index.html", error=error)
|
||||
|
||||
Reference in New Issue
Block a user