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>
33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
import type { Client } from "tdl";
|
|
import type { ChannelScanResult, ScanProgressCallback } from "./download.js";
|
|
export interface ForumTopic {
|
|
topicId: bigint;
|
|
name: string;
|
|
}
|
|
/**
|
|
* Check if a chat is a forum supergroup (topics enabled).
|
|
*/
|
|
export declare function isChatForum(client: Client, chatId: bigint): Promise<boolean>;
|
|
/**
|
|
* Get all forum topics in a supergroup.
|
|
* Includes stuck detection and timeout protection on API calls.
|
|
*/
|
|
export declare function getForumTopicList(client: Client, chatId: bigint): Promise<ForumTopic[]>;
|
|
/**
|
|
* Fetch messages from a specific forum topic (thread), stopping once
|
|
* we've scanned past the last-processed boundary (with one page of lookback).
|
|
* Uses searchChatMessages with message_thread_id to scan within a topic.
|
|
*
|
|
* Returns messages in chronological order (oldest first).
|
|
*
|
|
* When `lastProcessedMessageId` is null (first run), scans everything.
|
|
* The worker applies a post-grouping filter to skip fully-processed sets,
|
|
* and keeps `packageExistsBySourceMessage` as a safety net.
|
|
*
|
|
* Safety features:
|
|
* - Max page limit to prevent infinite loops
|
|
* - Stuck detection: breaks if from_message_id stops advancing
|
|
* - Timeout on each TDLib API call
|
|
*/
|
|
export declare function getTopicMessages(client: Client, chatId: bigint, topicId: bigint, lastProcessedMessageId?: bigint | null, limit?: number, onProgress?: ScanProgressCallback): Promise<ChannelScanResult>;
|