<%@language = "javascript" %>
<% /*
     $Revision$
     $Id$

     ChatGet.asp

     Get a chat message
*/

var JSON_Result = true;

%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="./chat.inc" -->
<%

var fromchannelId = getQParam("channelId");

// Get the message. TODO: In the database
var result = { success: true };

Application.Lock();
var chatdata = JSON.parse(Application(chat_data_name) || "{}");
if (chatdata.messages)
{
    result.messages = chatdata.messages[fromchannelId];
    delete chatdata.messages[fromchannelId];
    Application(chat_data_name) = JSON.stringify(chatdata);
    for (var i in result.messages) {
        result.messages[i].safe_message = safe.fclthtml(result.messages[i].message, { "fcltlinks": true });
    }
}
Application.UnLock();

Response.Write(JSON.stringify(result));
%>
<% ASPPAGE_END(); %>
