Skip to content
Snippets Groups Projects
Commit c632ecad authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

cti: improved recognition of the correct CTILOG-entry

parent e2f0b241
No related branches found
No related tags found
No related merge requests found
...@@ -55,8 +55,9 @@ function IncomingCallExecutor(pCallData) ...@@ -55,8 +55,9 @@ function IncomingCallExecutor(pCallData)
//key-value pairs of states-functions //key-value pairs of states-functions
this._handlerFunctions = {}; this._handlerFunctions = {};
this.notificationContentId = null;
} }
IncomingCallExecutor.prototype.toString = function() IncomingCallExecutor.prototype.toString = function()
{ {
return JSON.stringify(this, null, " "); return JSON.stringify(this, null, " ");
...@@ -118,19 +119,25 @@ IncomingCallExecutor.prototype.logData = function() ...@@ -118,19 +119,25 @@ IncomingCallExecutor.prototype.logData = function()
logging.log("contactsCall>>" + JSON.stringify(this.contactsCall)); logging.log("contactsCall>>" + JSON.stringify(this.contactsCall));
}; };
/**
* helper function that will log different callData and collected data to standard-output
* The function does not specify any module, importance or else
* Needed for live-analytics of problems and errors.
*
* @return undefined
*/
IncomingCallExecutor.prototype.getNotificationBaseConfig = function(pUserName) IncomingCallExecutor.prototype.getNotificationBaseConfig = function(pUserName)
{ {
if (!pUserName) if (!pUserName || !this.notificationContentId)
return null; return null;
var notificationConfig = notification.createConfig() var notificationConfig = notification.createConfig()
.addUserWithId(pUserName) .addUserWithId(pUserName)
.contentId(this.callData.callId)//group all notifications of one call together .contentId(this.notificationContentId)//group all notifications of one call together
.notificationType("_____SYSTEM_NOTIFICATION_PHONECALL"); .notificationType("_____SYSTEM_NOTIFICATION_PHONECALL");
return notificationConfig; return notificationConfig;
}; };
IncomingCallExecutor.prototype._setHandlerFn = function(pCallState, pFunction) IncomingCallExecutor.prototype._setHandlerFn = function(pCallState, pFunction)
{ {
this._handlerFunctions[pCallState] = pFunction; this._handlerFunctions[pCallState] = pFunction;
......
...@@ -32,7 +32,7 @@ var ringingHandlerFn = function() ...@@ -32,7 +32,7 @@ var ringingHandlerFn = function()
vals.push(affectedContactId); vals.push(affectedContactId);
} }
db.insertData("AB_CTILOG", cols, null, vals); db.insertData("AB_CTILOG", cols, null, vals);
this.notificationContentId = vals[0];
if (this.callData.isIncomingCall) if (this.callData.isIncomingCall)
{ {
...@@ -75,10 +75,14 @@ var talkingHandlerFn = function() ...@@ -75,10 +75,14 @@ var talkingHandlerFn = function()
{ {
var cols = ["DATE_EDIT", "ANSWERMODE"]; var cols = ["DATE_EDIT", "ANSWERMODE"];
var vals = [datetime.date(), $KeywordRegistry.callAnswerMode$accepted()]; var vals = [datetime.date(), $KeywordRegistry.callAnswerMode$accepted()];
newWhereIfSet("AB_CTILOG.CALLID", this.callData.callId) var newestCtiLogId = _getNewestCtiLogId(this.callData.callId);
.updateData(true, "AB_CTILOG", cols, null, vals); if (newestCtiLogId)
{
this.notificationContentId = newestCtiLogId;//currently not used but you never know
newWhereIfSet("AB_CTILOG.AB_CTILOGID", newestCtiLogId)
.updateData(true, "AB_CTILOG", cols, null, vals);
}
//do not notify here since the user _should_ know when he accepts a call //do not notify here since the user _should_ know when he accepts a call
}; };
...@@ -102,8 +106,13 @@ var disconnectingHandlerFn = function() ...@@ -102,8 +106,13 @@ var disconnectingHandlerFn = function()
cols.push("ANSWERMODE"); cols.push("ANSWERMODE");
vals.push($KeywordRegistry.callAnswerMode$missed()); vals.push($KeywordRegistry.callAnswerMode$missed());
} }
db.updateData("AB_CTILOG", cols, null, vals, sqlCond.build()); var newestCtiLogId = _getNewestCtiLogId(this.callData.callId);
if (newestCtiLogId)
{
this.notificationContentId = newestCtiLogId;
db.updateData("AB_CTILOG", cols, null, vals, newWhere("AB_CTILOG.AB_CTILOGID", newestCtiLogId).buildCondition());
}
//do not notify the user when the call is outgoing since the user knows when he/she does initiate a call //do not notify the user when the call is outgoing since the user knows when he/she does initiate a call
if (!this.callData.isIncomingCall) if (!this.callData.isIncomingCall)
return null; return null;
...@@ -164,6 +173,17 @@ var disconnectingHandlerFn = function() ...@@ -164,6 +173,17 @@ var disconnectingHandlerFn = function()
return null; return null;
}; };
function _getNewestCtiLogId(pCallid)
{
//get the newewst ctilogid for a given callid since the callid may not be unique in a telephon systems
//therefor sort descending by DATE_NEW and return that value
var ctiLogId = newSelect("AB_CTILOG.AB_CTILOGID")
.from("AB_CTILOG")
.where("AB_CTILOG.CALLID", pCallid)
.orderBy("AB_CTILOG.DATE_NEW desc")
.cell();
return ctiLogId;
}
//collect all data from the various call information //collect all data from the various call information
var callData = { var callData = {
action: vars.get("$local.action") action: vars.get("$local.action")
...@@ -183,7 +203,7 @@ var callData = { ...@@ -183,7 +203,7 @@ var callData = {
var ic = new IncomingCallExecutor(callData); var ic = new IncomingCallExecutor(callData);
//ic.logData(); //ic.logData();
ic.setHandlerRinging(ringingHandlerFn); ic.logData();
ic.setHandlerTalking(talkingHandlerFn); ic.setHandlerTalking(talkingHandlerFn);
ic.setHandlerDisconnect(disconnectingHandlerFn); ic.setHandlerDisconnect(disconnectingHandlerFn);
ic.execute();//actually doin' something ic.execute();//actually doin' something
\ No newline at end of file
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