Fix: Solucionados problemas de permisos en Docker y agregada gestion de Webhook de Telegram
This commit is contained in:
@@ -37,7 +37,10 @@ class TelegramController extends Controller
|
||||
$telegramAccount->update(['verification_code' => $verificationCode]);
|
||||
}
|
||||
|
||||
return view('telegram.verify', compact('telegramAccount'));
|
||||
return view('telegram.verify', [
|
||||
'telegramAccount' => $telegramAccount,
|
||||
'webhookInfo' => (new TelegramBotService())->getWebhookInfo()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,8 +101,7 @@ class TelegramController extends Controller
|
||||
Log::info('Telegram webhook received', $update);
|
||||
|
||||
if (empty($update)) {
|
||||
return response()->json(['ok' => true, 'message' => 'No update
|
||||
received']);
|
||||
return response()->json(['ok' => true, 'message' => 'No update received']);
|
||||
}
|
||||
|
||||
$botService = new TelegramBotService();
|
||||
@@ -117,24 +119,32 @@ received']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configurar webhook (ruta temporal para configurar desde el navegador)
|
||||
* Configurar webhook
|
||||
*/
|
||||
public function setupWebhook(Request $request)
|
||||
{
|
||||
$token = $request->get('token');
|
||||
|
||||
// Verificar token de seguridad simple
|
||||
if ($token !== config('app.key')) {
|
||||
abort(403, 'Token inválido');
|
||||
}
|
||||
|
||||
$botService = new TelegramBotService();
|
||||
$result = $botService->setWebhook();
|
||||
|
||||
if ($result) {
|
||||
return response()->json(['success' => true, 'message' => 'Webhook configurado correctamente']);
|
||||
return back()->with('success', 'Webhook configurado correctamente.');
|
||||
}
|
||||
|
||||
return response()->json(['success' => false, 'error' => 'Error al configurar webhook'], 500);
|
||||
return back()->with('error', 'Error al configurar webhook.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Borrar webhook
|
||||
*/
|
||||
public function deleteWebhook(Request $request)
|
||||
{
|
||||
$botService = new TelegramBotService();
|
||||
$result = $botService->deleteWebhook();
|
||||
|
||||
if ($result) {
|
||||
return back()->with('success', 'Webhook borrado correctamente.');
|
||||
}
|
||||
|
||||
return back()->with('error', 'Error al borrar el webhook.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user