mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
- Add invokeWithTimeout wrapper for TDLib API calls (2min timeout per call) - Add stuck detection to getChannelMessages: break if from_message_id doesn't advance - Add stuck detection to getTopicMessages: same protection for topic scanning - Add stuck detection to getForumTopicList: break if pagination offsets don't advance - Add max page limit (5000) to all scanning loops to prevent infinite pagination - Add mutex wait timeout (30min) to prevent indefinite blocking when holder hangs - Add cycle timeout (4h default, configurable via WORKER_CYCLE_TIMEOUT_MINUTES) - Fix end-of-page detection to use actual limit value instead of hardcoded 100 Co-authored-by: xCyanGrizzly <53275238+xCyanGrizzly@users.noreply.github.com>
29 lines
1.3 KiB
TypeScript
29 lines
1.3 KiB
TypeScript
import type { TelegramAccount } from "@prisma/client";
|
|
/**
|
|
* Authenticate a PENDING account by creating a TDLib client.
|
|
* TDLib will send an SMS code to the phone number, and the client.login()
|
|
* callbacks set the authState to AWAITING_CODE. Once the admin enters the
|
|
* code via the UI, pollForAuthCode picks it up and completes the login.
|
|
*
|
|
* After successful auth:
|
|
* 1. Fetches channels from Telegram and writes as a ChannelFetchRequest
|
|
* (so the admin can select sources in the UI)
|
|
* 2. Auto-joins the destination group if an invite link is configured
|
|
*/
|
|
export declare function authenticateAccount(account: TelegramAccount): Promise<void>;
|
|
/**
|
|
* Process a ChannelFetchRequest: fetch channels from Telegram,
|
|
* enrich with DB state, and write the result JSON.
|
|
* Called by the fetch listener (pg_notify) and by authenticateAccount.
|
|
*/
|
|
export declare function processFetchRequest(requestId: string): Promise<void>;
|
|
/**
|
|
* Run a full ingestion cycle for a single Telegram account.
|
|
* Every step writes live activity to the DB so the admin UI can display it.
|
|
*/
|
|
export declare function runWorkerForAccount(account: TelegramAccount): Promise<void>;
|
|
/**
|
|
* Clean up any leftover temp files/directories from previous runs.
|
|
*/
|
|
export declare function cleanupTempDir(): Promise<void>;
|