admin.nomadro.com gets sidebar L1/L2 social ops (paginated lists + entity detail); API adds soft-delete archives/stats and shared nomadro_pb for social/coffee/notify/work. Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
"""PocketBase connection for Nomadro verticals.
|
|
|
|
`.com` (US) and `.cn` / hackrobot are **independent**. Never hardcode
|
|
China-side hosts as the default for the .com stack.
|
|
|
|
Resolution order:
|
|
1. PB_INTERNAL_URL / POCKETBASE_INTERNAL_URL (same-machine / loopback)
|
|
2. PB_URL / POCKETBASE_URL (explicit env)
|
|
3. http://127.0.0.1:8090 (US VPS / local sibling PB)
|
|
|
|
China / hackrobot PB only via explicit env on that deploy — not in code defaults.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
# Same-box default (US VPS or local). Do NOT point at hackrobot.cn.
|
|
DEFAULT_PB_URL = "http://127.0.0.1:8090"
|
|
|
|
|
|
def resolve_pb_url() -> str:
|
|
internal = (
|
|
os.getenv("PB_INTERNAL_URL") or os.getenv("POCKETBASE_INTERNAL_URL") or ""
|
|
).strip()
|
|
explicit = (os.getenv("PB_URL") or os.getenv("POCKETBASE_URL") or "").strip()
|
|
if internal:
|
|
return internal.rstrip("/")
|
|
if explicit:
|
|
return explicit.rstrip("/")
|
|
return DEFAULT_PB_URL
|
|
|
|
|
|
def resolve_pb_admin() -> tuple[str, str]:
|
|
email = (
|
|
os.getenv("PB_ADMIN_EMAIL")
|
|
or os.getenv("POCKETBASE_EMAIL")
|
|
or ""
|
|
).strip()
|
|
password = (
|
|
os.getenv("PB_ADMIN_PASSWORD")
|
|
or os.getenv("POCKETBASE_PASSWORD")
|
|
or ""
|
|
).strip()
|
|
return email, password
|
|
|
|
|
|
PB_URL = resolve_pb_url()
|
|
PB_ADMIN_EMAIL, PB_ADMIN_PASSWORD = resolve_pb_admin()
|