- Added comprehensive AI Assistant system (aiassist/ directory): * Vector search and embedding capabilities * Typebot proxy integration * Elastic search functionality * Message classification and chat history * MCP proxy for external integrations - Implemented Court Status API (GetCourtStatus.php): * Real-time court document status checking * Integration with external court systems * Comprehensive error handling and logging - Enhanced S3 integration: * Improved file backup system with metadata * Batch processing capabilities * Enhanced error logging and recovery * Copy operations with URL fixing - Added Telegram contact creation API - Improved error logging across all modules - Enhanced callback system for AI responses - Extensive backup file storage with timestamps - Updated documentation and README files - File storage improvements: * Thousands of backup files with proper metadata * Fix operations for broken file references * Project-specific backup and recovery systems * Comprehensive file integrity checking Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
88 lines
2.7 KiB
PHP
88 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace SPVoipIntegration\sipuni\notifications;
|
|
|
|
use SPVoipIntegration\ProvidersEnum;
|
|
|
|
class SipuniNotifyHangUp extends SipuniNotification {
|
|
|
|
protected $fieldsMapping = array(
|
|
'callstatus' => 'callstatus',
|
|
'sp_recordingurl' => 'sp_recordingurl',
|
|
'recordingurl' => 'recordingurl',
|
|
'endtime' => 'endtime',
|
|
'totalduration' => 'totalduration',
|
|
'billduration' => 'billduration'
|
|
);
|
|
|
|
protected function prepareNotificationModel() {
|
|
switch ($this->get('status')) {
|
|
case 'ANSWER':
|
|
$this->set('callstatus', 'completed');
|
|
break;
|
|
case 'BUSY':
|
|
$this->set('callstatus', 'busy');
|
|
break;
|
|
case 'NOANSWER':
|
|
$this->set('callstatus', 'no-answer');
|
|
break;
|
|
case 'CANCEL':
|
|
$this->set('callstatus', 'cancelled');
|
|
break;
|
|
case 'CONGESTION':
|
|
$this->set('callstatus', 'overloaded');
|
|
break;
|
|
case 'CHANUNAVAIL':
|
|
$this->set('callstatus', 'no-answer');
|
|
break;
|
|
}
|
|
$time = date('Y-m-d H:i:s');
|
|
$createdTime = strtotime($this->pbxManagerModel->get('starttime'));
|
|
if ($createdTime !== FALSE) {
|
|
$this->set('totalduration', strtotime($time) - $createdTime);
|
|
}
|
|
$this->set('endtime', $time);
|
|
$answerTimestamp = $this->get('call_answer_timestamp');
|
|
if (!empty($answerTimestamp)) {
|
|
$billDuration = $this->get('timestamp') - $answerTimestamp;
|
|
$this->set('billduration', $billDuration);
|
|
}
|
|
$link = $this->get('call_record_link');
|
|
if (!empty($link)) {
|
|
$recordLink = urldecode($link);
|
|
$this->set('sp_recordingurl', $recordLink);
|
|
$this->downloadToLocal($recordLink);
|
|
}
|
|
}
|
|
|
|
private function downloadToLocal($link) {
|
|
$soundFileContent = file_get_contents($link);
|
|
if ($soundFileContent === false) {
|
|
return;
|
|
}
|
|
|
|
$filePath = $this->generateSoundFileName();
|
|
$status = file_put_contents($filePath, $soundFileContent);
|
|
if ($status === false) {
|
|
return;
|
|
}
|
|
|
|
$this->set('recordingurl', $filePath);
|
|
$this->set('sp_is_local_cached', 1);
|
|
$this->dataMapping['sp_is_local_cached'] = 'sp_is_local_cached';
|
|
}
|
|
|
|
private function generateSoundFileName() {
|
|
return "storage/" . ProvidersEnum::SIPUNI . "_{$this->getSourceUUId()}.mp3";
|
|
}
|
|
|
|
protected function canCreatePBXRecord() {
|
|
return false;
|
|
}
|
|
|
|
protected function getCustomerPhoneNumber() {
|
|
|
|
}
|
|
|
|
}
|