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

cti: improved recognition of the correct CTILOG-entry

(cherry picked from commit c2fdf046)
parent 2a07392d
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,8 @@ function IncomingCallExecutor(pCallData) ...@@ -55,6 +55,8 @@ function IncomingCallExecutor(pCallData)
//key-value pairs of callstates-functions //key-value pairs of callstates-functions
this._handlerFunctions = {}; this._handlerFunctions = {};
this.notificationContentId = null;
} }
...@@ -163,20 +165,21 @@ IncomingCallExecutor.prototype.logData = function() ...@@ -163,20 +165,21 @@ IncomingCallExecutor.prototype.logData = function()
}; };
/** /**
* helper function that will log different callData and collected data to standard-output * returns a basic configuration for phonecall-notifications
* The function does not specify any module, importance or else *
* Needed for live-analytics of problems and errors. * @param {String} pUserName user-name (which is NOT the login but the internal id of a userobject)
*
* @return {Object} notification config as it is created in the notification.createConfig()-method
* *
* @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;
......
...@@ -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,7 +75,13 @@ var talkingHandlerFn = function() ...@@ -75,7 +75,13 @@ 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()];
db.updateData("AB_CTILOG", cols, null, vals, SqlCondition.begin().andPrepare("AB_CTILOG.CALLID", this.callData.callId).build());
var newestCtiLogId = _getNewestCtiLogId(this.callData.callId);
if (newestCtiLogId)
{
this.notificationContentId = newestCtiLogId;//currently not used but you never know
db.updateData("AB_CTILOG", cols, null, vals, newWhere("AB_CTILOG.AB_CTILOGID", newestCtiLogId).buildCondition());
}
//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
}; };
...@@ -98,8 +104,13 @@ var disconnectingHandlerFn = function() ...@@ -98,8 +104,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;
...@@ -160,6 +171,18 @@ var disconnectingHandlerFn = function() ...@@ -160,6 +171,18 @@ 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")
...@@ -178,7 +201,7 @@ var callData = { ...@@ -178,7 +201,7 @@ var callData = {
//callData.localAddress = "PJSIP/xyzExample"; //callData.localAddress = "PJSIP/xyzExample";
var ic = new IncomingCallExecutor(callData); var ic = new IncomingCallExecutor(callData);
//ic.logData(); ic.logData();
ic.setHandlerRinging(ringingHandlerFn); ic.setHandlerRinging(ringingHandlerFn);
ic.setHandlerTalking(talkingHandlerFn); ic.setHandlerTalking(talkingHandlerFn);
ic.setHandlerDisconnect(disconnectingHandlerFn); ic.setHandlerDisconnect(disconnectingHandlerFn);
......
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