- POST /webhooks exige X-Hub-Signature-256 (HMAC-SHA256 del cuerpo crudo); falla cerrado si app_secret no está configurado - nueva clave app_secret en whatsapp_system_config, editable desde Configuración Bot - menú lateral de WhatsApp visible de nuevo (Correo/IMAP sigue en Chat/Bot) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire\Whatsapp;
|
|
|
|
use App\Models\WhatsappSystemConfig;
|
|
use Livewire\Component;
|
|
use Jantinnerezo\LivewireAlert\LivewireAlert;
|
|
|
|
class ShowConfiguracionBot extends Component
|
|
{
|
|
use LivewireAlert;
|
|
|
|
public string $whatsapp_token = '';
|
|
public string $phone_number_id = '';
|
|
public string $whatsapp_api_url = '';
|
|
public string $webhook_verify_token = '';
|
|
public string $app_secret = '';
|
|
public string $bot_enabled = '1';
|
|
public string $welcome_message = '';
|
|
public string $default_no_match = '';
|
|
public string $advisor_message = '';
|
|
public string $business_hours_enabled = '0';
|
|
public string $business_hours_start = '';
|
|
public string $business_hours_end = '';
|
|
|
|
protected $rules = [
|
|
'whatsapp_token' => 'required|string',
|
|
'phone_number_id' => 'required|string',
|
|
'whatsapp_api_url' => 'required|url',
|
|
'webhook_verify_token' => 'required|string',
|
|
'app_secret' => 'required|string',
|
|
'welcome_message' => 'required|string|max:1000',
|
|
'default_no_match' => 'required|string|max:500',
|
|
'advisor_message' => 'required|string|max:500',
|
|
];
|
|
|
|
public function mount(): void
|
|
{
|
|
$keys = [
|
|
'whatsapp_token', 'phone_number_id', 'whatsapp_api_url',
|
|
'webhook_verify_token', 'app_secret', 'bot_enabled', 'welcome_message',
|
|
'default_no_match', 'advisor_message', 'business_hours_enabled',
|
|
'business_hours_start', 'business_hours_end',
|
|
];
|
|
|
|
foreach ($keys as $key) {
|
|
$this->{$key} = WhatsappSystemConfig::get($key);
|
|
}
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$this->validate();
|
|
|
|
$keys = [
|
|
'whatsapp_token', 'phone_number_id', 'whatsapp_api_url',
|
|
'webhook_verify_token', 'app_secret', 'bot_enabled', 'welcome_message',
|
|
'default_no_match', 'advisor_message', 'business_hours_enabled',
|
|
'business_hours_start', 'business_hours_end',
|
|
];
|
|
|
|
foreach ($keys as $key) {
|
|
WhatsappSystemConfig::set($key, $this->{$key});
|
|
}
|
|
|
|
$this->alert('success', 'Configuración guardada correctamente.');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.whatsapp.show-configuracion-bot');
|
|
}
|
|
}
|