- Add /api/portal/team.cfm for employee listing - Add chat endpoints (getMessages, sendMessage, markRead, getActiveChat) - Add OTP authentication endpoints - Add address management endpoints (delete, setDefault, states) - Add task completion and chat task endpoints - Update Application.cfm allowlist Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57 lines
1.3 KiB
Text
57 lines
1.3 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
<cfcontent type="application/json; charset=utf-8" reset="true">
|
|
|
|
<cfscript>
|
|
// Close/complete a chat task
|
|
// Input: TaskID
|
|
// Output: { OK: true }
|
|
|
|
function apiAbort(required struct payload) {
|
|
writeOutput(serializeJSON(payload));
|
|
abort;
|
|
}
|
|
|
|
function readJsonBody() {
|
|
var raw = getHttpRequestData().content;
|
|
if (isNull(raw)) raw = "";
|
|
if (!len(trim(raw))) return {};
|
|
try {
|
|
var data = deserializeJSON(raw);
|
|
if (isStruct(data)) return data;
|
|
} catch (any e) {}
|
|
return {};
|
|
}
|
|
|
|
try {
|
|
data = readJsonBody();
|
|
taskID = val(structKeyExists(data, "TaskID") ? data.TaskID : 0);
|
|
|
|
if (taskID == 0) {
|
|
apiAbort({ "OK": false, "ERROR": "missing_params", "MESSAGE": "TaskID is required" });
|
|
}
|
|
|
|
// Mark the task as completed
|
|
queryExecute("
|
|
UPDATE Tasks
|
|
SET TaskCompletedOn = NOW()
|
|
WHERE TaskID = :taskID
|
|
AND TaskTypeID = 2
|
|
AND TaskCompletedOn IS NULL
|
|
", {
|
|
taskID: { value: taskID, cfsqltype: "cf_sql_integer" }
|
|
}, { datasource: "payfrit" });
|
|
|
|
apiAbort({
|
|
"OK": true,
|
|
"MESSAGE": "Chat closed"
|
|
});
|
|
|
|
} catch (any e) {
|
|
apiAbort({
|
|
"OK": false,
|
|
"ERROR": "server_error",
|
|
"MESSAGE": e.message
|
|
});
|
|
}
|
|
</cfscript>
|