feat: detect and persist Telegram Premium status after authentication

After TDLib login completes, calls getMe() to detect isPremium, persists
it to DB via updateAccountPremiumStatus, and returns { client, isPremium }
from createTdlibClient. All callers updated to destructure accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-02 23:02:46 +02:00
parent f454303352
commit 436a576085
7 changed files with 38 additions and 13 deletions

View File

@@ -73,10 +73,10 @@ export async function authenticateAccount(
let client: Client | undefined;
try {
client = await createTdlibClient({
client = (await createTdlibClient({
id: account.id,
phone: account.phone,
});
})).client;
aLog.info("Authentication successful");
// Auto-fetch channels and create a fetch request result
@@ -131,7 +131,7 @@ export async function processFetchRequest(requestId: string): Promise<void> {
await updateFetchRequestStatus(requestId, "IN_PROGRESS");
aLog.info({ accountId: request.accountId }, "Processing fetch request");
const client = await createTdlibClient({
const { client } = await createTdlibClient({
id: request.account.id,
phone: request.account.phone,
});
@@ -336,10 +336,11 @@ export async function runWorkerForAccount(
currentStep: "connecting",
});
const client = await createTdlibClient({
const { client, isPremium } = await createTdlibClient({
id: account.id,
phone: account.phone,
});
void isPremium; // will be used in Task 6 for upload limits
// Load all chats into TDLib's local cache using loadChats (the recommended API).
// Without this, getChat/searchChatMessages fail with "Chat not found".