- 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>
53 lines
1.6 KiB
Text
53 lines
1.6 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfcontent type="application/json; charset=utf-8">
|
|
<cfscript>
|
|
try {
|
|
// Create ChatMessages table
|
|
queryExecute("
|
|
CREATE TABLE IF NOT EXISTS ChatMessages (
|
|
MessageID INT AUTO_INCREMENT PRIMARY KEY,
|
|
TaskID INT NOT NULL,
|
|
SenderUserID INT NOT NULL,
|
|
SenderType ENUM('customer', 'worker') NOT NULL,
|
|
MessageText TEXT NOT NULL,
|
|
IsRead TINYINT(1) DEFAULT 0,
|
|
CreatedOn DATETIME DEFAULT NOW(),
|
|
|
|
INDEX idx_task (TaskID),
|
|
INDEX idx_sender (SenderUserID),
|
|
INDEX idx_created (CreatedOn)
|
|
)
|
|
", {}, { datasource: "payfrit" });
|
|
|
|
// Also add a "Chat" category if it doesn't exist for business 17
|
|
existing = queryExecute("
|
|
SELECT TaskCategoryID FROM TaskCategories
|
|
WHERE TaskCategoryBusinessID = 17 AND TaskCategoryName = 'Chat'
|
|
", {}, { datasource: "payfrit" });
|
|
|
|
if (existing.recordCount == 0) {
|
|
queryExecute("
|
|
INSERT INTO TaskCategories (TaskCategoryBusinessID, TaskCategoryName, TaskCategoryColor)
|
|
VALUES (17, 'Chat', '##2196F3')
|
|
", {}, { datasource: "payfrit" });
|
|
}
|
|
|
|
// Verify table was created
|
|
cols = queryExecute("DESCRIBE ChatMessages", {}, { datasource: "payfrit" });
|
|
colNames = [];
|
|
for (c in cols) {
|
|
arrayAppend(colNames, c.Field);
|
|
}
|
|
|
|
writeOutput(serializeJSON({
|
|
"OK": true,
|
|
"MESSAGE": "ChatMessages table created successfully",
|
|
"COLUMNS": colNames
|
|
}));
|
|
} catch (any e) {
|
|
writeOutput(serializeJSON({
|
|
"OK": false,
|
|
"ERROR": e.message
|
|
}));
|
|
}
|
|
</cfscript>
|