|
|
|
@ -13,7 +13,6 @@ use app\Interfaces\IApiMedia;
|
|
|
|
|
use app\Models\Atendimento; |
|
|
|
|
use app\Models\Evento; |
|
|
|
|
use app\Models\ListaNegraPalavras; |
|
|
|
|
use app\Models\Ramal; |
|
|
|
|
use app\Models\SupervisorModel; |
|
|
|
|
use websocket\WsInterface; |
|
|
|
|
|
|
|
|
@ -24,20 +23,47 @@ use websocket\WsInterface;
|
|
|
|
|
*/ |
|
|
|
|
class CoreMedia |
|
|
|
|
{ |
|
|
|
|
private $api; |
|
|
|
|
private $request; |
|
|
|
|
private $commands; |
|
|
|
|
private $queue; |
|
|
|
|
private $agente; |
|
|
|
|
private $palavroes; |
|
|
|
|
private $ws; |
|
|
|
|
private $atendimento; |
|
|
|
|
private $supervisor; |
|
|
|
|
private $eventos; |
|
|
|
|
private $host; |
|
|
|
|
private $bilheteController; |
|
|
|
|
private $message; |
|
|
|
|
private $systemController; |
|
|
|
|
/** @var IApiMedia $api api do provedor de mensagens */ |
|
|
|
|
protected $api; |
|
|
|
|
|
|
|
|
|
/** @var array $request hook da requisição de webhook*/ |
|
|
|
|
protected $request; |
|
|
|
|
|
|
|
|
|
/** @var Commands $commands classe de comandos do sistema*/ |
|
|
|
|
protected $commands; |
|
|
|
|
|
|
|
|
|
/** @var QueueController $queue controller da queue*/ |
|
|
|
|
protected $queue; |
|
|
|
|
|
|
|
|
|
/** @var AgentController $agente controller do agente*/ |
|
|
|
|
protected $agente; |
|
|
|
|
|
|
|
|
|
/** @var ListaNegraPalavras $palavroes model de palavras banida*/ |
|
|
|
|
protected $palavroes; |
|
|
|
|
|
|
|
|
|
/** @var WsInterface $ws classe de comandos do sistema*/ |
|
|
|
|
protected $ws; |
|
|
|
|
|
|
|
|
|
/** @var Atendimento $atendimento model de atendimentos*/ |
|
|
|
|
protected $atendimento; |
|
|
|
|
|
|
|
|
|
/** @var SupervisorModel $supervisor model de supervisor*/ |
|
|
|
|
protected $supervisor; |
|
|
|
|
|
|
|
|
|
/** @var Evento $eventos model de eventos*/ |
|
|
|
|
protected $eventos; |
|
|
|
|
|
|
|
|
|
/** @var BilheteController $eventos controller dos bilhetess*/ |
|
|
|
|
protected $bilheteController; |
|
|
|
|
|
|
|
|
|
/** @var Message $message model de mensagens*/ |
|
|
|
|
protected $message; |
|
|
|
|
|
|
|
|
|
/** @var SystemMessageController $systemController controller de mensagens de sistema*/ |
|
|
|
|
protected $systemController; |
|
|
|
|
|
|
|
|
|
/** @var Crypt $crypt core de criptografia*/ |
|
|
|
|
protected $crypt; |
|
|
|
|
|
|
|
|
|
public function __construct() |
|
|
|
|
{ |
|
|
|
@ -54,7 +80,7 @@ class CoreMedia
|
|
|
|
|
$this->bilheteController = new BilheteController; |
|
|
|
|
$this->systemController = new SystemMessageController(); |
|
|
|
|
} |
|
|
|
|
public function setApi($api) |
|
|
|
|
public function setApi(IApiMedia $api) |
|
|
|
|
{ |
|
|
|
|
$this->api = $api; |
|
|
|
|
} |
|
|
|
@ -83,32 +109,7 @@ class CoreMedia
|
|
|
|
|
//verifica se tem atendimento em aberto, se tiver ja manda msg para o agente via ws |
|
|
|
|
$atendiment = $this->atendimento->findAtenEmAberto($this->api->getPhone()); |
|
|
|
|
if ($atendiment) { |
|
|
|
|
$this->message->addMessage( |
|
|
|
|
$atendiment->uniqueid, |
|
|
|
|
$this->api->getPhone(), |
|
|
|
|
$atendiment->matricula, |
|
|
|
|
$this->api->getType(), |
|
|
|
|
$this->retornaConteudo(), |
|
|
|
|
empty($this->api->getProfile()) ? '' : $this->api->getProfile(), |
|
|
|
|
$this->api->getchannel(), |
|
|
|
|
"sended", |
|
|
|
|
$this->api->getMimetype(), |
|
|
|
|
$this->api->retornaTituloDocument(), |
|
|
|
|
$this->api->getId() |
|
|
|
|
); |
|
|
|
|
$this->ws->enviaMsg( |
|
|
|
|
$this->api->convertToWebsocket( |
|
|
|
|
$this->retornaConteudo(), |
|
|
|
|
$atendiment->matricula, |
|
|
|
|
$atendiment->uniqueid, |
|
|
|
|
$this->api->getType(), |
|
|
|
|
$this->api->getProfile(), |
|
|
|
|
$this->api->getPhone(), |
|
|
|
|
time(), |
|
|
|
|
$this->api->getId(), |
|
|
|
|
$this->api->getMimetype() |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
$this->enviaMensagemAgente($atendiment); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
//verifica se tem atendimento em espera, se tiver ja mostra a sua posição na fila |
|
|
|
@ -253,39 +254,52 @@ class CoreMedia
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function listaFilas() |
|
|
|
|
{ |
|
|
|
|
$ramal = new Ramal(); |
|
|
|
|
$user = $ramal->findRamal($this->api->getPhone()); |
|
|
|
|
$search = $this->queue->listaAllFilas(); |
|
|
|
|
$listaPausas = []; |
|
|
|
|
foreach ($search as $key => $value) { |
|
|
|
|
$value->nome = strtolower($value->nome); |
|
|
|
|
array_push($listaPausas, ['title' => substr($value->nome, 0, 23), 'sub' => "/E {$value->nome} {$user->callerid}"]); |
|
|
|
|
} |
|
|
|
|
return $listaPausas; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function retornaConteudo() |
|
|
|
|
{ |
|
|
|
|
switch ($this->api->getType()) { |
|
|
|
|
case 'text': |
|
|
|
|
return $this->api->getMessage(); |
|
|
|
|
case 'image': |
|
|
|
|
return $this->api->getLinkDownload($this->host); |
|
|
|
|
case 'sticker': |
|
|
|
|
return $this->api->getLinkDownload($this->host); |
|
|
|
|
case 'video': |
|
|
|
|
return $this->api->getLinkDownload($this->host); |
|
|
|
|
case 'voice': |
|
|
|
|
case 'audio': |
|
|
|
|
return $this->api->getLinkDownload($this->host); |
|
|
|
|
case 'document': |
|
|
|
|
return $this->api->getLinkDownload($this->host); |
|
|
|
|
return $this->api->getId(); |
|
|
|
|
case 'contacts': |
|
|
|
|
return null; |
|
|
|
|
case 'location': |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function enviaMensagemAgente($atendiment) |
|
|
|
|
{ |
|
|
|
|
$this->message->addMessage( |
|
|
|
|
$atendiment->uniqueid, |
|
|
|
|
$this->api->getPhone(), |
|
|
|
|
$atendiment->matricula, |
|
|
|
|
$this->api->getType(), |
|
|
|
|
$this->retornaConteudo(), |
|
|
|
|
empty($this->api->getProfile()) ? '' : $this->api->getProfile(), |
|
|
|
|
$this->api->getchannel(), |
|
|
|
|
"sended", |
|
|
|
|
$this->api->getMimetype(), |
|
|
|
|
$this->api->retornaTituloDocument(), |
|
|
|
|
$this->api->getId() |
|
|
|
|
); |
|
|
|
|
$this->ws->enviaMsg( |
|
|
|
|
$this->api->convertToWebsocket( |
|
|
|
|
$this->retornaConteudo(), |
|
|
|
|
$atendiment->matricula, |
|
|
|
|
$atendiment->uniqueid, |
|
|
|
|
$this->api->getType(), |
|
|
|
|
$this->api->getProfile(), |
|
|
|
|
$this->api->getPhone(), |
|
|
|
|
time(), |
|
|
|
|
$this->api->getId(), |
|
|
|
|
$this->api->getMimetype() |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |