diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 47858e9..73ee1c1 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -137,7 +137,7 @@ TimWolla.WCF ?= {} dataType: 'json' type: 'POST' success: $.proxy((data, textStatus, jqXHR) -> - @handleMessages(data) + @handleMessages(data.messages) , this) ### # Inserts the new messages. diff --git a/file/lib/page/ChatMessagePage.class.php b/file/lib/page/ChatMessagePage.class.php index b3b674d..6fc4506 100644 --- a/file/lib/page/ChatMessagePage.class.php +++ b/file/lib/page/ChatMessagePage.class.php @@ -50,11 +50,12 @@ public function show() { parent::show(); @header('Content-type: application/json'); - $result = '['; + $json = array('users' => array(), 'messages' => array()); + foreach ($this->messages as $message) { - $result .= $message->jsonify().','; + $json['messages'][] = $message->jsonify(true); } - echo rtrim($result, ',').']'; + echo \wcf\util\JSON::encode($json); exit; } }