File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 138138
139139try {
140140 $ contentId = TelegramBot::handleUpdate ($ update );
141-
142- // If the ID is valid and AI is enabled, process immediately (we are already in background)
143- if ($ contentId && ($ config ['ai_enabled ' ] ?? false )) {
144- AIService::processContent ($ contentId );
145- }
141+
142+ // AI processing is intentionally NOT done here.
143+ //
144+ // Calling AIService::processContent() inline would block the webhook
145+ // response for the duration of the Gemini API call (typically 1-5s).
146+ // Telegram considers a webhook failed if it does not receive a 2xx
147+ // within a few seconds and will retry — redelivering the same update
148+ // and causing duplicate content or double-tagging.
149+ //
150+ // The cron endpoint (/api/cron.php) picks up rows with ai_processed=0
151+ // on its own schedule. Set it up via: Settings → Cron in the admin.
146152} catch (Throwable $ e ) {
147153 error_log ('[TELEPAGE][WEBHOOK] ' . $ e ->getMessage ());
148154}
You can’t perform that action at this time.
0 commit comments