Add subscription link field to user model
- Add subscription_link column to users table (nullable, unique) - Add SUBSCRIPTION_URL to config settings - Update user creation to include subscription link from Remnawave - Add support subscription ticket creation with formatted message - Add "update link" button to main menu - Refactor support subscription formatting to include user details
This commit is contained in:
@@ -4,9 +4,10 @@ from aiogram.types import CallbackQuery, Message
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from misc.utils import format_subscription_link
|
||||
from schemas.di import DependenciesDTO
|
||||
from keyboards.client import main_menu
|
||||
from texts import build_main_menu_text
|
||||
from keyboards.client import main_menu, return_to_menu
|
||||
from texts import GENERAL_PROCESSING, build_main_menu_text, FAQ_TEXT
|
||||
|
||||
router = Router()
|
||||
|
||||
@@ -27,9 +28,14 @@ async def fetch_referal(
|
||||
return
|
||||
|
||||
referal = data[0]
|
||||
await deps.user_service.add_user(session, user_id=msg.from_user.id, referal=referal)
|
||||
user = await deps.user_service.add_user(
|
||||
session, user_id=msg.from_user.id, referal=referal, rw_sdk=deps.rw_sdk
|
||||
)
|
||||
|
||||
await msg.reply(build_main_menu_text(), reply_markup=main_menu)
|
||||
await msg.reply(
|
||||
build_main_menu_text(format_subscription_link(user.subscription_link)),
|
||||
reply_markup=main_menu,
|
||||
)
|
||||
|
||||
|
||||
@router.message(Command(commands=["start", "cancel"]))
|
||||
@@ -42,13 +48,48 @@ async def standard_start(
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
await deps.user_service.add_user(session, user_id=msg.from_user.id)
|
||||
user = await deps.user_service.add_user(
|
||||
session, user_id=msg.from_user.id, rw_sdk=deps.rw_sdk
|
||||
)
|
||||
|
||||
await msg.reply(build_main_menu_text(), reply_markup=main_menu)
|
||||
await msg.reply(
|
||||
build_main_menu_text(format_subscription_link(user.subscription_link)),
|
||||
reply_markup=main_menu,
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == "menu:main")
|
||||
async def main_menu_cb(cb: CallbackQuery, state: FSMContext):
|
||||
async def main_menu_cb(
|
||||
cb: CallbackQuery, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
await cb.message.edit_text(build_main_menu_text(), reply_markup=main_menu)
|
||||
user = await deps.user_repository.get_user_by_id(session, cb.from_user.id)
|
||||
await cb.message.edit_text(
|
||||
build_main_menu_text(format_subscription_link(user.subscription_link)),
|
||||
reply_markup=main_menu,
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == "update_link")
|
||||
async def update_link(
|
||||
cb: CallbackQuery, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
await cb.message.edit_text(GENERAL_PROCESSING)
|
||||
|
||||
user = await deps.user_service.update_user_link(
|
||||
session, cb.from_user.id, deps.rw_sdk
|
||||
)
|
||||
await cb.answer("✅")
|
||||
await cb.message.edit_text(
|
||||
build_main_menu_text(format_subscription_link(user.subscription_link)),
|
||||
reply_markup=main_menu,
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(F.data == "faq")
|
||||
async def faq(cb: CallbackQuery, state: FSMContext):
|
||||
await state.clear()
|
||||
|
||||
await cb.message.edit_text(FAQ_TEXT, reply_markup=return_to_menu)
|
||||
|
||||
Reference in New Issue
Block a user