Files
crm.clientright.ru/modules/SPVoipIntegration/zadarma/notifications/ZadarmaNotifyRecord.php
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

64 lines
2.3 KiB
PHP

<?php
namespace SPVoipIntegration\zadarma\notifications;
use SPVoipIntegration\loggers\Logger;
class ZadarmaNotifyRecord extends ZadarmaNotification {
public function getValidationString() {
return $this->get('pbx_call_id') . $this->get('call_id_with_rec');
}
public function process() {
$pbxModel = $this->findCallByRecordedId();
if ($pbxModel != null) {
$pbxModel->set('mode', 'edit');
try {
$zadarmaFactory = new \SPVoipIntegration\zadarma\ZadarmaFactory;
$apiManager = $zadarmaFactory->getCallApiManager();
$audioLink = $apiManager->getRecordLink($this->get('call_id_with_rec'));
$soundFileContent = file_get_contents($audioLink);
if($soundFileContent === false) {
throw new \Exception('Cant get audou data');
}
$filePath = $this->generateSoundFileName();
$status = file_put_contents($filePath, $soundFileContent);
if ($status === false) {
throw new \Exception('Cant save audio file');
}
$pbxModel->set('recordingurl', $filePath);
$pbxModel->set('sp_is_local_cached', 1);
$pbxModel->save();
} catch (\Exception $ex) {
Logger::log('Error on save audiofile', $ex);
}
}
}
protected function canCreatePBXRecord() {
return false;
}
protected function getCustomerPhoneNumber() {
return '';
}
private function generateSoundFileName() {
return "storage/{$this->get('call_id_with_rec')}.mp3";
}
private function findCallByRecordedId() {
$db = \PearDatabase::getInstance();
$pbxModel = null;
$result = $db->pquery("SELECT pbxmanagerid FROM vtiger_pbxmanager "
. "INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_pbxmanager.pbxmanagerid "
. "WHERE vtiger_crmentity.deleted=0 AND vtiger_pbxmanager.sp_recorded_call_id=?", array($this->get('call_id_with_rec')));
if ($result && $resRow = $db->fetchByAssoc($result)) {
$pbxModel = \Vtiger_Record_Model::getInstanceById($resRow['pbxmanagerid']);
}
return $pbxModel;
}
}