1
0
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:
Anton Afanasyeu
2026-08-12 14:08:17 +02:00
parent dc3830dc6b
commit 6a58eb716d
13 changed files with 416 additions and 10 deletions

View File

@@ -14,6 +14,17 @@ require_once dirname(__DIR__, 4) . '/platform/shared_session.php';
platform_start_session('ac_crash_sess', '/app/androidcast_project');
$composedSrc = dirname(__DIR__, 2) . '/src';
if (is_file($composedSrc . '/AuthRemember.php')) {
require_once $composedSrc . '/Database.php';
require_once $composedSrc . '/Rbac.php';
require_once $composedSrc . '/Auth.php';
require_once $composedSrc . '/AuthRemember.php';
require_once $composedSrc . '/AuthEmailSchema.php';
require_once $composedSrc . '/AuthFactors.php';
AuthRemember::tryRestore();
}
$user = $_SESSION['user'] ?? null;
if (empty($user['id'])) {

View File

@@ -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: