*
Chat was unanswered for n minits, execute callback.
public static unansweredChatWorkflow ( erLhcoreClassModelChat &$chat ) | ||
$chat | erLhcoreClassModelChat |
public static function mainUnansweredChatWorkflow() { $output = ''; if (erLhcoreClassModelChatConfig::fetch('run_unaswered_chat_workflow')->current_value > 0) { $output .= "Starting unaswered chats workflow\n"; $delay = time() - erLhcoreClassModelChatConfig::fetch('run_unaswered_chat_workflow')->current_valu * 60; foreach (erLhcoreClassChat::getList(array('limit' => 500, 'filterlt' => array('time' => $delay), 'filter' => array('status' => erLhcoreClassModelChat::STATUS_PENDING_CHAT, 'na_cb_executed' => 0))) as $chat) { erLhcoreClassChatWorkflow::unansweredChatWorkflow($chat); $output .= "executing unanswered callback for chat - " . $chat->id . "\n"; } $output .= "Ended unaswered chats workflow\n"; } return $output; }
try { $theme = erLhAbstractModelWidgetTheme::fetch($defaultTheme); $tpl->set('theme', $theme); } catch (Exception $e) { } } } $responseArray = array(); try { $chat = erLhcoreClassModelChat::fetch($Params['user_parameters']['chat_id']); if ($chat->hash == $Params['user_parameters']['hash']) { // Main unasnwered chats callback if ($chat->na_cb_executed == 0 && $chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT && erLhcoreClassModelChatConfig::fetch('run_unaswered_chat_workflow')->current_value > 0) { $delay = time() - erLhcoreClassModelChatConfig::fetch('run_unaswered_chat_workflow')->current_value * 60; if ($chat->time < $delay) { erLhcoreClassChatWorkflow::unansweredChatWorkflow($chat); } } if ($chat->nc_cb_executed == 0 && $chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT) { $department = $chat->department; if ($department !== false) { $options = $department->inform_options_array; $delay = time() - $department->inform_delay; if ($chat->time < $delay) { erLhcoreClassChatWorkflow::newChatInformWorkflow(array('department' => $department, 'options' => $options), $chat); } } else { $chat->nc_cb_executed = 1; $chat->updateThis(); } }