Ejemplo n.º 1
0
 public function handle($stanza, $parent = false)
 {
     $message = $stanza->forwarded->message;
     $jid = explode('/', (string) $message->attributes()->from);
     $to = current(explode('/', (string) $message->attributes()->to));
     if ($message->composing) {
         $this->event('composing', array($jid[0], $to));
     }
     if ($message->paused) {
         $this->event('paused', array($jid[0], $to));
     }
     if ($message->gone) {
         $this->event('gone', array($jid[0], $to));
     }
     if ($message->body || $message->subject) {
         $m = new \Modl\Message();
         $m->set($message, $stanza->forwarded);
         if (!preg_match('#^\\?OTR#', $m->body)) {
             $md = new \Modl\MessageDAO();
             $md->set($m);
             $this->pack($m);
             $this->deliver();
         }
     }
 }
Ejemplo n.º 2
0
 public function handle($stanza, $parent = false)
 {
     $jid = explode('/', (string) $stanza->attributes()->from);
     $to = current(explode('/', (string) $stanza->attributes()->to));
     if ($stanza->composing) {
         $this->event('composing', array($jid[0], $to));
     }
     if ($stanza->paused) {
         $this->event('paused', array($jid[0], $to));
     }
     if ($stanza->gone) {
         $this->event('gone', array($jid[0], $to));
     }
     if ($stanza->body || $stanza->subject) {
         if ($stanza->request) {
             $from = (string) $stanza->attributes()->from;
             $id = (string) $stanza->attributes()->id;
             \Moxl\Stanza\Message::receipt($from, $id);
         }
         $m = new \Modl\Message();
         $m->set($stanza, $parent);
         if (!preg_match('#^\\?OTR#', $m->body)) {
             $md = new \Modl\MessageDAO();
             $md->set($m);
             $this->pack($m);
             $this->deliver();
         }
     }
 }
Ejemplo n.º 3
0
 public function handle($stanza, $parent = false)
 {
     if ($stanza->forwarded->delay) {
         $m = new \Modl\Message();
         $m->set($stanza->forwarded->message, $stanza->forwarded);
         if (!preg_match('#^\\?OTR#', $m->body)) {
             $md = new \Modl\MessageDAO();
             $md->set($m);
             $this->pack($m);
             $this->deliver();
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @brief Send a message
  *
  * @param string $to
  * @param string $message
  * @return void
  */
 function ajaxSendMessage($to, $message, $muc = false, $resource = false, $replace = false)
 {
     $body = trim(rawurldecode($message));
     if ($body == '' || $body == '/me') {
         return;
     }
     $m = new \Modl\Message();
     $m->session = $this->user->getLogin();
     $m->jidto = echapJid($to);
     $m->jidfrom = $this->user->getLogin();
     if ($replace != false) {
         $m->newid = Uuid::uuid4();
         $m->id = $replace->id;
         $m->edited = true;
         $m->published = $replace->published;
         $m->delivered = $replace->delivered;
     } else {
         $m->id = Uuid::uuid4();
         $m->published = gmdate('Y-m-d H:i:s');
     }
     $session = \Session::start();
     $m->type = 'chat';
     $m->resource = $session->get('resource');
     if ($muc) {
         $m->type = 'groupchat';
         $m->resource = $session->get('username');
         $m->jidfrom = $to;
     }
     $m->body = $body;
     $m->checkPicture();
     //$m->html      = prepareString($m->body, false, true);
     if ($resource != false) {
         $to = $to . '/' . $resource;
     }
     // We decode URL codes to send the correct message to the XMPP server
     $p = new Publish();
     $p->setTo($to);
     //$p->setHTML($m->html);
     $p->setContent($m->body);
     if ($replace != false) {
         $p->setId($m->newid);
         $p->setReplace($m->id);
     } else {
         $p->setId($m->id);
     }
     if ($muc) {
         $p->setMuc();
     }
     $p->request();
     /* Is it really clean ? */
     if (!$p->getMuc()) {
         if (!preg_match('#^\\?OTR#', $m->body)) {
             $md = new \Modl\MessageDAO();
             $md->set($m);
         }
         $packet = new Moxl\Xec\Payload\Packet();
         $packet->content = $m;
         $this->onMessage($packet);
     }
 }