fix: catch all exceptions in Telegram email flow + webhook global handler
- processEmail: wrap DB lookup and ChatContact create/update in try-catch so any exception sends an error message to the user instead of silently failing and leaving state stuck at await_email - sendOtp: inform user if mail sending fails so they know to wait/retry - TelegramWebhookController: top-level try-catch returns 200 always so Telegram never retries on server errors (retries caused duplicate state resets) - ChatContact canal_id cast to string to avoid type mismatch on insert Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
eb6bb8e7f3
commit
77c3353213
@@ -4,10 +4,25 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\TelegramBotService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TelegramWebhookController extends Controller
|
||||
{
|
||||
public function handle(Request $request)
|
||||
{
|
||||
try {
|
||||
return $this->process($request);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('[TelegramWebhook] Uncaught exception: ' . $e->getMessage(), [
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'body' => $request->all(),
|
||||
]);
|
||||
// Always return 200 so Telegram doesn't retry
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
private function process(Request $request)
|
||||
{
|
||||
$update = $request->all();
|
||||
$bot = new TelegramBotService();
|
||||
@@ -57,3 +72,4 @@ class TelegramWebhookController extends Controller
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user