You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

<?php
namespace app\Controllers;
use app\Core\Controller;
use app\Models\Message;
use Exception;
/**
* Description of MessageController
*
* @author root
*/
class MessageController extends Controller
{
/** @var Message $message model de Message */
protected $message;
public function __construct()
{
$this->message = new Message();
}
/**
* Calcula o timeout para o encerramento da chamada
* @param type $matricula
* @param type $ramal
* @param type $timer
* @return boolean
*/
public function timeoutTalk($uniqueid, $cliente)
{
try {
$message = $this->message->findLastMessage($uniqueid);
if ($cliente == $message->dst) {
if (strtotime($message->msg_date . '+' . CONF_WHATSAPP_TIMEOUT_CLIENT_RESPOSTA . ' seconds') < time()) {
print('FINISH');
return "FINISH";
}
$timealert = strtotime($message->msg_date . '+' . (CONF_WHATSAPP_TIMEOUT_CLIENT_RESPOSTA - 60) . ' seconds');
if ($timealert < strtotime(date('Y-m-d H:i:s'))) {
print('alerta');
return "ALERT";
}
}
return false;
} catch (Exception $ex) {
$this->message->rollback();
$this->message($ex->getMessage());
logger()->error($ex->getMessage());
}
return false;
}
}