mirror of
https://github.com/BEDOLAGA-DEV/remnawave-bedolaga-telegram-bot.git
synced 2026-03-04 12:55:10 +00:00
Revert "Add localization and account data to mini app"
This commit is contained in:
@@ -3,13 +3,12 @@ from __future__ import annotations
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from sqlalchemy import select
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.config import settings
|
||||
from app.database.crud.user import get_user_by_telegram_id
|
||||
from app.database.models import Subscription, Transaction
|
||||
from app.database.models import Subscription
|
||||
from app.services.subscription_service import SubscriptionService
|
||||
from app.utils.telegram_webapp import (
|
||||
TelegramWebAppAuthError,
|
||||
@@ -196,32 +195,8 @@ async def get_subscription_details(
|
||||
traffic_limit_label=_format_limit_label(traffic_limit),
|
||||
lifetime_used_traffic_gb=lifetime_used,
|
||||
has_active_subscription=status_actual in {"active", "trial"},
|
||||
balance_kopeks=user.balance_kopeks,
|
||||
balance_rubles=round((user.balance_kopeks or 0) / 100, 2),
|
||||
)
|
||||
|
||||
transactions_result = await db.execute(
|
||||
select(Transaction)
|
||||
.where(Transaction.user_id == user.id)
|
||||
.order_by(Transaction.created_at.desc())
|
||||
.limit(20)
|
||||
)
|
||||
transactions = transactions_result.scalars().all()
|
||||
|
||||
serialized_transactions = [
|
||||
{
|
||||
"id": transaction.id,
|
||||
"type": transaction.type,
|
||||
"amount_kopeks": transaction.amount_kopeks,
|
||||
"amount_rubles": round(transaction.amount_kopeks / 100, 2),
|
||||
"description": transaction.description,
|
||||
"is_completed": transaction.is_completed,
|
||||
"created_at": transaction.created_at,
|
||||
"payment_method": transaction.payment_method,
|
||||
}
|
||||
for transaction in transactions
|
||||
]
|
||||
|
||||
return MiniAppSubscriptionResponse(
|
||||
subscription_id=subscription.id,
|
||||
remnawave_short_uuid=subscription.remnawave_short_uuid,
|
||||
@@ -234,9 +209,5 @@ async def get_subscription_details(
|
||||
happ=links_payload.get("happ"),
|
||||
happ_link=links_payload.get("happ_link"),
|
||||
happ_crypto_link=links_payload.get("happ_crypto_link"),
|
||||
happ_cryptolink_redirect_template=settings.get_happ_cryptolink_redirect_template(),
|
||||
transactions=serialized_transactions,
|
||||
balance_kopeks=user.balance_kopeks,
|
||||
balance_rubles=round((user.balance_kopeks or 0) / 100, 2),
|
||||
)
|
||||
|
||||
|
||||
@@ -29,19 +29,6 @@ class MiniAppSubscriptionUser(BaseModel):
|
||||
traffic_limit_label: str
|
||||
lifetime_used_traffic_gb: float = 0.0
|
||||
has_active_subscription: bool = False
|
||||
balance_kopeks: int = 0
|
||||
balance_rubles: float = 0.0
|
||||
|
||||
|
||||
class MiniAppTransaction(BaseModel):
|
||||
id: int
|
||||
type: str
|
||||
amount_kopeks: int
|
||||
amount_rubles: float
|
||||
description: Optional[str] = None
|
||||
is_completed: bool = True
|
||||
created_at: datetime
|
||||
payment_method: Optional[str] = None
|
||||
|
||||
|
||||
class MiniAppSubscriptionResponse(BaseModel):
|
||||
@@ -57,10 +44,4 @@ class MiniAppSubscriptionResponse(BaseModel):
|
||||
happ: Optional[Dict[str, Any]] = None
|
||||
happ_link: Optional[str] = None
|
||||
happ_crypto_link: Optional[str] = None
|
||||
happ_cryptolink_redirect_template: Optional[str] = None
|
||||
transactions: List[MiniAppTransaction] = Field(default_factory=list)
|
||||
balance_kopeks: int = 0
|
||||
balance_rubles: float = 0.0
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user