public function getPresence($jid)
{
$split = split("/", $jid);
$jid = $split[0];
if (!$this->isContact($jid)) {
return false;
}
$current = ['resource' => '', 'active' => '', 'priority' => -129, 'show' => '', 'status' => ''];
//Priorities can only be -128 = 127
foreach ($this->roster_array[$jid]['presence'] as $resource => $presence) {
//Highest available priority or just highest priority
if ($presence['priority'] > $current['priority'] && ($presence['show'] === 'chat' || $presence['show'] === 'available' or ($current['show'] !== 'chat' or $current['show'] !== 'available'))) {
$current = $presence;
$current['resource'] = $resource;
}
}
return $current;
}