fix: prefer dedicated telegram pricing group
This commit is contained in:
@@ -89,12 +89,15 @@ def verify_telegram_login_payload(
|
|||||||
class TelegramGroupPricing:
|
class TelegramGroupPricing:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.bot_token = str(os.getenv("TELEGRAM_BOT_TOKEN") or "").strip()
|
self.bot_token = str(os.getenv("TELEGRAM_BOT_TOKEN") or "").strip()
|
||||||
self.group_chat_ids = parse_telegram_chat_ids(
|
dedicated_group_chat_ids = parse_telegram_chat_ids(
|
||||||
os.getenv("POLYWEATHER_TELEGRAM_GROUP_ID"),
|
os.getenv("POLYWEATHER_TELEGRAM_GROUP_ID"),
|
||||||
os.getenv("POLYWEATHER_TELEGRAM_GROUP_IDS"),
|
os.getenv("POLYWEATHER_TELEGRAM_GROUP_IDS"),
|
||||||
|
)
|
||||||
|
fallback_group_chat_ids = parse_telegram_chat_ids(
|
||||||
os.getenv("TELEGRAM_CHAT_IDS"),
|
os.getenv("TELEGRAM_CHAT_IDS"),
|
||||||
os.getenv("TELEGRAM_CHAT_ID"),
|
os.getenv("TELEGRAM_CHAT_ID"),
|
||||||
)
|
)
|
||||||
|
self.group_chat_ids = dedicated_group_chat_ids or fallback_group_chat_ids
|
||||||
self.member_price = _decimal_env("POLYWEATHER_GROUP_MEMBER_PRICE_USDC", "5")
|
self.member_price = _decimal_env("POLYWEATHER_GROUP_MEMBER_PRICE_USDC", "5")
|
||||||
self.public_price = _decimal_env("POLYWEATHER_PUBLIC_PRICE_USDC", "10")
|
self.public_price = _decimal_env("POLYWEATHER_PUBLIC_PRICE_USDC", "10")
|
||||||
self.timeout_sec = max(
|
self.timeout_sec = max(
|
||||||
|
|||||||
@@ -104,6 +104,16 @@ def test_group_pricing_treats_left_status_as_public_price(monkeypatch):
|
|||||||
assert result["telegram_status"] == "left"
|
assert result["telegram_status"] == "left"
|
||||||
|
|
||||||
|
|
||||||
|
def test_dedicated_group_id_overrides_legacy_chat_ids(monkeypatch):
|
||||||
|
monkeypatch.setenv("TELEGRAM_BOT_TOKEN", "bot-token")
|
||||||
|
monkeypatch.setenv("POLYWEATHER_TELEGRAM_GROUP_ID", "-100internal")
|
||||||
|
monkeypatch.setenv("TELEGRAM_CHAT_IDS", "-100old")
|
||||||
|
|
||||||
|
pricing = TelegramGroupPricing()
|
||||||
|
|
||||||
|
assert pricing.group_chat_ids == ["-100internal"]
|
||||||
|
|
||||||
|
|
||||||
def test_payment_plan_uses_linked_telegram_group_price(monkeypatch, tmp_path):
|
def test_payment_plan_uses_linked_telegram_group_price(monkeypatch, tmp_path):
|
||||||
monkeypatch.setenv("POLYWEATHER_PAYMENT_ENABLED", "true")
|
monkeypatch.setenv("POLYWEATHER_PAYMENT_ENABLED", "true")
|
||||||
monkeypatch.setenv("SUPABASE_URL", "https://example.supabase.co")
|
monkeypatch.setenv("SUPABASE_URL", "https://example.supabase.co")
|
||||||
|
|||||||
Reference in New Issue
Block a user