/** * @brief Get history */ function ajaxGetHistory($jid) { if (!$this->validateJid($jid)) { return; } $md = new \Modl\MessageDAO(); $messages = $md->getContact(echapJid($jid), 0, 1); $g = new \Moxl\Xec\Action\MAM\Get(); $g->setJid(echapJid($jid)); if (!empty($messages)) { $g->setStart(strtotime($messages[0]->published)); } $g->request(); }
/** * @brief Get history */ function ajaxGetHistory($jid = false) { $g = new \Moxl\Xec\Action\MAM\Get(); $md = new \Modl\MessageDAO(); if ($jid == false) { $chats = Cache::c('chats'); foreach ($chats as $jid => $value) { $messages = $md->getContact(echapJid($jid), 0, 1); $g->setJid(echapJid($jid)); if (!empty($messages)) { $g->setStart(strtotime($messages[0]->published) + 10); } $g->request(); } } elseif ($this->validateJid($jid)) { $messages = $md->getContact(echapJid($jid), 0, 1); $g->setJid(echapJid($jid)); if (!empty($messages)) { // We add a little delay of 10sec to prevent some sync issues $g->setStart(strtotime($messages[0]->published) + 10); } $g->request(); } }