Files
Facilitor/APPL/CHAT/ChatAsk.asp
2024-08-19 11:21:06 +00:00

61 lines
1.3 KiB
Plaintext

<%@language = "javascript" %>
<% /*
$Revision$
$Id$
ChatSend.asp
Send a chat message to channelId
*/
var JSON_Result = true;
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/FlexFiles.inc" -->
<!-- #include file="./chat.inc" -->
<%
var wantchannelId = getFParam("channelId");
var message = getFParam("message");
var dis_key = getFParamInt("dis_key", -1); // discipline
var remove = getFParamInt("remove", 0);
// Store the initial message. TODO: In the database
Application.Lock();
var chat_queue = JSON.parse(Application(chat_queue_name) || "{}");
if (!chat_queue.wanting)
chat_queue.wanting = {};
var data = { prs_key: user_key,
naam: user.naam(),
picture: user.photoinfo().photopaththumb,
since: new Date().getTime(),
message: message
};
if (dis_key > 0)
{
data.dis_key = dis_key;
}
if (remove == 1)
{
delete chat_queue.wanting[wantchannelId];
}
else
{
chat_queue.wanting[wantchannelId] = data;
}
Application(chat_queue_name) = JSON.stringify(chat_queue);
Application.UnLock();
result = { success: true, message: "Bericht verstuurd" };
if (remove == 1)
{
result.removed = 1;
}
Response.Write(JSON.stringify(result));
%>
<% ASPPAGE_END(); %>