From 269ee9545f0caa77f8e3a129226b65b62511eb63 Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@adito.de> Date: Wed, 11 Dec 2019 07:49:54 +0000 Subject: [PATCH] added comments to IncomingCallExecutor_lib (cherry picked from commit 4c7cc7d69bb24dbe13a6bf14f22ed19559f1d03b) --- process/IncomingCallExecutor_lib/process.js | 56 +++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/process/IncomingCallExecutor_lib/process.js b/process/IncomingCallExecutor_lib/process.js index dd06e535e9..b9ef2495f6 100644 --- a/process/IncomingCallExecutor_lib/process.js +++ b/process/IncomingCallExecutor_lib/process.js @@ -10,8 +10,6 @@ import("Sql_lib"); import("system.cti"); import("system.indexsearch"); -//TODO: comment library completely - /** * object for processing cti-calls * Within the constructor, data is collected but not further processed. To perform operations, different methods are provide (lke the .execute-function) @@ -205,6 +203,30 @@ IncomingCallExecutor._callstateToText = function(pCallstate) return callstateName; }; +/** + * helper function to load a contact by a given number (or contactId) as they are required for formatting of a callers name for example + * will use the index for a fast phone number search; will load the actual data from the database + * + * either the number or contactIds have to be given to the function. you can specify both if you want to extent the search + * (look for the phoneNumber XXX and also look for those YYY contactIds; Note that this is an extension and not a an addtional filter and therefor + * will result in an SQL-OR-condtion) + * + * @param {String} pNumber phone number that shall be searched, formatting is ignored for searching + * @param {Array} pContactIds additional contactIds to load + * + * @return {Array} array of contacts where each element is an object with these properites + * <ul> + * <li>CONTACTID</li> + * <li>ORGANISATION_ID</li> + * <li>ORGANISATION_NAME</li> + * <li>PERSON_ID</li> + * <li>LANGUAGE</li> + * <li>PERSON_FULL_NAME</li> + * </ul> + * + * @private + * @static + */ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds) { var phoneNumber = pNumber; @@ -269,12 +291,28 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds) ORGANISATION_ID: e[1], ORGANISATION_NAME: e[2].trim(), PERSON_ID: e[3], - LANGUAGE: e[4], + ISOLANGUAGE: e[4], PERSON_FULL_NAME: e.slice(5).join(" ").trim() //quick solution until the ticket above (#1047680) is solved }; }); }; +/** + * helper function to load user data models by given contacts as they are returned in IncomingCallExecutor._getContactsFromNumber + * the CONTACTID-property of the contact will be used to search within the users + * Only active users are returned + * + * either the number or contactIds have to be given to the function. you can specify both if you want to extent the search + * (look for the phoneNumber XXX and also look for those YYY contactIds; Note that this is an extension and not a an addtional filter and therefor + * will result in an SQL-OR-condtion) + * + * @param {Array} pContacts contacts as they are returned in IncomingCallExecutor._getContactsFromNumber(...) + * + * @return {Array} array of user data models (PROFILE_DEFAULT) + * + * @private + * @static + */ IncomingCallExecutor._getUsersFromContacts = function (pContacts) { var users = tools.getUsersByAttribute(tools.CONTACTID, pContacts.map(function(e){ @@ -286,6 +324,16 @@ IncomingCallExecutor._getUsersFromContacts = function (pContacts) return users; }; +/** + * will search within the contacts for a given user and then return the contacts language + * The CONTACTID of the user is used for finding the matching contact + * + * @param {Object} pUserObject user data model whose contact shall be searched + * + * @return {String} language as isocode of the contact or null if no language is set/the user was not found in the "contactsLocal" property + * + * @private + */ IncomingCallExecutor.prototype.getLocaleFromUser = function(pUserObject) { var contactId = pUserObject[tools.CONTACTID]; @@ -293,7 +341,7 @@ IncomingCallExecutor.prototype.getLocaleFromUser = function(pUserObject) return e.CONTACTID == contactId; }); //language for output like notifications, this is most likely used within the callback-functions (action handlers): - if (contact && contact.LANGUAGE) + if (contact && contact.ISOLANGUAGE) return contact.ISOLANGUAGE; else return null; -- GitLab