From 04ca0b6b0bad079b95fa4cf67f62057a67c595ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Sat, 31 Mar 2018 23:56:14 +0200 Subject: [PATCH] Fix messages handling in Chat widget --- app/Message.php | 8 +++----- app/widgets/Chat/Chat.php | 15 +++++---------- app/widgets/Chat/_chat.tpl | 6 +++--- app/widgets/Chat/chat.js | 8 ++++++-- app/widgets/Stickers/Stickers.php | 9 ++++----- .../20180327203201_create_messages_table.php | 1 + 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/app/Message.php b/app/Message.php index 74e529b67..e6439af78 100644 --- a/app/Message.php +++ b/app/Message.php @@ -107,11 +107,7 @@ class Message extends Model $this->body = trim(html_entity_decode($this->body)); } - if ($stanza->markable) { - $this->markable = true; - } else { - $this->markable = false; - } + $this->markable = (bool)($stanza->markable); if ($stanza->subject) { $this->subject = (string)$stanza->subject; @@ -211,6 +207,8 @@ class Message extends Model if ($stanza->replace && $this->user->messages()->where('id', $this->id)->count() == 0) { + $this->oldid = (string)$stanza->replace->attributes()->id; + $this->edited = true; Message::where('id', (string)$stanza->replace->attributes()->id)->update([ 'id' => $this->id, 'edited' => true diff --git a/app/widgets/Chat/Chat.php b/app/widgets/Chat/Chat.php index d18769a7a..9b6e339c3 100644 --- a/app/widgets/Chat/Chat.php +++ b/app/widgets/Chat/Chat.php @@ -375,10 +375,6 @@ class Chat extends \Movim\Widget\Base /* Is it really clean ? */ if (!$p->getMuc()) { - /*if (!$m->isOTR()) { - $md = new \Modl\MessageDAO; - $md->set($m); - }*/ $m->save(); $m->oldid = $oldid; @@ -525,7 +521,7 @@ class Chat extends \Movim\Widget\Base /** * @brief Get the subject form of a chatroom */ - function ajaxGetSubject($room) + /*function ajaxGetSubject($room) { if (!$this->validateJid($room)) return; @@ -538,12 +534,12 @@ class Chat extends \Movim\Widget\Base $view->assign('subject', $s); Dialog::fill($view->draw('_chat_subject', true)); - } + }*/ /** * @brief Change the subject of a chatroom */ - function ajaxSetSubject($room, $form) + /*function ajaxSetSubject($room, $form) { if (!$this->validateJid($room)) return; @@ -554,7 +550,7 @@ class Chat extends \Movim\Widget\Base $p->setTo($room) ->setSubject($form->subject->value) ->request(); - } + }*/ /** * @brief Set last displayed message @@ -610,12 +606,11 @@ class Chat extends \Movim\Widget\Base $view->assign('info', $info); if ($muc) { - $md = new \Modl\MessageDAO; $cd = new \Modl\ConferenceDAO; $pd = new \Modl\PresenceDAO; $view->assign('room', $jid); - $view->assign('subject', $md->getRoomSubject($jid)); + //$view->assign('subject', $md->getRoomSubject($jid)); $view->assign('conference', $this->user->session->conferences ->where('conference', $jid) ->first()); diff --git a/app/widgets/Chat/_chat.tpl b/app/widgets/Chat/_chat.tpl index 1b96c2a06..61c7bcfca 100644 --- a/app/widgets/Chat/_chat.tpl +++ b/app/widgets/Chat/_chat.tpl @@ -63,12 +63,12 @@