- 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.
95 lines
2.9 KiB
PHP
95 lines
2.9 KiB
PHP
<?php
|
|
namespace SPVoipIntegration\gravitel\notifications;
|
|
|
|
class GravitelHistoryNotification extends AbstractGraviltelNotification {
|
|
|
|
const INBOUND_TYPE = 'in';
|
|
const OUTBOUND_TYPE = 'out';
|
|
|
|
private $dataMapping = array(
|
|
'direction' => 'direction',
|
|
'callstatus' => 'callstatus'
|
|
);
|
|
|
|
protected function getNotificationDataMapping() {
|
|
return $this->dataMapping;
|
|
}
|
|
|
|
protected function prepareNotificationModel() {
|
|
$this->set('sourceuuid', $this->getSourceUUId());
|
|
|
|
$type = $this->getType();
|
|
$direction = ($type == self::INBOUND_TYPE) ? 'inbound' : 'outbound';
|
|
$this->set('direction', $direction);
|
|
|
|
$recordingLink = $this->get("link");
|
|
if(!empty($recordingLink)) {
|
|
$this->dataMapping['recordingurl'] = 'recordingurl';
|
|
$this->set('recordingurl', $recordingLink);
|
|
$this->downloadToLocal($recordingLink);
|
|
}
|
|
|
|
$this->processStatus();
|
|
$this->processDuration();
|
|
}
|
|
|
|
private function processStatus() {
|
|
$status = $this->get('status');
|
|
if($status == 'Success') {
|
|
$this->set('callstatus', 'completed');
|
|
return;
|
|
}
|
|
|
|
if($status == 'missed' || $status == 'Cancel') {
|
|
$this->set('callstatus', 'no-answer');
|
|
return;
|
|
}
|
|
|
|
$this->set('callstatus', 'busy');
|
|
}
|
|
|
|
|
|
private function processDuration() {
|
|
$startTime = strtotime($this->get('start'));
|
|
if($startTime) {
|
|
$this->dataMapping['starttime'] = 'starttime';
|
|
$this->set('starttime', date('Y-m-d H:i:s', $startTime));
|
|
}
|
|
|
|
$duration = $this->get('duration');
|
|
if(is_numeric($duration) && $duration > 0) {
|
|
$this->dataMapping['totalduration'] = 'totalduration';
|
|
$this->set('totalduration', $duration);
|
|
}
|
|
|
|
if ($this->pbxManagerModel) {
|
|
$billduration = $this->pbxManagerModel->get('billduration');
|
|
if ($billduration > $duration) {
|
|
$this->dataMapping['billduration'] = 'billduration';
|
|
$this->set('billduration', $duration);
|
|
}
|
|
}
|
|
}
|
|
|
|
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/{$this->getSourceUUId()}.mp3";
|
|
}
|
|
}
|