nomadro/apps/api/services/social_svc/config.py
Eric ffa456afdf Ship social join profile + SeaweedFS avatars, notify/coffee, and .com audience stack.
Pay-then-profile join desk with live card, S3 upload fallback, hydration-safe drafts; document on test9 README.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-04 02:25:05 +08:00

74 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from __future__ import annotations
import os
from pathlib import Path
# 默认写在仓库 data/social,与 PocketBase / community 目录分离
_ROOT = Path(__file__).resolve().parents[4] # nomadro/
_DEFAULT_DB = _ROOT / "data" / "social" / "social.db"
SOCIAL_DB_PATH = Path(os.getenv("SOCIAL_DB_PATH", str(_DEFAULT_DB))).resolve()
SOCIAL_UPLOAD_DIR = Path(
os.getenv("SOCIAL_UPLOAD_DIR", str(SOCIAL_DB_PATH.parent / "uploads"))
).resolve()
SOCIAL_UPLOAD_MAX_BYTES = int(os.getenv("SOCIAL_UPLOAD_MAX_BYTES", str(25 * 1024 * 1024)))
SOCIAL_ENABLED = os.getenv("SOCIAL_ENABLED", "true").lower() in {"1", "true", "yes", "on"}
# Centrifugo(实时层;缺省关,部署后用环境变量打开)
CENTRIFUGO_ENABLED = os.getenv("CENTRIFUGO_ENABLED", "false").lower() in {"1", "true", "yes", "on"}
CENTRIFUGO_API_URL = os.getenv("CENTRIFUGO_API_URL", "http://127.0.0.1:8008/api").rstrip("/")
CENTRIFUGO_API_KEY = os.getenv("CENTRIFUGO_API_KEY", "")
CENTRIFUGO_TOKEN_SECRET = os.getenv("CENTRIFUGO_TOKEN_SECRET", "")
# 浏览器 WebSocket(经 nginx 反代,与门户同域)
CENTRIFUGO_WS_URL = os.getenv(
"CENTRIFUGO_WS_URL",
"wss://nomadro.cn/rt/connection/websocket",
)
# 原生音视频厅(SRS RTMP 推 / HTTP-FLV 拉)— 微信 LivePusher/LivePlayer
LIVE_RTMP_PUSH_BASE = os.getenv(
"LIVE_RTMP_PUSH_BASE",
"rtmp://82.157.112.245/live",
)
LIVE_HTTP_PLAY_BASE = os.getenv(
"LIVE_HTTP_PLAY_BASE",
"https://nomadro.cn/live",
)
LIVE_STREAM_SECRET = os.getenv(
"LIVE_STREAM_SECRET",
os.getenv("CENTRIFUGO_TOKEN_SECRET", "nomadro-live-dev-secret"),
)
LIVE_MAX_PEERS = int(os.getenv("LIVE_MAX_PEERS", "6"))
LIVE_PEER_TTL_SEC = int(os.getenv("LIVE_PEER_TTL_SEC", "45"))
# Geo discovery (MapLibre / Photon / H3 + PocketBase trips)
PHOTON_BASE_URL = os.getenv(
"PHOTON_BASE_URL",
"https://photon.komoot.io",
).rstrip("/")
PHOTON_TIMEOUT_SEC = float(os.getenv("PHOTON_TIMEOUT_SEC", "6"))
H3_CITY_RES = int(os.getenv("H3_CITY_RES", "4"))
H3_NEAR_RES = int(os.getenv("H3_NEAR_RES", "7"))
# PocketBase for social_trips (same env family as pay_svc)
_pb_internal = os.getenv("PB_INTERNAL_URL") or os.getenv("POCKETBASE_INTERNAL_URL")
_pb_explicit = os.getenv("PB_URL") or os.getenv("POCKETBASE_URL")
if _pb_internal:
PB_URL = _pb_internal.rstrip("/")
elif _pb_explicit:
PB_URL = _pb_explicit.rstrip("/")
else:
PB_URL = "http://127.0.0.1:8090"
PB_ADMIN_EMAIL = (
os.getenv("PB_ADMIN_EMAIL") or os.getenv("POCKETBASE_EMAIL") or ""
)
PB_ADMIN_PASSWORD = (
os.getenv("PB_ADMIN_PASSWORD") or os.getenv("POCKETBASE_PASSWORD") or ""
)
SOCIAL_TRIPS_COLLECTION = os.getenv("SOCIAL_TRIPS_COLLECTION", "social_trips")
SOCIAL_GEO_USE_PB = os.getenv("SOCIAL_GEO_USE_PB", "true").lower() in {
"1",
"true",
"yes",
"on",
}