fix: traffic reset / coupon menu display
This commit is contained in:
@@ -828,6 +828,7 @@ async def handle_days_input(message: Message, state: FSMContext, session: AsyncS
|
||||
new_expiry_time=new_expiry,
|
||||
total_gb=total_gb,
|
||||
session=session,
|
||||
reset_traffic=False,
|
||||
)
|
||||
await update_key_expiry(session, key.client_id, new_expiry)
|
||||
|
||||
|
||||
@@ -1203,7 +1203,8 @@ async def change_expiry_time(
|
||||
new_expiry_time=expiry_time,
|
||||
total_gb=traffic_limit,
|
||||
session=session,
|
||||
hwid_device_limit=device_limit
|
||||
hwid_device_limit=device_limit,
|
||||
reset_traffic=False,
|
||||
)
|
||||
|
||||
await update_key_expiry(session, client_id, expiry_time)
|
||||
|
||||
+2
-1
@@ -243,8 +243,9 @@ async def handle_key_extension(
|
||||
client_id=client_id,
|
||||
new_expiry_time=new_expiry,
|
||||
total_gb=total_gb,
|
||||
session=session,
|
||||
hwid_device_limit=device_limit,
|
||||
session=session
|
||||
reset_traffic=False,
|
||||
)
|
||||
await update_key_expiry(session, client_id, new_expiry)
|
||||
await update_coupon_usage_count(session, coupon.id)
|
||||
|
||||
@@ -142,6 +142,7 @@ async def process_callback_unfreeze_subscription_confirm(
|
||||
total_gb=total_gb,
|
||||
session=session,
|
||||
hwid_device_limit=hwid_limit,
|
||||
reset_traffic=False,
|
||||
)
|
||||
|
||||
text_ok = SUBSCRIPTION_UNFROZEN_MSG
|
||||
|
||||
@@ -287,6 +287,7 @@ async def renew_key_in_cluster(
|
||||
total_gb: int,
|
||||
session: AsyncSession,
|
||||
hwid_device_limit: int = None,
|
||||
reset_traffic: bool = True,
|
||||
):
|
||||
try:
|
||||
servers = await get_servers(session)
|
||||
@@ -368,7 +369,8 @@ async def renew_key_in_cluster(
|
||||
)
|
||||
if updated:
|
||||
logger.info(f"Подписка Remnawave {client_id} успешно продлена")
|
||||
await remna.reset_user_traffic(client_id)
|
||||
if reset_traffic:
|
||||
await remna.reset_user_traffic(client_id)
|
||||
else:
|
||||
logger.warning(
|
||||
f"Не удалось продлить подписку Remnawave {client_id}"
|
||||
|
||||
+14
-1
@@ -19,7 +19,13 @@ from config import (
|
||||
SHOW_START_MENU_ONCE,
|
||||
SUPPORT_CHAT_URL,
|
||||
)
|
||||
from database import add_user, check_user_exists, get_trial, get_key_count
|
||||
from database import (
|
||||
add_user,
|
||||
check_user_exists,
|
||||
get_trial,
|
||||
get_key_count,
|
||||
get_coupon_by_code,
|
||||
)
|
||||
from database.models import TrackingSource, User
|
||||
from handlers.buttons import (
|
||||
ABOUT_VPN,
|
||||
@@ -175,6 +181,10 @@ async def process_start_logic(
|
||||
if "coupons" in part:
|
||||
logger.info(f"Обнаружена ссылка на купон: {part}")
|
||||
coupon_code = part.split("coupons")[1].strip("_")
|
||||
coupon = await get_coupon_by_code(session, coupon_code)
|
||||
if not coupon:
|
||||
continue
|
||||
|
||||
await activate_coupon(
|
||||
message,
|
||||
state,
|
||||
@@ -183,6 +193,9 @@ async def process_start_logic(
|
||||
admin=admin,
|
||||
user_data=user_data,
|
||||
)
|
||||
|
||||
if coupon.days:
|
||||
return
|
||||
continue
|
||||
|
||||
if "gift" in part:
|
||||
|
||||
Reference in New Issue
Block a user