Correções de segurança
This commit is contained in:
@@ -36,22 +36,31 @@ class SettingsController
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$telegramService = new TelegramService();
|
||||
try {
|
||||
$telegramService = new TelegramService();
|
||||
|
||||
// Use sendOrderNotification to test with the configured template
|
||||
$response = $telegramService->sendOrderNotification([
|
||||
'id' => '12345',
|
||||
'title' => 'Teste de Integração',
|
||||
'type' => 'Teste'
|
||||
], 999);
|
||||
// Use sendOrderNotification to test with the configured template
|
||||
$response = $telegramService->sendOrderNotification([
|
||||
'id' => '12345',
|
||||
'title' => 'Teste de Integração',
|
||||
'type' => 'Teste'
|
||||
], 999);
|
||||
|
||||
$result = json_decode($response, true);
|
||||
if ($response === false) {
|
||||
throw new \Exception("Falha ao conectar com a API do Telegram (curl retornou false). Verifique o Token e o Chat ID.");
|
||||
}
|
||||
|
||||
if ($result && isset($result['ok']) && $result['ok']) {
|
||||
echo json_encode(['success' => true, 'message' => 'Mensagem enviada com sucesso!']);
|
||||
} else {
|
||||
$error = $result['description'] ?? 'Erro desconhecido ao contatar API do Telegram.';
|
||||
echo json_encode(['success' => false, 'message' => 'Falha ao enviar: ' . $error]);
|
||||
$result = json_decode($response, true);
|
||||
|
||||
if ($result && isset($result['ok']) && $result['ok']) {
|
||||
echo json_encode(['success' => true, 'message' => 'Mensagem enviada com sucesso!']);
|
||||
} else {
|
||||
$error = $result['description'] ?? 'Erro desconhecido ao contatar API do Telegram. Resposta bruta: ' . $response;
|
||||
echo json_encode(['success' => false, 'message' => 'Falha ao enviar: ' . $error]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
error_log("Erro no teste do Telegram: " . $e->getMessage());
|
||||
echo json_encode(['success' => false, 'message' => 'Erro interno: ' . $e->getMessage()]);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user