Files
crm.clientright.ru/modules/SPVoipIntegration/uiscom/notifications/UIScomNotification.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

105 lines
3.9 KiB
PHP

<?php
namespace SPVoipIntegration\uiscom\notifications;
use SPVoipIntegration\integration\AbstractNotification;
abstract class UIScomNotification extends AbstractNotification {
const UISCOM_NOTIFICATION_OUT_START = "\"Исходящее плечо\"";
const UISCOM_NOTIFICATION_ANSWER = "\"Начало разговора\"";
const UISCOM_NOTIFICATION_END = "\"Завершение звонка\"";
const UISCOM_NOTIFICATION_LOST = "\"Потерянный звонок\"";
const UISCOM_NOTIFICATION_RECORD = "\"Записанный разговор\"";
protected $fieldsMapping = array();
protected abstract function canCreatePBXRecord();
protected function getSourceUUId() {
return $this->get('call_session_id');
}
public function __construct($values = array()) {
parent::__construct($values);
$sourceUUID = $this->getSourceUUId();
$this->pbxManagerModel = $this->getInstanceBySourceUUID($sourceUUID);
$pbxManagerId = $this->pbxManagerModel->get('pbxmanagerid');
if (!empty($pbxManagerId)) {
$this->pbxManagerModel = \Vtiger_Record_Model::getInstanceById($pbxManagerId);
}
}
public function process() {
if ((!$this->pbxManagerModel->getId() && !$this->canCreatePBXRecord()) ) {
return;
}
$voipModel = $this->getVoipRecordModelFromNotificationModel();
$voipModel->save();
}
public function validateNotification() {
return true;
}
public static function getInstance($requestData) {
$type = $requestData['notification_name'];
switch ($type) {
case self::UISCOM_NOTIFICATION_OUT_START:
return new UIScomNotifyOutStart($requestData);
case self::UISCOM_NOTIFICATION_ANSWER:
return new UIScomNotifyAnswer($requestData);
case self::UISCOM_NOTIFICATION_END:
return new UIScomNotifyEnd($requestData);
case self::UISCOM_NOTIFICATION_LOST:
return new UIScomNotifyLost($requestData);
case self::UISCOM_NOTIFICATION_RECORD:
return new UIScomNotifyRecord($requestData);
default:
throw new \Exception("Unknown notification type");
}
}
protected function getUserPhoneNumber() {
if ($this->get('direction') == "in"){
return $this->get('called_phone_number');
}
else{
return $this->get('calling_phone_number');
}
}
protected function getNotificationDataMapping() {
return $this->fieldsMapping;
}
protected function prepareNotificationModel() {
$this->set('user', '');
$this->set('sp_voip_provider', 'uiscom');
$userModel = self::getUserByNumber($this->getUserPhoneNumber());
if ($userModel != null) {
$this->set('sp_user', $userModel->getId());
}
$notificationFieldName = str_replace(['"', "\\"], "", $this->get('start_time'));
$this->set('start_time', $notificationFieldName);
}
public function getInstanceBySourceUUID($sourceuuid, $number = NULL){
$db = \PearDatabase::getInstance();
$record = new \PBXManager_Record_Model();
if (!empty($number)){
$query = "SELECT * FROM vtiger_pbxmanager WHERE sourceuuid=? and sp_called_to_number=?";
$result = $db->pquery($query, array($sourceuuid, $number));
} else {
$query = "SELECT * FROM vtiger_pbxmanager WHERE sourceuuid=? and callstatus != 'no-answer'";
$result = $db->pquery($query, array($sourceuuid));
}
$rowCount = $db->num_rows($result);
if($rowCount){
$rowData = $db->query_result_rowdata($result, 0);
$record->setData($rowData);
}
return $record;
}
}