From d465ccb3ac3a86add6313d6bb61d53d0fe143d5e Mon Sep 17 00:00:00 2001 From: c0mrade Date: Fri, 10 Apr 2026 10:32:39 +0300 Subject: [PATCH] fix: resync RemnaWave after Telegram account linking (BUG-1) --- app/cabinet/routes/account_linking.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/cabinet/routes/account_linking.py b/app/cabinet/routes/account_linking.py index 3424161f..0738f69a 100644 --- a/app/cabinet/routes/account_linking.py +++ b/app/cabinet/routes/account_linking.py @@ -622,6 +622,24 @@ async def link_telegram( telegram_id=telegram_id, user_id=user.id, ) + # BUG-1 fix: Sync all subscriptions with RemnaWave panel so it knows the new telegram_id + try: + from app.services.remnawave_resync_service import resync_user_subscriptions_with_panel + + resync_result = await resync_user_subscriptions_with_panel(db, user) + logger.info( + 'Post-TG-link resync completed', + user_id=user.id, + telegram_id=telegram_id, + synced=resync_result['synced'], + failed=resync_result['failed'], + ) + except Exception as resync_error: + logger.error( + 'Post-TG-link resync failed (non-fatal)', + user_id=user.id, + error=resync_error, + ) return LinkCallbackResponse(success=True, message='linked')