mirror of
git://f0xx.org/ac/ac-deploy
synced 2026-08-12 18:12:19 +03:00
Lab: remember-me, Grafana proxy fix, builder cache dirs, branded QR alerts.
Grafana auth restore + nginx proxy_cookie_path; alert-notifier branded QR; prepare-be-builder-dirs shared ccache/gradle; bump ac-scripts for Docker DLC maintenance. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -99,13 +99,25 @@ def shorten(url: str) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def make_qr_png(url: str) -> bytes:
|
||||
def make_qr_png(url: str, slug: str = '') -> bytes:
|
||||
"""
|
||||
Generate a QR code PNG for *url* using the system qrencode binary.
|
||||
Returns raw PNG bytes. Raises on failure.
|
||||
Branded QR PNG: prefer URL shortener /api/v1/qr/{slug}.png (logo overlay),
|
||||
fall back to local qrencode.
|
||||
"""
|
||||
if slug:
|
||||
try:
|
||||
req = urllib.request.Request(
|
||||
f'{SHORTENER_INTERNAL}/api/v1/qr/{slug}.png?size=256',
|
||||
headers={'Host': SHORTENER_HOST_HDR},
|
||||
)
|
||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||
data = resp.read()
|
||||
if len(data) > 100:
|
||||
return data
|
||||
except Exception as exc:
|
||||
log.warning('branded QR fetch failed (%s), falling back to qrencode', exc)
|
||||
result = subprocess.run(
|
||||
['qrencode', '-t', 'PNG', '-o', '-', '-s', '6', '--', url],
|
||||
['qrencode', '-l', 'H', '-t', 'PNG', '-o', '-', '-s', '6', '--', url],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
@@ -287,8 +299,7 @@ class WebhookHandler(http.server.BaseHTTPRequestHandler):
|
||||
# ── shorten & QR ────────────────────────────────────────────────────
|
||||
try:
|
||||
short = shorten(ext_url)
|
||||
# QR image encodes short_url?src=qr — generated locally via qrencode
|
||||
qr_png = make_qr_png(short['qr_url'])
|
||||
qr_png = make_qr_png(short['qr_url'], short.get('slug', ''))
|
||||
log.info('shortened %s → %s qr_url=%s (%d B)',
|
||||
ext_url, short['short_url'], short['qr_url'], len(qr_png))
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user