Files
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- 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.
2025-10-16 11:17:21 +03:00

90 lines
3.4 KiB
PHP

<?php
namespace SPVoipIntegration\mango\notifications;
class MangoNotifyCall extends MangoNotification {
protected $fieldsMapping = array(
'sourceuuid' => 'sourceuuid',
'callstatus' => 'call_state',
'user' => 'sp_user',
'sp_called_from_number' => 'sp_called_from_number',
'sp_called_to_number' => 'sp_called_to_number',
'sp_call_status_code' => 'disconnect_reason',
'sp_voip_provider' => 'sp_voip_provider',
'customernumber' => 'customernumber',
'direction' => 'direction',
'starttime' => 'starttime',
'endtime' => 'endtime',
'totalduration' => 'totalduration',
'sp_call_status_code' => 'disconnect_reason'
);
protected function prepareNotificationModel() {
$to = (array) $this->get('to');
$from = (array) $this->get('from');
switch ($this->get('call_state')) {
case 'Appeared':
$this->set('call_state', 'ringing');
$time = date('Y-m-d H:i:s');
$this->set('starttime', $time);
break;
case 'Connected':
$this->set('call_state', 'in progress');
unset($this->fieldsMapping['starttime']);
break;
case 'OnHold':
$this->set('call_state', 'on hold');
unset($this->fieldsMapping['starttime']);
break;
case 'Disconnected':
$state = $this->pbxManagerModel->get('callstatus');
if ($state == 'in progress' || $state == 'on hold') {
$this->set('call_state', 'completed');
} else {
$this->set('call_state', 'no-response');
}
$time = date('Y-m-d H:i:s');
unset($this->fieldsMapping['starttime']);
$createdtime = $this->pbxManagerModel->get('starttime');
if ($createdtime !== FALSE) {
$this->set('totalduration', strtotime($time) - strtotime($createdtime));
}
$this->set('endtime', $time);
break;
}
if (array_key_exists('extension', $this->get('to'))) {
$this->set('sp_called_to_number', $to['extension']);
$this->sp_user = $to['extension'];
$this->set('sourceuuid', $this->get('entry_id') . $to['extension']);
} else {
$this->set('sp_called_to_number', $to['number']);
$this->set('customernumber', $to['number']);
$this->set('sourceuuid', $this->get('entry_id') . $from['extension']);
}
if (array_key_exists('extension', $this->get('from'))) {
$this->set('sp_called_from_number', $from['extension']);
$this->sp_user = $from['extension'];
if (array_key_exists('extension', $this->get('to'))) {
$this->set('direction', 'internal');
} else {
$this->set('direction', 'outbound');
}
} else {
$this->set('sp_called_from_number', $from['number']);
$this->set('customernumber', $from['number']);
$this->set('direction', 'inbound');
}
parent::prepareNotificationModel();
}
protected function canCreatePBXRecord() {
return strpos($this->get('json'),'Appeared') !== false;
}
protected function getCustomerPhoneNumber() {
return $this->get('customernumber');
}
}