Skip to content
Snippets Groups Projects
Commit eaee30a5 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

mstBot_rest webservice

parent 11227a0d
No related branches found
No related tags found
No related merge requests found
import("system.datetime");
import("system.teams");
import("system.logging");
import("system.text");
import("system.util");
import("Sql_lib");
import("KeywordRegistry_basic");
import("Date_lib");
function restpost(pRequestAsJson)
{
......@@ -54,11 +57,11 @@ function restpost(pRequestAsJson)
var plainMessage = text.html2text(pHTML);
var splitMessage = plainMessage.split("/");
if (splitMessage.length !== 2)
var messageParts = plainMessage.split("/");
if (messageParts.length !== 2)
return pRequestAsJson;
var command = splitMessage[1].split(/\s+?/);
var command = messageParts[1].split(/\s+?/);
var parameters = {};
command.slice(1).forEach(function (param)
{
......@@ -69,14 +72,23 @@ function restpost(pRequestAsJson)
});
command = command[0];
switch (command)
if (command == "addTask" && parameters.editor && parameters.subject)
{
case "addTask":
var fieldValues = {};
if ("editor" in parameters)
//TODO: insert task
var currentDate = datetime.date();
var fieldValues = {
"KIND": $KeywordRegistry.taskType$task(),
"START_DATE": currentDate,
"MATURITY_DATE": Duration.ofDays(7).getDateWithDurationAdded(currentDate).getTime(),
"PRIORITY": $KeywordRegistry.taskPriority$low(),
"STATUS": $KeywordRegistry.taskStatus$new(),
"SUBJECT": parameters.subject,
"REQUESTOR_CONTACT_ID": "",
"PROGRESS": $KeywordRegistry.taskProgress$0()
};
if ("editor" in parameters)
fieldValues["EDITOR_CONTACT_ID"] = ""; //TODO: find out contactid
new SqlBuilder.insertFields(fieldValues, "TASK", "TASKID");
}
return pRequestAsJson;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment