Files
NexusPBX/scripts/voicemail_pass_sync.php

30 lines
747 B
PHP
Executable File

<?php
declare(strict_types=1);
// Arguments transmis par Asterisk externpassnotify : <context> <mailbox> <newpassword>
$context = $argv[1] ?? 'default';
$mailbox = trim((string)($argv[2] ?? ''));
$newPass = trim((string)($argv[3] ?? ''));
if ($mailbox === '' || $newPass === '') {
exit(0);
}
require_once __DIR__ . '/../src/Database.php';
try {
$db = \App\Database::getConnection();
$stmt = $db->prepare('
UPDATE extensions
SET voicemail_pin = :pin, force_pin_change = 0
WHERE extension = :ext
');
$stmt->execute([
':pin' => $newPass,
':ext' => $mailbox,
]);
} catch (\Throwable $e) {
error_log("[voicemail_pass_sync] Erreur synchronisation PIN : " . $e->getMessage());
}